From 1d80b5090d75e9a2ed13a0c853738d95666be20d Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 18 Apr 2025 12:32:02 -0700 Subject: [PATCH] Create updateActivityLED() --- app/js/custom.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/js/custom.js b/app/js/custom.js index ffd2fc39..bf376dc0 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -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');