Minify settings page to improve performance

This commit is contained in:
Daniel Öster 2024-07-10 23:40:46 +03:00
parent fb3bfdd3e3
commit 53bb283446

View file

@ -90,228 +90,99 @@ String settings_processor(const String& var) {
content += "</div>"; content += "</div>";
#endif #endif
content += "<script>"; content += "<script>"; // Note, this section is minified to improve performance
content += "function editComplete() {"; content += "function editComplete(){if(this.status==200){window.location.reload();}}";
content += " if (this.status == 200) {"; content += "function editError(){alert('Invalid input');}";
content += " window.location.reload();";
content += " }";
content += "}";
content += "function editError() {";
content += " alert('Invalid input');";
content += "}";
content += "function editSSID() {";
content += "var value = prompt('Enter new SSID:');";
content += "if (value !== null) {";
content += " var xhr = new XMLHttpRequest();";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateSSID?value=' + encodeURIComponent(value), true);";
content += " xhr.send();";
content += "}";
content += "}";
content += "function editPassword() {";
content += "var value = prompt('Enter new password:');";
content += "if (value !== null) {";
content += " var xhr = new XMLHttpRequest();";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updatePassword?value=' + encodeURIComponent(value), true);";
content += " xhr.send();";
content += "}";
content += "}";
content += "function editWh() {";
content += "var value = prompt('How much energy the battery can store. Enter new Wh value (1-120000):');";
content += "if (value !== null) {";
content += " if (value >= 1 && value <= 120000) {";
content += " var xhr = new XMLHttpRequest();";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateBatterySize?value=' + value, true);";
content += " xhr.send();";
content += " } else {";
content += " alert('Invalid value. Please enter a value between 1 and 120000.');";
content += " }";
content += "}";
content += "}";
content += "function editUseScaledSOC() {";
content += "var value = prompt('Should SOC% be scaled? (0 = No, 1 = Yes):');";
content += "if (value !== null) {";
content += " if (value == 0 || value == 1) {";
content += " var xhr = new XMLHttpRequest();";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateUseScaledSOC?value=' + value, true);";
content += " xhr.send();";
content += " } else {";
content += " alert('Invalid value. Please enter a value between 0 and 1.');";
content += " }";
content += "}";
content += "}";
content += "function editSocMax() {";
content += content +=
"var value = prompt('Inverter will see fully charged (100pct)SOC when this value is reached. Enter new maximum " "function editSSID(){var value=prompt('Enter new SSID:');if(value!==null){var xhr=new "
"SOC value that battery will charge to (50.0-100.0):');"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += "if (value !== null) {"; "updateSSID?value='+encodeURIComponent(value),true);xhr.send();}}";
content += " if (value >= 50 && value <= 100) {";
content += " var xhr = new XMLHttpRequest();";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateSocMax?value=' + value, true);";
content += " xhr.send();";
content += " } else {";
content += " alert('Invalid value. Please enter a value between 50.0 and 100.0');";
content += " }";
content += "}";
content += "}";
content += "function editSocMin() {";
content += content +=
"var value = prompt('Inverter will see completely discharged (0pct)SOC when this value is reached. Enter new " "function editPassword(){var value=prompt('Enter new password:');if(value!==null){var xhr=new "
"minimum SOC value that battery will discharge to (0-50.0):');"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += "if (value !== null) {"; "updatePassword?value='+encodeURIComponent(value),true);xhr.send();}}";
content += " if (value >= 0 && value <= 50) {";
content += " var xhr = new XMLHttpRequest();";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateSocMin?value=' + value, true);";
content += " xhr.send();";
content += " } else {";
content += " alert('Invalid value. Please enter a value between 0 and 50.0');";
content += " }";
content += "}";
content += "}";
content += "function editMaxChargeA() {";
content += content +=
"var value = prompt('BYD CAN specific setting, some inverters needs to be artificially limited. Enter new " "function editWh(){var value=prompt('How much energy the battery can store. Enter new Wh value "
"maximum charge current in A (0-1000.0):');"; "(1-120000):');if(value!==null){if(value>=1&&value<=120000){var xhr=new "
content += "if (value !== null) {"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += " if (value >= 0 && value <= 1000) {"; "updateBatterySize?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between 1 "
content += " var xhr = new XMLHttpRequest();"; "and 120000.');}}}";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateMaxChargeA?value=' + value, true);";
content += " xhr.send();";
content += " } else {";
content += " alert('Invalid value. Please enter a value between 0 and 1000.0');";
content += " }";
content += "}";
content += "}";
content += "function editMaxDischargeA() {";
content += content +=
"var value = prompt('BYD CAN specific setting, some inverters needs to be artificially limited. Enter new " "function editUseScaledSOC(){var value=prompt('Should SOC% be scaled? (0 = No, 1 = "
"maximum discharge current in A (0-1000.0):');"; "Yes):');if(value!==null){if(value==0||value==1){var xhr=new "
content += "if (value !== null) {"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += " if (value >= 0 && value <= 1000) {"; "updateUseScaledSOC?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between 0 "
content += " var xhr = new XMLHttpRequest();"; "and 1.');}}}";
content += " xhr.onload = editComplete;"; content +=
content += " xhr.onerror = editError;"; "function editSocMax(){var value=prompt('Inverter will see fully charged (100pct)SOC when this value is "
content += " xhr.open('GET', '/updateMaxDischargeA?value=' + value, true);"; "reached. Enter new maximum SOC value that battery will charge to "
content += " xhr.send();"; "(50.0-100.0):');if(value!==null){if(value>=50&&value<=100){var xhr=new "
content += " } else {"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += " alert('Invalid value. Please enter a value between 0 and 1000.0');"; "updateSocMax?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between 50.0 and "
content += " }"; "100.0');}}}";
content += "}"; content +=
content += "}"; "function editSocMin(){var value=prompt('Inverter will see completely discharged (0pct)SOC when this value is "
"reached. Enter new minimum SOC value that battery will discharge to "
"(0-50.0):');if(value!==null){if(value>=0&&value<=50){var xhr=new "
"XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
"updateSocMin?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between 0 and "
"50.0');}}}";
content +=
"function editMaxChargeA(){var value=prompt('Some inverters needs to be artificially limited. Enter new "
"maximum charge current in A (0-1000.0):');if(value!==null){if(value>=0&&value<=1000){var xhr=new "
"XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
"updateMaxChargeA?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between 0 "
"and 1000.0');}}}";
content +=
"function editMaxDischargeA(){var value=prompt('Some inverters needs to be artificially limited. Enter new "
"maximum discharge current in A (0-1000.0):');if(value!==null){if(value>=0&&value<=1000){var xhr=new "
"XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
"updateMaxDischargeA?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between 0 "
"and 1000.0');}}}";
content += "</script>";
#ifdef TEST_FAKE_BATTERY #ifdef TEST_FAKE_BATTERY
content += "function editFakeBatteryVoltage() {"; content +=
content += " var value = prompt('Enter new fake battery voltage');"; "function editFakeBatteryVoltage(){var value=prompt('Enter new fake battery "
content += "if (value !== null) {"; "voltage');if(value!==null){if(value>=0&&value<=5000){var xhr=new "
content += " if (value >= 0 && value <= 5000) {"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += " var xhr = new XMLHttpRequest();"; "updateFakeBatteryVoltage?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value "
content += " xhr.onload = editComplete;"; "between 0 and 1000');}}}";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateFakeBatteryVoltage?value=' + value, true);";
content += " xhr.send();";
content += " } else {";
content += " alert('Invalid value. Please enter a value between 0 and 1000');";
content += " }";
content += "}";
content += "}";
#endif #endif
#if defined CHEVYVOLT_CHARGER || defined NISSANLEAF_CHARGER #if defined CHEVYVOLT_CHARGER || defined NISSANLEAF_CHARGER
content += "function editChargerHVDCEnabled() {";
content += " var value = prompt('Enable or disable HV DC output. Enter 1 for enabled, 0 for disabled');";
content += " if (value !== null) {";
content += " if (value == 0 || value == 1) {";
content += " var xhr = new XMLHttpRequest();";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateChargerHvEnabled?value=' + value, true);";
content += " xhr.send();";
content += " }";
content += " } else {";
content += " alert('Invalid value. Please enter 1 or 0');";
content += " }";
content += "}";
content += "function editChargerAux12vEnabled() {";
content += content +=
"var value = prompt('Enable or disable low voltage 12v auxiliary DC output. Enter 1 for enabled, 0 for " "function editChargerHVDCEnabled(){var value=prompt('Enable or disable HV DC output. Enter 1 for enabled, 0 "
"disabled');"; "for disabled');if(value!==null){if(value==0||value==1){var xhr=new "
content += "if (value !== null) {"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += " if (value == 0 || value == 1) {"; "updateChargerHvEnabled?value='+value,true);xhr.send();}}else{alert('Invalid value. Please enter 1 or 0');}}";
content += " var xhr = new XMLHttpRequest();";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateChargerAux12vEnabled?value=' + value, true);";
content += " xhr.send();";
content += " } else {";
content += " alert('Invalid value. Please enter 1 or 0');";
content += " }";
content += "}";
content += "}";
content += "function editChargerSetpointVDC() {";
content += content +=
"var value = prompt('Set charging voltage. Input will be validated against inverter and/or charger " "function editChargerAux12vEnabled(){var value=prompt('Enable or disable low voltage 12v auxiliary DC output. "
"configuration parameters, but use sensible values like 200 to 420.');"; "Enter 1 for enabled, 0 for disabled');if(value!==null){if(value==0||value==1){var xhr=new "
content += "if (value !== null) {"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += " if (value >= 0 && value <= 1000) {"; "updateChargerAux12vEnabled?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter 1 or "
content += " var xhr = new XMLHttpRequest();"; "0');}}}";
content += " xhr.onload = editComplete;";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateChargeSetpointV?value=' + value, true);";
content += " xhr.send();";
content += " } else {";
content += " alert('Invalid value. Please enter a value between 0 and 1000');";
content += " }";
content += "}";
content += "}";
content += "function editChargerSetpointIDC() {";
content += content +=
"var value = prompt('Set charging amperage. Input will be validated against inverter and/or charger " "function editChargerSetpointVDC(){var value=prompt('Set charging voltage. Input will be validated against "
"configuration parameters, but use sensible values like 6 to 48.');"; "inverter and/or charger configuration parameters, but use sensible values like 200 to "
content += "if (value !== null) {"; "420.');if(value!==null){if(value>=0&&value<=1000){var xhr=new "
content += " if (value >= 0 && value <= 1000) {"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += " var xhr = new XMLHttpRequest();"; "updateChargeSetpointV?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between "
content += " xhr.onload = editComplete;"; "0 and 1000');}}}";
content += " xhr.onerror = editError;";
content += " xhr.open('GET', '/updateChargeSetpointA?value=' + value, true);";
content += " xhr.send();";
content += " } else {";
content += " alert('Invalid value. Please enter a value between 0 and 100');";
content += " }";
content += "}";
content += "}";
content += "function editChargerSetpointEndI() {";
content += content +=
"var value = prompt('Set amperage that terminates charge as being sufficiently complete. Input will be " "function editChargerSetpointIDC(){var value=prompt('Set charging amperage. Input will be validated against "
"validated against inverter and/or charger configuration parameters, but use sensible values like 1-5.');"; "inverter and/or charger configuration parameters, but use sensible values like 6 to "
content += "if (value !== null) {"; "48.');if(value!==null){if(value>=0&&value<=1000){var xhr=new "
content += " if (value >= 0 && value <= 1000) {"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += " var xhr = new XMLHttpRequest();"; "updateChargeSetpointA?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between "
content += " xhr.onload = editComplete;"; "0 and 100');}}}";
content += " xhr.onerror = editError;"; content +=
content += " xhr.open('GET', '/updateChargeEndA?value=' + value, true);"; "function editChargerSetpointEndI(){var value=prompt('Set amperage that terminates charge as being "
content += " xhr.send();"; "sufficiently complete. Input will be validated against inverter and/or charger configuration parameters, but "
content += " } else {"; "use sensible values like 1-5.');if(value!==null){if(value>=0&&value<=1000){var xhr=new "
content += " alert('Invalid value. Please enter a value between 0 and 100');"; "XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
content += " }"; "updateChargeEndA?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between 0 "
content += "}"; "and 100');}}}";
content += "}";
#endif #endif
content += "</script>"; content += "</script>";