-
Notifications
You must be signed in to change notification settings - Fork 688
/
index.html
18 lines (18 loc) · 26.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>ESP-AT</title>
<link rel="icon" href="data:image/ico;base64,aWNv">
<style>
*{margin:0;padding:0;outline:0!important}.d-flex{display:-moz-box;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:box;display:flex}.d-j-c{-webkit-justify-content:center;-moz-box-pack:center;-webkit-box-pack:center;box-pack:center;justify-content:center}.d-a-i{-webkit-align-items:center;box-align:center;-moz-box-align:center;-webkit-box-align:center;align-items:center}.home-wrap{position:relative;height:100vh;background:#4a93f6}.header-wrap{position:fixed;top:0;left:0;box-sizing:border-box;padding:0 20px;width:100%;height:56px;border-bottom:1px solid rgba(255,255,255,.2)}.header-wrap .header-logo{color:transparent;letter-spacing:6px;font-weight:700;font-style:oblique;font-size:30px;-webkit-text-stroke:1.6px #fff}.header-wrap ul{display:inline-block;margin-left:90px;list-style:none;vertical-align:middle}.header-wrap ul li{display:inline-block}.header-wrap ul li a{margin:0 10px;padding:6px 20px;color:#fff;text-decoration:none!important;font-size:16px}.header-wrap ul li a.active,.header-wrap ul li a:hover{border-radius:20px;background:#fff;box-shadow:0 0 6px #fff;color:#409eff}.home-content{width:80%;height:80%;max-height:700px;max-width:1100px;background:#fff;border-radius:20px;box-shadow:2px 0 12px #fff;font-size:14px}.home-left{height:105%;background:#66aafe;width:40%;margin-left:-10px;border-top-left-radius:20px;border-bottom-left-radius:20px;border-bottom-right-radius:20%;border-top-right-radius:20%;box-shadow:-6px 0 20px #66aafe}.home-left .content{color:#fff;padding-left:6%;box-sizing:border-box;text-align:left;width:100%;color:transparent;font-size:50px;font-weight:700;letter-spacing:6px;font-style:oblique;-webkit-text-stroke:1.6px #fff}.home-left .content h2{font-size:40px;margin-bottom:20px}.home-left .content p{font-size:30px}.home-left,.home-right{width:50%}.home-right .content{width:80%;text-align:center}.home-right .content h3{color:#666;font-size:30px;letter-spacing:4px;font-style:oblique;-webkit-text-stroke:1.6px #000}.device-wrap{width:100%;margin:50px 0}.ota-device-wrap{margin:80px 0 60px}.device-item{position:relative;width:100%;max-width:300px;margin:0 auto 20px}.ssid-input{width:100%}.note-wrap{margin-top:20px;text-align:left}.device-item input{width:100%;border:0;padding:16px 4px 12px;border-bottom:1px solid #d5d5d5;outline:0!important;font-size:14px;background:0 0;transition:all .2s linear;box-sizing:border-box}.device-item input.partition-input{border: 1px solid #d5d5d5;padding: 10px 4px 10px;border-radius: 6px;}.device-item input.partition-input ~ .icon {height: 37px}.device-item input.partition-input ~ .icon:after {top: 10px}.device-item input:focus{border-color:#66aafe}.btn-wrap button{width:80%;max-width:300px;line-height:40px;background:#66aafe;color:#fff;border:0;border-radius:6px;cursor:pointer;transition:all .2s linear}.btn-wrap button:hover{opacity:.8}.msg{position:fixed;height:100%;width:100%;left:0;top:0;background:rgba(0,0,0,.1);z-index:10}.msg.hide{display:none}.msg .content,.msg .content-time{position:absolute;top:50%;left:50%;padding:8px 15px;background:rgba(0,0,0,.6);color:#fff;width:80%;max-width:200px;text-align:center;font-size:14px;border-radius:20px;transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%)}.spinner{margin:-10px -40px;width:70px;text-align:center;position:absolute;left:50%;top:50%}.spinner>div{width:16px;height:16px;background-color:#fff;border-radius:100%;display:inline-block;margin:0 2px;-webkit-animation:sk-bouncedelay 1.4s infinite ease-in-out both;animation:sk-bouncedelay 1.4s infinite ease-in-out both}.spinner .bounce1{-webkit-animation-delay:-.32s;animation-delay:-.32s}.spinner .bounce2{-webkit-animation-delay:-.16s;animation-delay:-.16s}@-webkit-keyframes sk-bouncedelay{0%,100%,80%{-webkit-transform:scale(0)}40%{-webkit-transform:scale(1)}}@keyframes sk-bouncedelay{0%,100%,80%{-webkit-transform:scale(0);transform:scale(0)}40%{-webkit-transform:scale(1);transform:scale(1)}}.timeout-info{color:red}.icon{position:absolute;right:0;top:0;display:inline-block;width:44px;height:44px;cursor:pointer}.icon:after{content:"";position:absolute;top:15px;left:15px;width:10px;height:10px;border-bottom:2px solid #999;border-right:2px solid #999;transform:rotate(45deg)}#ssid{padding-right:45px}.wifi-list-wrap{position:absolute;left:0;top:45px;background:#fff;padding:6px 0;box-shadow:0 0 6px #ccc;z-index:1;border-radius:6px;width:100%;max-height:300px;overflow:hidden;overflow-y:auto;text-align:left;box-sizing:border-box}.wifi-list-wrap ul{width:100%;list-style:none}.wifi-list-wrap li{display:block;position:relative;line-height:2.1;font-size:14px;color:#666;padding:4px 40px;box-sizing:border-box;cursor:pointer;width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wifi-list-wrap li:hover{background:rgba(102,170,254,.5)}.wifi-list-wrap .selected{position:absolute;top:12px;left:15px;display:none;width:12px;height:6px;border-left:2px solid #66aafe;border-bottom:2px solid #66aafe;transform:rotate(-45deg)}.wifi-list-wrap li.active .selected{display:inline-block}.lock-img{position:absolute;top:9px;right:15px;width:20px;height:20px}.lock-img svg{width:18px;height:auto}.no-data{text-align:center}.device-item-link{margin-bottom:0;text-align:right}.device-item-link a{color:#409eff;font-size:14px}.ota-device-wrap .device-item{max-width:400px}.file-input{position:relative;font-size:0}.device-item input.file-info{position:absolute;top:0;right:0;padding:0;width:70px;line-height:38px;opacity:0;cursor:pointer}.device-item input.file-name{padding:10px 4px 10px;width:-webkit-calc(100% - 80px);width:-moz-calc(100% - 80px);width:calc(100% - 80px);border:1px solid #d5d5d5;border-radius:6px;font-size:14px;flex:1}.device-item input#file-upload-btn{cursor:pointer}.file-btn{display:inline-block;margin-left:10px;width:70px;border-radius:6px;background:#409eff;color:#fff;font-size:14px;line-height:38px;cursor:pointer}.ota-btn-wrap{margin:0 auto;width:100%;max-width:400px;text-align:left}.ota-device-wrap p{margin:15px 0;text-align:left}.ota-note-wrap{margin-top:20px;max-width:400px}.version-label{display:inline-block;margin-right:6px;min-width:100px;text-align:right}.hide{display:none}.msg-confirm{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1}.msg-confirm .mask{height:100%;width:100%;background:rgba(0,0,0,.2)}.msg-confirm .content{position:absolute;top:50%;left:50%;width:90%;max-width:300px;transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%);background:#fff;border-radius:6px;font-size:14px;box-shadow:0 0 8px #fff;text-align:center;box-sizing:border-box}.msg-confirm .content .header{font-weight:700;padding:10px 0 0}.msg-confirm .content .content-info{padding:20px 15px;box-sizing:border-box}.msg-confirm .content .footer-btn{border-top:1px solid #ccc;padding:10px 0;box-sizing:border-box}.msg-confirm .content .footer-btn button{border:none;background:#fff;color:#66aafe;cursor:pointer}@media(max-width:768px){input::-webkit-input-placeholder{color:rgba(255,255,255,.5)}input::-moz-placeholder{color:rgba(255,255,255,.5)}input:-moz-placeholder{color:rgba(255,255,255,.5)}input:-ms-input-placeholder{color:rgba(255,255,255,.5)}.home-wrap{background:0;background-image:linear-gradient(#4a93f6,rgba(81,146,255,.4))}.home-right .content h3{color:transparent;font-size:32px;letter-spacing:4px;font-style:oblique;-webkit-text-stroke:1.6px #fff}.home-left{display:none}.home-right{width:100%}.home-content{height:auto;width:100%;max-width:100%;max-height:100vh;padding:30px 30px 56px;background:0 0;box-shadow:none;box-sizing:border-box}.home-right .content{width:100%}.device-item{max-width:100%}.device-item,.ota-device-wrap .device-item{max-width:100%}.ota-btn-wrap{max-width:100%}.device-item input{width:100%;background:0 0;padding:12px 4px 12px 20px;border:1px solid rgba(255,255,255,.5);color:#fff;border-radius:20px;box-sizing:border-box}.device-item input:focus,.device-item input:hover{border-color:#fff}.btn-wrap button{width:100%;max-width:100%}.ota-btn-wrap button{max-width:260px}.icon{width:42px;height:42px}.icon:after{top:12px;left:12px;border-color:rgba(255,255,255,.5)}.wifi-list-wrap{position:fixed;top:0;left:0;bottom:0;width:100%;height:100%;max-height:100%;padding:0;background:0 0;border-radius:0}.wifi-list-wrap .mask{height:100%;width:100%;background:rgba(0,0,0,.3)}.wifi-list-wrap .content{position:absolute;bottom:0;width:100%;overflow:hidden;background:#fff;border-top-left-radius:6px;border-top-right-radius:6px}.wifi-list-wrap .content h3{font-size:16px;margin:0;padding:10px 20px;box-sizing:border-box;text-align:center;border-bottom:1px solid #eee}.wifi-list-wrap .content h3 span{font-size:14px;font-weight:400;color:#66aafe;float:right;cursor:pointer}.wifi-list-wrap .content ul{height:250px;overflow:hidden;overflow-y:auto}.wifi-list-wrap .content ul li{padding:6px 40px;border-bottom:1px solid #eee}.cancel-wrap{border-top:1px solid #eee;padding:10px 0;text-align:center;font-size:14px;cursor:pointer}.header-wrap{top:unset;bottom:0;border-top:1px solid rgba(255,255,255,.2);background: rgba(81,146,255,.08);}.header-wrap .header-logo{display:none}.header-wrap ul{margin-left:0;width:100%;font-size:0}.header-wrap ul li{display:inline-block;width:50%;text-align:center}.header-wrap ul li a{outline:0!important;color:#333;font-size:14px}.header-wrap ul li a.active,.header-wrap ul li a:hover{background:0;box-shadow:none}}
</style>
</head>
<body id="body-wrap">
<div class="home-wrap d-flex d-a-i d-j-c"><div class="header-wrap d-flex d-a-i"><span class="header-logo">ESP-AT</span><ul><li><a onclick="selectMenu('esp-at-wrap', this)" id="esp-at-link" class="active" href="javascript:void(0)">Wi-Fi</a></li><li><a onclick="selectMenu('esp-ota-wrap', this)" id="esp-ota-link" href="javascript:void(0)">OTA</a></li></ul></div><div class="home-content d-flex d-a-i"><div class="home-left d-flex d-a-i"><div class="content"><h2>ESP-AT</h2><p id="welcome-wrap">Welcome to ESP-AT Web</p></div></div><div id="esp-at-wrap" class="home-right d-flex d-a-i d-j-c"><div class="content"><h3>ESP-AT</h3><div class="device-wrap"><div id="ssid-wrap" class="device-item"><div class="ssid-input"><input id="ssid" maxlength="32" type="text" placeholder="SSID" /><span id="show-wifi-list" class="icon"></span></div></div><div class="device-item"><input id="password" maxlength="64" type="password" placeholder="PASSWORD" /></div><div class="device-item"><input id="message" disabled type="text" readonly placeholder="Message" /></div></div><div class="btn-wrap"><button id="start-connect" onclick="postData()" class="btn">Connect</button></div><div class="note-wrap device-item"><span id="note-text" style="color: red">Note:</span><span id="note-desc">Please note that if your target AP is the hotspot of the device which opens the web pages,you may not receive the Wi-Fi connection result.</span></div></div></div><div id="esp-ota-wrap" class="home-right d-flex d-a-i d-j-c hide"><div class="content"><h3>ESP-AT</h3><div class="device-wrap ota-device-wrap"><div class="device-item"><p id="ota-title">Please select a new firmware and click the“OTA upgrade”button to start the upgrade:</p><div id="partition-wrap" class="device-item"><div class="partition-input"><input id="partition" readonly class="partition-input" maxlength="32" type="text" placeholder="Partition" /><span id="show-partition-list" class="icon"></span></div></div><div class="file-input d-flex d-a-i"><input id="file-name" class="file-name" readonly type="text" /><input type="file" onchange="fileChange(this)" id="file-info" class="file-info" name="file"><span id="file-btn" class="file-btn">Browse</span></div></div></div><div class="btn-wrap ota-btn-wrap"><button id="start-upgrade" onclick="postOta()" class="btn">OTA upgrade</button></div><div class="note-wrap ota-note-wrap device-item"><p><span id="cur-version" class="version-label">Current firmware version:</span><span id="version-wrap" class="version">0</span></p><p><span id="at-version" class="version-label">AT Core version:</span><span id="at-core-wrap" class="version">0</span></p></div></div></div></div></div>
<script>
var isSend=!1,isShowWifi=!1,wifiList=[],partitionList=[],timeoutNum=0,Ajax={get:function(e,t,i){var n;window.XMLHttpRequest?n=new XMLHttpRequest:window.ActiveObject&&(n=new ActiveXobject("Microsoft.XMLHTTP")),n.open("GET",e,!0),i&&n.setRequestHeader("Object",i),n.onreadystatechange=function(){4==n.readyState&&(console.log(n.status),200==n.status||304==n.status?t.call(this,n.responseText):(showMessage(getPrompt("requestFailed"),1e3),hideLoading("msg-load")))},n.send()},post:function(e,t,i,n,o=!0,s=!1){var a;showLoading(),window.XMLHttpRequest?a=new XMLHttpRequest:window.ActiveObject&&(a=new ActiveXobject("Microsoft.XMLHTTP")),a.open("POST",e,o),a.setRequestHeader("Content-Type",s?"application/json":"application/x-www-form-urlencoded;charset=UTF-8"),n&&a.setRequestHeader("Object",n),a.onreadystatechange=function(){4==a.readyState&&(200==a.status||304==a.status?i.call(this,a.responseText):(hideLoading("msg-load"),showMessage(getPrompt("connectFailed"),2e3)))},a.send(t)},postFile:function(e,t,i,n){var o;showLoading(),window.XMLHttpRequest?o=new XMLHttpRequest:window.ActiveObject&&(o=new ActiveXobject("Microsoft.XMLHTTP")),o.open("POST",e,!0),o.setRequestHeader("Content-Type","application/octet-stream;charset=UTF-8"),n&&o.setRequestHeader("Object",n),o.onreadystatechange=function(){4==o.readyState&&(200==o.status||304==o.status?i.call(this,o.responseText):(hideLoading("msg-load"),showConfirm(getPrompt("prompt"),getPrompt("otaFailed"),getPrompt("confirm"))))},o.send(t)}};const constHtmlLang=[{zh:"设备配网",en:"Wi-Fi",id:"esp-at-link",type:"text"},{zh:"OTA 升级",en:"OTA",id:"esp-ota-link",type:"text"},{zh:"欢迎使用 ESP-AT 配网",en:"Welcome to ESP-AT Web",id:"welcome-wrap",type:"text"},{zh:"请输入 SSID",en:"SSID",id:"ssid",type:"input"},{zh:"请输入 PASSWORD",en:"PASSWORD",id:"password",type:"input"},{zh:"开始配网",en:"Connect",id:"start-connect",type:"text"},{zh:"注意:",en:"Note: ",id:"note-text",type:"text"},{zh:"配网手机作为待接入热点时,浏览器可能收不到配网结果",en:"Please note that if your target AP is the hotspot of the device which opens the web pages, you may not receive the Wi-Fi connection result.",id:"note-desc",type:"text"},{zh:"请选择新版本固件,然后点击升级按钮进行升级:",en:"Please select a new firmware and click the “OTA upgrade” button to start the upgrade: ",id:"ota-title",type:"text"},{zh:"浏览",en:"Browse",id:"file-btn",type:"text"},{zh:"固件升级",en:"OTA upgrade",id:"start-upgrade",type:"text"},{zh:"当前 app 固件版本:",en:"Current app version: ",id:"cur-version",type:"text"},{zh:"AT Core 版本:",en:"AT Core version: ",id:"at-version",type:"text"}],constPromptInfo={prompt:{zh:"提示",en:"Prompt"},confirm:{zh:"确定",en:"OK"},cancel:{zh:"取消",en:"Cancel"},requestFailed:{zh:"数据请求失败",en:"Data request failed"},connectFailed:{zh:"配网失败, 请重试",en:"Connection failed"},connectTimeout:{zh:"配网超时, 请重试",en:"Connection timeout"},connectSuc:{zh:"配网成功",en:"Connection succeeded"},upgradeFailed:{zh:"升级失败,请稍后重试",en:"Upgrade failed. Please try again later."},enterSsid:{zh:"请输入 SSID",en:"Please enter SSID"},ssidError:{zh:"输入 SSID 过长,请保持在32个字节之内",en:"The SSID is too long. Please keep it within 32 bytes"},passwordError:{zh:"输入 Password 过长,请保持在64个字节之内",en:"Password is too long. Please keep it within 64 bytes"},closedWeb:{zh:'配网成功, <span id="timeout-info" class="timeout-info">5</span> 秒后自动关闭网页',en:'Connection succeeded, This page will be closed in <span id="timeout-info" class="timeout-info">5</span> seconds.'},wifiList:{zh:"Wi-Fi 列表",en:"Wi-Fi List"},partitionList:{zh:"分区列表",en:"Partition List"},refresh:{zh:"刷新",en:"Refresh"},getWifiFailed:{zh:"获取 Wi-Fi 列表失败",en:"Failed to get Wi-Fi AP list"},getPartitionFailed:{zh:"获取分区列表失败",en:"Failed to get partition list"},enterPartition:{zh:"请选择分区",en:"Please select partition"},noData:{zh:"暂无数据",en:"No data available"},selectFile:{zh:"请选择文件",en:"Please select file"},formatError:{zh:"选择的文件格式有误",en:"Incorrect file format"},fileLarge:{zh:"选择的文件过大,请选择小于 2MB 的文件",en:"File is too large. Please select a file less than 2MB."},getVersionFailed:{zh:"获取固件版本失败",en:"Failed to get firmware version"},otaSuc:{zh:"升级成功",en:"OTA Succeeded"},otaFailed:{zh:"升级失败,请稍后重试",en:"OTA Failed"}};var curLangeage="en";function loadLanguage(){var e=navigator.language||navigator.userLanguage;e=e.substr(0,2),curLangeage="zh"==e?"zh":"en";for(var t=0;t<constHtmlLang.length;t++){var i=constHtmlLang[t];"input"!=i.type?setTextByLang(i.id,i[curLangeage]):setInputByLang(i.id,i[curLangeage])}}function setTextByLang(e,t){document.getElementById(e).innerText=t}function setInputByLang(e,t){document.getElementById(e).setAttribute("placeholder",t)}function getPrompt(e){return constPromptInfo[e][curLangeage]}function getData(){Ajax.get("/getstainfo",function(e){e=JSON.parse(e),console.log(e);try{document.getElementById("ssid").value=e.sta_ssid,document.getElementById("password").value=e.sta_password,document.getElementById("message").value=e.message}catch(e){}})}function getStatus(){if(timeoutNum>40)return hideLoading("msg-load"),showMessage(getPrompt("connectTimeout"),2e3),!1;timeoutNum++,Ajax.get("/getstainfo",function(e){e=JSON.parse(e),console.log(e),document.getElementById("message").value=e.message,1==e.state?getResult():0==e.state?setTimeout(function(){getStatus()},1e3):(hideLoading("msg-load"),showMessage(getPrompt("connectFailed"),2e3))})}function getResult(){Ajax.post("/getresult","received=1",function(e){isSend=!1,hideLoading("msg-load"),showTimeout()})}function postData(){timeoutNum=0;var e=document.getElementById("ssid").value,t=document.getElementById("password").value;if(""==e||null==e)return showMessage(getPrompt("enterSsid"),1e3),!1;if(e.length>32)return showMessage(getPrompt("ssidError"),1e3),!1;if(t.length>64)return showMessage(getPrompt("passwordError"),1e3),!1;var i={ssid_len:e.length||0,ssid:e,password_len:t.length||0,password:t};Ajax.post("/setstainfo",JSON.stringify(i),function(e){e=JSON.parse(e),isSend=!0,console.log(e),0==e.state?setTimeout(function(){getStatus()},1e3):(hideLoading("msg-load"),showMessage(getPrompt("connectFailed"),2e3))},null,!0,!0)}function showMessage(e,t){var i=document.getElementById("body-wrap"),n=document.createElement("div");n.innerHTML='<div class="content">'+e+"</div>",n.setAttribute("class","msg"),i.appendChild(n),t&&setTimeout(function(){i.removeChild(n)},t)}function showTimeout(){hideLoading("msg-load");var e=document.getElementById("body-wrap"),t=document.createElement("div");t.innerHTML='<div id="timeoutId" class="content-time">'+getPrompt("closedWeb")+"</div>",t.setAttribute("class","msg"),e.appendChild(t);var i=5,n=setInterval(function(){i--,document.getElementById("timeout-info").innerText=i,i<0&&(e.removeChild(t),closeWindow(),clearInterval(n))},1e3)}function closeWindow(){window.open("about:blank","_self").close()}function showLoading(){var e=document.getElementById("body-wrap"),t=document.createElement("div");t.innerHTML='<div class="load"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div></div>',t.setAttribute("class","msg"),t.setAttribute("id","msg-load"),e.appendChild(t)}function showConfirm(e,t,i){var n=document.getElementById("body-wrap"),o=document.createElement("div");o.innerHTML='<div class="mask"></div><div class="content"><div class="header">'+e+'</div><div class="content-info">'+t+'</div><div onclick="removeConfirm()" class="footer-btn"><button>'+i+"</button></div></div>",o.setAttribute("class","msg-confirm"),o.setAttribute("id","msg-confirm"),n.appendChild(o)}function removeConfirm(){document.getElementById("body-wrap").removeChild(document.getElementById("msg-confirm"))}function hideLoading(e){var t=document.getElementById(e);t&&(t.setAttribute("class","msg hide"),document.getElementById("body-wrap").removeChild(t))}loadLanguage(),window.onbeforeunload=function(e){if(isSend)try{if(!navigator.sendBeacon)return;navigator.sendBeacon("http://192.168.4.1/getresult","received=1")}catch(e){console.log(e)}};var isMobile=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||768)<=768;function getaprecord(){showLoading(),console.log("getaprecord"),Ajax.get("/getaprecord",function(e){e=JSON.parse(e),console.log(e);try{0==e.state?(initWifiList(wifiList=e.aplist,null,"wifi-list-wrap","ssid","ssid-wrap"),hideLoading("msg-load")):showMessage(getPrompt("getWifiFailed"),2e3)}catch(e){showMessage(getPrompt("getWifiFailed"),2e3)}})}function initWifiList(e,t,i="wifi-list-wrap",n="ssid",o="ssid-wrap"){removeWifiList(i,o);var s=document.createElement("div");if(s.setAttribute("id",i),s.setAttribute("class","wifi-list-wrap"),isMobile){var a=document.createElement("div");a.setAttribute("class","mask"),a.setAttribute("id","mask"),a.onclick=function(){removeWifiList(i,o)},s.appendChild(a)}for(var d=document.createElement("ul"),r="",c=document.getElementById(n).value,l=0;l<e.length;l++){var m=e[l];if(!t||-1!=m.ssid.indexOf(t)){var u="";c==m.ssid&&(u="active"),r+=`<li data-value="${encodeURIComponent(m.ssid)}"onclick="selectCurWifi(event, '${n}', '${i}', '${o}')"class="d-flex d-a-i ${u}"><span class="selected"></span>${m.ssid}`,m.auth_mode&&0!=m.auth_mode&&(r+='<span class="lock-img"><svg class="icon" width="12px" height="12px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M800.421 436.525H736.76V287.852c0-124.507-100.762-225.757-224.732-225.757-123.98 0-224.857 101.25-224.857 225.766v148.662h-63.593c-30.667 0-55.532 24.952-55.532 55.752v407.048c0 30.848 24.865 55.82 55.532 55.82h576.9c30.667 0 55.465-24.97 55.465-55.82V492.275c0-30.802-24.855-55.752-55.532-55.752zM543.203 706.409v88.88a7.354 7.354 0 0 1-7.282 7.325h-47.733a7.373 7.373 0 0 1-7.334-7.322V706.41c-22.423-11.518-37.953-34.602-37.953-61.659 0-38.288 30.945-69.425 69.07-69.425 38.183 0 69.138 31.136 69.138 69.415 0.057 27.067-15.473 50.152-37.905 61.659z m107.311-269.884H373.525V291.539c0-76.691 62.196-139.146 138.552-139.146 76.366 0 138.447 62.454 138.447 139.146v144.986z" fill="#666666" ></path></svg></span>'),r+="</li>"}}if(""==r&&(r='<li class="no-data">'+getPrompt("noData")+"</li>"),d.innerHTML=r,isMobile){var g=document.createElement("div");g.setAttribute("class","content");var p=document.createElement("div"),f=`<h3>${getPrompt("wifi-list-wrap"===i?"wifiList":"partitionList")}`;"wifi-list-wrap"==i&&(f+=`<span onclick="getaprecord()"id="refresh"class="refresh">${getPrompt("refresh")}</span>`),f+="</h3>",p.innerHTML=f;var h=document.createElement("div");return h.setAttribute("class","cancel-wrap"),h.setAttribute("id","cancel-wrap"),h.innerHTML=getPrompt("cancel"),h.onclick=function(){removeWifiList(i,o)},g.appendChild(p),g.appendChild(d),g.appendChild(h),s.appendChild(g),void document.getElementById("body-wrap").appendChild(s)}s.appendChild(d),setTimeout(function(){document.getElementById(o).appendChild(s)})}function selectCurWifi(e,t="ssid",i="wifi-list-wrap",n="ssid-wrap"){isShowWifi=!1,document.getElementById(t).value=decodeURIComponent(e.target.dataset.value),console.log(i,n),removeWifiList(i,n),window.event?window.event.cancelBubble=!0:e.stopPropagation()}function initShowList(){document.getElementById("show-wifi-list").onclick=function(e){(isShowWifi=!isShowWifi)?getaprecord():removeWifiList("wifi-list-wrap","ssid-wrap"),document.getElementById("ssid").focus(),window.event?window.event.cancelBubble=!0:e.stopPropagation()},document.getElementById("partition-wrap").onclick=function(e){(isShowWifi=!isShowWifi)?initWifiList(partitionList,null,"partition-list-wrap","partition","partition-wrap"):removeWifiList("partition-list-wrap","partition-wrap"),window.event?window.event.cancelBubble=!0:e.stopPropagation()},document.getElementById("ssid").onclick=function(e){window.event?window.event.cancelBubble=!0:e.stopPropagation()},document.getElementById("body-wrap").onclick=function(e){isMobile||(isShowWifi=!1,removeWifiList(),removeWifiList("partition-list-wrap","partition-wrap"))},document.getElementById("ssid").oninput=function(){if(isShowWifi&&!isMobile){var e=document.getElementById("wifi-list-wrap");e&&(document.getElementById("ssid-wrap").removeChild(e),initWifiList(wifiList,this.value,"wifi-list-wrap","ssid","ssid-wrap"))}}}function removeWifiList(e="wifi-list-wrap",t="ssid-wrap"){isMobile&&(isShowWifi=!1);var i=document.getElementById(e);i&&(document.getElementById(isMobile?"body-wrap":t).removeChild(i),(i=document.getElementById(e))&&removeWifiList(e,t))}function fileChange(e){var t=e.files;if(t&&t.length>0){var i=(t=t[0]).name.toLowerCase();if(i.indexOf(".bin")!=i.length-4)return document.getElementById("file-info").value="",void showMessage(getPrompt("formatError"),2e3);if(t.size>=2097152)return document.getElementById("file-info").value="",void showMessage(getPrompt("fileLarge"),2e3);document.getElementById("file-name").value=i,console.log(document.getElementById("file-info").files)}}function getotainfo(){showLoading(),Ajax.get("/getotainfo",function(e){e=JSON.parse(e);try{if(0==e.state){document.getElementById("version-wrap").innerText=e.fw_version,document.getElementById("at-core-wrap").innerText=e.at_core_version;var t=e.partitions||[];partitionList=[],t.forEach(function(e){partitionList.push({ssid:e})}),hideLoading("msg-load")}else showMessage(getPrompt("getVersionFailed"),2e3)}catch(e){showMessage(getPrompt("getVersionFailed"),2e3)}},"none")}function postOta(){timeoutNum=0;var e=document.getElementById("partition").value;if(e){var t=document.getElementById("file-info").files;t&&t.length>0?(t=t[0],Ajax.postFile("/setotadata",t,function(e){e=JSON.parse(e),hideLoading("msg-load"),0==e.state?showConfirm(getPrompt("prompt"),getPrompt("otaSuc"),getPrompt("confirm")):showConfirm(getPrompt("prompt"),getPrompt("otaFailed"),getPrompt("confirm"))},e||"")):showMessage(getPrompt("selectFile"),2e3)}else showMessage(getPrompt("enterPartition"),2e3)}function selectMenu(e,t){document.getElementById(e).classList.remove("hide"),t.classList.add("active"),"esp-at-wrap"==e?(document.getElementById("esp-ota-wrap").classList.add("hide"),document.getElementById("esp-ota-link").classList.remove("active"),getData()):(document.getElementById("esp-at-wrap").classList.add("hide"),document.getElementById("esp-at-link").classList.remove("active"),getotainfo()),isShowWifi=!1}window.onresize=function(){isMobile=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||768)<=768},getData(),initShowList();
</script>
</body>
</html>