scan networks

This commit is contained in:
Justin 2023-07-19 19:07:06 +08:00 committed by GitHub
parent 2a902ed416
commit 70b4195bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3317,3 +3317,31 @@ function sendNetworkToSSID(element) {
ssid_input.value = value;
element.classList.add("active");
}
// scan nearby networks
function scanNetworks() {
var networksListReset = document.getElementById("networks-list");
networksListReset.innerHTML = "";
fetch("/scanNetworks", {
method: "PUT",
})
.then(response => response.text())
.then(data => {
// Parse the response data as JSON
var networks = JSON.parse(data);
// Iterate over the networks object and create list items
for (var ssid in networks) {
var listItem = document.createElement("li");
listItem.textContent = ssid;
listItem.onclick = function() {
sendNetworkToSSID(this);
};
networksListReset.appendChild(listItem);
}
})
.catch(error => console.log(error));
}