From 63b721cf09668bd1109155b870d69dff0f1e2475 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Mon, 20 Apr 2026 14:48:57 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20ripristina=20pulsanti=20kiosk=20(X/refre?= =?UTF-8?q?sh)=20e=20riduce=20attesa=20stabilit=C3=A0=20bilancia=20a=205s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Aggiunge iniezione overlay kiosk lato web (X chiudi + ↻ refresh) quando _kioskBridge è disponibile, più affidabile dell'iniezione Android-side - Riduce timer stabilità bilancia da 10s a 5s --- assets/js/app.js | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 2bb5f8d..de50ffb 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -70,7 +70,7 @@ let _scaleWeightCallback = null; // pending on-demand weight request callback let _scaleLatestWeight = null; // last received weight message let _scaleAutoConfirmTimer = null; // countdown timer for auto-confirm after stable weight let _scaleAutoConfirmRAF = null; // rAF handle for auto-confirm progress bar animation -let _scaleStabilityTimer = null; // setTimeout: wait 10 s stable before starting confirm bar +let _scaleStabilityTimer = null; // setTimeout: wait 5 s stable before starting confirm bar let _scaleStabilityRAF = null; // rAF handle for stability progress bar in the live box let _scaleStabilityVal = null; // value we are currently timing for stability let _scaleUserDismissed = false; // user tapped or edited → don't retrigger for same value @@ -565,11 +565,11 @@ function _cancelScaleStabilityWait() { /** * Start a 10-second stability wait with an animated progress bar. * Updates both #scale-live-progress-bar (use page) and #ruse-scale-progress-bar (recipe modal). - * Calls onStable() when weight unchanged for 10 s. + * Calls onStable() when weight unchanged for 5 s. */ function _startScaleStabilityWait(onStable) { _cancelScaleStabilityWait(); - const duration = 10000; + const duration = 5000; const start = performance.now(); const bar = document.getElementById('scale-live-progress-bar'); const bar2 = document.getElementById('ruse-scale-progress-bar'); @@ -1745,6 +1745,46 @@ async function loadSettingsUI() { } } +// ── Kiosk overlay: X (close) + ↻ (refresh) buttons ─────────────────── +// Injected from the web app so they survive SPA navigations. +// Only shown when _kioskBridge JS interface is available (Android WebView). +function _injectKioskOverlay() { + if (typeof _kioskBridge === 'undefined') return; + if (document.getElementById('_kiosk_overlay')) return; + + const wrap = document.createElement('div'); + wrap.id = '_kiosk_overlay'; + wrap.style.cssText = 'position:fixed;top:8px;right:8px;z-index:2147483647;display:flex;gap:6px;align-items:center;pointer-events:auto;'; + + const btnStyle = 'background:rgba(0,0,0,0.45);border:1.5px solid rgba(255,255,255,0.5);color:#fff;width:34px;height:34px;border-radius:50%;font-size:15px;cursor:pointer;display:flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent;touch-action:manipulation;'; + + // Exit button + const exitBtn = document.createElement('button'); + exitBtn.id = '_kiosk_exit_btn'; + exitBtn.textContent = '\u2715'; + exitBtn.title = 'Esci dal kiosk'; + exitBtn.style.cssText = btnStyle; + exitBtn.addEventListener('click', (e) => { + e.stopPropagation(); + if (confirm('Uscire dalla modalità kiosk?')) _kioskBridge.exit(); + }); + + // Refresh button + const refBtn = document.createElement('button'); + refBtn.id = '_kiosk_refresh_btn'; + refBtn.textContent = '\u21bb'; + refBtn.title = 'Aggiorna pagina'; + refBtn.style.cssText = btnStyle.replace('font-size:15px', 'font-size:18px'); + refBtn.addEventListener('click', (e) => { + e.stopPropagation(); + _kioskBridge.hardReload(); + }); + + wrap.appendChild(exitBtn); + wrap.appendChild(refBtn); + document.documentElement.appendChild(wrap); +} + function renderAppliances(appliances) { const container = document.getElementById('appliances-list'); if (!appliances || appliances.length === 0) { @@ -10736,6 +10776,7 @@ async function _initApp() { initScreensaverShortcuts(); startBgShoppingRefresh(); scaleInit(); // connect to smart scale gateway if configured + _injectKioskOverlay(); // kiosk X / refresh buttons (only when running inside Android WebView) // ── Auto-refresh dati ───────────────────────────────────────────────── // 1) Ogni 5 minuti: ricarica la pagina corrente (scadenze, inventario, ecc.)