parent
9b215ea547
commit
41181e1cc7
@ -0,0 +1,2 @@ |
||||
var t=function(a,b){return function(c,d){return a.replace(/#{([^}]*)}/g,function(a,f){return Function("x","with(x)return "+f).call(c,d||b||{})})}},s=function(a,b){return b?{get:function(c){return a[c]&&b.parse(a[c])},set:function(c,d){a[c]=b.stringify(d)}}:{}}(this.localStorage||{},JSON),p=function(a,b,c,d){c=c||document;d=c[b="on"+b];a=c[b]=function(e){d=d&&d(e=e||c.event);return(a=a&&b(e))?b:d};c=this},m=function(a,b,c){b=document;c=b.createElement("p");c.innerHTML=a;for(a=b.createDocumentFragment();b= |
||||
c.firstChild;)a.appendChild(b);return a},$=function(a,b){a=a.match(/^(\W)?(.*)/);return(b||document)["getElement"+(a[1]?a[1]=="#"?"ById":"sByClassName":"sByTagName")](a[2])},j=function(a){for(a=0;a<4;a++)try{return a?new ActiveXObject([,"Msxml2","Msxml3","Microsoft"][a]+".XMLHTTP"):new XMLHttpRequest}catch(b){}}; |
@ -0,0 +1,75 @@ |
||||
<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() { |
||||
xhr.open("GET", "reboot"); |
||||
xhr.onreadystatechange=function() { |
||||
if (xhr.readyState==4 && xhr.status>=200 && xhr.status<300) { |
||||
window.setTimeout(function() { |
||||
location.reload(true); |
||||
}, 3000); |
||||
} |
||||
} |
||||
//ToDo: set timer to |
||||
xhr.send(); |
||||
} |
||||
|
||||
function setProgress(amt) { |
||||
$("#progressbarinner").style.width=String(amt*200)+"px"; |
||||
} |
||||
|
||||
function doUpgrade() { |
||||
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 (typeof xhr.upload.onprogress != 'undefined') { |
||||
xhr.upload.onprogress=function(e) { |
||||
setProgress(e.loaded / e.total); |
||||
} |
||||
} |
||||
xhr.send(f); |
||||
return false; |
||||
} |
||||
|
||||
|
||||
window.onload=function(e) { |
||||
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> |
@ -0,0 +1,34 @@ |
||||
|
||||
body { |
||||
background-color: #404040; |
||||
font-family: sans-serif; |
||||
} |
||||
|
||||
#main { |
||||
background-color: #d0d0FF; |
||||
-moz-border-radius: 5px; |
||||
-webkit-border-radius: 5px; |
||||
border-radius: 5px; |
||||
border: 2px solid #000000; |
||||
width: 800px; |
||||
margin: 0 auto; |
||||
padding: 20px |
||||
} |
||||
|
||||
#progressbar { |
||||
margin: 10px; |
||||
padding: 0; |
||||
border: 1px solid #000000; |
||||
height: 20px; |
||||
width: 200px; |
||||
background-color: #808080; |
||||
} |
||||
|
||||
#progressbarinner { |
||||
width: 10px; |
||||
height: 20px; |
||||
border: none; |
||||
background-color: #00ff00; |
||||
} |
||||
|
||||
|
@ -1 +1 @@ |
||||
Subproject commit a38909a9559c5f1562d2933213e4ec6301ef99c3 |
||||
Subproject commit cbed5b369459649401dea5e6a3be9700c9af4ef1 |
Loading…
Reference in new issue