mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Update script.js to allow filler to use multiple forms
This commit is contained in:
parent
00919d7f05
commit
3338b86974
@ -40,9 +40,8 @@ function loader(e, t, o) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function fill() {
|
function fill() {
|
||||||
(data = JSON.parse(this.response)),
|
data = JSON.parse(this.response);
|
||||||
(form = document.forms.item(0)),
|
for (const form of document.forms) populate(form, data);
|
||||||
populate(form, data);
|
|
||||||
}
|
}
|
||||||
function filler(e, t) {
|
function filler(e, t) {
|
||||||
window.addEventListener("load", function () {
|
window.addEventListener("load", function () {
|
||||||
|
Binary file not shown.
@ -297,9 +297,6 @@ void debug_get_tag(uint8_t tag, char* buffer)
|
|||||||
case TAG_OTA:
|
case TAG_OTA:
|
||||||
memcpy_P(buffer, PSTR("OTA "), 5);
|
memcpy_P(buffer, PSTR("OTA "), 5);
|
||||||
break;
|
break;
|
||||||
case TAG_FWUP:
|
|
||||||
memcpy_P(buffer, PSTR("FWUP"), 5);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TAG_LVGL:
|
case TAG_LVGL:
|
||||||
memcpy_P(buffer, PSTR("LVGL"), 5);
|
memcpy_P(buffer, PSTR("LVGL"), 5);
|
||||||
|
@ -182,8 +182,6 @@ enum {
|
|||||||
TAG_FILE = 31,
|
TAG_FILE = 31,
|
||||||
TAG_GPIO = 40,
|
TAG_GPIO = 40,
|
||||||
|
|
||||||
TAG_FWUP = 50,
|
|
||||||
|
|
||||||
TAG_ETH = 60,
|
TAG_ETH = 60,
|
||||||
TAG_WIFI = 61,
|
TAG_WIFI = 61,
|
||||||
TAG_HTTP = 62,
|
TAG_HTTP = 62,
|
||||||
|
@ -90,9 +90,9 @@ const char MAIN_MENU_BUTTON[] PROGMEM = "<a href='/'>" D_HTTP_MAIN_MENU "</a>";
|
|||||||
const char HTTP_DOCTYPE[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta charset='utf-8'><meta "
|
const char HTTP_DOCTYPE[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta charset='utf-8'><meta "
|
||||||
"name=\"viewport\" content=\"width=device-width,initial-scale=1\"/>";
|
"name=\"viewport\" content=\"width=device-width,initial-scale=1\"/>";
|
||||||
const char HTTP_META_GO_BACK[] PROGMEM = "<meta http-equiv='refresh' content='%d;url=/'/>";
|
const char HTTP_META_GO_BACK[] PROGMEM = "<meta http-equiv='refresh' content='%d;url=/'/>";
|
||||||
|
const char HTTP_STYLESHEET[] PROGMEM = "<link rel=\"stylesheet\" href=\"/%s.css\">";
|
||||||
const char HTTP_HEADER[] PROGMEM = "<title>%s</title>";
|
const char HTTP_HEADER[] PROGMEM = "<title>%s</title>";
|
||||||
const char HTTP_HEADER_END[] PROGMEM =
|
const char HTTP_HEADER_END[] PROGMEM = "<script src=\"/script.js\"></script>"
|
||||||
"<script src=\"/script.js\"></script><link rel=\"stylesheet\" href=\"/vars.css\">"
|
|
||||||
"<link rel=\"stylesheet\" href=\"/style.css\"></head><body><div id='doc'>";
|
"<link rel=\"stylesheet\" href=\"/style.css\"></head><body><div id='doc'>";
|
||||||
const char HTTP_FOOTER[] PROGMEM = "<div class='clear'><hr/><a class='foot' href='/about'>" D_MANUFACTURER " ";
|
const char HTTP_FOOTER[] PROGMEM = "<div class='clear'><hr/><a class='foot' href='/about'>" D_MANUFACTURER " ";
|
||||||
const char HTTP_END[] PROGMEM = " " D_HTTP_FOOTER "</div></body></html>";
|
const char HTTP_END[] PROGMEM = " " D_HTTP_FOOTER "</div></body></html>";
|
||||||
@ -219,6 +219,7 @@ static void webSendHeader(const char* nodename, uint32_t httpdatalength, uint8_t
|
|||||||
uint32_t contentLength = strlen(haspDevice.get_version()); // version length
|
uint32_t contentLength = strlen(haspDevice.get_version()); // version length
|
||||||
contentLength += sizeof(HTTP_DOCTYPE) - 1;
|
contentLength += sizeof(HTTP_DOCTYPE) - 1;
|
||||||
contentLength += sizeof(HTTP_HEADER) - 1 - 2 + strlen(nodename); // -2 for %s
|
contentLength += sizeof(HTTP_HEADER) - 1 - 2 + strlen(nodename); // -2 for %s
|
||||||
|
contentLength += sizeof(HTTP_STYLESHEET) - 1 - 2 + strlen("vars"); // -2 for %s
|
||||||
if(gohome > 0) {
|
if(gohome > 0) {
|
||||||
snprintf_P(buffer, sizeof(buffer), HTTP_META_GO_BACK, gohome);
|
snprintf_P(buffer, sizeof(buffer), HTTP_META_GO_BACK, gohome);
|
||||||
contentLength += strlen(buffer); // gohome
|
contentLength += strlen(buffer); // gohome
|
||||||
@ -241,6 +242,9 @@ static void webSendHeader(const char* nodename, uint32_t httpdatalength, uint8_t
|
|||||||
#endif
|
#endif
|
||||||
webServer.sendContent(buffer); // gohome
|
webServer.sendContent(buffer); // gohome
|
||||||
|
|
||||||
|
snprintf_P(buffer, sizeof(buffer), HTTP_STYLESHEET, "vars");
|
||||||
|
webServer.sendContent(buffer); // stylesheet
|
||||||
|
|
||||||
snprintf_P(buffer, sizeof(buffer), HTTP_HEADER, nodename);
|
snprintf_P(buffer, sizeof(buffer), HTTP_HEADER, nodename);
|
||||||
webServer.sendContent(buffer); // 17-2+len
|
webServer.sendContent(buffer); // 17-2+len
|
||||||
}
|
}
|
||||||
@ -1230,7 +1234,7 @@ static void webHandleGuiConfig()
|
|||||||
|
|
||||||
// Backlight Pin
|
// Backlight Pin
|
||||||
int8_t bcklpin = settings[FPSTR(FP_GUI_BACKLIGHTPIN)].as<int8_t>();
|
int8_t bcklpin = settings[FPSTR(FP_GUI_BACKLIGHTPIN)].as<int8_t>();
|
||||||
httpMessage += F("<div class='row'><div class='col-25'><label for='group'>Backlight Control</label></div>");
|
httpMessage += F("<div class='row'><div class='col-25'><label for='group'>Backlight Pin</label></div>");
|
||||||
httpMessage += F("<div class='col-75'><select id='bckl' name='bckl'>");
|
httpMessage += F("<div class='col-75'><select id='bckl' name='bckl'>");
|
||||||
httpMessage += getOption(-1, F("None"), bcklpin);
|
httpMessage += getOption(-1, F("None"), bcklpin);
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
@ -2048,11 +2052,13 @@ static void webHandleFirmware()
|
|||||||
|
|
||||||
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
||||||
|
|
||||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 20);
|
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 50);
|
||||||
webServer.sendContent(httpMessage);
|
webServer.sendContent(httpMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
webSendFooter();
|
||||||
dispatch_web_update(NULL, url.c_str(), TAG_HTTP);
|
dispatch_web_update(NULL, url.c_str(), TAG_HTTP);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Send Firmware page
|
// Send Firmware page
|
||||||
String httpMessage((char*)0);
|
String httpMessage((char*)0);
|
||||||
|
@ -1306,7 +1306,7 @@ void webHandleGuiConfig(AsyncWebServerRequest* request)
|
|||||||
httpMessage += F("><b>Show Pointer</b>");
|
httpMessage += F("><b>Show Pointer</b>");
|
||||||
|
|
||||||
int8_t bcklpin = settings[FPSTR(FP_GUI_BACKLIGHTPIN)].as<int8_t>();
|
int8_t bcklpin = settings[FPSTR(FP_GUI_BACKLIGHTPIN)].as<int8_t>();
|
||||||
httpMessage += F("<p><b>Backlight Control</b> <select id='bckl' name='bckl'>");
|
httpMessage += F("<p><b>Backlight Pin</b> <select id='bckl' name='bckl'>");
|
||||||
httpMessage += getOption(-1, F("None"), bcklpin == -1);
|
httpMessage += getOption(-1, F("None"), bcklpin == -1);
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
add_gpio_select_option(httpMessage, 5, bcklpin); // D8 on ESP32 for D1 mini 32
|
add_gpio_select_option(httpMessage, 5, bcklpin); // D8 on ESP32 for D1 mini 32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user