diff --git a/components/wifi-manager/code.js b/components/wifi-manager/code.js
index e6efa95a..4f7d3148 100644
--- a/components/wifi-manager/code.js
+++ b/components/wifi-manager/code.js
@@ -279,263 +279,264 @@ $(document).ready(function(){
}
});
var [ver, idf, cfg, branch] = release.name.split('#');
- var body = release.body.replace(/\\n/ig, "
").replace(/\'/ig, "\"");
- var [date, time] = release.created_at.split('T');
- $("#releaseTable").append(
- "
Your IP address now is: " + text(data["ip"]) + "
"); - $( "#connect-success" ).show(); - $( "#connect-fail" ).hide(); + $( "#wifi-list" ).html(h) +} - enableAPTimer = false; - if (!recovery) enableStatusTimer = false; - } - else if(data["urc"] === 1){ - //failed attempt - $("#connected-to span").text(''); - $("#connect-details h1").text(''); - $("#ip").text('0.0.0.0'); - $("#netmask").text('0.0.0.0'); - $("#gw").text('0.0.0.0'); - $("span#foot-wifi").html(""); +function checkStatus(){ + RepeatCheckStatusInterval(); + if (!enableStatusTimer) return; + if (blockAjax) return; + blockAjax = true; + $.getJSON( "/status.json", function( data ) { + if(data.hasOwnProperty('ssid') && data['ssid'] != ""){ + if(data["ssid"] === selectedSSID){ + //that's a connection attempt + if(data["urc"] === 0){ + //got connection + $("#connected-to span").text(data["ssid"]); + $("#connect-details h1").text(data["ssid"]); + $("#ip").text(data["ip"]); + $("#netmask").text(data["netmask"]); + $("#gw").text(data["gw"]); + $("#wifi-status").slideDown( "fast", function() {}); + $("span#foot-wifi").html(", SSID: "+data["ssid"]+", IP: "+data["ip"]+""); - //don't show any connection - $("#wifi-status").slideUp( "fast", function() {}); + //unlock the wait screen if needed + $( "#ok-connect" ).prop("disabled",false); - //unlock the wait screen - $( "#ok-connect" ).prop("disabled",false); + //update wait screen + $( "#loading" ).hide(); + $( "#connect-success" ).append("Your IP address now is: " + text(data["ip"]) + "
"); + $( "#connect-success" ).show(); + $( "#connect-fail" ).hide(); - //update wait screen - $( "#loading" ).hide(); - $( "#connect-fail" ).show(); - $( "#connect-success" ).hide(); - - enableAPTimer = true; - enableStatusTimer = true; - } - } - else if(data.hasOwnProperty('urc') && data['urc'] === 0){ - //ESP32 is already connected to a wifi without having the user do anything - if( !($("#wifi-status").is(":visible")) ){ - $("#connected-to span").text(data["ssid"]); - $("#connect-details h1").text(data["ssid"]); - $("#ip").text(data["ip"]); - $("#netmask").text(data["netmask"]); - $("#gw").text(data["gw"]); - $("#wifi-status").slideDown( "fast", function() {}); - $("span#foot-wifi").html(", SSID: "+data["ssid"]+", IP: "+data["ip"]+""); - } enableAPTimer = false; if (!recovery) enableStatusTimer = false; } - } - else if(data.hasOwnProperty('urc') && data['urc'] === 2){ - //that's a manual disconnect - if($("#wifi-status").is(":visible")){ - $("#wifi-status").slideUp( "fast", function() {}); + else if(data["urc"] === 1){ + //failed attempt + $("#connected-to span").text(''); + $("#connect-details h1").text(''); + $("#ip").text('0.0.0.0'); + $("#netmask").text('0.0.0.0'); + $("#gw").text('0.0.0.0'); $("span#foot-wifi").html(""); - } - enableAPTimer = true; - enableStatusTimer = true; - } - if (data.hasOwnProperty('recovery')) { - if (data["recovery"] === 1) { - recovery = true; - $("#otadiv").show(); - enableStatusTimer = true; - } else { - recovery = false; - $("#otadiv").hide(); - enableStatusTimer = false; - } - } - if(data.hasOwnProperty('project_name') && data['project_name'] != ''){ - pname = data['project_name']; - } - if(data.hasOwnProperty('version') && data['version'] != ''){ - ver = data['version']; - $("span#foot-fw").html("fw: "+ver+", mode: "+pname+""); - } - if(data.hasOwnProperty('ota_pct') && data['ota_pct'] != 0){ - otapct = data['ota_pct']; - $('.progress-bar').css('width', otapct+'%').attr('aria-valuenow', otapct); - $('.progress-bar').html(otapct+'%'); - } - blockAjax = false; - }) - .fail(function() { - //don't do anything, the server might be down while esp32 recalibrates radio - }); - } - function getConfig() { - $.getJSON("/config.json", function(data) { - if (data.hasOwnProperty('autoexec')) { - if (data["autoexec"] === 1) { - console.log('turn on autoexec'); - $("#autoexec-cb")[0].checked=true; - } else { - console.log('turn off autoexec'); - $("#autoexec-cb")[0].checked=false; + //don't show any connection + $("#wifi-status").slideUp( "fast", function() {}); + + //unlock the wait screen + $( "#ok-connect" ).prop("disabled",false); + + //update wait screen + $( "#loading" ).hide(); + $( "#connect-fail" ).show(); + $( "#connect-success" ).hide(); + + enableAPTimer = true; + enableStatusTimer = true; } } - if (data.hasOwnProperty('list')) { - data.list.forEach(function(line) { - let key = Object.keys(line)[0]; - let val = Object.values(line)[0]; - console.log(key, val); - if (key == 'autoexec1') { - $("#autoexec1").val(val); - } - }); + else if(data.hasOwnProperty('urc') && data['urc'] === 0){ + //ESP32 is already connected to a wifi without having the user do anything + if( !($("#wifi-status").is(":visible")) ){ + $("#connected-to span").text(data["ssid"]); + $("#connect-details h1").text(data["ssid"]); + $("#ip").text(data["ip"]); + $("#netmask").text(data["netmask"]); + $("#gw").text(data["gw"]); + $("#wifi-status").slideDown( "fast", function() {}); + $("span#foot-wifi").html(", SSID: "+data["ssid"]+", IP: "+data["ip"]+""); + } + enableAPTimer = false; + if (!recovery) enableStatusTimer = false; } - }) - .fail(function() { - console.log("failed to fetch config!"); - }); - } + } + else if(data.hasOwnProperty('urc') && data['urc'] === 2){ + //that's a manual disconnect + if($("#wifi-status").is(":visible")){ + $("#wifi-status").slideUp( "fast", function() {}); + $("span#foot-wifi").html(""); + } + enableAPTimer = true; + enableStatusTimer = true; + } + if (data.hasOwnProperty('recovery')) { + if (data["recovery"] === 1) { + recovery = true; + $("#otadiv").show(); + enableStatusTimer = true; + } else { + recovery = false; + $("#otadiv").hide(); + enableStatusTimer = false; + } + } + if(data.hasOwnProperty('project_name') && data['project_name'] != ''){ + pname = data['project_name']; + } + if(data.hasOwnProperty('version') && data['version'] != ''){ + ver = data['version']; + $("span#foot-fw").html("fw: "+ver+", mode: "+pname+""); + } + if(data.hasOwnProperty('ota_pct') && data['ota_pct'] != 0){ + otapct = data['ota_pct']; + $('.progress-bar').css('width', otapct+'%').attr('aria-valuenow', otapct); + $('.progress-bar').html(otapct+'%'); + } + blockAjax = false; + }) + .fail(function() { + //don't do anything, the server might be down while esp32 recalibrates radio + }); +} + +function getConfig() { + $.getJSON("/config.json", function(data) { + if (data.hasOwnProperty('autoexec')) { + if (data["autoexec"] === 1) { + console.log('turn on autoexec'); + $("#autoexec-cb")[0].checked=true; + } else { + console.log('turn off autoexec'); + $("#autoexec-cb")[0].checked=false; + } + } + if (data.hasOwnProperty('list')) { + data.list.forEach(function(line) { + let key = Object.keys(line)[0]; + let val = Object.values(line)[0]; + console.log(key, val); + if (key == 'autoexec1') { + $("#autoexec1").val(val); + } + }); + } + }) + .fail(function() { + console.log("failed to fetch config!"); + }); +}