Sonar Cleanup - Phase 7
This commit is contained in:
parent
45207f9cfc
commit
764b8c103b
|
@ -13,42 +13,58 @@ var submitField = document.getElementById("submit-field");
|
||||||
var endpoint = "none";
|
var endpoint = "none";
|
||||||
var apiStatus = "activate";
|
var apiStatus = "activate";
|
||||||
|
|
||||||
|
function validateUserField() {
|
||||||
|
return !(userField.value > 0 && userField.checkValidity());
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateEmailField() {
|
||||||
|
return !(emailField.value.length > 0 && emailField.checkValidity());
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateApiField() {
|
||||||
|
return !(apiField.value.length > 0 && apiField.checkValidity());
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateChannelField() {
|
||||||
|
return !(channelField.value > 0 && channelField.checkValidity());
|
||||||
|
}
|
||||||
|
|
||||||
// Checks if all fields needed for the selected endpoint are valid
|
// Checks if all fields needed for the selected endpoint are valid
|
||||||
function validateFields() {
|
function validateFields() {
|
||||||
if (!(userField.value > 0 && userField.checkValidity())) {
|
if (validateUserField()) {
|
||||||
submitField.disabled = true;
|
submitField.disabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (endpoint) {
|
switch (endpoint) {
|
||||||
case "generate":
|
case "generate":
|
||||||
if (!(emailField.value.length > 0 && emailField.checkValidity())) {
|
if (validateEmailField()) {
|
||||||
submitField.disabled = true;
|
submitField.disabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "delete":
|
case "delete":
|
||||||
if (!(apiField.value.length > 0 && apiField.checkValidity())) {
|
if (validateApiField()) {
|
||||||
submitField.disabled = true;
|
submitField.disabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(emailField.value.length > 0 && emailField.checkValidity())) {
|
if (validateEmailField()) {
|
||||||
submitField.disabled = true;
|
submitField.disabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "view":
|
case "view":
|
||||||
if (!(apiField.value.length > 0 && apiField.checkValidity())) {
|
if (validateApiField()) {
|
||||||
submitField.disabled = true;
|
submitField.disabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "add":
|
case "add":
|
||||||
case "activate":
|
case "activate":
|
||||||
if (!(apiField.value.length > 0 && apiField.checkValidity())) {
|
if (validateApiField()) {
|
||||||
submitField.disabled = true;
|
submitField.disabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(channelField.value > 0 && channelField.checkValidity())) {
|
if (validateChannelField()) {
|
||||||
submitField.disabled = true;
|
submitField.disabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue