From 37cdda33c7b0ebd525892fc23f825cb530febcc9 Mon Sep 17 00:00:00 2001 From: Shawn A Date: Thu, 19 Jul 2018 13:10:37 -0500 Subject: [PATCH] adds setClass(invert) black theme adds class string to body, invert(black) is built in ` wm.setClass("invert");` --- WiFiManager.cpp | 20 ++++++++++++++++++-- WiFiManager.h | 5 +++++ extras/WiFiManager.template.html | 24 +++++++++++++++++++----- strings_en.h | 28 ++++++++++++++-------------- 4 files changed, 56 insertions(+), 21 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index b18423e..39cea64 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -817,7 +817,16 @@ String WiFiManager::getHTTPHead(String title){ page += FPSTR(HTTP_SCRIPT); page += FPSTR(HTTP_STYLE); page += _customHeadElement; - page += FPSTR(HTTP_HEAD_END); + + if(_bodyClass != ""){ + String p = FPSTR(HTTP_HEAD_END); + p.replace(FPSTR(T_c), _bodyClass); // add class str + page += p; + } + else { + page += FPSTR(HTTP_HEAD_END); + } + return page; } @@ -1567,7 +1576,6 @@ void WiFiManager::handleErase(boolean opt) { DEBUG_WM(DEBUG_VERBOSE,F("<- HTTP Erase")); handleRequest(); String page = getHTTPHead(FPSTR(S_titleerase)); // @token titleerase - page += FPSTR(HTTP_HEAD_END); bool ret = erase(opt); @@ -2141,6 +2149,14 @@ void WiFiManager::setCountry(String cc){ _wificountry = cc; } +/** + * setClass + * @param String str body class string + */ +void WiFiManager::setClass(String str){ + _bodyClass = str; +} + // HELPERS // DEBUG diff --git a/WiFiManager.h b/WiFiManager.h index 6433261..7f63817 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -235,7 +235,11 @@ class WiFiManager // debug output platform info and versioning void debugPlatformInfo(); String htmlEntities(String str); + + // set the country code for wifi settings void setCountry(String cc); + // set body class (invert) + void setClass(String str); private: std::unique_ptr dnsServer; @@ -307,6 +311,7 @@ class WiFiManager const char * _hostname = ""; const char* _customHeadElement = ""; // store custom head element html from user + String _bodyClass = ""; // class to add to body // internal options boolean _preloadwifiscan = true; // preload wifiscan if true diff --git a/extras/WiFiManager.template.html b/extras/WiFiManager.template.html index e3b6ee9..e4dc77f 100644 --- a/extras/WiFiManager.template.html +++ b/extras/WiFiManager.template.html @@ -7,6 +7,23 @@ "; const char HTTP_HELP[] PROGMEM = @@ -134,7 +134,7 @@ const char HTTP_JS[] PROGMEM = #ifdef ESP32 const char HTTP_INFO_esphead[] PROGMEM = "

esp32


"; const char HTTP_INFO_chiprev[] PROGMEM = "
Chip Rev
{1}
"; - const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
CPU0: {1}
CPU1: {2}
"; + const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
CPU0: {1}
CPU1: {2}
"; const char HTTP_INFO_aphost[] PROGMEM = "
Acccess Point Hostname
{1}
"; #else const char HTTP_INFO_esphead[] PROGMEM = "

esp8266


"; @@ -245,11 +245,11 @@ const char S_dns[] PROGMEM = "dns"; // softap ssid default prefix #ifdef ESP8266 - const char S_ssidpre[] PROGMEM = "ESP"; + const char S_ssidpre[] PROGMEM = "ESP"; #elif defined(ESP32) - const char S_ssidpre[] PROGMEM = "ESP32"; + const char S_ssidpre[] PROGMEM = "ESP32"; #else - const char S_ssidpre[] PROGMEM = "WM"; + const char S_ssidpre[] PROGMEM = "WM"; #endif //Tokens @@ -276,8 +276,8 @@ const char T_h[] PROGMEM = "{h}"; // @token h const char HTTP_HEAD_CL[] PROGMEM = "Content-Length"; const char HTTP_HEAD_CT[] PROGMEM = "text/html"; const char HTTP_HEAD_CT2[] PROGMEM = "text/plain"; -const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin"; -const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*"; +const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin"; +const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*"; const char * const WIFI_STA_STATUS[] PROGMEM {