Replaced the html content by files

This commit is contained in:
Kai Lauterbach 2023-05-01 15:55:42 +02:00
parent 382486000c
commit e9026c064d
4 changed files with 10 additions and 18 deletions

View file

@ -1,4 +1,4 @@
const String config_html = R"=====(
<form class="pure-form pure-form-aligned" action="/" method="post"> <form class="pure-form pure-form-aligned" action="/" method="post">
<h3>Config</h3> <h3>Config</h3>
<div class="pure-control-group"> <div class="pure-control-group">
@ -60,3 +60,4 @@
<button type="submit" class="pure-button pure-button-primary">Save</button> <button type="submit" class="pure-button pure-button-primary">Save</button>
</div> </div>
</form> </form>
)=====";

View file

@ -1,3 +1,4 @@
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266mDNS.h> #include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h> #include <ESP8266HTTPUpdateServer.h>
@ -5,7 +6,6 @@
#include <WiFiManager.h> #include <WiFiManager.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <EEPROM.h> #include <EEPROM.h>
#include "FS.h"
#include "config.h" #include "config.h"
@ -605,11 +605,7 @@ void init_webserver()
} }
// Generate HTML page // Generate HTML page
String http_content = "123"; String http_content = index_html;
// HTML-Datei öffnen und Inhalt in eine Zeichenfolge speichern
File file = SPIFFS.open("/index.html", "r");
http_content = file.readString();
file.close();
http_content.replace("{{LIGHT_NAME}}", (String)light_name); http_content.replace("{{LIGHT_NAME}}", (String)light_name);
@ -630,11 +626,7 @@ void init_webserver()
http_content.replace("{{TRANSITION_TIME}}", (String)default_transitiontime); http_content.replace("{{TRANSITION_TIME}}", (String)default_transitiontime);
// Generate lights part of the HTML page // Generate lights part of the HTML page
String light_content = ""; String light_content = light_html;
// HTML-Datei öffnen und Inhalt in eine Zeichenfolge speichern
File file2 = SPIFFS.open("/light_control.html", "r");
light_content = file2.readString();
file2.close();
// Light control // Light control
for (uint8 light_num = 0; light_num < LIGHTS_COUNT; light_num++) for (uint8 light_num = 0; light_num < LIGHTS_COUNT; light_num++)
@ -691,11 +683,7 @@ void init_webserver()
} }
// Generate lights part of the HTML page // Generate lights part of the HTML page
String config_content = ""; String config_content = config_html;
// HTML-Datei öffnen und Inhalt in eine Zeichenfolge speichern
File file3 = SPIFFS.open("/config.html", "r");
config_content = file3.readString();
file3.close();
// Wifi settings // Wifi settings
config_content.replace("{{WIFI_SSIF}}", WiFi.SSID()); config_content.replace("{{WIFI_SSIF}}", WiFi.SSID());

View file

@ -1,3 +1,4 @@
const String index_html = R"=====(
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
@ -272,4 +273,4 @@
</fieldset> </fieldset>
</body> </body>
</html> </html>
)=====";

View file

@ -1,3 +1,4 @@
const String light_html = R"=====(
<h4>Light {{LIGHT_NUMBER}}</h4> <h4>Light {{LIGHT_NUMBER}}</h4>
<div class="pure-control-group"> <div class="pure-control-group">
<label for="power"> <label for="power">
@ -27,3 +28,4 @@
} }
</script> </script>
</div> </div>
)=====";