From e16f2ec90f02e2c395a2b3826fe385c667a6931d Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 21 May 2026 15:29:03 -0400 Subject: [PATCH] gallery: split Take Photo vs Pick from Gallery inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Two dedicated elements: cameraInput (capture=environment) for direct camera, galleryInput (no capture) for gallery picker - Both wired to handlePickedPhoto() via a shared wireInput helper - refreshGPS() fires on button click (before picker opens) for a fresh high-accuracy GPS fix — no maximumAge, so it pulls current location instead of relying on cached values from page-load initGPS() - Workaround for browser EXIF GPS stripping: camera captures may preserve EXIF GPS, gallery picks fall through to device geolocation API --- static/index.html | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/static/index.html b/static/index.html index ce6b8c1..ddaea4a 100644 --- a/static/index.html +++ b/static/index.html @@ -1213,8 +1213,9 @@ TAB: ADD ASSET (Barcode / OCR / Manual) ═══════════════════════════════════════════════════════════════════════ -->
- - + + +
@@ -1238,7 +1239,8 @@
Point camera at a barcode or sticker
- + +
@@ -2369,6 +2371,25 @@ ); } + // Refresh GPS fix on demand (called when user taps Take Photo / Pick from Gallery) + function refreshGPS() { + if (!navigator.geolocation) return; + navigator.geolocation.getCurrentPosition( + pos => { + AppState.gpsLat = pos.coords.latitude; + AppState.gpsLng = pos.coords.longitude; + AppState.gpsAcc = pos.coords.accuracy; + const badge = document.getElementById('gpsBadge'); + if (badge) { + badge.className = 'gps-badge ok'; + badge.textContent = `📍 ${AppState.gpsLat.toFixed(4)}, ${AppState.gpsLng.toFixed(4)}`; + } + }, + () => {}, // silent fail — keep existing fix if user denies + { enableHighAccuracy: true, timeout: 10000, maximumAge: 0 } + ); + } + // ========================================================================= // TOAST // ========================================================================= @@ -2594,16 +2615,20 @@ let pickedPhotoFile = null; let pickedPhotoGps = null; // { lat, lng, accuracy } from EXIF - // Wire the hidden file input + // Wire the hidden file inputs (camera + gallery — two paths for EXIF GPS workaround) (function() { - const pp = document.getElementById('photoPicker'); - if (pp) { - pp.addEventListener('change', function(e) { - if (e.target.files && e.target.files[0]) { - handlePickedPhoto(e.target.files[0]); - } - }); + function wireInput(id) { + const el = document.getElementById(id); + if (el) { + el.addEventListener('change', function(e) { + if (e.target.files && e.target.files[0]) { + handlePickedPhoto(e.target.files[0]); + } + }); + } } + wireInput('cameraInput'); + wireInput('galleryInput'); })(); function handlePickedPhoto(file) {