Watchdog WiFi + reconnexion auto + fix timing surprise capture

- Watchdog connectivite toutes les 60s (check TCP 1.1.1.1:53)
- Si offline : scan WiFi et reconnexion auto aux reseaux enregistres
- Si internet restaure : flush immediat des spools (email + galerie)
- Surprise : capture declenchee 500ms apres affichage (au lieu de 1.7s apres)
  pour capturer la reaction naturelle des gens

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-18 12:32:31 +02:00
parent d21d87347d
commit 5f1a96ab8a
4 changed files with 113 additions and 36 deletions

View File

@@ -1146,7 +1146,7 @@
<script src="/js/websocket.js?v=16"></script>
<script src="/js/app.js?v=25"></script>
<script src="/js/camera.js?v=23"></script>
<script src="/js/camera.js?v=24"></script>
<script src="/js/effects.js?v=4"></script>
<script src="/js/gallery.js?v=5"></script>
<script src="/js/share.js?v=10"></script>

View File

@@ -22,13 +22,12 @@ function prechargerSurprise() {
_surprisePreloaded = img;
}
async function afficherSurprise() {
function montrerSurprise() {
const surprise = (config || {}).surprise;
if (!surprise || !surprise.actif || !surprise.fichier) return;
const delai = surprise.delai_ms || 1500;
if (!surprise || !surprise.actif || !surprise.fichier) return false;
const overlay = document.getElementById('surprise-overlay');
if (!overlay) return;
if (!overlay) return false;
if (surprise.type === 'video') {
overlay.innerHTML = '<video src="/api/surprise/media" autoplay muted playsinline style="max-width:100%;max-height:100%;object-fit:contain"></video>';
@@ -39,26 +38,24 @@ async function afficherSurprise() {
overlay.appendChild(_surprisePreloaded);
} else {
overlay.innerHTML = '<img src="/api/surprise/media" style="max-width:100%;max-height:100%;object-fit:contain">';
const img = overlay.querySelector('img');
if (img && !img.complete) {
await new Promise(r => { img.onload = r; img.onerror = r; setTimeout(r, 500); });
}
}
}
overlay.style.opacity = '0';
overlay.classList.remove('cache');
overlay.style.transition = 'opacity 0.2s';
overlay.style.transition = 'opacity 0.15s';
overlay.style.opacity = '1';
return true;
}
await new Promise(r => setTimeout(r, delai));
function cacherSurprise() {
const overlay = document.getElementById('surprise-overlay');
if (!overlay) return;
overlay.style.opacity = '0';
await new Promise(r => setTimeout(r, 200));
overlay.classList.add('cache');
overlay.style.transition = '';
overlay.style.opacity = '';
prechargerSurprise();
setTimeout(() => {
overlay.classList.add('cache');
overlay.style.transition = '';
overlay.style.opacity = '';
}, 200);
}
// --- Preview live ---
@@ -320,7 +317,9 @@ async function lancerCapture() {
await compteARebours(avecPreMessages);
// Surprise : seulement en photo simple (pas strip/multi)
if (modeActuel === 'simple') await afficherSurprise();
// Affiche la surprise PUIS capture pendant que les gens reagissent
const aSurprise = (modeActuel === 'simple') && montrerSurprise();
if (aSurprise) await pause(500);
// Flash blanc immédiat + lancer capture en parallèle
const flash = document.getElementById('flash-blanc');
@@ -331,6 +330,7 @@ async function lancerCapture() {
arreterPreview();
let resultat = await apiPost('/api/capturer').catch(() => null);
if (aSurprise) { cacherSurprise(); prechargerSurprise(); }
if (!resultat && !resultat?.erreur) {
flash.classList.add('cache');