Update display_global.php

This commit is contained in:
Lizandro Guarnizo
2026-06-11 22:25:00 -05:00
parent 438c313f86
commit 06caa0270c
+22 -17
View File
@@ -391,33 +391,38 @@ function activarSonido() {
document.addEventListener('click', () => { if (!sonidoActivo) activarSonido(); }, { once: true });
document.addEventListener('touchstart', () => { if (!sonidoActivo) activarSonido(); }, { once: true });
function playBeep() {
function playBell() {
if (!sonidoActivo || !audioCtx) return;
try {
const osc = audioCtx.createOscillator();
const g = audioCtx.createGain();
osc.type = 'sine';
osc.connect(g); g.connect(audioCtx.destination);
osc.frequency.setValueAtTime(880, audioCtx.currentTime);
osc.frequency.setValueAtTime(1100, audioCtx.currentTime + 0.1);
osc.frequency.setValueAtTime(880, audioCtx.currentTime + 0.2);
g.gain.setValueAtTime(0.35, audioCtx.currentTime);
g.gain.exponentialRampToValueAtTime(0.0001, audioCtx.currentTime + 0.65);
osc.start(audioCtx.currentTime);
osc.stop(audioCtx.currentTime + 0.65);
const t = audioCtx.currentTime;
// Campana de dos tonos (ding-dong)
[800, 1000].forEach((freq, i) => {
const osc = audioCtx.createOscillator();
const g = audioCtx.createGain();
osc.type = 'sine';
osc.connect(g); g.connect(audioCtx.destination);
osc.frequency.setValueAtTime(freq, t + i * 0.3);
g.gain.setValueAtTime(0.4, t + i * 0.3);
g.gain.exponentialRampToValueAtTime(0.001, t + i * 0.3 + 0.4);
osc.start(t + i * 0.3);
osc.stop(t + i * 0.3 + 0.4);
});
} catch (_) {}
}
function anunciarTurno(codigo, destino) {
playBeep();
function anunciarTurno(codigo, destino, paciente) {
playBell();
if ('speechSynthesis' in window) {
setTimeout(() => {
window.speechSynthesis.cancel();
const letras = codigo.split('').join(' ');
const utt = new SpeechSynthesisUtterance(`Turno ${letras}, pase a ${destino}`);
let texto = `Turno ${letras}`;
if (paciente) texto += `, ${paciente}`;
texto += `, pase a ${destino}`;
const utt = new SpeechSynthesisUtterance(texto);
utt.lang = 'es-CO'; utt.rate = 0.85; utt.pitch = 1.05; utt.volume = 1;
window.speechSynthesis.speak(utt);
}, 700);
}, 800);
}
}
@@ -463,7 +468,7 @@ function showAnnouncement({ codigo, destino, paciente, color }) {
ov.classList.add('visible');
anunciarTurno(codigo, destino);
anunciarTurno(codigo, destino, paciente);
bar.style.transition = 'none';
bar.style.width = '100%';