|
@@ -2152,14 +2152,18 @@ function ReadParameterAll() {
|
|
|
ReadParameter(param, "Webhook", "ApiKey", true);
|
|
ReadParameter(param, "Webhook", "ApiKey", true);
|
|
|
ReadParameter(param, "Webhook", "UploadImg", false);
|
|
ReadParameter(param, "Webhook", "UploadImg", false);
|
|
|
|
|
|
|
|
- // GPIO fields are irrelevant while the complete GPIO category is disabled.
|
|
|
|
|
- // In particular, stale values from older firmware must not block saving
|
|
|
|
|
- // unrelated configuration changes.
|
|
|
|
|
- if (category["GPIO"]["enabled"]) {
|
|
|
|
|
- (window.GPIO_AVAILABLE_PINS || []).forEach(function (gpio) {
|
|
|
|
|
|
|
+ (window.GPIO_AVAILABLE_PINS || []).forEach(function (gpio) {
|
|
|
|
|
+ if (category["GPIO"]["enabled"]) {
|
|
|
ReadParameter(param, "GPIO", "IO" + gpio, true);
|
|
ReadParameter(param, "GPIO", "IO" + gpio, true);
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // Clear stale validation errors when the complete GPIO category
|
|
|
|
|
+ // is disabled (e.g. after the user just unchecked the category).
|
|
|
|
|
+ for (var field = 1; field <= 6; ++field) {
|
|
|
|
|
+ var element = document.getElementById("GPIO_IO" + gpio + "_value" + field);
|
|
|
|
|
+ if (element) element.classList.remove("invalid-input");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
ReadParameter(param, "GPIO", "LEDType", false);
|
|
ReadParameter(param, "GPIO", "LEDType", false);
|
|
|
ReadParameter(param, "GPIO", "LEDNumbers", false);
|
|
ReadParameter(param, "GPIO", "LEDNumbers", false);
|
|
|
ReadParameter(param, "GPIO", "LEDColor", false);
|
|
ReadParameter(param, "GPIO", "LEDColor", false);
|
|
@@ -2785,6 +2789,10 @@ function ReadParameter(_param, _cat, _name, _optional, _number = -1) {
|
|
|
_param[_cat][_name]["enabled"] = document.getElementById(_cat+"_"+_name+"_enabled").checked;
|
|
_param[_cat][_name]["enabled"] = document.getElementById(_cat+"_"+_name+"_enabled").checked;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Do not validate optional GPIO channel values while that channel is disabled.
|
|
|
|
|
+ // Remove a previous error marker as well, so it cannot block unrelated saves.
|
|
|
|
|
+ var validateParameter = !_optional || _param[_cat][_name]["enabled"];
|
|
|
|
|
+
|
|
|
for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
|
|
for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
|
|
|
let element = document.getElementById(_cat+"_"+_name+"_value"+j);
|
|
let element = document.getElementById(_cat+"_"+_name+"_value"+j);
|
|
|
|
|
|
|
@@ -2796,7 +2804,7 @@ function ReadParameter(_param, _cat, _name, _optional, _number = -1) {
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
if ((_param[_cat][_name].checkRegExList != null) && (_param[_cat][_name].checkRegExList[j-1] != null)) {
|
|
if ((_param[_cat][_name].checkRegExList != null) && (_param[_cat][_name].checkRegExList[j-1] != null)) {
|
|
|
- if (!element.value.match(_param[_cat][_name].checkRegExList[j-1])) {
|
|
|
|
|
|
|
+ if (validateParameter && !element.value.match(_param[_cat][_name].checkRegExList[j-1])) {
|
|
|
element.classList.add("invalid-input");
|
|
element.classList.add("invalid-input");
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|