Optimalizace i pro ESP32, moznost uploadu firmware
This commit is contained in:
@@ -21,7 +21,7 @@ function c(l){document.getElementById('_s').value=l.innerText||l.textContent;doc
|
||||
function hAP(){if (document.getElementById('_a').checked){document.getElementById('apconfig').style.display = 'block';}else{document.getElementById('apconfig').style.display = 'none';}}
|
||||
function hSC(){if (document.getElementById('_st').checked){document.getElementById('staticip').style.display = 'block';}else{document.getElementById('staticip').style.display = 'none';}}
|
||||
</script>
|
||||
</head><body><h1>ESP8266 WiFiConfig</h1><div style='text-align:left;display:inline-block;min-width:260px;'>
|
||||
</head><body><h1>ESP WiFiConfig</h1><div style='text-align:left;display:inline-block;min-width:260px;'>
|
||||
)=====";
|
||||
|
||||
/* Polozky nalezenych SSID
|
||||
@@ -119,10 +119,22 @@ static const char PAGE_CAPTIVEPORTALCATCH[] PROGMEM = R"=====(
|
||||
<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;}
|
||||
</style>
|
||||
</head><body><div style='text-align:left;display:inline-block;min-width:260px;'>
|
||||
<form action="/config" method="get"><button>Konfigurace WiFi</button></form><br/><form action="/i" method="get"><button>Informace o modulu</button></form><br/><form action="/r" method="post"><button class="red">Reset</button></form><br>
|
||||
)=====";
|
||||
<form action="/config" method="get">
|
||||
<button>Konfigurace WiFi</button>
|
||||
</form><br/>
|
||||
<form action="/i" method="get">
|
||||
<button>Informace o modulu</button>
|
||||
</form><br/><form action="/r" method="post">
|
||||
<button class="red">Reset</button></form><br>)====="
|
||||
#if defined USE_WIFICONFIG_OTAUPDATE
|
||||
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"=====(
|
||||
@@ -150,3 +162,58 @@ static const char PAGE_RESTART[] PROGMEM = R"=====(
|
||||
Restartuji...
|
||||
</body></html>
|
||||
)=====";
|
||||
|
||||
static const char PAGE_UPDATE[] PROGMEM = R"=====(
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width,initial-scale=1'/>
|
||||
</head>
|
||||
<body>
|
||||
<form method="POST" action="#" enctype="multipart/form-data" id="upload_form">
|
||||
<input type="file" name="update" accept='.bin' id="file">
|
||||
<input type="submit" value="Update"> </form>
|
||||
<div id="prg_wrap" style="border: 0px solid; width: 100%;">
|
||||
<div id="prg" style="text-shadow: 2px 2px 3px black; padding: 5px 0; display: none; border: 1px solid #008aff; background: #002180; text-align: center; color: white;"></div>
|
||||
</div>
|
||||
<script>
|
||||
var domReady = function(callback) {
|
||||
document.readyState === "interactive" || document.readyState === "complete" ? callback() : document.addEventListener("DOMContentLoaded", callback);
|
||||
};
|
||||
domReady(function() {
|
||||
var myform = document.getElementById('upload_form');
|
||||
var filez = document.getElementById('file');
|
||||
myform.onsubmit = function(event) {
|
||||
event.preventDefault();
|
||||
var formData = new FormData();
|
||||
var file = filez.files[0];
|
||||
if(!file) {
|
||||
return false;
|
||||
}
|
||||
formData.append("files", file, file.name);
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.upload.addEventListener("progress", function(evt) {
|
||||
if(evt.lengthComputable) {
|
||||
var per = Math.round((evt.loaded / evt.total) * 100);
|
||||
var prg = document.getElementById('prg');
|
||||
prg.innerHTML = per + "%"
|
||||
prg.style.width = per + "%"
|
||||
prg.style.display = "block"
|
||||
}
|
||||
}, false);
|
||||
xhr.open('POST', location.href, true);
|
||||
// Set up a handler for when the request finishes.
|
||||
xhr.onload = function() {
|
||||
if(xhr.status === 200) {
|
||||
//alert('Success');
|
||||
} else {
|
||||
//alert('An error occurred!');
|
||||
}
|
||||
};
|
||||
xhr.send(formData);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
)=====";
|
||||
|
||||
Reference in New Issue
Block a user