From 97b846b2b66b288864719e3a5a86e3d553b97828 Mon Sep 17 00:00:00 2001 From: billz Date: Sat, 19 Apr 2025 06:04:59 -0700 Subject: [PATCH] Revise updateActivityLED() to handle multiple hostapd-led classes --- app/js/custom.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index bf376dc0..6af1313e 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -1023,28 +1023,32 @@ function disableValidation(form) { } function updateActivityLED() { + const threshold_bytes = 300; fetch('/app/net_activity') .then(res => res.text()) .then(data => { const activity = parseInt(data.trim()); - console.log(activity); - const led = document.getElementById('hostapd-led'); + const leds = document.querySelectorAll('.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); + leds.forEach(led => { + if (activity > threshold_bytes) { + led.setAttribute('data-active', 'true'); + led.classList.add('led-pulse'); + setTimeout(() => { + led.removeAttribute('data-active'); + led.classList.remove('led-pulse'); + }, 50); + } else { + led.classList.remove('led-pulse'); + led.removeAttribute('data-active'); + } + }); } }) .catch(() => { /* ignore fetch errors */ }); } -setInterval(updateActivityLED, 200); +setInterval(updateActivityLED, 100); $(document).ready(function() { const $htmlElement = $('html');