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:
co-authored by
Claude Sonnet 4.6
parent
2ed9eff653
commit
4cd307ba4f
@@ -1261,21 +1261,24 @@ const CONSENT_LBL = {
|
||||
const _tomaAlertados = new Set();
|
||||
let _bannerTurnoId = null;
|
||||
|
||||
function _playBeepLugar() {
|
||||
function _playAlarmaLugar() {
|
||||
try {
|
||||
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();
|
||||
osc.connect(gain); gain.connect(ctx.destination);
|
||||
osc.frequency.value = freq;
|
||||
const t0 = ctx.currentTime + i * 0.22;
|
||||
gain.gain.setValueAtTime(0.7, t0);
|
||||
gain.gain.exponentialRampToValueAtTime(0.001, t0 + 0.18);
|
||||
osc.start(t0); osc.stop(t0 + 0.18);
|
||||
const t0 = ctx.currentTime + i * 0.32;
|
||||
gain.gain.setValueAtTime(1.0, t0);
|
||||
gain.gain.exponentialRampToValueAtTime(0.001, t0 + 0.28);
|
||||
osc.start(t0); osc.stop(t0 + 0.28);
|
||||
});
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
let _alarmaInterval = null;
|
||||
|
||||
function verPacienteToma() {
|
||||
cerrarBannerToma();
|
||||
if (_bannerTurnoId) seleccionarSinLlamar(_bannerTurnoId);
|
||||
@@ -1283,6 +1286,8 @@ function verPacienteToma() {
|
||||
function cerrarBannerToma() {
|
||||
const b = document.getElementById('banner-toma-alerta');
|
||||
if (b) b.classList.remove('show');
|
||||
clearInterval(_alarmaInterval);
|
||||
_alarmaInterval = null;
|
||||
}
|
||||
|
||||
setInterval(function() {
|
||||
@@ -1309,8 +1314,19 @@ setInterval(function() {
|
||||
bannerTxt.textContent = '¡Hora de la siguiente muestra! — ' + pacNombre;
|
||||
banner.classList.add('show');
|
||||
}
|
||||
_playBeepLugar();
|
||||
if (navigator.vibrate) navigator.vibrate([400, 150, 400]);
|
||||
_playAlarmaLugar();
|
||||
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 {
|
||||
// Si el tiempo se actualizó (nueva toma programada), resetear la alerta
|
||||
@@ -1339,7 +1355,7 @@ setInterval(() => {
|
||||
row.classList.add('alerta');
|
||||
if (!info.alertado) {
|
||||
info.alertado = true;
|
||||
_playBeepLugar();
|
||||
_playAlarmaLugar();
|
||||
}
|
||||
} else {
|
||||
row.classList.remove('alerta');
|
||||
|
||||
Reference in New Issue
Block a user