firmware WIP - add style.css 8)

This commit is contained in:
Marcus 2024-04-14 15:43:18 +02:00
parent f7c42a906d
commit be590b2e2d

View file

@ -115,12 +115,19 @@ const bool APhidden = false;
ESP8266WebServer webserver(80);
/*
* HTML pages
* HTML constants for header, footer, css, ...
*/
// Template: const char HTMLexamplepage[] PROGMEM = R"EOF()EOF";
const char HTMLheader[] PROGMEM = R"EOF(
<!DOCTYPE html>
<html>
<head>
<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>
)EOF";
@ -129,6 +136,26 @@ const char HTMLfooter[] PROGMEM = R"EOF(
</html>
)EOF";
const char HTMLstyleCSS[] PROGMEM = R"EOF(
body {
font-family: helvetica;
background-color: #cccccc;
}
a:link, a:visited {
color: #33ff33;
}
a:hover {
color: #ffff00;
}
a:active {
color: #da7a0a;
}
)EOF";
/*
*
* Pin assignments
@ -641,6 +668,7 @@ void setup() {
// generic handler
webserver.on("/wifiConfig/save", HTTP_POST, POSTwifiConfig);
webserver.on("/style.css", HTTP_GET, WEBstyleCSS);
// 404 handling
webserver.onNotFound(WEB404);
@ -686,20 +714,28 @@ void WebHandler_configured() {
*
*/
// 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 += "404 - not found";
body += FPSTR(HTMLfooter);
webserver.send(200, "text/html", body);
}
void WEBrootUnconfigured() {
byte ssidsAvail = WiFi.scanNetworks();
String body = FPSTR(HTMLheader);
body += "<h1>unconfigured!</h1>\n";
body += "<h1>WiFi config</h1>\n";
body += "<p>Select your wifi network from the SSID list.<br>Leave IP field empty, to use DHCP.</p>";
body += "<p>Select your wifi network from the SSID list.<br>To use DHCP leave IP, Subnet, Gateway and DNS fields blank!</p>";
body += "<form method='post' action='/wifiConfig/save'>\n";
body += "SSID: <select id='WIFIssid' name='WIFIssid'>\n";
// build option list for selecting wifi
Serial.println("Available Wifis: ");
for(int i = 0 ; i < ssidsAvail; i++) {
String wifiName = WiFi.SSID(i);
@ -714,13 +750,10 @@ void WEBrootUnconfigured() {
body += "Password: <input type='password' name='WIFIpassword'><br>\n";
body += "IP: <input type='text' name='WIFIip'><br>\n";
body += "Subnet mask: <input type='text' name='WIFInetmask'><br>\n";
body += "gateway: <input type='text' name='WIFIgateway'><br>\n";
body += "dns: <input type='text' name='WIFIdns'><br>\n";
body += "Gateway: <input type='text' name='WIFIgateway'><br>\n";
body += "DNS: <input type='text' name='WIFIdns'><br>\n";
body += "<input type='submit' value='Save'>\n";
body += "</form>\n";
body += "<p>Available WiFi <pre>\n";
body += "</pre></p>\n";
body += FPSTR(HTMLfooter);
webserver.send(200, "text/html", body);