turnero: notificación del sistema cuando vence el countdown de toma progresiva

Usa Web Notifications API via postMessage iframe→parent para alertar
incluso cuando el tab está en segundo plano o la pantalla ocupada.
Pide permiso al iniciar el protocolo (primer gesto del usuario).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-21 09:36:23 -05:00
co-authored by Claude Sonnet 4.6
parent 6ce2fc340b
commit 019d2f4fb0
2 changed files with 8 additions and 1 deletions
+7 -1
View File
@@ -1541,7 +1541,13 @@ function cerrarModalConsentimiento(forzar) {
window.addEventListener('message', function(e) {
if (e.data && e.data.type === 'tomaProgresivaIniciada') {
_tomaProgresivaActiva = true;
// Botón cerrar permanece habilitado; el operador puede cerrar en cualquier momento
if ('Notification' in window && Notification.permission === 'default') Notification.requestPermission();
}
if (e.data && e.data.type === 'tomaProgresivaAlerta') {
var lbl = (e.data.label || '¡Siguiente muestra!');
if ('Notification' in window && Notification.permission === 'granted') {
new Notification('⏰ Toma de muestras', { body: lbl, icon: '/favicon.ico', requireInteraction: true });
}
}
if (e.data && e.data.type === 'turneroFirmado') {
_tomaProgresivaActiva = false;
+1
View File
@@ -2196,6 +2196,7 @@ function _mpIniciarCountdown(targetMsOrMins, nextLabel, nextFirmaId) {
+ (nextLabel ? '<div style="font-size:.85rem;opacity:.9;margin-top:4px">' + nextLabel + '</div>' : '');
if (navigator.vibrate) navigator.vibrate([900,150,900,150,900,150,900,150,900]);
_mpPlayBeep();
try { window.parent.postMessage({ type: 'tomaProgresivaAlerta', label: nextLabel || '¡Siguiente muestra!' }, '*'); } catch(e) {}
// Desbloquear y mostrar siguiente canvas
var nw = nextFirmaId ? document.getElementById('fpw-' + nextFirmaId) : null;
if (!nw) nw = document.querySelector('.firma-pro-widget[style*="display:none"]');