From 8d5d2b0838ff5c41797e66cf112ea2b0ed136fcb Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 1 Apr 2026 07:44:38 +0000 Subject: [PATCH] Autosave: 20260401-074438 --- admin_clinics.php | 4 ++-- assets/js/main.js | 35 ++++++++++++++++++++++++++++++++++- display.php | 19 ++++++++++++++++--- doctor.php | 2 +- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/admin_clinics.php b/admin_clinics.php index ea4a18d..5e81a36 100644 --- a/admin_clinics.php +++ b/admin_clinics.php @@ -107,12 +107,12 @@ qh_page_start(
- +
- +
diff --git a/assets/js/main.js b/assets/js/main.js index 9ac5238..03c2439 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -84,9 +84,42 @@ document.addEventListener('DOMContentLoaded', () => { fullscreenButton.hidden = true; } + const audioBtn = document.querySelector('.js-audio-toggle'); + if (audioBtn) { + const updateAudioBtnState = () => { + const isEnabled = window.localStorage.getItem('hospitalQueue:audioEnabled') === 'true'; + if (isEnabled) { + audioBtn.innerHTML = ''; + } else { + audioBtn.innerHTML = ''; + } + audioBtn.setAttribute('aria-pressed', isEnabled.toString()); + + const videoPlayer = document.getElementById('adsVideoPlayer'); + if (videoPlayer) { + videoPlayer.muted = !isEnabled; + } + }; + + updateAudioBtnState(); + + audioBtn.addEventListener('click', () => { + const isEnabled = window.localStorage.getItem('hospitalQueue:audioEnabled') === 'true'; + const nextState = !isEnabled; + window.localStorage.setItem('hospitalQueue:audioEnabled', nextState.toString()); + updateAudioBtnState(); + + if (nextState && 'speechSynthesis' in window) { + const primeUtterance = new SpeechSynthesisUtterance(''); + window.speechSynthesis.speak(primeUtterance); + } + }); + } + const cards = Array.from(document.querySelectorAll('.announcement-card')); const latest = cards[0]; - if (latest && 'speechSynthesis' in window) { + const audioEnabled = window.localStorage.getItem('hospitalQueue:audioEnabled') === 'true'; + if (latest && 'speechSynthesis' in window && audioEnabled) { const announcementKey = latest.dataset.announcementKey || ''; const storageKey = `hospitalQueue:lastAnnouncement:${locale}`; const storedKey = window.localStorage.getItem(storageKey) || ''; diff --git a/display.php b/display.php index a071b96..72664b3 100644 --- a/display.php +++ b/display.php @@ -59,13 +59,16 @@ qh_page_start(
+
-
+
@@ -78,7 +81,7 @@ qh_page_start(
-
+
@@ -158,7 +161,17 @@ qh_page_start( player.src = videos[currentIdx]; player.currentTime = isNaN(currentTime) ? 0 : currentTime; - player.play().catch(function(e) { console.error("Error playing video:", e); }); + if (window.localStorage.getItem('hospitalQueue:audioEnabled') === 'true') { + player.muted = false; + } + + player.play().catch(function(e) { + console.error("Error playing video:", e); + if (!player.muted) { + player.muted = true; + player.play().catch(e => console.error("Fallback play failed:", e)); + } + }); if (videos.length > 1) { player.addEventListener('ended', function() { diff --git a/doctor.php b/doctor.php index 1403cf4..ae7b334 100644 --- a/doctor.php +++ b/doctor.php @@ -56,7 +56,7 @@ qh_page_start(
-
+