feat: make roast planner mobile PWA ready

This commit is contained in:
2026-07-29 21:23:32 -04:00
parent 106b1104c3
commit 0efefb7b05
8 changed files with 197 additions and 0 deletions
+22
View File
@@ -494,6 +494,27 @@ function wireToolbar() {
});
}
function wirePwa() {
const status = document.getElementById("connection-status");
const renderConnection = () => {
const offline = !navigator.onLine;
status.classList.toggle("hidden", !offline);
status.textContent = offline ? "Offline — changes continue saving on this device." : "";
};
window.addEventListener("online", renderConnection);
window.addEventListener("offline", renderConnection);
renderConnection();
if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker.register("/sw.js").catch((error) => {
console.warn("Service worker registration failed:", error);
});
});
}
}
function wireSectionNav() {
const links = [...document.querySelectorAll(".section-nav a")];
const sections = links
@@ -523,6 +544,7 @@ function init() {
wireForm();
wireDrawers();
wireToolbar();
wirePwa();
wireSectionNav();
initPrefillPanel({ state, renderBlendRows: renderBlend, renderActuatorRows: renderActuators, renderFormFromPlan, recompute });
initAlogPanel({ state, recompute });