forked from rjpcomputing/raspap-webgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
61 lines (55 loc) · 2.31 KB
/
functions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function WiFiDown() {
var down = confirm("Take down wlan0 ?");
if(down) {
} else {
alert("Action cancelled");
}
}
function UpdateNetworks() {
var existing = document.getElementById("networkbox").getElementsByTagName('div').length;
document.getElementById("Networks").value = existing;
}
function AddNetwork() {
var Networks = document.getElementById('Networks').value;
document.getElementById('networkbox').innerHTML += '<div id="Networkbox'+Networks+'" class="Networkboxes">Network ' + Networks + '<br /> \
<span class="tableft">SSID :</span><input type="text" name="ssid'+Networks+'" onkeyup="CheckSSID(this)"><br> \
<span class="tableft">Password :</span><input type="password" name="psk'+Networks+'" onkeyup="CheckPSK(this)"></div>';
Networks++;
document.getElementById('Networks').value=Networks;
}
function AddScanned(network) {
var Networks = document.getElementById('Networks').value;
document.getElementById('networkbox').innerHTML += '<div id="Networkbox' + Networks + '" class="Networkboxes">Network ' + Networks + '<br /> \
<span class="tableft">SSID :</span><input type="text" name="ssid'+Networks+'" id="ssid'+Networks+'" onkeyup="CheckSSID(this)"><br> \
<span class="tableft">Password :</span><input type="password" name="psk'+Networks+'" onkeyup="CheckPSK(this)"></div>';
document.getElementById('ssid' + Networks).value = network;
Networks++;
document.getElementById('Networks').value = Networks;
}
function CheckSSID(ssid) {
if(ssid.value.length>31) {
ssid.style.background='#FFD0D0';
document.getElementById('Save').disabled = true;
} else {
ssid.style.background='#D0FFD0'
document.getElementById('Save').disabled = false;
}
}
function CheckPSK(psk) {
if(psk.value.length < 8) {
psk.style.background='#FFD0D0';
document.getElementById('Save').disabled = true;
} else {
psk.style.background='#D0FFD0';
document.getElementById('Save').disabled = false;
}
}
function DeleteNetwork(network) {
element = document.getElementById('Networkbox'+network);
element.parentNode.removeChild(element);
// var Networks = document.getElementById('Networks').value;
// Networks--
// document.getElementById('Networks').value = Networks;
// Enble save so that user can commit the changes
document.getElementById('Save').disabled = false;
}