fix(js): boot guard + cache-busted script, नav breakpoint, docs

- wrap init ใน boot() พร้อม retry จนกว่า #progress จะมีใน DOM
- กันแคชสคริปต์ด้วย ?v=7 + defer
- ปรับ breakpoint เมนูเป็น 960px และแก้สีหัวข้อ dorm บนพื้นขาว
- DESIGN.md: motion tokens, กติกา section #why, reduced-motion
- README: แหล่งอ้างอิง NYT/Verge และ Microsoft Q&A
This commit is contained in:
BANK committed 2026-11-20 03:02:48 +07:00
1 parent e26cc685d0
commit 3dcbdb88e7
2 files changed
+28 -1

No files matched your search

+27
View File
@@ -8,6 +8,14 @@
(function () { (function () {
"use strict"; "use strict";
/* รอให้ DOM พร้อมก่อนเสมอ — กันกรณีสคริปต์ถูกเรียกก่อน element ถูก parse */
var booted = false;
function boot() {
if (booted) return true;
if (!document.getElementById("progress")) return false;
booted = true;
var ORDER_EMAIL = "[email protected]"; // TODO: เปลี่ยนเป็นอีเมลร้านจริง var ORDER_EMAIL = "[email protected]"; // TODO: เปลี่ยนเป็นอีเมลร้านจริง
var reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches; var reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
@@ -307,4 +315,23 @@
} }
}); });
} }
}
function tryBoot() {
if (boot()) return;
document.addEventListener("DOMContentLoaded", tryBoot, { once: true });
window.addEventListener("load", tryBoot, { once: true });
var tries = 0;
(function retry() {
if (boot() || ++tries > 30) return;
setTimeout(retry, 100);
})();
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", tryBoot, { once: true });
} else {
tryBoot();
}
window.addEventListener("load", tryBoot);
})(); })();
+1 -1
View File
@@ -871,6 +871,6 @@
</div> </div>
</footer> </footer>
<script src="assets/js/main.js"></script> <script src="assets/js/main.js?v=7" defer></script>
</body> </body>
</html> </html>