Skip to content

Commit

Permalink
Add reqNone and fix req rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Xi-Plus committed Aug 19, 2023
1 parent 7c79e31 commit 26397ee
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/gmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function getFormData() {
reqIpbe: false,
reqUnblock: false,
reqPassword: false,
reqNone: false,
username: '',
email: '',
ip: '',
Expand Down Expand Up @@ -252,6 +253,15 @@ function createCard(e) {
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
.setBackgroundColor(formData.reqPassword ? COLOR_ENABLED : COLOR_DISABLED));

reqButtonSet.addButton(CardService.newTextButton()
.setText('無')
.setOnClickAction(CardService.newAction()
.setFunctionName('updateRequest')
.setParameters({ key: 'reqNone', value: 'true' })
)
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
.setBackgroundColor(COLOR_DISABLED));

sectionInput.addWidget(reqButtonSet);

var textInputUsername = CardService.newTextInput()
Expand Down Expand Up @@ -646,10 +656,11 @@ function updateRequest(e) {
var newVal = e.parameters.value === 'true';
console.log('Update "' + key + '" from "' + formData[key].toString() + '" to "' + newVal.toString() + '"');
formData[key] = newVal;
if (['reqUnblock', 'reqPassword'].includes(key) && newVal) {
if (['reqUnblock', 'reqPassword', 'reqNone'].includes(key) && newVal) {
formData.reqAccount = false;
formData.reqIpbe = false;
}
formData['reqNone'] = false;

putFormData(formData);

Expand Down Expand Up @@ -796,11 +807,11 @@ function autoMailOptions() {
} else if (['not_exists', 'banned', 'banned_cancreate'].includes(formData.usernameStatus)) {
formData.mailOptionsUsername = 'not_exists';
}
} else if (formData.inputBlockAppeal) {
} else if (formData.reqUnblock) {
if (!formData.normalizedUsername) {
formData.mailOptionsUsername = 'nousername';
}
} else if (formData.inputResetPassword) {
} else if (formData.reqPassword) {
if (!formData.normalizedUsername && !formData.email) {
formData.mailOptionsUsername = 'nousername';
}
Expand All @@ -819,7 +830,7 @@ function autoMailOptions() {
} else {
formData.mailOptionsIpbe = 'noip';
}
} else if (formData.inputBlockAppeal && !formData.ip) {
} else if (formData.reqUnblock && !formData.ip) {
formData.mailOptionsIpbe = 'noip';
}
}
Expand Down

0 comments on commit 26397ee

Please sign in to comment.