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">
<h3>Config</h3>
<div class="pure-control-group">
@ -60,3 +60,4 @@
<button type="submit" class="pure-button pure-button-primary">Save</button>
</div>
</form>
)=====";

View file

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

View file

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

View file

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