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:
Bkk1234 committed 2026-09-03 00:08:04 +07:00
1 parent 8a6133fd77
commit c44f79b7d9
41 files changed
+4214 -2359

No files matched your search

+126 -204
View File
@@ -266,23 +266,119 @@
/* ===== SPA central view ===== */
#view { min-height: 60vh; }
</style>
<link rel="manifest" href="./manifest.json">
<meta name="theme-color" content="#7a4cc0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="apple-touch-icon" href="../resource/images/icons/minibus-192x192.png">
<script src="./pwa.js" defer></script>
<script src="./i18n.js" defer></script>
<script src="./router.js" defer></script>
<link rel="stylesheet" href="./responsive.css">
</head>
<body class="main-theme-page">
<svg xmlns="http://www.w3.org/2000/svg" style="display:none" aria-hidden="true">
<symbol id="ic-alarm-clock" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="13" r="8" />
<path d="M12 9v4l2 2" />
<path d="M5 3 2 6" />
<path d="m22 6-3-3" />
<path d="M6.38 18.7 4 21" />
<path d="M17.64 18.67 20 21" />
</symbol>
<symbol id="ic-arrow-right" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M5 12h14" />
<path d="m12 5 7 7-7 7" />
</symbol>
<symbol id="ic-bus" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M8 6v6" />
<path d="M15 6v6" />
<path d="M2 12h19.6" />
<path d="M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3" />
<circle cx="7" cy="18" r="2" />
<path d="M9 18h5" />
<circle cx="16" cy="18" r="2" />
</symbol>
<symbol id="ic-bus-front" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 6 2 7" />
<path d="M10 6h4" />
<path d="m22 7-2-1" />
<rect width="16" height="16" x="4" y="3" rx="2" />
<path d="M4 11h16" />
<path d="M8 15h.01" />
<path d="M16 15h.01" />
<path d="M6 19v2" />
<path d="M18 21v-2" />
</symbol>
<symbol id="ic-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M20 6 9 17l-5-5" />
</symbol>
<symbol id="ic-clock" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10" />
<path d="M12 6v6l4 2" />
</symbol>
<symbol id="ic-globe" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10" />
<path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" />
<path d="M2 12h20" />
</symbol>
<symbol id="ic-hourglass" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M5 22h14" />
<path d="M5 2h14" />
<path d="M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22" />
<path d="M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2" />
</symbol>
<symbol id="ic-map" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z" />
<path d="M15 5.764v15" />
<path d="M9 3.236v15" />
</symbol>
<symbol id="ic-map-pin" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" />
<circle cx="12" cy="10" r="3" />
</symbol>
<symbol id="ic-message-circle" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719" />
</symbol>
<symbol id="ic-phone" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384" />
</symbol>
<symbol id="ic-refresh-cw" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" />
<path d="M21 3v5h-5" />
<path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" />
<path d="M8 16H3v5" />
</symbol>
<symbol id="ic-search" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="m21 21-4.34-4.34" />
<circle cx="11" cy="11" r="8" />
</symbol>
<symbol id="ic-triangle-alert" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" />
<path d="M12 9v4" />
<path d="M12 17h.01" />
</symbol>
</svg>
<header class="mu-topbar">
<div class="mu-container mu-topbar-inner">
<div class="mu-brand">
<img class="mu-logo-img" src="../resource/images/icons/minibus-512x512.png" alt="AT Transit logo" width="44" height="44" decoding="async">
<div>
<p class="mu-brand-title">AT Transit</p>
<p class="mu-brand-subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</p>
<p class="mu-brand-subtitle" data-i18n="brand.subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</p>
</div>
</div>
<nav class="mu-nav" aria-label="เมนูหลัก">
<a class="active" href="./index.html">หน้าแรก</a>
<a href="./busStop.html">ป้ายหยุดรถ</a>
<a href="./busDetail.html">รายละเอียดสายรถ</a>
<a class="active" href="#/" data-i18n="nav.home">หน้าแรก</a>
<a href="#/stops" data-i18n="nav.stops">ป้ายหยุดรถ</a>
<a href="#/routes" data-i18n="nav.routes">รายละเอียดสายรถ</a>
</nav>
<a class="mu-action-btn" href="./busDetail.html">เช็กเวลาเดินรถ</a>
<div class="mu-lang-switch" role="group" aria-label="ภาษา / Language">
<button type="button" class="mu-lang-btn" data-i18n-switch="th">ไทย</button>
<button type="button" class="mu-lang-btn" data-i18n-switch="en">EN</button>
</div>
<a class="mu-action-btn" href="#/check" data-i18n="cta.check">เช็กเวลาเดินรถ</a>
</div>
</header>
@@ -296,40 +392,37 @@
<img src="../resource/images/icons/minibus-512x512.png" alt="AT Transit">
<div>
<strong>AT Transit</strong>
<span>สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
<span data-i18n="brand.subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
</div>
</div>
<p class="about">ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง อัปเดตข้อมูลล่าสุดจากผู้ประกอบการแต่ละสายโดยตรง</p>
<p class="about" data-i18n="footer.about">ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง อัปเดตข้อมูลล่าสุดจากผู้ประกอบการแต่ละสายโดยตรง</p>
</div>
<div class="mu-footer-col">
<h4>เมนู</h4>
<h4 data-i18n="footer.menu">เมนู</h4>
<ul>
<li><a href="./index.html">หน้าแรก</a></li>
<li><a href="./busStop.html">ค้นหาป้ายหยุดรถ</a></li>
<li><a href="./busDetail.html">รายละเอียดสายรถ</a></li>
<li><a href="./busDetailExpanded.html">ตารางขยาย</a></li>
</ul>
<li><a href="#/" data-i18n="nav.home">หน้าแรก</a></li>
<li><a href="#/stops" data-i18n="nav.stops">ค้นหาป้ายหยุดรถ</a></li>
<li><a href="#/routes" data-i18n="nav.routes">รายละเอียดสายรถ</a></li>
<li><a href="#/routes/expanded" data-i18n="nav.expanded">ตารางขยาย</a></li>
<li><a href="#/credits" data-i18n="nav.credits">เครดิต</a></li></ul>
</div>
<div class="mu-footer-col">
<h4>สายยอดนิยม</h4>
<h4 data-i18n="footer.popular">สายที่ค้นหาบ่อยที่สุด</h4>
<ul>
<li><a href="./busDetail.html?route=101">สาย 101 · อ่างทอง-อยุธยา</a></li>
<li><a href="./busDetail.html?route=902">สาย 902 · กรุงเทพ-อ่างทอง</a></li>
<li><a href="./busDetail.html?route=15">สาย 15 · สายใน</a></li>
<li><a href="./busDetail.html?route=464">สาย 464 · สุพรรณ-สระบุรี</a></li>
<li><a href="#/routes/101">สาย 101 · อ่างทอง-อยุธยา</a></li>
<li><a href="#/routes/902">สาย 902 · กรุงเทพ-อ่างทอง</a></li>
<li><a href="#/routes/15">สาย 15 · สายใน</a></li>
<li><a href="#/routes/464">สาย 464 · สุพรรณ-สระบุรี</a></li>
</ul>
</div>
<div class="mu-footer-col mu-footer-contact">
<h4>ติดต่อ</h4>
<div class="row"><a href="tel:+666****9025">📞 +66 64 963 9025</a></div>
<div class="row"><span>📍 ถนนเทศบาล 1 อ.เมือง อ่างทอง</span></div>
<div class="row"><span>🕒 บริการ 04:30 - 21:00 น.</span></div>
<div class="row"><a href="#">💬 LINE Official: @attransit</a></div>
<h4 data-i18n="footer.contact">ติดต่อ</h4>
<div class="row"><a href="mailto:[email protected]"><svg class="ic" aria-hidden="true"><use href="#ic-mail"/></svg> [email protected]</a></div>
</div>
</div>
<div class="mu-footer-bottom">
<p>© 2026 AT Transit <span class="pill">mockup template</span></p>
<p>© 2026 AT Transit</p>
<span class="mu-visitor" title="จำนวนผู้เข้าชมเว็บไซต์">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/></svg>
<span>ผู้เข้าชม</span>
@@ -339,187 +432,16 @@
</div>
</footer>
<script>
<script>
(function () {
'use strict';
var PROVINCES = [
'กรุงเทพมหานคร', 'กระบี่', 'กาญจนบุรี', 'กาฬสินธุ์', 'กำแพงเพชร', 'ขอนแก่น',
'จันทบุรี', 'ฉะเชิงเทรา', 'ชลบุรี', 'ชัยนาท', 'ชัยภูมิ', 'ชุมพร', 'เชียงราย', 'เชียงใหม่',
'ตรัง', 'ตราด', 'ตาก', 'นครนายก', 'นครปฐม', 'นครพนม', 'นครราชสีมา', 'นครศรีธรรมราช',
'นครสวรรค์', 'นนทบุรี', 'นราธิวาส', 'น่าน', 'บึงกาฬ', 'บุรีรัมย์', 'ปทุมธานี',
'ประจวบคีรีขันธ์', 'ปราจีนบุรี', 'ปัตตานี', 'พระนครศรีอยุธยา', 'พะเยา', 'พังงา', 'พัทลุง',
'พิจิตร', 'พิษณุโลก', 'เพชรบุรี', 'เพชรบูรณ์', 'แพร่', 'ภูเก็ต', 'มหาสารคาม', 'มุกดาหาร',
'แม่ฮ่องสอน', 'ยโสธร', 'ยะลา', 'ร้อยเอ็ด', 'ระนอง', 'ระยอง', 'ราชบุรี', 'ลพบุรี',
'ลำปาง', 'ลำพูน', 'เลย', 'ศรีสะเกษ', 'สกลนคร', 'สงขลา', 'สตูล', 'สมุทรปราการ',
'สมุทรสงคราม', 'สมุทรสาคร', 'สระแก้ว', 'สระบุรี', 'สิงห์บุรี', 'สุโขทัย', 'สุพรรณบุรี',
'สุราษฎร์ธานี', 'สุรินทร์', 'หนองคาย', 'หนองบัวลำภู', 'อ่างทอง', 'อำนาจเจริญ', 'อุดรธานี',
'อุตรดิตถ์', 'อุทัยธานี', 'อุบลราชธานี'
];
var STATIONS_BY_PROVINCE = {
'อ่างทอง': [
'บขส.อ่างทอง',
'สถานีขนส่งป่าโมก',
'สถานีขนส่งวิเศษชัยชาญ',
'สถานีขนส่งไชโย',
'สถานีขนส่งโพธิ์ทอง',
'สถานีขนส่งแสวงหา',
'สถานีขนส่งสามโก้',
'นะโมซุปเปอร์มาร์ท',
'บขส.999 อ่างทอง สายเอเชีย-เหนือ (ไม่เข้าเมือง)',
'จุดขึ้นรถประจำทางอื่นๆ'
],
'พระนครศรีอยุธยา': [
'จุดขึ้นลงรถสองแถว 101 อยุธยา-ป่าโมก-อ่างทอง',
'ตลาดเจ้าพรหม'
],
'ปทุมธานี': ['ท่ารถตู้ต่างจังหวัด รังสิต'],
'กรุงเทพมหานคร': [
'สถานีเดินรถโดยสารขนาดเล็ก (จตุจักร) รถตู้/มินิบัส',
'สายใต้เก่า ปิ่นเกล้า จุดจอดรถตู้'
],
'ลพบุรี': ['บขส.ลพบุรี'],
'สุพรรณบุรี': ['บขส.สุพรรณบุรี'],
'สระบุรี': ['บขส.สระบุรี'],
'ชัยนาท': ['บขส.ชัยนาท']
};
var DEFAULT_PROVINCE = 'อ่างทอง';
var view = document.getElementById('view');
function initHomeSelectors() {
var provinceSelect = document.getElementById('province-select');
var stationSelect = document.getElementById('station-select');
var stationHint = document.getElementById('station-hint');
var heroProvince = document.getElementById('hero-province');
if (!provinceSelect || !stationSelect) return;
provinceSelect.innerHTML = '';
PROVINCES.forEach(function (name) {
var opt = document.createElement('option');
opt.value = name;
opt.textContent = name;
if (name === DEFAULT_PROVINCE) opt.selected = true;
provinceSelect.appendChild(opt);
});
function populateStations(province) {
stationSelect.innerHTML = '';
var stations = STATIONS_BY_PROVINCE[province] || [];
if (stations.length === 0) {
var empty = document.createElement('option');
empty.value = '';
empty.textContent = '— ยังไม่มีสถานีขนส่งในจังหวัดนี้ —';
empty.disabled = true;
empty.selected = true;
stationSelect.appendChild(empty);
if (stationHint) stationHint.innerHTML = 'ยังไม่มีสถานีขนส่งผู้โดยสารในจังหวัด ' + province;
} else {
stations.forEach(function (name) {
var opt = document.createElement('option');
opt.value = name;
opt.textContent = name;
stationSelect.appendChild(opt);
});
if (stationHint) stationHint.innerHTML = 'มี <b>' + stations.length + '</b> สถานีขนส่งในจังหวัด ' + province;
}
if (heroProvince) heroProvince.textContent = 'จังหวัด' + province;
}
provinceSelect.addEventListener('change', function () {
populateStations(provinceSelect.value);
});
populateStations(DEFAULT_PROVINCE);
}
function injectBusDetailStyle(doc) {
if (document.getElementById('busdetail-style')) return;
var styleEl = doc.querySelector('style');
if (!styleEl) return;
var s = document.createElement('style');
s.id = 'busdetail-style';
s.textContent = styleEl.textContent;
document.head.appendChild(s);
}
function initMarquee() {
var track = document.querySelector('.mu-marquee-track');
if (!track || track.dataset.cloned) return;
var reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (!reduce) {
track.innerHTML += track.innerHTML;
track.dataset.cloned = '1';
}
}
function loadHome() {
return fetch('partials/home.html')
.then(function (res) {
if (!res.ok) throw new Error('HTTP ' + res.status);
return res.text();
})
.then(function (html) {
view.innerHTML = html;
initHomeSelectors();
initMarquee();
window.scrollTo(0, 0);
})
.catch(function () {
view.innerHTML = '<div class="mu-container" style="padding:64px 28px;text-align:center;color:#6f7b95;">โหลดเนื้อหาไม่สำเร็จ — กรุณารันผ่าน HTTP server (เช่น <code>python3 -m http.server</code>) แล้วเปิด <code>/ui/index.html</code></div>';
});
}
function loadRoute(routeId) {
return fetch('busDetail.html')
.then(function (res) {
if (!res.ok) throw new Error('HTTP ' + res.status);
return res.text();
})
.then(function (html) {
var doc = new DOMParser().parseFromString(html, 'text/html');
injectBusDetailStyle(doc);
var main = doc.querySelector('main.mu-page');
if (!main) throw new Error('main not found');
view.innerHTML = main.outerHTML;
window.scrollTo(0, 0);
})
.catch(function () {
window.location.href = 'busDetail.html?route=' + encodeURIComponent(routeId);
});
}
document.addEventListener('click', function (e) {
var link = e.target.closest('a');
if (!link) return;
var route = link.getAttribute('data-route');
if (route) {
e.preventDefault();
loadRoute(route);
return;
}
var href = link.getAttribute('href') || '';
if (link.classList.contains('mu-back-btn') || (href.indexOf('index.html') !== -1 && view.contains(link))) {
e.preventDefault();
loadHome();
}
});
(function () {
var KEY = 'at_transit_visitor_count';
var BASE = 12483;
var el = document.getElementById('visitor-count');
if (!el) return;
var n = parseInt(localStorage.getItem(KEY), 10);
n = isNaN(n) ? BASE : n + 1;
try { localStorage.setItem(KEY, String(n)); } catch (err) {}
el.textContent = n.toLocaleString('en-US');
})();
loadHome();
var KEY = 'at_transit_visitor_count';
var BASE = 12483;
var el = document.getElementById('visitor-count');
if (!el) return;
var n = parseInt(localStorage.getItem(KEY), 10);
n = isNaN(n) ? BASE : n + 1;
try { localStorage.setItem(KEY, String(n)); } catch (err) {}
el.textContent = n.toLocaleString('en-US');
})();
</script>
</body>