Browse Source

attr() returns text, do not compare to 0 / 1

webui
Max Prokhorov 6 years ago
parent
commit
0caf7a4aac
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      code/html/custom.js

+ 7
- 7
code/html/custom.js View File

@ -182,8 +182,8 @@ function validateForm(form) {
var re_hostname = new RegExp('^(?!-)[A-Za-z0-9-]{0,30}[A-Za-z0-9]$');
var hostname = $("input[name='hostname']", form);
var hasChanged = hostname.attr("hasChanged") || 0;
if (0 === hasChanged) {
var hasChanged = ("true" === hostname.attr("hasChanged"));
if (!hasChanged) {
return true;
}
@ -1472,27 +1472,27 @@ function hasChanged() {
newValue = $(this).val();
originalValue = $(this).attr("original");
}
var hasChanged = $(this).attr("hasChanged") || 0;
var hasChanged = ("true" === $(this).attr("hasChanged"));
var action = $(this).attr("action");
if (typeof originalValue === "undefined") { return; }
if ("none" === action) { return; }
if (newValue !== originalValue) {
if (0 === hasChanged) {
if (!hasChanged) {
++numChanged;
if ("reconnect" === action) { ++numReconnect; }
if ("reboot" === action) { ++numReboot; }
if ("reload" === action) { ++numReload; }
$(this).attr("hasChanged", 1);
$(this).attr("hasChanged", true);
}
} else {
if (1 === hasChanged) {
if (hasChanged) {
--numChanged;
if ("reconnect" === action) { --numReconnect; }
if ("reboot" === action) { --numReboot; }
if ("reload" === action) { --numReload; }
$(this).attr("hasChanged", 0);
$(this).attr("hasChanged", false);
}
}


Loading…
Cancel
Save