scan on demand

pull/30/head
Ondřej Hruška 8 years ago
parent f6621252f6
commit 812feebf54
  1. 10
      html_orig/css/app.css
  2. 1
      html_orig/lang/en.php
  3. 20
      html_orig/pages/cfg_wifi.php
  4. 74
      html_orig/pages/cfg_wifi_conn.php
  5. 10
      html_orig/sass/pages/_wifi.scss

@ -845,7 +845,7 @@ form span.required {
#ap-list {
column-count: 1; } }
#ap-loader, #ap-noscan {
#ap-loader, #ap-noscan, #ap-scan {
background: rgba(255, 255, 255, 0.1);
border-radius: 5px;
padding: 0.38198rem;
@ -917,9 +917,11 @@ form span.required {
word-wrap: normal; }
.AP-preview-nil {
padding: 0.38198rem 0.61805rem;
border-radius: 3px;
border: 2px dashed black; }
padding: 8px;
border-radius: 5px;
border: 1px dashed #ddd;
width: 250px;
height: 94px; }
.AP-preview .wrap {
flex-direction: row;

@ -30,6 +30,7 @@ return [
'wifi.submit' => 'Apply!',
'wifi.scanning' => 'Scanning',
'wifi.scan_now' => 'Start scanning!',
'wifi.cant_scan_no_sta' => 'Can\'t scan with Client mode disabled.',
'wifi.select_ssid' => 'Available networks:',

@ -85,7 +85,8 @@
<div id="ap-box">
<label><?= tr('wifi.select_ssid') ?></label>
<div id="ap-loader"><?= tr('wifi.scanning') ?><span class="anim-dots">.</span></div>
<div id="ap-scan"><a onclick="startScanning(); return false"><?= tr('wifi.scan_now') ?></a></div>
<div id="ap-loader" class="hidden"><?= tr('wifi.scanning') ?><span class="anim-dots">.</span></div>
<div id="ap-noscan" class="hidden"><?= tr('wifi.cant_scan_no_sta') ?></div>
<div id="ap-list" class="hidden"></div>
</div>
@ -238,6 +239,13 @@
});
}
function startScanning() {
$('#ap-loader').removeClass('hidden');
$('#ap-scan').addClass('hidden');
$('#ap-loader .anim-dots').html('.');
scanAPs();
}
/** Ask the CGI what APs are visible (async) */
function scanAPs() {
$.get('http://'+_root+'<?= url('wifi_scan', true) ?>', onScan);
@ -263,12 +271,12 @@
obj.mode = +obj.mode;
$('#ap-noscan').toggleClass('hidden', obj.mode != 2);
$('#ap-loader').toggleClass('hidden', obj.mode == 2);
$('#ap-scan').toggleClass('hidden', obj.mode == 2);
// scan if not AP
if (obj.mode != 2) {
scanAPs();
}
// // scan if not AP
// if (obj.mode != 2) {
// scanAPs();
// }
}
wifiInit({mode: '%opmode%'});

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

@ -13,7 +13,7 @@
margin: 0 (- dist(-3));
}
#ap-loader, #ap-noscan {
#ap-loader, #ap-noscan, #ap-scan {
background: rgba(white, .1);
border-radius: 5px;
padding: dist(-2);
@ -118,9 +118,11 @@
}
.AP-preview-nil {
padding: dist(-2) dist(-1);
border-radius: 3px;
border: 2px dashed black;
padding: 8px;
border-radius: 5px;
border: 1px dashed #ddd;
width: 250px;
height: 94px;
}
.AP-preview {

Loading…
Cancel
Save