mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
Optimize webserver speed
This commit is contained in:
parent
1622ed5dfb
commit
6b94fe0eba
5 changed files with 9 additions and 17 deletions
|
@ -2,7 +2,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
String cellmonitor_processor(const String& var) {
|
String cellmonitor_processor(const String& var) {
|
||||||
if (var == "PLACEHOLDER") {
|
if (var == "ABC") {
|
||||||
String content = "";
|
String content = "";
|
||||||
// Page format
|
// Page format
|
||||||
content += "<style>";
|
content += "<style>";
|
||||||
|
|
|
@ -13,7 +13,7 @@ const char EVENTS_HTML_END[] = R"=====(
|
||||||
)=====";
|
)=====";
|
||||||
|
|
||||||
String events_processor(const String& var) {
|
String events_processor(const String& var) {
|
||||||
if (var == "PLACEHOLDER") {
|
if (var == "ABC") {
|
||||||
String content = "";
|
String content = "";
|
||||||
content.reserve(5000);
|
content.reserve(5000);
|
||||||
// Page format
|
// Page format
|
||||||
|
|
|
@ -1,29 +1,21 @@
|
||||||
const char index_html[] = R"rawliteral(
|
const char index_html[] = R"rawliteral(
|
||||||
<!DOCTYPE HTML><html><head><title>Battery Emulator</title><meta name="viewport" content="width=device-width,initial-scale=1"><style>html{font-family:Arial;display:inline-block;text-align:center}h2{font-size:3rem}p{font-size:3rem}body{max-width:800px;margin:0 auto;padding-bottom:25px}.switch{position:relative;display:inline-block;width:120px;height:68px}.switch input{display:none}.slider{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#ccc;border-radius:6px}.slider:before{position:absolute;content:"";height:52px;width:52px;left:8px;bottom:8px;background-color:#fff;-webkit-transition:.4s;transition:.4s;border-radius:3px}input:checked+.slider{background-color:#b30000}input:checked+.slider:before{-webkit-transform:translateX(52px);-ms-transform:translateX(52px);transform:translateX(52px)}</style></head><body><h2>Battery Emulator</h2>%PLACEHOLDER%</body></html>
|
<!DOCTYPE HTML><html><head><title>Battery Emulator</title><meta name="viewport" content="width=device-width"><style>html{font-family:Arial;display:inline-block;text-align:center}h2{font-size:3rem}body{max-width:800px;margin:0 auto}</style></head><body><h2>Battery Emulator</h2>%ABC%</body></html>
|
||||||
)rawliteral";
|
)rawliteral";
|
||||||
|
|
||||||
/* The above code is minified to increase performance. Here is the full HTML function:
|
/* The above code is minified to increase performance. Here is the full HTML function:
|
||||||
<!DOCTYPE HTML><html>
|
<!DOCTYPE HTML><html>
|
||||||
<head>
|
<head>
|
||||||
<title>Battery Emulator</title>
|
<title>Battery Emulator</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width">
|
||||||
<style>
|
<style>
|
||||||
html {font-family: Arial; display: inline-block; text-align: center;}
|
html {font-family: Arial; display: inline-block; text-align: center;}
|
||||||
h2 {font-size: 3.0rem;}
|
h2 {font-size: 3.0rem;}
|
||||||
p {font-size: 3.0rem;}
|
body {max-width: 800px; margin:0px auto;}
|
||||||
body {max-width: 800px; margin:0px auto; padding-bottom: 25px;}
|
|
||||||
.switch {position: relative; display: inline-block; width: 120px; height: 68px}
|
|
||||||
.switch input {display: none}
|
|
||||||
.slider {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 6px}
|
|
||||||
.slider:before {position: absolute; content: ""; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 3px}
|
|
||||||
input:checked+.slider {background-color: #b30000}
|
|
||||||
input:checked+.slider:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2>Battery Emulator</h2>
|
<h2>Battery Emulator</h2>
|
||||||
%PLACEHOLDER%
|
%ABC%
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
String settings_processor(const String& var) {
|
String settings_processor(const String& var) {
|
||||||
if (var == "PLACEHOLDER") {
|
if (var == "ABC") {
|
||||||
String content = "";
|
String content = "";
|
||||||
//Page format
|
//Page format
|
||||||
content += "<style>";
|
content += "<style>";
|
||||||
|
|
|
@ -344,7 +344,7 @@ void init_ElegantOTA() {
|
||||||
}
|
}
|
||||||
|
|
||||||
String processor(const String& var) {
|
String processor(const String& var) {
|
||||||
if (var == "PLACEHOLDER") {
|
if (var == "ABC") {
|
||||||
String content = "";
|
String content = "";
|
||||||
//Page format
|
//Page format
|
||||||
content += "<style>";
|
content += "<style>";
|
||||||
|
@ -355,7 +355,7 @@ String processor(const String& var) {
|
||||||
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px;border-radius: 50px'>";
|
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px;border-radius: 50px'>";
|
||||||
|
|
||||||
// Show version number
|
// Show version number
|
||||||
content += "<h4>Software version: " + String(version_number) + "</h4>";
|
content += "<h4>Software: " + String(version_number) + "</h4>";
|
||||||
|
|
||||||
// Display LED color
|
// Display LED color
|
||||||
content += "<h4>LED color: ";
|
content += "<h4>LED color: ";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue