Skip to content

Commit

Permalink
Merge pull request #25 from davidchatting/master
Browse files Browse the repository at this point in the history
Fixes to capitive portal
  • Loading branch information
davidchatting authored Sep 21, 2020
2 parents f82822a + e757cd9 commit 19270ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<div class="mb-4" id="localWifiForm">
<div class="input-group mb-3">
<input id="local_ssid" class="form-control" type="text" placeholder="Network Name" list="networks-list">
<datalist id=networks-list>
<select id=networks-list-select></select>
<datalist id="networks-list">
<select id="networks-list-select"></select>
</datalist>
</div>

Expand Down
38 changes: 23 additions & 15 deletions data/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,35 @@ function configure(json) {

$('#local_ssid').text(json.local_ssid);
//TODO: use the password length to display
if(json.remote_mac != "") $('#remote-scad-code-input').attr('value', formatScadCode(json.remote_mac));
$('#local-scad-code').text(formatScadCode(json.local_mac));
if(json.remote_mac != "") $('#remote-scad-code-input').attr('value', formatScadCode(json.remote_mac));
$('#local-scad-code').text(formatScadCode(json.local_mac));

if(json.local_paired_status == "remoteSetup") {
//Show local wifi form, local and remote IDs
$('#remoteWifiForm').hide();
$('#remoteMacForm').show();
} else if(json.local_paired_status == "localSetup"){
//Show local wifi form and remote wifi form
$('#remoteWifiForm').show();
$('#remoteMacForm').hide();
} else if(json.local_paired_status == "pairedSetup"){
//just show local wifi details
$('#remoteWifiForm').hide();
$('#remoteMacForm').show();
}
configureDisplay(json.local_paired_status);

$('#local_ssid').attr('disabled', true);
populateNetworksList();
}

function configureDisplay(local_paired_status) {
switch(local_paired_status) {
case 'remoteSetup':
//Show local wifi form, local and remote IDs
$('#remoteWifiForm').hide();
$('#remoteMacForm').show();
break;
case 'localSetup':
//Show local wifi form and remote wifi form
$('#remoteWifiForm').show();
$('#remoteMacForm').hide();
break;
case 'pairedSetup':
//just show local wifi details
$('#remoteWifiForm').hide();
$('#remoteMacForm').show();
break;
}
}

function formatScadCode(code) {
return(code.slice(0, 4) + ' ' + code.slice(4));
}
Expand Down

0 comments on commit 19270ac

Please sign in to comment.