Created
May 28, 2018 09:54
-
-
Save arunkumar413/f730185337f64865fd84125986ed5206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var div = document.querySelector('wifi'); | |
var wifi = navigator.mozWifiManager; | |
var d = []; | |
var request = wifi.getNetworks(); // get the available networks | |
request.onsuccess = function () { | |
console.log(this.result); | |
var networks= this.result; | |
networks.sort(sortNetworks) | |
for(i=0;i<networks.length.i++){ | |
d[i]=document.createElement('div'); | |
d[i].textContent=networks[i].ssid; | |
div.appendChild(d[i]); | |
document.addEventListener("click", function() { | |
connect(i); | |
}); | |
} | |
} | |
function sortNetworks(a, b) { | |
return a.signalStrength > b.signalStrength ? -1 : 1; | |
} | |
function connect(i){ | |
if (networks[i].security === 'WEP') { | |
networks[i].wep = prompt('This network requires a WEP password:'); | |
} | |
else if (networks[i].security === 'WPA-PSK') { | |
networks[i].psk = prompt('This network requires a WPA Key:'); | |
} | |
else if (networks[i].security === 'WPA-EAP') { | |
networks[i].eap = prompt('Which EAP method should be used:'); | |
networks[i].identity = prompt('Which identity should be used:'); | |
networks[i].password = prompt('This network requires a password:'); | |
networks[i].pin = prompt('Thanks to finally provide your own PIN:'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment