mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-11 07:56:39 +02:00
added wifi scan to setup
fixed issues on index.html
This commit is contained in:
parent
8b8deded9a
commit
dbbfe25a44
10 changed files with 91 additions and 17 deletions
|
@ -68,6 +68,14 @@ function sel(name, opt, selId) {
|
|||
return e;
|
||||
}
|
||||
|
||||
function opt(val, html) {
|
||||
o = document.createElement('option');
|
||||
o.value = val;
|
||||
o.innerHTML = html;
|
||||
e.appendChild(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
function div(cl) {
|
||||
e = document.createElement('div');
|
||||
e.classList.add(...cl);
|
||||
|
|
|
@ -104,22 +104,26 @@
|
|||
+ ("0"+hrs).substr(-2) + ":"
|
||||
+ ("0"+min).substr(-2) + ":"
|
||||
+ ("0"+sec).substr(-2);
|
||||
var dSpan = document.getElementById("date")
|
||||
var dSpan = document.getElementById("date");
|
||||
if(0 != obj["ts_now"])
|
||||
dSpan.innerHTML = date.toLocaleString('de-DE');
|
||||
else {
|
||||
dSpan.innerHTML = "";
|
||||
var e = inp("set", "sync from browser", 0, ["btn"], "set", "button");
|
||||
dSpan.appendChild(span("NTP timeserver unreachable. "));
|
||||
dSpan.appendChild(e);
|
||||
dSpan.appendChild(span("", ["span"], "apiResult"));
|
||||
e.addEventListener("click", setTime);
|
||||
}
|
||||
document.getElementById("sunrise").innerHTML = sunrise.toLocaleString('de-DE');
|
||||
document.getElementById("sunset").innerHTML = sunset.toLocaleString('de-DE');
|
||||
|
||||
if(!obj["ts_sun_upd"]) {
|
||||
var elem = document.getElementById("sun");
|
||||
elem.parentNode.removeChild(elem);
|
||||
var e = document.getElementById("sun");
|
||||
if(null != e)
|
||||
e.parentNode.removeChild(e);
|
||||
}
|
||||
else {
|
||||
document.getElementById("sunrise").innerHTML = sunrise.toLocaleString('de-DE');
|
||||
document.getElementById("sunset").innerHTML = sunset.toLocaleString('de-DE');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
<fieldset>
|
||||
<legend class="des">WiFi</legend>
|
||||
<p>Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.</p>
|
||||
<label for="networks">Avail Networks</label>
|
||||
<select name="networks" id="networks" onChange="selNet()">
|
||||
<option value="-1">scanning ...</option>
|
||||
</select>
|
||||
<label for="ssid">SSID</label>
|
||||
<input type="text" name="ssid" class="text"/>
|
||||
<label for="pwd">Password</label>
|
||||
|
@ -377,12 +381,35 @@
|
|||
parseRadio(root["radio"]);
|
||||
parseSerial(root["serial"]);
|
||||
}
|
||||
getAjax('/api/setup/networks', listNetworks);
|
||||
window.setInterval("getAjax('/api/setup/networks', listNetworks)", 7000);
|
||||
}
|
||||
|
||||
function listNetworks(root) {
|
||||
if(root["networks"].length > 0) {
|
||||
var s = document.getElementById("networks");
|
||||
var i, l = s.options.length - 1;
|
||||
for(i = l; i >= 0; i--) {
|
||||
s.remove(i);
|
||||
}
|
||||
|
||||
for(i = 0; i < root["networks"].length; i++) {
|
||||
s.appendChild(opt(root["networks"][i]["ssid"], root["networks"][i]["ssid"] + " (" + root["networks"][i]["rssi"] + " dBm)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function selNet() {
|
||||
var s = document.getElementById("networks");
|
||||
var e = document.getElementsByName("ssid")[0];
|
||||
e.value = s.value;
|
||||
}
|
||||
|
||||
hiddenInput = document.getElementById("disclaimer")
|
||||
hiddenInput.value = sessionStorage.getItem("gDisclaimer");
|
||||
|
||||
getAjax("/api/setup", parse);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue