feat: make roast planner mobile PWA ready
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user