diff --git a/data/index.html b/data/index.html index 945a14d..0677039 100644 --- a/data/index.html +++ b/data/index.html @@ -31,8 +31,8 @@
- - + +
diff --git a/data/script.js b/data/script.js index 87e4914..87afd09 100644 --- a/data/script.js +++ b/data/script.js @@ -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)); }