Zaklad pro verzi 7.x.x - Pouziva knihovnu sysvars, takze neni zavisla na zadnem druhu souboroveho systemu

This commit is contained in:
2021-06-21 17:22:19 +02:00
parent 5c382257e9
commit 8e857a1ae2
4 changed files with 524 additions and 499 deletions

View File

@@ -9,16 +9,17 @@
static const char TEXTHTML[] PROGMEM = "text/html";
static const char TEXTPLAIN[] PROGMEM = "text/plain";
static const char TEXTJSON[] PROGMEM = "text/json";
static const char PAGE_INDEX1[] PROGMEM = R"=====(
<!DOCTYPE html><html lang="en"><head><meta charset= "utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
static const char PAGE_INDEX1[] PROGMEM = R"=====(<!DOCTYPE html>
<html lang="en"><head><meta charset= "utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>)=====" WIFICONFIG_WEBTITLE R"=====(</title>
<style>
.c{text-align: center;}
div,input{padding:5px;font-size:1em;}
input{width:95%;}
input{width:95%%;}
body{text-align: center;font-family:verdana;}
button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;}
button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%%;}
.q{float: right;width: 64px;text-align: right;}
.l{background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==") no-repeat left center;background-size: 1em;}
#rssiBar{width: 100px;height: 15px;background: #fff;}
@@ -30,65 +31,63 @@ function hAP(){if (document.getElementById('_a').checked){document.getElementByI
function hSC(){if (document.getElementById('_st').checked){document.getElementById('staticip').style.display = 'block';}else{document.getElementById('staticip').style.display = 'none';}}
</script>
</head><body><h1>)=====" WIFICONFIG_TITLE R"=====(</h1><div style='text-align:left;display:inline-block;min-width:260px;'>
)=====";
/* Polozky nalezenych SSID
{v} - SSID
{a} - RSSI (%)
{s} - bud nic, nebo 'l'>
Rozsahy otestovany zde https://css-tricks.com/html5-meter-element/
*/
static const char SSID_ITEM[] PROGMEM = R"=====(
<div><a href='#p' onclick='c(this)'>{v}</a>&nbsp;<span class='q {s}'><meter value="{a}" min="0" low="30" optimum="70" high="60" max="100" style="width: 70%;"></meter></span></div>
)=====";
/* Zacatek formulare pro vyplneni
{s} - SSID
{p} - password
{a} - AP mode (checkbox)
{ch}- cislo kanalu AP
{c} - staticka IP konfigurace (checkbox)
{i} - ip adresa
{m} - maska
{g} - brana
{d} - dns server
*/
static const char PAGE_INDEX2[] PROGMEM = R"=====(
<div id="ssids">
</div>
<form method='post' action='s'>
<label>SSID<br><input id='_s' name='_s' maxlength=32 required placeholder='SSID' {s}></label><br>
<label>Heslo<br><input id='_p' name='_p' maxlength=64 {p} type='password' placeholder='heslo'></label><br>
<label>SSID<br><input id='_s' name='_s' maxlength=32 required placeholder='SSID' value="%SSID%"></label><br>
<label>Heslo<br><input id='_p' name='_p' onfocus="this.select();" maxlength=64 value="%PASS%" type='password' placeholder='heslo'></label><br>
<div>
<label><input id='_a' name='_a' type='checkbox' style="width: 10%; float: left; margin-top: 5px;" onclick='hAP();' {a}>Režim AP</label>
<label><input id='_a' name='_a' type='checkbox' style="width: 10%%; float: left; margin-top: 5px;" onclick='hAP();' %APMODE%>Režim AP</label>
<div id="apconfig">
<label>Kanál<br><input type="number" name="_ch" min="1" max="13" title='cislo kanalu v intervalu 1-13' value='{ch}'></label><br>
<label>Kanál<br><input type="number" name="_ch" min="1" max="13" title='cislo kanalu v intervalu 1-13' value='%APCHAN%'></label><br>
</div>
</div>
<div>
<label><input id='_st' name='_st' type='checkbox' style="width: 10%; float: left; margin-top: 5px;" onclick='hSC();' {c}>Statická IP konfigurace</label>
<label><input id='_st' name='_st' type='checkbox' style="width: 10%%; float: left; margin-top: 5px;" onclick='hSC();' %STATIC%>Statická IP konfigurace</label>
<div id="staticip">
<label>IP adresa<br><input type="text" name="_i" value='{i}'></label><br>
<label>Síťová maska<br><input type="text" name="_m" value='{m}'></label><br>
<label>Síťová brána<br><input type="text" name="_g" value='{g}'></label><br>
<label>Server DNS<br><input type="text" name="_d" value='{d}'></label><br>
<label>IP adresa<br><input type="text" name="_i" value='%IP%'></label><br>
<label>Síťová maska<br><input type="text" name="_m" value='%MASK%'></label><br>
<label>Síťová brána<br><input type="text" name="_g" value='%GATE%'></label><br>
<label>Server DNS<br><input type="text" name="_d" value='%DNS%'></label><br>
</div>
</div>
<script>hAP();hSC();</script>
)=====";
// Uzivatelsky pridane polozky
static const char PAGE_PARAM_HDR[] PROGMEM = R"=====(
<hr>
<h2>Uživatelské položky</h2>
)=====";
static const char PAGE_PARAM[] PROGMEM = R"=====(
<label>{t}<br><input name='{n}' maxlength='{l}' value='{v}'></label><br>
)=====";
// Konec formulare a stranky
static const char PAGE_END[] PROGMEM = R"=====(
%USER%
<br>
<button type='submit'>Uložit a restartovat</button></form>
<script>
window.onload = function() {
hAP();
hSC();
var req = new XMLHttpRequest();
req.open("GET", "/scan", true);
req.onreadystatechange = function() {
if (req.readyState != 4 || req.status != 200)
return;
ssids = document.getElementById('ssids');
data = JSON.parse(req.responseText);
status = data.status;
html = "";
if (status > 0) {
for (i= 0 ; i < status; ++i) {
lock = "";
if (data.ssids[i].secure != 0)
lock = "l";
value = data.ssids[i].rssi;
if (value <= -100)
value = 0;
else if (value >= -50)
value = 100;
else
value = 2 * (value + 100);
line = "<div><a href='#p' onclick='c(this)'>" + data.ssids[i].ssid + "</a>&nbsp;<span class='q " + lock + "'><meter value='" + value + "' min='0' low='30' optimum='70' high='60' max='100' style='width: 70%%;'></meter></span></div>";
html += line;
}
ssids.innerHTML = html;
}
};
req.send();
};
</script>
</div>)====="
#if defined APP_NAME && defined APP_VERSION
R"=====(<div style='text-align:right;font-size:11px;'><hr/>)====="
@@ -102,6 +101,17 @@ R"=====(<div style='text-align:right;font-size:11px;'><hr/><a href='http://xpabl
#endif
R"=====(</body></html>
)=====";
// Uzivatelsky pridane polozky
static const char PAGE_PARAM_HDR[] PROGMEM = R"=====(
<hr>
<h2>Uživatelské položky</h2>
)=====";
static const char PAGE_PARAM[] PROGMEM = R"=====(
<label>%s<br><input name='%s' maxlength='%d' value='%s'></label><br>
)=====";
/*
<div style='text-align:right;font-size:11px;'><hr/><a href='http://xpablo.cz' target='_blank' style='color:#aaa;'>WiFiConfig by xPablo</a></div>
*/
@@ -118,13 +128,13 @@ static const char PAGE_SAVED[] PROGMEM = R"=====(
<style>div,input {margin-bottom: 5px;}body{width:200px;display:block;margin-left:auto;margin-right:auto;}</style>
</head><body>
Uloženo do EEPROM...<br/>
Restart za 5 sekund.
Restart za několik sekund.
</body></html>
)=====";
static const char PAGE_CAPTIVEPORTALCATCH[] PROGMEM = R"=====(
<!DOCTYPE html><html lang="cs"><head><meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/><title>xPablo.cz Setup</title>
<style>.c{text-align: center;} div,input{padding:5px;font-size:1em;} input{width:95%;} body{text-align: center;font-family:verdana;} button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;} .q{float: right;width: 64px;text-align: right;}
static const char PAGE_CAPTIVEPORTALCATCH[] PROGMEM = R"=====(<!DOCTYPE html>
<html lang="cs"><head><meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/><title>xPablo.cz Setup</title>
<style>.c{text-align: center;} div,input{padding:5px;font-size:1em;} input{width:95%%;} body{text-align: center;font-family:verdana;} button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%%;} .q{float: right;width: 64px;text-align: right;}
.vl-info {border-left: thick solid #1fa3ec;background: #cee6ff; text-align:left; display:inline-block; min-width:260px; margin-top:15px}
.red { background-color: #ff0000;}
.magenta { background-color: #ff00ff;}
@@ -142,11 +152,8 @@ R"=====(
</form><br/><form action="/u" method="get">
<button class="magenta">Aktualizace firmware</button></form><br>)====="
#endif
;
// druha cast (mezi 1. a 2. cast muzeme doplnit dodatecne informace)
static const char PAGE_CAPTIVEPORTALCATCH2[] PROGMEM = R"=====(
</div>
R"=====(
<div class=\"vl-info\">Pokus o připojení: %STATUS%</div>
)====="
#if defined APP_NAME && defined APP_VERSION
R"=====(<div style='text-align:right;font-size:11px;'><hr/>)====="
@@ -161,8 +168,8 @@ R"=====(<div style='text-align:right;font-size:11px;'><hr/><a href='http://xpabl
R"=====(</body></html>
)=====";
static const char PAGE_RESTART[] PROGMEM = R"=====(
<!DOCTYPE html><html lang="cs"><head><meta http-equiv="refresh" content="5;url=/"/>
static const char PAGE_RESTART[] PROGMEM = R"=====(<!DOCTYPE html>
<html lang="cs"><head><meta http-equiv="refresh" content="5;url=/"/>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1"/>
<title>xPablo Setup - Restart</title>
<style>div,input {margin-bottom: 5px;}body{width:200px;display:block;margin-left:auto;margin-right:auto;}</style>
@@ -225,3 +232,26 @@ domReady(function() {
</body>
</html>
)=====";
static const char PAGE_INFO[] PROGMEM = R"=====(
<!DOCTYPE html><html lang="en"><head><meta charset= "utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>)=====" WIFICONFIG_WEBTITLE R"=====(</title>
<style>
.c{text-align: center;}
div,input{padding:5px;font-size:1em;}
input{width:95%%;}
body{text-align: center;font-family:verdana;}
button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%%;}
.q{float: right;width: 64px;text-align: right;}
</style>
</head><body><h1>)=====" WIFICONFIG_TITLE R"=====(</h1><div style='text-align:left;display:inline-block;min-width:260px;'>
<form><table><tr><th>System Info<th>
<tr><td>Core Version:<td>%SDK%
<tr><td>Flash Size:<td>%FS% kB
<tr><td>Sketch Size/Free:<td>%SS% kB / %FSS% kB
<tr><td>STA MAC:<td>%STAMAC%
<tr><td>AP MAC:<td>%APMAC%
<tr><td>ESP Chip ID:<td>%ESPID%
<tr><td>Flash Chip ID:<td>%FID%
</table></form>
)=====";