fix IE issues

pull/25/head
Thorsten von Eicken 10 years ago
parent d29fa0423f
commit 8b3161a3f4
  1. 7
      html/140medley.min.js
  2. 1
      html/head.tpl
  3. 9
      html/ui.js
  4. 23
      html/wifi/wifi.tpl
  5. 2
      user/cgi.c

@ -1,2 +1,5 @@
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),b=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= var b=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},
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){}}; 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){}};

@ -1,3 +1,4 @@
<!doctype html>
<html><head> <html><head>
<title>ESP Link</title> <title>ESP Link</title>
<link rel="stylesheet" href="/pure-min.css"> <link rel="stylesheet" href="/pure-min.css">

@ -68,11 +68,12 @@ function showNotification(text) {
function ajaxReq(method, url, ok_cb, err_cb) { function ajaxReq(method, url, ok_cb, err_cb) {
var xhr = j(); var xhr = j();
xhr.open(method, url); xhr.open(method, url, true);
var timeout = setTimeout(function() { var timeout = setTimeout(function() {
xhr.abort(); xhr.abort();
console.log("XHR abort:", method, url); console.log("XHR abort:", method, url);
err_cb(599, "Request timeout"); xhr.status = 599;
xhr.responseText = "request time-out";
}, 9000); }, 9000);
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState != 4) { return; } if (xhr.readyState != 4) { return; }
@ -81,7 +82,7 @@ function ajaxReq(method, url, ok_cb, err_cb) {
console.log("XHR done:", method, url, "->", xhr.status); console.log("XHR done:", method, url, "->", xhr.status);
ok_cb(xhr.responseText); ok_cb(xhr.responseText);
} else { } else {
console.log("XHR ERR :", method, url, "->", xhr.status, xhr.responseText); console.log("XHR ERR :", method, url, "->", xhr.status, xhr.responseText, xhr);
err_cb(xhr.status, xhr.responseText); err_cb(xhr.status, xhr.responseText);
} }
} }
@ -116,7 +117,7 @@ function ajaxSpin(method, url, ok_cb, err_cb) {
ok_cb(resp); ok_cb(resp);
}, function(status, statusText) { }, function(status, statusText) {
$("#spinner").setAttribute('hidden', ''); $("#spinner").setAttribute('hidden', '');
showWarning("Error: " + statusText); //showWarning("Error: " + statusText);
err_cb(status, statusText); err_cb(status, statusText);
}); });
} }

@ -40,6 +40,7 @@
<script type="text/javascript"> <script type="text/javascript">
var currAp = ""; var currAp = "";
var blockScan = 0;
function createInputForAp(ap) { function createInputForAp(ap) {
if (ap.essid=="" && ap.rssi==0) return; if (ap.essid=="" && ap.rssi==0) return;
@ -88,8 +89,13 @@ function getSelectedEssid() {
} }
var scanTimeout = null; var scanTimeout = null;
var scanReqCnt = 0;
function scanResult() { function scanResult() {
if (scanReqCnt > 60) {
return scanAPs();
}
scanReqCnt += 1;
ajaxJson('GET', "scan", function(data) { ajaxJson('GET', "scan", function(data) {
currAp = getSelectedEssid(); currAp = getSelectedEssid();
if (data.result.inProgress == "0" && data.result.APs.length > 1) { if (data.result.inProgress == "0" && data.result.APs.length > 1) {
@ -114,12 +120,17 @@ function scanResult() {
} }
function scanAPs() { function scanAPs() {
if (blockScan) {
scanTimeout = window.setTimeout(scanAPs, 1000);
return;
}
scanTimeout = null; scanTimeout = null;
ajaxSpin('POST', "scan", function(data) { scanReqCnt = 0;
showNotification("Wifi scan started"); ajaxReq('POST', "scan", function(data) {
//showNotification("Wifi scan started");
window.setTimeout(scanResult, 1000); window.setTimeout(scanResult, 1000);
}, function(s, st) { }, function(s, st) {
showNotification("Wifi scan may have started?"); //showNotification("Wifi scan may have started?");
window.setTimeout(scanResult, 1000); window.setTimeout(scanResult, 1000);
}); });
} }
@ -149,6 +160,7 @@ function getStatus() {
var txt = "Connected! Got IP "+data.ip; var txt = "Connected! Got IP "+data.ip;
showNotification(txt); showNotification(txt);
showWifiInfo(data); showWifiInfo(data);
blockScan = 0;
var txt2 = "ESP Link will switch to STA-only mode in a few seconds"; var txt2 = "ESP Link will switch to STA-only mode in a few seconds";
window.setTimeout(function() { showNotification(txt2); }, 4000); window.setTimeout(function() { showNotification(txt2); }, 4000);
@ -158,6 +170,7 @@ function getStatus() {
"If you are in the same network, go to <a href=\"http://"+data.ip+ "If you are in the same network, go to <a href=\"http://"+data.ip+
"/\">"+data.ip+"</a>, else connect to network "+data.ssid+" first."; "/\">"+data.ip+"</a>, else connect to network "+data.ssid+" first.";
} else { } else {
blockScan = 0;
showWarning("Connection failed: " + data.status + ", " + data.reason); showWarning("Connection failed: " + data.status + ", " + data.reason);
$("#aps").innerHTML = $("#aps").innerHTML =
"Check password and selected AP. <a href=\"wifi.tpl\">Go Back</a>"; "Check password and selected AP. <a href=\"wifi.tpl\">Go Back</a>";
@ -169,13 +182,16 @@ function getStatus() {
} }
function changeWifiMode(m) { function changeWifiMode(m) {
blockScan = 1;
hideWarning(); hideWarning();
ajaxSpin("POST", "setmode?mode=" + m, function(resp) { ajaxSpin("POST", "setmode?mode=" + m, function(resp) {
showNotification("Mode changed"); showNotification("Mode changed");
window.setTimeout(getWifiInfo, 100); window.setTimeout(getWifiInfo, 100);
blockScan = 0;
}, function(s, st) { }, function(s, st) {
showWarning("Error changing mode: " + st); showWarning("Error changing mode: " + st);
window.setTimeout(getWifiInfo, 100); window.setTimeout(getWifiInfo, 100);
blockScan = 0;
}); });
} }
@ -193,6 +209,7 @@ function changeWifiAp(e) {
var cb = $("#connect-button"); var cb = $("#connect-button");
var cn = cb.className; var cn = cb.className;
cb.className += ' pure-button-disabled'; cb.className += ' pure-button-disabled';
blockScan = 1;
ajaxSpin("POST", url, function(resp) { ajaxSpin("POST", url, function(resp) {
$("#spinner").removeAttribute('hidden'); // hack $("#spinner").removeAttribute('hidden'); // hack
showNotification("Waiting for network change..."); showNotification("Waiting for network change...");

@ -53,7 +53,7 @@ int ICACHE_FLASH_ATTR printGlobalInfo(char *buff, int buflen, char *token) {
void ICACHE_FLASH_ATTR printGlobalJSON(HttpdConnData *connData) { void ICACHE_FLASH_ATTR printGlobalJSON(HttpdConnData *connData) {
httpdSend(connData, httpdSend(connData,
"<script type=\"text/javascript\">\n" "<script type=\"text/javascript\">\n"
"menu = [\"Home\", \"/home.tpl\", \"Wifi\", \"/wifi/wifi.tpl\"," "var menu = [\"Home\", \"/home.tpl\", \"Wifi\", \"/wifi/wifi.tpl\","
"\"\xC2\xB5" "C Console\", \"/console.tpl\", \"Debug log\", \"/log.tpl\", " "\"\xC2\xB5" "C Console\", \"/console.tpl\", \"Debug log\", \"/log.tpl\", "
"\"Help\", \"/help.tpl\" ];\n", -1); "\"Help\", \"/help.tpl\" ];\n", -1);
# define VERS_STR_STR(V) #V # define VERS_STR_STR(V) #V

Loading…
Cancel
Save