Update display_global.php
This commit is contained in:
@@ -391,33 +391,38 @@ function activarSonido() {
|
|||||||
document.addEventListener('click', () => { if (!sonidoActivo) activarSonido(); }, { once: true });
|
document.addEventListener('click', () => { if (!sonidoActivo) activarSonido(); }, { once: true });
|
||||||
document.addEventListener('touchstart', () => { if (!sonidoActivo) activarSonido(); }, { once: true });
|
document.addEventListener('touchstart', () => { if (!sonidoActivo) activarSonido(); }, { once: true });
|
||||||
|
|
||||||
function playBeep() {
|
function playBell() {
|
||||||
if (!sonidoActivo || !audioCtx) return;
|
if (!sonidoActivo || !audioCtx) return;
|
||||||
try {
|
try {
|
||||||
|
const t = audioCtx.currentTime;
|
||||||
|
// Campana de dos tonos (ding-dong)
|
||||||
|
[800, 1000].forEach((freq, i) => {
|
||||||
const osc = audioCtx.createOscillator();
|
const osc = audioCtx.createOscillator();
|
||||||
const g = audioCtx.createGain();
|
const g = audioCtx.createGain();
|
||||||
osc.type = 'sine';
|
osc.type = 'sine';
|
||||||
osc.connect(g); g.connect(audioCtx.destination);
|
osc.connect(g); g.connect(audioCtx.destination);
|
||||||
osc.frequency.setValueAtTime(880, audioCtx.currentTime);
|
osc.frequency.setValueAtTime(freq, t + i * 0.3);
|
||||||
osc.frequency.setValueAtTime(1100, audioCtx.currentTime + 0.1);
|
g.gain.setValueAtTime(0.4, t + i * 0.3);
|
||||||
osc.frequency.setValueAtTime(880, audioCtx.currentTime + 0.2);
|
g.gain.exponentialRampToValueAtTime(0.001, t + i * 0.3 + 0.4);
|
||||||
g.gain.setValueAtTime(0.35, audioCtx.currentTime);
|
osc.start(t + i * 0.3);
|
||||||
g.gain.exponentialRampToValueAtTime(0.0001, audioCtx.currentTime + 0.65);
|
osc.stop(t + i * 0.3 + 0.4);
|
||||||
osc.start(audioCtx.currentTime);
|
});
|
||||||
osc.stop(audioCtx.currentTime + 0.65);
|
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function anunciarTurno(codigo, destino) {
|
function anunciarTurno(codigo, destino, paciente) {
|
||||||
playBeep();
|
playBell();
|
||||||
if ('speechSynthesis' in window) {
|
if ('speechSynthesis' in window) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.speechSynthesis.cancel();
|
window.speechSynthesis.cancel();
|
||||||
const letras = codigo.split('').join(' ');
|
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;
|
utt.lang = 'es-CO'; utt.rate = 0.85; utt.pitch = 1.05; utt.volume = 1;
|
||||||
window.speechSynthesis.speak(utt);
|
window.speechSynthesis.speak(utt);
|
||||||
}, 700);
|
}, 800);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,7 +468,7 @@ function showAnnouncement({ codigo, destino, paciente, color }) {
|
|||||||
|
|
||||||
ov.classList.add('visible');
|
ov.classList.add('visible');
|
||||||
|
|
||||||
anunciarTurno(codigo, destino);
|
anunciarTurno(codigo, destino, paciente);
|
||||||
|
|
||||||
bar.style.transition = 'none';
|
bar.style.transition = 'none';
|
||||||
bar.style.width = '100%';
|
bar.style.width = '100%';
|
||||||
|
|||||||
Reference in New Issue
Block a user