fix: rename photoPicker to cameraInput/galleryInput broke JS IIFE
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.
This commit is contained in:
+23
-20
@@ -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();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user