mock: start mocking real dashboard settings

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
2023-12-03 17:54:18 +08:00
parent 0a3b6fe96e
commit efe0397fab
20 changed files with 1742 additions and 26 deletions

2
static/old/flash/140medley.min.js vendored Normal file
View File

@ -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){}};

View File

@ -0,0 +1,86 @@
<!DOCTYPE html>
<html>
<head>
<title>Update firmware</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript">
var xhr = new XMLHttpRequest();
function doReboot() {
xhr.open("GET", "/flash/reboot");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 300) {
window.setTimeout(function () {
location.reload(true);
}, 3000);
}
}
xhr.send();
}
function setProgress(amt) {
$("#progressbarinner")[0].style.width = String(amt * 200) + "px";
}
function doUpgrade() {
var f = $("#file")[0].files[0];
if (typeof f == 'undefined') {
$("#remark")[0].innerHTML = "Can't read file!";
return
}
xhr.onreadystatechange = function () {
console.log("Ready state changed: " + xhr.readyState);
if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 300) {
setProgress(1);
let response = JSON.parse(xhr.responseText);
if (!response["success"]) {
$("#remark")[0].innerHTML = "Error: " + xhr.responseText;
} else {
$("#remark")[0].innerHTML = "Uploading done. Rebooting.";
doReboot();
}
}
}
if (typeof xhr.upload.onprogress != 'undefined') {
xhr.upload.onprogress = function (e) {
console.log("Upload progress: " + e.loaded + " / " + e.total);
setProgress(e.loaded / e.total);
}
}
xhr.open("POST", "/flash/upload");
xhr.send(f);
return false;
}
window.onload = function (e) {
xhr.open("GET", "/flash/init");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 300) {
var txt = "Please upload " + xhr.responseText + " or ota file.";
$("#remark")[0].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="Update!" onclick="doUpgrade()" />
<div id="progressbar">
<div id="progressbarinner"></div>
</div>
</div>
</body>

View File

@ -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;
}