1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2025-07-14 19:27:39 +02:00

Create updateActivityLED()

This commit is contained in:
billz 2025-04-18 12:32:02 -07:00
parent 658e931aa6
commit 1d80b5090d

View File

@ -1022,6 +1022,30 @@ function disableValidation(form) {
});
}
function updateActivityLED() {
fetch('/app/net_activity')
.then(res => res.text())
.then(data => {
const activity = parseInt(data.trim());
console.log(activity);
const led = document.getElementById('hostapd-led');
if (!isNaN(activity)) {
if (activity > 170) {
led.setAttribute('data-active', 'true');
setTimeout(() => led.removeAttribute('data-active'), 50);
led.classList.add('led-pulse');
} else {
led.classList.remove('led-pulse');
}
} else {
console.warn('Unexpected data:', data);
}
})
.catch(() => { /* ignore fetch errors */ });
}
setInterval(updateActivityLED, 200);
$(document).ready(function() {
const $htmlElement = $('html');
const $modeswitch = $('#night-mode');