Log flights offline: the form is kept by the service worker, flights queue on the device (IndexedDB) and send when back online; one-time keys prevent duplicates

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-11 21:13:59 -05:00
1 parent 08ba017c7e
commit 191eb030e8
14 files changed
+314 -14

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
// The offline page: reload when the connection is back, and link to the Log
// Flight forms this device has kept (so a flight can be logged offline).
window.addEventListener("online", function () { location.reload() })
try {
var forms = JSON.parse(localStorage.getItem("sam-offline-forms") || "{}")
var box = document.getElementById("forms")
Object.keys(forms).forEach(function (path) {
if (!/^\/aircraft\/\d+\/flight_logs\/new$/.test(path)) return
var a = document.createElement("a")
a.href = path
a.textContent = "Log a flight: " + forms[path]
box.appendChild(a)
box.hidden = false
})
} catch (e) { /* storage off */ }