feat(lugar): alarma persistente para tomas progresivas

Sonido más fuerte (gain 1.0, 3 pulsos grave-agudo), se repite cada
30 s mientras el banner no se cierre con click.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-23 12:45:22 -05:00
co-authored by Claude Sonnet 4.6
parent 2ed9eff653
commit 4cd307ba4f
+25 -9
View File
@@ -1261,21 +1261,24 @@ const CONSENT_LBL = {
const _tomaAlertados = new Set(); const _tomaAlertados = new Set();
let _bannerTurnoId = null; let _bannerTurnoId = null;
function _playBeepLugar() { function _playAlarmaLugar() {
try { try {
const ctx = new (window.AudioContext || window.webkitAudioContext)(); const ctx = new (window.AudioContext || window.webkitAudioContext)();
[880, 1100, 880, 1100].forEach(function(freq, i) { // 3 pulsos: grave-agudo, gain máximo, 0.3s cada tono
[440, 880, 440, 880, 440, 880].forEach(function(freq, i) {
const osc = ctx.createOscillator(), gain = ctx.createGain(); const osc = ctx.createOscillator(), gain = ctx.createGain();
osc.connect(gain); gain.connect(ctx.destination); osc.connect(gain); gain.connect(ctx.destination);
osc.frequency.value = freq; osc.frequency.value = freq;
const t0 = ctx.currentTime + i * 0.22; const t0 = ctx.currentTime + i * 0.32;
gain.gain.setValueAtTime(0.7, t0); gain.gain.setValueAtTime(1.0, t0);
gain.gain.exponentialRampToValueAtTime(0.001, t0 + 0.18); gain.gain.exponentialRampToValueAtTime(0.001, t0 + 0.28);
osc.start(t0); osc.stop(t0 + 0.18); osc.start(t0); osc.stop(t0 + 0.28);
}); });
} catch(e) {} } catch(e) {}
} }
let _alarmaInterval = null;
function verPacienteToma() { function verPacienteToma() {
cerrarBannerToma(); cerrarBannerToma();
if (_bannerTurnoId) seleccionarSinLlamar(_bannerTurnoId); if (_bannerTurnoId) seleccionarSinLlamar(_bannerTurnoId);
@@ -1283,6 +1286,8 @@ function verPacienteToma() {
function cerrarBannerToma() { function cerrarBannerToma() {
const b = document.getElementById('banner-toma-alerta'); const b = document.getElementById('banner-toma-alerta');
if (b) b.classList.remove('show'); if (b) b.classList.remove('show');
clearInterval(_alarmaInterval);
_alarmaInterval = null;
} }
setInterval(function() { setInterval(function() {
@@ -1309,8 +1314,19 @@ setInterval(function() {
bannerTxt.textContent = '¡Hora de la siguiente muestra! — ' + pacNombre; bannerTxt.textContent = '¡Hora de la siguiente muestra! — ' + pacNombre;
banner.classList.add('show'); banner.classList.add('show');
} }
_playBeepLugar(); _playAlarmaLugar();
if (navigator.vibrate) navigator.vibrate([400, 150, 400]); if (navigator.vibrate) navigator.vibrate([400, 150, 400, 150, 400]);
clearInterval(_alarmaInterval);
_alarmaInterval = setInterval(function() {
const b = document.getElementById('banner-toma-alerta');
if (b && b.classList.contains('show')) {
_playAlarmaLugar();
if (navigator.vibrate) navigator.vibrate([400, 150, 400, 150, 400]);
} else {
clearInterval(_alarmaInterval);
_alarmaInterval = null;
}
}, 30000);
} }
} else { } else {
// Si el tiempo se actualizó (nueva toma programada), resetear la alerta // Si el tiempo se actualizó (nueva toma programada), resetear la alerta
@@ -1339,7 +1355,7 @@ setInterval(() => {
row.classList.add('alerta'); row.classList.add('alerta');
if (!info.alertado) { if (!info.alertado) {
info.alertado = true; info.alertado = true;
_playBeepLugar(); _playAlarmaLugar();
} }
} else { } else {
row.classList.remove('alerta'); row.classList.remove('alerta');