var currAp=""; var blockScan=0; function createInputForAp(b){if(b.essid==""&&b.rssi==0){return }var g=e("input"); g.type="radio"; g.name="essid"; g.value=b.essid; g.id="opt-"+b.essid; if(currAp==b.essid){g.checked="1" }var i=e("div"); var j=-Math.floor(b.rssi/51)*32; i.className="lock-icon"; i.style.backgroundPosition="0px "+(j-1)+"px"; var d=e("div"); d.innerHTML=""+b.rssi+"dB"; var c=e("div"); var h="-65"; if(b.enc=="0"){h="0" }if(b.enc=="1"){h="-33" }c.className="lock-icon"; c.style.backgroundPosition="-32px "+h+"px"; var f=e("div"); f.innerHTML=b.essid; var a=m('').childNodes[0]; a.appendChild(g); a.appendChild(c); a.appendChild(i); a.appendChild(d); a.appendChild(f); return a }function getSelectedEssid(){var c=document.forms.wifiform.elements; for(var b=0; b60){return scanAPs() }scanReqCnt+=1; ajaxJson("GET","scan",function(c){currAp=getSelectedEssid(); if(c.result.inProgress=="0"&&c.result.APs.length>0){$("#aps").innerHTML=""; var d=0; for(var b=0; b'+c.ip+", else connect to network "+c.ssid+" first." }else{blockScan=0; showWarning("Connection failed: "+c.status+", "+c.reason); $("#aps").innerHTML='Check password and selected AP. Go Back' }}},function(b,a){window.setTimeout(getStatus,2000) }) }function changeWifiMode(a){blockScan=1; hideWarning(); ajaxSpin("POST","setmode?mode="+a,function(b){showNotification("Mode changed"); window.setTimeout(getWifiInfo,100); blockScan=0; window.setTimeout(scanAPs,500); $("#aps").innerHTML='Scanning...
' },function(c,b){showWarning("Error changing mode: "+b); window.setTimeout(getWifiInfo,100); blockScan=0 }) }function changeWifiAp(d){d.preventDefault(); var b=$("#wifi-passwd").value; var f=getSelectedEssid(); showNotification("Connecting to "+f); var c="connect?essid="+encodeURIComponent(f)+"&passwd="+encodeURIComponent(b); hideWarning(); $("#reconnect").setAttribute("hidden",""); $("#wifi-passwd").value=""; var a=$("#connect-button"); var g=a.className; a.className+=" pure-button-disabled"; blockScan=1; ajaxSpin("POST",c,function(h){$("#spinner").removeAttribute("hidden"); showNotification("Waiting for network change..."); window.scrollTo(0,0); window.setTimeout(getStatus,2000) },function(i,h){showWarning("Error switching network: "+h); a.className=g; window.setTimeout(scanAPs,1000) }) }function changeSpecial(c){c.preventDefault(); var b="special"; b+="?dhcp="+document.querySelector('input[name="dhcp"]:checked').value; b+="&staticip="+encodeURIComponent($("#wifi-staticip").value); b+="&netmask="+encodeURIComponent($("#wifi-netmask").value); b+="&gateway="+encodeURIComponent($("#wifi-gateway").value); hideWarning(); var a=$("#special-button"); addClass(a,"pure-button-disabled"); ajaxSpin("POST",b,function(d){removeClass(a,"pure-button-disabled") },function(f,d){showWarning("Error: "+d); removeClass(a,"pure-button-disabled"); getWifiInfo() }) }function doDhcp(){$("#dhcp-on").removeAttribute("hidden"); $("#dhcp-off").setAttribute("hidden","") }function doStatic(){$("#dhcp-off").removeAttribute("hidden"); $("#dhcp-on").setAttribute("hidden","") };