Rebuild mock as hash-routed SPA with i18n and PWA refresh
- Single-page shell (ui/index.html) + vanilla hash router; each screen is a partial - New #/check schedule view (all stop times open, no collapse) wired to the 'check schedules' CTA; contact-operator box, route map and gallery trimmed from it - Mobile-first responsive.css (375px iPhone 8 up to 27-inch/1440p) - TH/EN i18n system (data-i18n, browser-language detect, topbar switcher) - Shared form controls moved to _shared.css (mu-btn, custom select chevron, focus-visible ring); footer contact column now mailto:[email protected] - SW v9: JS network-first, precache i18n.js + all partials - Legacy pages become redirect stubs to index.html#/...
This commit is contained in:
1 parent
8a6133fd77
commit
c44f79b7d9
41 files changed
+4214
-2359
No files matched your search
@@ -0,0 +1,36 @@
|
||||
/* ============================================================
|
||||
AT Transit — PWA registration + auto-update
|
||||
ผู้ใช้ไม่ต้องล้างแคชเอง:
|
||||
1. register แบบ updateViaCache:"none" → ไม่เชื่อ HTTP cache ของ sw.js
|
||||
2. เรียก reg.update() ทุกครั้งที่โหลดหน้า → ตรวจ SW ใหม่ทันที
|
||||
(ปกติ browser เช็คแค่ทุก 24 ชม.)
|
||||
3. ตรวจซ้ำทุก 30 นาที → เหมาะกับจอแสดงข้อมูลที่เปิดทิ้งไว้
|
||||
4. SW ใหม่ skipWaiting+claim → controllerchange → reload เงียบ ๆ
|
||||
============================================================ */
|
||||
(function () {
|
||||
if (!("serviceWorker" in navigator)) return;
|
||||
|
||||
var CHECK_INTERVAL_MS = 30 * 60 * 1000; // ตรวจอัปเดตทุก 30 นาที
|
||||
|
||||
window.addEventListener("load", function () {
|
||||
navigator.serviceWorker
|
||||
.register("./sw.js", { updateViaCache: "none" })
|
||||
.then(function (reg) {
|
||||
// ตรวจหา SW เวอร์ชันใหม่ทุกครั้งที่โหลดหน้า
|
||||
reg.update();
|
||||
|
||||
// ตรวจซ้ำเป็นระยะ (กันจอที่เปิดค้างไม่เคยโหลดหน้าใหม่)
|
||||
setInterval(function () {
|
||||
reg.update();
|
||||
}, CHECK_INTERVAL_MS);
|
||||
|
||||
// SW ใหม่接管การควบคุมแล้ว → รีโหลดหน้ารับเวอร์ชันใหม่ทันที
|
||||
navigator.serviceWorker.addEventListener("controllerchange", function () {
|
||||
window.location.reload();
|
||||
});
|
||||
})
|
||||
.catch(function () {
|
||||
/* ไม่มี SW = ไม่มีโหมดออฟไลน์ — เว็บยังใช้งานปกติ */
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in new issue
Block a user