ESPTerm - ESP8266 terminal emulator. Branches: [master] patches, [work] next release
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
espterm-firmware/html/flash/index.html

82 lines
2.1 KiB

<html>
<head><title>Upgrade firmware</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="140medley.min.js"></script>
<script type="text/javascript">
var xhr=j();
function doReboot() {
//Grab the /flash/reboot url in order to reboot into the new firmware.
xhr.open("GET", "reboot");
xhr.onreadystatechange=function() {
if (xhr.readyState==4 && xhr.status>=200 && xhr.status<300) {
//Reload the window after 5 seconds.
window.setTimeout(function() {
location.reload(true);
}, 5000);
}
}
xhr.send();
}
//Sets the progress bar to a specific level. Amt is between 0 and 1.
function setProgress(amt) {
$("#progressbarinner").style.width=String(amt*200)+"px";
}
//Called when the submit button is called.
function doUpgrade() {
//Grab the file, see if it's a real file.
var f=$("#file").files[0];
if (typeof f=='undefined') {
$("#remark").innerHTML="Can't read file!";
return
}
xhr.open("POST", "upload");
xhr.onreadystatechange=function() {
if (xhr.readyState==4 && xhr.status>=200 && xhr.status<300) {
setProgress(1);
if (xhr.responseText!="") {
$("#remark").innerHTML="Error: "+xhr.responseText;
} else {
$("#remark").innerHTML="Uploading done. Rebooting.";
doReboot();
}
}
}
//If the webbrowser enables it, make progress bar show progress.
if (typeof xhr.upload.onprogress != 'undefined') {
xhr.upload.onprogress=function(e) {
setProgress(e.loaded / e.total);
}
}
//Upload the file
xhr.send(f);
return false;
}
window.onload=function(e) {
//Grab the initial remark telling user which userx.bin file to upload.
xhr.open("GET", "next");
xhr.onreadystatechange=function() {
if (xhr.readyState==4 && xhr.status>=200 && xhr.status<300) {
var txt="Please upload "+xhr.responseText+" or ota file.";
$("#remark").innerHTML=txt;
setProgress(0);
}
}
xhr.send();
}
</script>
</head>
<body>
<div id="main">
<h1>Update firmware</h1>
<div id="remark">Loading...</div>
<input type="file" id="file" />
<input type="submit" value="Upgrade!" onclick="doUpgrade()" />
<div id="progressbar"><div id="progressbarinner"></div></div>
</body>