Add soft-ap mode, remove wifi config.

Device defaukts to soft-ap mode. User can use the "WIFI" button to set wifi credentials. Pressing "boot" for 1 second resets to soft-ap mode.

Re-work UI to fill screen.
This commit is contained in:
Matt
2025-12-14 11:23:18 +00:00
parent 855d287e1d
commit 46514b5c76
7 changed files with 702 additions and 195 deletions

View File

@@ -461,5 +461,44 @@ document.getElementById('resetBtn').addEventListener('click', () => {
window.location.reload();
});
document.getElementById('powerOff').addEventListener('click', () => window.location.href = "/poweroff");
function setupWifiListeners() {
const modal = document.getElementById('wifiModal');
const btn = document.getElementById('wifiBtn');
const closeBtn = document.getElementById('closeWifi');
const saveBtn = document.getElementById('saveWifi');
if (btn) btn.onclick = () => {
modal.style.display = "flex";
document.getElementById('wifiSsid').focus();
};
if (closeBtn) closeBtn.onclick = () => modal.style.display = "none";
if (saveBtn) saveBtn.onclick = () => {
const ssid = document.getElementById('wifiSsid').value;
const pass = document.getElementById('wifiPass').value;
if (!ssid) {
alert("SSID is required");
return;
}
saveBtn.innerText = "Saving...";
fetch('/api/save_wifi', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ssid, password: pass })
})
.then(res => res.text())
.then(text => {
alert(text);
window.location.reload();
})
.catch(err => {
alert("Error: " + err);
saveBtn.innerText = "Save";
});
};
}
setupWifiListeners();
setParams();
connect();