put css into HTMLheader so it is always available. especially for WebRestart()
This commit is contained in:
parent
19cd6c1288
commit
4fb0a6fdb7
1 changed files with 108 additions and 95 deletions
|
@ -163,28 +163,9 @@ const char HTMLheader[] PROGMEM = R"EOF(
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>CanGrow</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<ul class="nav">
|
||||
<li><a href="/">CanGrow</a></li>
|
||||
<li><a id="growSettings" href="/growSettings">Grow settings</a></li>
|
||||
<li><a id="systemSettings" href="/systemSettings">System settings</a></li>
|
||||
<li><a href="/wifiSettings">WiFi settings</a></li>
|
||||
<li><a href="/help">Help</a></li>
|
||||
<li><span id="GrowName"></span></li>
|
||||
</ul>
|
||||
<div class="center">
|
||||
|
||||
)EOF";
|
||||
|
||||
const char HTMLfooter[] PROGMEM = R"EOF(
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
)EOF";
|
||||
|
||||
const char HTMLstyleCSS[] PROGMEM = R"EOF(
|
||||
<!-- <link rel="stylesheet" href="/style.css"> -->
|
||||
<style>
|
||||
/* Having the whole CSS here ensures it's all the time present*/
|
||||
body {
|
||||
color: #cae0d0;
|
||||
background-color: #1d211e;
|
||||
|
@ -274,11 +255,37 @@ a:active {
|
|||
.nav li a:active {
|
||||
color: #cae0d0;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<ul class="nav">
|
||||
<li><a href="/">CanGrow</a></li>
|
||||
<li><a id="growSettings" href="/growSettings">Grow settings</a></li>
|
||||
<li><a id="systemSettings" href="/systemSettings">System settings</a></li>
|
||||
<li><a href="/wifiSettings">WiFi settings</a></li>
|
||||
<li><a href="/help">Help</a></li>
|
||||
<li><span id="GrowName"></span></li>
|
||||
</ul>
|
||||
<div class="center">
|
||||
|
||||
)EOF";
|
||||
|
||||
const char HTMLfooter[] PROGMEM = R"EOF(
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
)EOF";
|
||||
|
||||
/*
|
||||
* I decided to embed CSS into HTMLheader because after
|
||||
* a wifi change triggerd restart of the esp, the the style.css never get deliverd
|
||||
* because the esp restarts after the webpage was delivered. style.css would be a second call
|
||||
* but when the browser sends this, it's too late.
|
||||
const char HTMLstyleCSS[] PROGMEM = R"EOF(
|
||||
|
||||
)EOF";
|
||||
*/
|
||||
|
||||
const char HTMLsuccess[] PROGMEM = R"EOF(
|
||||
<div class='infomsg'>Successfully saved!</div>
|
||||
)EOF";
|
||||
|
@ -952,7 +959,7 @@ void WebHandler() {
|
|||
* WebHandler_unconfigured() and WebHandler_configured()
|
||||
*/
|
||||
// style.css
|
||||
webserver.on("/style.css", HTTP_GET, WEBstyleCSS);
|
||||
//webserver.on("/style.css", HTTP_GET, WEBstyleCSS);
|
||||
|
||||
// Web root
|
||||
webserver.on("/", HTTP_GET, WEBroot);
|
||||
|
@ -985,8 +992,8 @@ void WebHandler() {
|
|||
}
|
||||
|
||||
void WebRestart() {
|
||||
if(NeedRestart == true) {
|
||||
String body = FPSTR(HTMLheader);
|
||||
if(NeedRestart == true) {
|
||||
body += "<h1>Restarting</h1>";
|
||||
body += "<div class='infomsg'>After restart you will be connected to Wifi<br><b>";
|
||||
body += WIFIssid;
|
||||
|
@ -996,6 +1003,10 @@ void WebRestart() {
|
|||
Serial.println("Restarting... see you soon space cowboy!");
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
} else {
|
||||
body += "<div class='warnmsg'><h1>Not allowed</h1></div>";
|
||||
body += returnHTMLfooter();
|
||||
webserver.send(405, "text/html", body);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1071,13 +1082,15 @@ String returnStrSelected(byte savedValue, byte selectId) {
|
|||
*/
|
||||
|
||||
// not really a webpage, but CSS is important for them :p
|
||||
/*
|
||||
void WEBstyleCSS() {
|
||||
webserver.send(200, "text/css", HTMLstyleCSS);
|
||||
}
|
||||
*/
|
||||
|
||||
void WEB404() {
|
||||
String body = FPSTR(HTMLheader);
|
||||
body += "<h1>404 - not found</h1>";
|
||||
body += "<div class='warnmsg'><h1>404 - not found</h1></div>";
|
||||
body += returnHTMLfooter();
|
||||
webserver.send(404, "text/html", body);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue