From 5d2d16988550d94004b8ceeb46b7f792238914e2 Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 21 May 2026 16:16:53 -0400 Subject: [PATCH] fix: rename photoPicker to cameraInput/galleryInput broke JS IIFE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two places referenced old photoPicker element ID that was removed: 1. connectFromGallery() — switched to window._connectMode flag + galleryInput.click() 2. Connect mode hook IIFE — now hooks both cameraInput and galleryInput via shared hookPicker() helper using window._connectMode instead of DOM attr This was crashing the entire inline script (TypeError on null) ~line 4040, preventing initAuth()/checkAuthGate() from ever running — no login screen. --- static/index.html | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/static/index.html b/static/index.html index ddaea4a..eb7ddf7 100644 --- a/static/index.html +++ b/static/index.html @@ -3707,12 +3707,9 @@ } function connectFromGallery() { - const pp = document.getElementById('photoPicker'); - if (pp) { - // Override the default handler for connect mode - pp._connectMode = true; - pp.click(); - } + window._connectMode = true; + const gi = document.getElementById('galleryInput'); + if (gi) gi.click(); } async function captureConnectPhoto() { @@ -4031,20 +4028,24 @@ document.getElementById('connectLabelList').innerHTML = ''; } - // ── Hook into gallery picker for connect mode ──────────────────────────── + // ── Hook into gallery/camera pickers for connect mode ───────────────── (function() { - const pp = document.getElementById('photoPicker'); - const origHandler = pp.onchange; - pp.addEventListener('change', function(e) { - if (pp._connectMode) { - pp._connectMode = false; - if (e.target.files && e.target.files[0]) { - processConnectLabelPhoto(e.target.files[0]); + function hookPicker(elId) { + const el = document.getElementById(elId); + if (!el) return; + el.addEventListener('change', function(e) { + if (window._connectMode) { + window._connectMode = false; + if (e.target.files && e.target.files[0]) { + processConnectLabelPhoto(e.target.files[0]); + } + el.value = ''; // Reset so same file can be picked again + return; } - pp.value = ''; // Reset so same file can be picked again - return; - } - }); + }); + } + hookPicker('cameraInput'); + hookPicker('galleryInput'); })(); // ═══════════════════════════════════════════════════════════════════════ @@ -7316,7 +7317,6 @@ req.onerror = (e) => { reject(e.target.error); }; }); } - async function queueOfflineCreate(assetPayload, photoBlob) { await openOfflineDB(); const entry = { @@ -7578,6 +7578,8 @@ return { id: null, _queued: true, machine_id: payload.machine_id, name: payload.name }; } + + async function initOfflineSupport() { await registerServiceWorker(); await openOfflineDB(); @@ -7587,6 +7589,7 @@ if (!navigator.onLine) { showOfflineBanner(); } } + window.__scriptLineReached = 7593; // ═══════════════════════════════════════════════════════════════════════ // T3: Hook EXIF GPS extraction into camera capture // ═══════════════════════════════════════════════════════════════════════ @@ -7635,7 +7638,7 @@ // ═══════════════════════════════════════════════════════════════════════ // INIT — only lightweight auth & offline. Camera/GPS/assets start after login. // ═══════════════════════════════════════════════════════════════════════ - initOfflineSupport(); + initOfflineSupport().catch(e => console.warn('[Offline] init failed:', e)); initAuth();