From ee10659e84b0aef8d29a9ee54c615ddc07a5057b Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Mon, 1 Nov 2021 23:12:26 +0100 Subject: [PATCH] Update forms to use CSS #246 --- .gitignore | 3 + data/style.css | 1 + data/style.css.gz | Bin 0 -> 962 bytes data/vars.css | 13 ++ platformio.ini | 1 + src/sys/svc/hasp_http.cpp | 420 ++++++++++++++++++++++---------------- 6 files changed, 257 insertions(+), 181 deletions(-) create mode 100644 data/style.css create mode 100644 data/style.css.gz create mode 100644 data/vars.css diff --git a/.gitignore b/.gitignore index 83980cca..e65d6fd8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ data/* !data/edit.htm !data/edit.htm.gz +!data/vars.css +!data/style.css +!data/style.css.gz src/user_setups/active/* include/user_config_override.h src/user_config_override.h diff --git a/data/style.css b/data/style.css new file mode 100644 index 00000000..de23e58c --- /dev/null +++ b/data/style.css @@ -0,0 +1 @@ +:root{--star:url('data:image/svg+xml,')}.c,body{text-align:center}.clear{clear:both}.foot{color:var(--txt);background-color:transparent!important;all:revert;float:right;margin:0;font-size:11px}input:not([type=file]){background-color:var(--fldbg);color:var(--fldfg)}input[type=checkbox],input[type=radio]{width:1em}select{background-color:var(--fldbg);color:var(--fldfg)}input:invalid{border:1px solid var(--redbg)}body{font-family:verdana;width:60%;margin:auto;background:var(--bg);color:var(--txt)}.red{background-color:var(--btnred)}.red:focus,.red:hover{background-color:var(--btnredhi)}#doc{text-align:left;display:inline-block;color:var(--txt);width:100%;min-width:260px;max-width:700px;display:table;clear:both;padding:0 20px;margin:20px}td{font-size:.87rem;padding-bottom:0;padding-top:0}th{padding-top:.5em}*{box-sizing:border-box}a,input,select,textarea{width:100%;padding:12px;border:1px solid #ccc;border-radius:.6rem;resize:vertical}label{padding:12px 18px 12px 0;display:inline-block}.required{background-image:var(--star);background-size:1.5em 1.5em;background-position:right;background-repeat:no-repeat}a,button,input[type=submit]{padding:12px;border:1px solid var(--btnbrd);border-radius:.6rem;background-color:var(--btnbg);color:var(--btnfg);font-size:1rem;width:100%;margin:12px 0;display:flex;align-items:center;justify-content:center;text-decoration:none}a:hover,button:hover,input[type=submit]:hover{background-color:var(--btnbghi)}.container{border-radius:.6rem;background-color:var(--grpbg);padding:10px;margin:20px 0}.col-25{float:left;width:25%;text-align:right;margin:0}.col-75{margin:0;float:left;width:75%}.row:after{content:"";display:table;clear:both}.row{font-size:.833rem;margin:5px}.gap,.row:last-of-type{margin:5px 5px 20px 5px}.menu{width:100%;content:"";display:table;clear:both;padding:0 20px;margin:20px}.error,.info,.success,.validation,.warning{border:1px solid;margin:10px auto;padding:15px 10px 15px 50px;background-repeat:no-repeat;background-position:10px center;max-width:460px}@media screen and (max-width:800px){.col-25,.col-75,input[type=submit]{width:100%;margin-top:0}.col-25{text-align:left}label{padding:5px 18px 5px 0}} \ No newline at end of file diff --git a/data/style.css.gz b/data/style.css.gz new file mode 100644 index 0000000000000000000000000000000000000000..4bab67bd05f3a9c4c91dc7037eff504bb87e4600 GIT binary patch literal 962 zcmV;z13mm7iwFpwQh;Fs0CRMCY-KKEb8`TtRO_;nFc5wf#BppDD6P^u!8(qw;rJs! zpz(wR!_rb2-rY^01>58CHggV5HhcYcza?5J=zPBhs!5~8;$=pG5?<1Rt?Fa(x-EtG z9uE#4WW9F}02NuSPN!3FdJ`yJtTtg78dcXha(4Qp+P&+qL&x7bYxC!RcrUnQ&UuaU zH?DKu>|Ok+L8}M0cQwmg2Q-y+u5^ia1r*p~9WBvtWi0>6e)pgD{@b|&Q{IP{%RWfG zL}lj=SPMQCypSYi5}3vp!Km)+mm~@feUKYuQzeupN2(XT4=pU?gr*OLR*lU3;myXb zs761}cv&e8R6^`>o7%I-gTly98y)zvf1asyJ|cqU5NEuu1U+NPW~BT?sPy43 zt9S%9G$nEA57*5$tXeFw9q+pk?^lOF6T#wX@ZySQ8J7hKoek<;pfTqjvThoj;N4EM z@}lmeEvS-&R{^MsggqR(xgdzJ>94S1t#M+)488MF($is7ykRIj0|C{Hc2iZ?v7@5Uz-|ue#WR0P;wF5vCmklG_~kR zC0S1g=8Q0mmwPaN%dey`^a@N!$|b7)1tNv65RqyAZm8je#;@=#<%UGxHnPn`(O0h7KU=DNS+uvPzws&C$4ZI_@CQaLDS5nDLICbh&GbSA>GiNcWyfa&M*^N`+ kjct95vv-^sSLJAWyZUdIRdm@^k)68!2Obqb@q!5e08>KNQUCw| literal 0 HcmV?d00001 diff --git a/data/vars.css b/data/vars.css new file mode 100644 index 00000000..54fe4b58 --- /dev/null +++ b/data/vars.css @@ -0,0 +1,13 @@ +:root { + --txt: #000; + --bg: #fff; + --btnfg: #fff; + --btnbg: #1fa3ec; + --btnbghi: #0083cc; + --grpbg: #f2f2f2; + --fldbg: #fff; + --fldfg: #000; + --btnred: #f00; + --btnredhi: #b00; + --btnbrd: transparent; +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 5a5f91df..fbf850b2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -101,6 +101,7 @@ board_build.partitions = user_setups/esp32/partitions_4MB.csv board_build.filesystem = littlefs board_build.embed_files = data/edit.htm.gz + data/style.css.gz ; ----- crash reporter monitor_filters = esp32_exception_decoder diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index 3182bdcc..f8654eb5 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -106,6 +106,8 @@ WebServer webServer(80); #if defined(CONFIG_IDF_TARGET_ESP32) extern const uint8_t EDIT_HTM_GZ_START[] asm("_binary_data_edit_htm_gz_start"); extern const uint8_t EDIT_HTM_GZ_END[] asm("_binary_data_edit_htm_gz_end"); +extern const uint8_t STYLE_CSS_GZ_START[] asm("_binary_data_style_css_gz_start"); +extern const uint8_t STYLE_CSS_GZ_END[] asm("_binary_data_style_css_gz_end"); #endif // CONFIG_IDF_TARGET_ESP32 #endif // ESP32 @@ -115,19 +117,17 @@ HTTPUpload* upload; static const char HTTP_MENU_BUTTON[] PROGMEM = "

"; -const char MAIN_MENU_BUTTON[] PROGMEM = - "

"; -const char MIT_LICENSE[] PROGMEM = "
MIT License

"; +const char MAIN_MENU_BUTTON[] PROGMEM = "" D_HTTP_MAIN_MENU ""; +const char MIT_LICENSE[] PROGMEM = "
MIT License

"; const char HTTP_DOCTYPE[] PROGMEM = ""; const char HTTP_META_GO_BACK[] PROGMEM = ""; const char HTTP_HEADER[] PROGMEM = "%s"; -const char HTTP_HEADER_END[] PROGMEM = - "
"; -const char HTTP_FOOTER[] PROGMEM = - ""; +const char HTTP_HEADER_END[] PROGMEM = "
"; +const char HTTP_FOOTER[] PROGMEM = ""; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -172,11 +172,11 @@ static void close_form(String& str) static void add_form_button(String& str, const __FlashStringHelper* label, const __FlashStringHelper* action, const __FlashStringHelper* extra) { - str += F("

"); - add_button(str, label, extra); - close_form(str); + str += label; + str += F(""); } static String getContentType(const String& path) @@ -240,9 +240,15 @@ void webSendFooter() #endif } +void webSendCacheHeader(int size, int age) +{ + webServer.sendHeader(F("Content-Length"), (String)(size)); + webServer.sendHeader(F("Cache-Control"), F("max-age=3600, public")); +} + static int webSendCached(int statuscode, const char* contenttype, const char* data, size_t size) { - webServer.sendHeader(F("Cache-Control"), F("public, max-age=604800, immutable")); + webSendCacheHeader(size, 3600); #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) webServer.send_P(statuscode, contenttype, data, size); #else @@ -348,19 +354,11 @@ void webHandleRoot() httpMessage += haspDevice.get_hostname(); httpMessage += F("
"); - httpMessage += F("

"); - - httpMessage += F("

"); - httpMessage += - F("

"); - add_form_button(httpMessage, F(D_HTTP_CONFIGURATION), F("/config"), F("")); - // httpMessage += F("

"); - - httpMessage += F("

"); + httpMessage += F("" D_HTTP_HASP_DESIGN ""); + httpMessage += F("" D_HTTP_SCREENSHOT ""); + httpMessage += F("" D_HTTP_INFORMATION ""); + httpMessage += F("" D_HTTP_CONFIGURATION ""); + httpMessage += F("" D_HTTP_FIRMWARE_UPGRADE ""); #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #ifdef ARDUINO_ARCH_ESP32 @@ -369,18 +367,15 @@ void webHandleRoot() bool flashfile = false; #endif if(flashfile || HASP_FS.exists(F("/edit.htm.gz")) || HASP_FS.exists(F("/edit.htm"))) { - httpMessage += F("

"); + httpMessage += F("" D_HTTP_FILE_BROWSER ""); } #endif - httpMessage += F("

"); + httpMessage += F("" D_HTTP_REBOOT ""); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); webServer.sendContent(httpMessage); } - // httpMessage.clear(); webSendFooter(); } @@ -428,39 +423,28 @@ void webHandleScreenshot() webServer.send_P(200, PSTR("image/bmp"), ""); guiTakeScreenshot(); webServer.client().stop(); - - } else { - { - String httpMessage((char*)0); - httpMessage.reserve(HTTP_PAGE_SIZE); - httpMessage += F("

"); - httpMessage += haspDevice.get_hostname(); - httpMessage += F("


"); - - // httpMessage += - // F(""); - httpMessage += F("

"); - - httpMessage += F("

"); - httpMessage += - F("

"); - httpMessage += - F("

"); - httpMessage += FPSTR(MAIN_MENU_BUTTON); - - webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); - webServer.sendContent(httpMessage); - } - // httpMessage.clear(); - webSendFooter(); + return; } + + { + String httpMessage((char*)0); + httpMessage.reserve(HTTP_PAGE_SIZE); + httpMessage += F("

"); + httpMessage += haspDevice.get_hostname(); + httpMessage += F("


"); + + httpMessage += F("

"); // Automatic refresh + + httpMessage += F("" D_HTTP_REFRESH ""); + httpMessage += F("" D_HTTP_PREV_PAGE ""); + httpMessage += F("" D_HTTP_NEXT_PAGE ""); + httpMessage += FPSTR(MAIN_MENU_BUTTON); + + webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); + webServer.sendContent(httpMessage); + } + webSendFooter(); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -976,6 +960,14 @@ int handleFileRead(String path) } #endif +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_IDF_TARGET_ESP32) + if(path == F("/style.css")) { + size_t size = STYLE_CSS_GZ_END - STYLE_CSS_GZ_START; + webServer.sendHeader(F("Content-Encoding"), F("gzip")); + return webSendCached(200, PSTR("text/css"), (const char*)STYLE_CSS_GZ_START, size); // OK + } +#endif + if(!strcasecmp_P(path.c_str(), PSTR("/favicon.ico"))) return webSendCached(204, PSTR("image/bmp"), "", 0); // No content @@ -1183,30 +1175,20 @@ void webHandleConfig() httpMessage += F("
"); #if HASP_USE_WIFI > 0 - add_form_button(httpMessage, F(D_HTTP_WIFI_SETTINGS), F("/config/wifi"), F("")); + httpMessage += F("" D_HTTP_WIFI_SETTINGS ""); #endif #if HASP_USE_MQTT > 0 - add_form_button(httpMessage, F(D_HTTP_MQTT_SETTINGS), F("/config/mqtt"), F("")); + httpMessage += F("" D_HTTP_MQTT_SETTINGS ""); #endif - add_form_button(httpMessage, F(D_HTTP_HTTP_SETTINGS), F("/config/http"), F("")); - add_form_button(httpMessage, F(D_HTTP_GUI_SETTINGS), F("/config/gui"), F("")); - - // httpMessage += - // F("

"); + httpMessage += F("" D_HTTP_HTTP_SETTINGS ""); + httpMessage += F("" D_HTTP_GUI_SETTINGS ""); #if HASP_USE_GPIO > 0 - httpMessage += F("

"); + httpMessage += F("" D_HTTP_GPIO_SETTINGS ""); #endif - httpMessage += F("

"); - - httpMessage += - F("

"); - + httpMessage += F("" D_HTTP_DEBUG_SETTINGS ""); + httpMessage += F("" D_HTTP_FACTORY_RESET ""); httpMessage += FPSTR(MAIN_MENU_BUTTON); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); @@ -1226,36 +1208,64 @@ void webHandleMqttConfig() mqttGetConfig(settings.to()); { - // char buffer[128]; String httpMessage((char*)0); httpMessage.reserve(HTTP_PAGE_SIZE); httpMessage += F("

"); httpMessage += haspDevice.get_hostname(); httpMessage += F("


"); + httpMessage += F("

" D_HTTP_MQTT_SETTINGS "

"); - httpMessage += F("
"); - httpMessage += F("HASP Node Name (required. lowercase letters, numbers, and _ only)" - "

Group Name (required)

MQTT Broker (required)
MQTT Port (required)
MQTT User (optional)
MQTT Password (optional)"); + // Node Name httpMessage += - F("'>

"); + F("
"); + httpMessage += + F("
"); + + // Group Name + httpMessage += F("
"); + httpMessage += + F("
"); + + // Broker + httpMessage += F("
"); + httpMessage += F("
"); + + // Mqtt Port + httpMessage += F("
"); + httpMessage += F("
"); + + // Mqtt User + httpMessage += F("
"); + httpMessage += F("
"); + + // Mqtt Password + httpMessage += F("
"); + httpMessage += F("
"); + + // Submit & End Form + httpMessage += F(""); + httpMessage += F("
"); add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); @@ -1280,21 +1290,29 @@ void webHandleGuiConfig() httpMessage += F("

"); httpMessage += haspDevice.get_hostname(); httpMessage += F("


"); + httpMessage += F("

" D_HTTP_GUI_SETTINGS "

"); - httpMessage += F("
"); + // Form + httpMessage += F("
"); - httpMessage += F("

Short Idle

"); + httpMessage += F("

"); + httpMessage += F("'>
"); - httpMessage += F("

Long Idle

"); + httpMessage += F("

"); + httpMessage += F("'>
"); + // Rotation int8_t rotation = settings[FPSTR(FP_GUI_ROTATION)].as(); - httpMessage += F("

Orientation "); httpMessage += getOption(0, F("0 degrees"), rotation); httpMessage += getOption(1, F("90 degrees"), rotation); httpMessage += getOption(2, F("180 degrees"), rotation); @@ -1303,18 +1321,24 @@ void webHandleGuiConfig() httpMessage += getOption(7, F("90 degrees - mirrored"), rotation); httpMessage += getOption(4, F("180 degrees - mirrored"), rotation); httpMessage += getOption(5, F("270 degrees - mirrored"), rotation); - httpMessage += F("

"); + httpMessage += F(""); - httpMessage += F("

"); + httpMessage += F("
()) httpMessage += F(" checked"); - httpMessage += F(">Invert Colors"); + httpMessage += F(">Invert Colors
"); - httpMessage += F("

"); + httpMessage += F("
()) httpMessage += F(" checked"); - httpMessage += F(">Show Pointer"); + httpMessage += F(">Show Pointer
"); + // Backlight int8_t bcklpin = settings[FPSTR(FP_GUI_BACKLIGHTPIN)].as(); - httpMessage += F("

Backlight Control "); httpMessage += getOption(-1, F("None"), bcklpin); #if defined(ARDUINO_ARCH_ESP32) char buffer[10]; @@ -1329,18 +1353,17 @@ void webHandleGuiConfig() httpMessage += getOption(0, F("D3 - GPIO 0"), bcklpin); httpMessage += getOption(2, F("D4 - GPIO 2"), bcklpin); #endif - httpMessage += F("

"); + httpMessage += F(""); - add_button(httpMessage, F(D_HTTP_SAVE_SETTINGS), F("name='save' value='gui'")); - close_form(httpMessage); - // httpMessage += - // F("

"); + // Submit & End Form + httpMessage += F(""); + httpMessage += F(""); #if TOUCH_DRIVER == 2046 && defined(TOUCH_CS) - add_form_button(httpMessage, F(D_HTTP_CALIBRATE), F("/config/gui"), F("name='cal' value='1'")); + add_form_button(httpMessage, F(D_HTTP_CALIBRATE), F("/config/gui?cal=1"), F("name='cal' value='1'")); #endif - add_form_button(httpMessage, F(D_HTTP_ANTIBURN), F("/config/gui"), F("name='brn' value='1'")); + add_form_button(httpMessage, F(D_HTTP_ANTIBURN), F("/config/gui?brn=1"), F("name='brn' value='1'")); add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); webServer.sendContent(httpMessage); @@ -1365,18 +1388,30 @@ void webHandleWifiConfig() httpMessage += F("

"); httpMessage += haspDevice.get_hostname(); httpMessage += F("


"); + httpMessage += F("

" D_HTTP_WIFI_SETTINGS "

"); - httpMessage += F("
"); - httpMessage += F("WiFi SSID (required)"); + + // Wifi SSID + httpMessage += F("
"); + httpMessage += F("

WiFi Password (required)
"); + + // Wifi Password + httpMessage += F("
"); + httpMessage += F("

"); + httpMessage += F("'>
"); + + // Submit & End Form + httpMessage += F(""); + httpMessage += F(""); #if HASP_USE_WIFI > 0 && !defined(STM32F4xx) if(WiFi.getMode() == WIFI_STA) { @@ -1473,7 +1508,6 @@ void webHandleHttpConfig() webSendPage(haspDevice.get_hostname(), len, false); webServer.sendContent(httpMessage); } - // httpMessage.clear(); webSendFooter(); } @@ -1508,6 +1542,7 @@ void webHandleGpioConfig() httpMessage += F("

"); httpMessage += haspDevice.get_hostname(); httpMessage += F("


"); + httpMessage += F("

" D_HTTP_GPIO_SETTINGS "

"); httpMessage += F("
"); @@ -1647,21 +1682,16 @@ void webHandleGpioConfig() httpMessage += F("
"); if(configCount < HASP_NUM_GPIO_CONFIG) { - httpMessage += F("

"); - httpMessage += F("

"); + httpMessage += F("'>" D_HTTP_ADD_GPIO " Input"); - httpMessage += F("

"); - httpMessage += F("

"); + httpMessage += F("'>" D_HTTP_ADD_GPIO " Output"); } add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); - // httpMessage += F("

"); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); webServer.sendContent(httpMessage); @@ -1858,11 +1888,15 @@ void webHandleDebugConfig() httpMessage += F("

"); httpMessage += haspDevice.get_hostname(); httpMessage += F("


"); + httpMessage += F("

" D_HTTP_DEBUG_SETTINGS "

"); - httpMessage += F("
"); + // Form + httpMessage += F("
"); + // Baudrate uint16_t baudrate = settings[FPSTR(FP_CONFIG_BAUD)].as(); - httpMessage += F("

Serial Port "); httpMessage += getOption(1, F(D_SETTING_DISABLED), baudrate); // Don't use 0 here which is default 115200 httpMessage += getOption(960, F("9600"), baudrate); httpMessage += getOption(1920, F("19200"), baudrate); @@ -1870,39 +1904,57 @@ void webHandleDebugConfig() httpMessage += getOption(5760, F("57600"), baudrate); httpMessage += getOption(7488, F("74880"), baudrate); httpMessage += getOption(11520, F("115200"), baudrate); - httpMessage += F("

Telemetry Period (Seconds, 0=disable) " - "

"); + httpMessage += F("

"); + httpMessage += F("'>
"); #if HASP_USE_SYSLOG > 0 - httpMessage += F("Syslog Hostname (optional)
"); + httpMessage += F("

Syslog Port (optional)
"); - httpMessage += F("'>Syslog Facility "); + + // Syslog Facility uint8_t logid = settings[FPSTR(FP_CONFIG_LOG)].as(); + httpMessage += F("
"); + httpMessage += F("
"); - httpMessage += F("
Syslog Protocol () == 0) httpMessage += F(" checked"); + // Syslog Protocol + uint8_t proto = settings[FPSTR(FP_CONFIG_PROTOCOL)].as(); + httpMessage += F("
"); + httpMessage += F("
IETF (RFC 5424)   () == 1) httpMessage += F(" checked"); + if(proto == 1) httpMessage += F(" checked"); httpMessage += F(">BSD (RFC 3164)"); + httpMessage += F("
"); #endif - httpMessage += - F("

"); + // Submit & End Form + httpMessage += F(""); + httpMessage += F(""); + + // ******************************************************************* add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); - // httpMessage += PSTR("

"); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); webServer.sendContent(httpMessage); @@ -1925,6 +1977,7 @@ void webHandleHaspConfig() httpMessage += F("

"); httpMessage += haspDevice.get_hostname(); httpMessage += F("


"); + httpMessage += F("

" D_HTTP_HASP_DESIGN "

"); httpMessage += F("

"); @@ -2216,27 +2269,33 @@ void httpStop() // Do not keep CSS in memory because it is cached in the browser void webSendCss() { - String HTTP_CSS = - F("body,.c{text-align:center;}" - "div,input{padding:5px;font-size:1em;}" - "a{color:" D_HTTP_COLOR_TEXT "}" - "input:not([type=file]){width:90%;background-color:" D_HTTP_COLOR_INPUT ";color:" D_HTTP_COLOR_INPUT_TEXT ";}" - "input[type=checkbox],input[type=radio]{width:1em;}" - "select{background-color:" D_HTTP_COLOR_INPUT ";color:" D_HTTP_COLOR_INPUT_TEXT ";}" - "input:invalid{border:1px solid " D_HTTP_COLOR_INPUT_WARNING ";}" - //"#hue{width:100%;}" - "body{font-family:verdana;width:60%;margin:auto;background:" D_HTTP_COLOR_BACKGROUND - ";color:" D_HTTP_COLOR_TEXT ";}" - "button{border:0;border-radius:0.6rem;background-color:" D_HTTP_COLOR_BUTTON - ";color:" D_HTTP_COLOR_BUTTON_TEXT ";line-height:2.4rem;font-size:1.2rem;width:100%;}" - //".q{float:right;width:64px;text-align:right;}" - ".red{background-color:" D_HTTP_COLOR_BUTTON_RESET ";}" - "#doc{text-align:left;display:inline-block;color:" D_HTTP_COLOR_TEXT ";min-width:260px;}" - // ".button3{background-color:#f44336;}" - // ".button4{background-color:#e7e7e7;color:black;}" - // ".button5{background-color:#555555;}" - // ".button6{background-color:#4CAF50;}" - "td{font-size:0.87rem;padding-bottom:0px;padding-top:0px;}th{padding-top:0.5em;}"); + char filename[32]; + strncpy(filename, webServer.uri().c_str(), sizeof(filename)); + + if(HASP_FS.exists(filename)) { + String contentType((char*)0); + contentType = getContentType(filename); + File file = HASP_FS.open(filename, "r"); + webSendCacheHeader(file.size(), 3600); + webServer.streamFile(file, contentType); + file.close(); + return; + } + + String HTTP_CSS = F(":root{" + "--txt:" D_HTTP_COLOR_TEXT ";" + "--bg:" D_HTTP_COLOR_BACKGROUND ";" + "--btnfg:" D_HTTP_COLOR_BUTTON_TEXT ";" + "--btnbg:" D_HTTP_COLOR_BUTTON ";" + "--btnbghi: #0083cc;" + "--btnred:" D_HTTP_COLOR_BUTTON_RESET ";" + "--btnredhi: #b00;" + "--btnbrd: transparent;" + "--grpbg: #f2f2f2;" + "--fldbg:" D_HTTP_COLOR_INPUT ";" + "--fldfg:" D_HTTP_COLOR_INPUT_TEXT ";" + "--fldred:" D_HTTP_COLOR_INPUT_WARNING ";" + "}"); webSendCached(200, PSTR("text/css"), HTTP_CSS.c_str(), HTTP_CSS.length()); } @@ -2265,7 +2324,7 @@ void httpSetup() // Shared pages webServer.on(F("/about"), webHandleAbout); - webServer.on(F("/css"), webSendCss); + webServer.on(F("/vars.css"), webSendCss); webServer.on(F("/js"), webSendJavascript); webServer.onNotFound(httpHandleNotFound); @@ -2395,7 +2454,6 @@ IRAM_ATTR void httpLoop(void) webServer.handleClient(); } - //////////////////////////////////////////////////////////////////////////////////////////////////// #if HASP_USE_CONFIG > 0 bool httpGetConfig(const JsonObject& settings)