Skip to content

Instantly share code, notes, and snippets.

@arunkumar413
Created May 28, 2018 08:11
Show Gist options
  • Save arunkumar413/cd40fead2bcd69ec62976016f6a69df6 to your computer and use it in GitHub Desktop.
Save arunkumar413/cd40fead2bcd69ec62976016f6a69df6 to your computer and use it in GitHub Desktop.
wifi settings servonk
var div = document.querySelector('wifi');
var wifi = navigator.mozWifiManager;
var d = [];
var request = wifi.getNetworks();
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;
d[i].addEventListener('click',connect);
div.appendChild(d[i]);
wifi.associate(network);
}
function sortNetworks(a, b) {
return a.signalStrength > b.signalStrength ? -1 : 1;
}
function connect(e){
if (this.security === 'WEP') {
this.wep = prompt('This network requires a WEP password:');
}
else if (this.security === 'WPA-PSK') {
this.psk = prompt('This network requires a WPA Key:');
}
else if (this.security === 'WPA-EAP') {
this.eap = prompt('Which EAP method should be used:');
this.identity = prompt('Which identity should be used:');
this.password = prompt('This network requires a password:');
this.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