|
|
@ -6,48 +6,46 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
(function() { |
|
|
|
var xhr = new XMLHttpRequest(); |
|
|
|
var xhr = new XMLHttpRequest(); |
|
|
|
var abortTmeo; |
|
|
|
var abortTmeo; |
|
|
|
|
|
|
|
|
|
|
|
var messages = <?= json_encode([ |
|
|
|
var messages = <?= json_encode([ |
|
|
|
'idle' => tr('wifi.conn.idle'), |
|
|
|
'idle' => tr('wifi.conn.idle'), |
|
|
|
'success' => tr('wifi.conn.success'), |
|
|
|
'success' => tr('wifi.conn.success'), |
|
|
|
'working' => tr('wifi.conn.working'), |
|
|
|
'working' => tr('wifi.conn.working'), |
|
|
|
'fail' => tr('wifi.conn.fail'), |
|
|
|
'fail' => tr('wifi.conn.fail'), |
|
|
|
]) ?>; |
|
|
|
]) ?>; |
|
|
|
|
|
|
|
|
|
|
|
function getStatus() { |
|
|
|
function getStatus() { |
|
|
|
xhr.open("GET", 'http://'+_root+'<?= url('wifi_connstatus', true) ?>');
|
|
|
|
xhr.open("GET", 'http://'+_root+'<?= url('wifi_connstatus', true) ?>');
|
|
|
|
xhr.onreadystatechange = function () { |
|
|
|
xhr.onreadystatechange = function () { |
|
|
|
if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 300) { |
|
|
|
if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 300) { |
|
|
|
clearTimeout(abortTmeo); |
|
|
|
clearTimeout(abortTmeo); |
|
|
|
var data = JSON.parse(xhr.responseText); |
|
|
|
var data = JSON.parse(xhr.responseText); |
|
|
|
var done = false; |
|
|
|
var done = false; |
|
|
|
var msg = messages[data.status] || '...'; |
|
|
|
var msg = messages[data.status] || '...'; |
|
|
|
if (data.status == 'success') msg += data.ip; |
|
|
|
if (data.status == 'success') msg += data.ip; |
|
|
|
|
|
|
|
|
|
|
|
$("#status").html(msg); |
|
|
|
$("#status").html(msg); |
|
|
|
|
|
|
|
|
|
|
|
if (done) { |
|
|
|
if (done) { |
|
|
|
|
|
|
|
// $('#backbtn').removeClass('hidden'); |
|
|
|
// $('#backbtn').removeClass('hidden'); |
|
|
|
$('.anim-dots').addClass('hidden'); |
|
|
|
$('.anim-dots').addClass('hidden'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
window.setTimeout(getStatus, 1000); |
|
|
|
window.setTimeout(getStatus, 1000); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
abortTmeo = setTimeout(function () { |
|
|
|
abortTmeo = setTimeout(function () { |
|
|
|
xhr.abort(); |
|
|
|
xhr.abort(); |
|
|
|
$("#status").html(<?= json_encode(tr('wifi.conn.telemetry_lost')) ?>);
|
|
|
|
$("#status").html(<?= json_encode(tr('wifi.conn.telemetry_lost')) ?>);
|
|
|
|
// $('#backbtn').removeClass('hidden'); |
|
|
|
// $('#backbtn').removeClass('hidden'); |
|
|
|
$('.anim-dots').addClass('hidden'); |
|
|
|
$('.anim-dots').addClass('hidden'); |
|
|
|
}, 4000); |
|
|
|
}, 4000); |
|
|
|
|
|
|
|
|
|
|
|
xhr.send(); |
|
|
|
xhr.send(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getStatus(); |
|
|
|
getStatus(); |
|
|
|
})(); |
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|