From 2604230a778e61857f20b33f1ab8f3454900d183 Mon Sep 17 00:00:00 2001 From: Andreas Breitschopp Date: Mon, 1 Jan 2024 16:03:50 +0100 Subject: [PATCH] Added setCustomTopBodyElement allowing to define custom HTML to be added at the top of the "" tag. --- WiFiManager.cpp | 11 +++++++++++ WiFiManager.h | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index acf5f107..8a4b328f 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1288,6 +1288,7 @@ String WiFiManager::getHTTPHead(String title){ page += FPSTR(HTTP_HEAD_END); } + page += _customTopBodyElement; return page; } @@ -2889,6 +2890,16 @@ void WiFiManager::setCustomHeadElement(const char* html) { _customHeadElement = html; } +/** + * set custom top body html + * custom element will be added to shortly after body tag opened, eg. to show a logo etc. + * @access public + * @param char element + */ +void WiFiManager::setCustomTopBodyElement(const char* html) { + _customTopBodyElement = html; +} + /** * set custom menu html * custom element will be added to menu under custom menu item. diff --git a/WiFiManager.h b/WiFiManager.h index 78394c5d..c5f031f5 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -374,6 +374,9 @@ class WiFiManager //add custom html at inside for all pages void setCustomHeadElement(const char* html); + //add custom html at start of for all pages + void setCustomTopBodyElement(const char* html); + //if this is set, customise style void setCustomMenuHTML(const char* html); @@ -596,8 +599,9 @@ class WiFiManager boolean _disableConfigPortal = true; // FOR autoconnect - stop config portal if cp wifi save String _hostname = ""; // hostname for esp8266 for dhcp, and or MDNS - const char* _customHeadElement = ""; // store custom head element html from user isnide - const char* _customMenuHTML = ""; // store custom head element html from user inside <> + const char* _customHeadElement = ""; // store custom head element html from user inside + const char* _customTopBodyElement = ""; // store custom top body element html from user inside + const char* _customMenuHTML = ""; // store custom menu html from user String _bodyClass = ""; // class to add to body String _title = FPSTR(S_brand); // app title - default WiFiManager