-
Notifications
You must be signed in to change notification settings - Fork 48
/
index.js
62 lines (56 loc) · 2.01 KB
/
index.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
62
$(function(){
var networks = undefined;
function showHideFormFields() {
var security = $(this).find(':selected').attr('data-security');
// start off with all fields hidden
$('#identity-group').addClass('hidden');
$('#passphrase-group').addClass('hidden');
$('#hidden-ssid-group').addClass('hidden');
if(security === 'NONE') {
return; // nothing to do
}
if(security === 'ENTERPRISE') {
$('#identity-group').removeClass('hidden');
$('#passphrase-group').removeClass('hidden');
return;
}
if(security === 'HIDDEN') {
$('#hidden-ssid-group').removeClass('hidden');
// fall through
}
// otherwise security is HIDDEN, WEP, WPA, or WPA2 which need password
$('#passphrase-group').removeClass('hidden');
}
$('#ssid-select').change(showHideFormFields);
$.get("/regcode", function(data){
if(data.length !== 0){
$('#regcode').val(data);
} else {
$('.reg-row').hide(); // no reg code, so hide that part of the UI
}
});
$.get("/networks", function(data){
if(data.length === 0){
$('.before-submit').hide();
$('#no-networks-message').removeClass('hidden');
} else {
networks = JSON.parse(data);
$.each(networks, function(i, val){
$('#ssid-select').append(
$('<option>')
.text(val.ssid)
.attr('val', val.ssid)
.attr('data-security', val.security.toUpperCase())
);
});
jQuery.proxy(showHideFormFields, $('#ssid-select'))();
}
});
$('#connect-form').submit(function(ev){
$.post('/connect', $('#connect-form').serialize(), function(data){
$('.before-submit').hide();
$('#submit-message').removeClass('hidden');
});
ev.preventDefault();
});
});