mock: three search tabs - stop code, place name, near me

- busStop.html: added the third tab (data-mode=near) and its own panel with
  the location button, hint and result area; removed the near button from the
  toolbar and deleted the old on-screen numpad markup
- busStop.search.js: MODE_NEAR in setMode, disables the other panels, hides
  the stop list while ranked results are shown, skips filtering in that mode,
  and removed the dead initNumpad code
- security gate: the tab is revealed only when isSecureContext and
  navigator.geolocation exist; otherwise it stays hidden and the mode is
  refused
- map.js: re-enable the button after a successful lookup
- i18n: stops.modeNear / nearCta / nearHint
- bump SW version to 2026.09.27.98

Verified on localhost:8090 - three tabs, near mode shows a map with 8 ranked
stops, button re-enables and works again, switching back restores the list;
with isSecureContext forced false the tab is hidden and unselectable.
This commit is contained in:
Bkk1234 committed 2026-10-24 00:11:56 +07:00
1 parent 74d605f1c4
commit 750b4a2ea8
25 files changed
+426 -180

No files matched your search

+45 -9
View File
@@ -1,13 +1,49 @@
{
"provinces": [
{ "province_id": 1, "province_name_th": "อ่างทอง" },
{ "province_id": 2, "province_name_th": "อยุธยา" },
{ "province_id": 3, "province_name_th": "ปทุมธานี" },
{ "province_id": 4, "province_name_th": "กรุงเทพมหานคร" },
{ "province_id": 5, "province_name_th": "สุพรรณบุรี" },
{ "province_id": 6, "province_name_th": "สระบุรี" },
{ "province_id": 7, "province_name_th": "ลพบุรี" },
{ "province_id": 8, "province_name_th": "สิงห์บุรี" },
{ "province_id": 9, "province_name_th": "ชัยนาท" }
{
"province_id": 1,
"province_name_th": "อ่างทอง",
"province_name_en": "Ang Thong"
},
{
"province_id": 2,
"province_name_th": "อยุธยา",
"province_name_en": "Ayutthaya"
},
{
"province_id": 3,
"province_name_th": "ปทุมธานี",
"province_name_en": "Pathum Thani"
},
{
"province_id": 4,
"province_name_th": "กรุงเทพมหานคร",
"province_name_en": "Bangkok"
},
{
"province_id": 5,
"province_name_th": "สุพรรณบุรี",
"province_name_en": "Suphan Buri"
},
{
"province_id": 6,
"province_name_th": "สระบุรี",
"province_name_en": "Saraburi"
},
{
"province_id": 7,
"province_name_th": "ลพบุรี",
"province_name_en": "Lopburi"
},
{
"province_id": 8,
"province_name_th": "สิงห์บุรี",
"province_name_en": "Sing Buri"
},
{
"province_id": 9,
"province_name_th": "ชัยนาท",
"province_name_en": "Chai Nat"
}
]
}
+17 -2
View File
@@ -75,15 +75,18 @@
el.textContent = t(el.getAttribute('data-i18n'), vars);
});
scope.querySelectorAll('[data-i18n-attr]').forEach(function (el) {
var avars = null;
var an = el.getAttribute('data-i18n-n');
if (an !== null) avars = { n: an };
el.getAttribute('data-i18n-attr').split(',').forEach(function (pair) {
var parts = pair.split(':');
if (parts.length === 2) {
var attr = parts[0].trim();
var key = parts[1].trim();
if (attr === 'html') {
el.innerHTML = t(key);
el.innerHTML = t(key, avars);
} else {
el.setAttribute(attr, t(key));
el.setAttribute(attr, t(key, avars));
}
}
});
@@ -109,8 +112,20 @@
});
}
/* เลือกชื่อเฉพาะตามภาษา: ชื่อฟิลด์ฐาน เช่น 'province_name' → province_name_en / province_name_th
ไม่มีคำแปล = ถอยไปใช้ภาษาไทย (ชื่อเฉพาะไม่บังคับต้องแปล) */
function name(obj, base) {
if (!obj) return '';
var v = obj[base + '_' + current];
if (v != null && v !== '') return v;
var b = obj[base + '_' + BASE];
if (b != null && b !== '') return b;
return obj[base] != null ? obj[base] : '';
}
window.I18N = {
t: t,
name: name,
apply: apply,
setLang: setLang,
getLang: function () { return current; },
+11 -11
View File
@@ -12,8 +12,8 @@
<link href="./_shared.css" rel="stylesheet">
<link href="./vendor/leaflet/leaflet.css" rel="stylesheet">
<link href="./map.css" rel="stylesheet">
<meta name="app-version" content="2026.09.27.94">
<link rel="icon" type="image/png" href="../.image/icons/minibus-512x512.png?v=2026.09.27.94">
<meta name="app-version" content="2026.09.27.98">
<link rel="icon" type="image/png" href="../.image/icons/minibus-512x512.png?v=2026.09.27.98">
<style>
.mu-card.empty { width: 100%; padding: 16px; text-align: center; color: #6f7b95; background: #fff7fb; border: 1px dashed #f4c7df; }
a.mu-card { text-decoration: none; color: inherit; display: block; }
@@ -339,7 +339,7 @@
<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="../.image/icons/minibus-192x192.png?v=2026.09.27.94">
<link rel="apple-touch-icon" href="../.image/icons/minibus-192x192.png?v=2026.09.27.98">
<script src="./imageurl.js" defer></script>
<script src="./pwa.js" defer></script>
<script src="./i18n.js" defer></script>
@@ -443,14 +443,14 @@
<header class="mu-topbar">
<div class="mu-container mu-topbar-inner">
<a class="mu-brand" href="#/" aria-label="Atroute — หน้าแรก">
<img class="mu-logo-img" src="../.image/icons/minibus-512x512.png?v=2026.09.27.94" alt="Atroute logo" width="44" height="44" decoding="async">
<a class="mu-brand" href="#/" aria-label="Atroute — หน้าแรก" data-i18n-attr="aria-label:aria.brandHome">
<img class="mu-logo-img" src="../.image/icons/minibus-512x512.png?v=2026.09.27.98" alt="Atroute logo" width="44" height="44" decoding="async">
<span>
<span class="mu-brand-title">Atroute</span>
<span class="mu-brand-subtitle" data-i18n="brand.subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
</span>
</a>
<nav class="mu-nav" aria-label="เมนูหลัก">
<nav class="mu-nav" aria-label="เมนูหลัก" data-i18n-attr="aria-label:aria.mainMenu">
<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>
@@ -459,7 +459,7 @@
<a href="#/credits" data-i18n="nav.credits">เครดิต</a>
</nav>
<details class="mu-menu" id="topnav">
<summary class="mu-menu-btn" aria-label="เมนูหลัก" aria-haspopup="true">
<summary class="mu-menu-btn" aria-label="เมนูหลัก" data-i18n-attr="aria-label:aria.mainMenu" aria-haspopup="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="18" y2="18"/></svg>
</summary>
<div class="mu-menu-panel" role="menu">
@@ -472,7 +472,7 @@
<a href="#/credits" data-i18n="nav.credits" role="menuitem">เครดิต</a>
</div>
</details>
<div class="mu-lang-switch" role="group" aria-label="ภาษา / Language">
<div class="mu-lang-switch" role="group" aria-label="ภาษา / Language" data-i18n-attr="aria-label:aria.langSwitch">
<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>
@@ -487,7 +487,7 @@
<div class="mu-footer-grid">
<div class="mu-footer-brand">
<div class="mu-footer-brand-row">
<img src="../.image/icons/minibus-512x512.png?v=2026.09.27.94" alt="Atroute">
<img src="../.image/icons/minibus-512x512.png?v=2026.09.27.98" alt="Atroute">
<div>
<strong>Atroute</strong>
<span data-i18n="brand.subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
@@ -523,9 +523,9 @@
<div class="mu-footer-bottom">
<p>© 2026 Atroute</p>
<span class="mu-visitor" title="จำนวนผู้เข้าชมเว็บไซต์">
<span class="mu-visitor" title="จำนวนผู้เข้าชมเว็บไซต์" data-i18n-attr="title:visitors.tip">
<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>
<span data-i18n="visitors.label">ผู้เข้าชม</span>
<strong id="visitor-count">12,834</strong>
</span>
</div>
+89 -2
View File
@@ -131,7 +131,10 @@
"stops.noOffset": "No travel time from the first stop yet",
"stops.noBusLine": "No bus line listed",
"stops.modeCode": "Search by stop code",
"stops.modePlace": "Search by place name",
"stops.modeNear": "Near me",
"stops.nearCta": "Use my location",
"stops.nearHint": "We ask your device for a location, then rank stops by real distance.",
"stops.modePlace": "Search by place name",
"stops.codePh": "3+000",
"stops.codeHint": "Type 4 digits and the + sign is added automatically (e.g. 3000 → 3+000)",
"stops.codeHintBox": "Type digits in the boxes — empty boxes are filled with 0 automatically. For 4-digit codes such as 8+591, enter 08+591",
@@ -265,5 +268,89 @@
"check.noMoreToday": "No departures left today",
"check.stopsCount": "stops",
"check.toStopDetail": "View stop detail",
"common.routes": "routes"
"common.routes": "routes",
"page.home": "Home | Atroute",
"page.stops": "Bus Stops | Atroute",
"page.routes": "Route Details | Atroute",
"page.check": "Departure Schedule | Atroute",
"page.stop": "Stop Details | Atroute",
"page.credits": "Credits | Atroute",
"page.about": "About | Atroute",
"page.blog": "Blog | Atroute",
"router.loadFail": "Could not load content — please serve over HTTP (e.g. python3 -m http.server)",
"common.routePrefix": "Route {n}",
"common.stopPrefix": "Stop {n}",
"route.qrAlt": "LINE QR for route {n}",
"route.vehicleAlt": "Vehicle photo for route {n}",
"check.fromName": "From {name}",
"check.stopNameN": "Stop {n}",
"map.mUnit": "m",
"map.originShort": "Origin",
"day.sun": "Sunday",
"day.mon": "Monday",
"day.tue": "Tuesday",
"day.wed": "Wednesday",
"day.thu": "Thursday",
"day.fri": "Friday",
"day.sat": "Saturday",
"day.sunS": "Sun",
"day.monS": "Mon",
"day.tueS": "Tue",
"day.wedS": "Wed",
"day.thuS": "Thu",
"day.friS": "Fri",
"day.satS": "Sat",
"visitors.resetTitle": "Reset visitor counter",
"visitors.resetPass": "Reset code",
"visitors.cancel": "Cancel",
"visitors.confirm": "Reset",
"visitors.done": "Reset done — counting restarts from 0",
"visitors.unsupported": "Browser not supported — needs https or localhost",
"visitors.badPass": "Incorrect code",
"aria.mapsView": "View",
"aria.searchMode": "Search mode",
"aria.stopCode": "Stop code",
"aria.digitN": "Digit {n}",
"aria.routeSummary": "Route summary",
"aria.routeMap": "Route map",
"aria.routeGeom": "Route geometry map",
"aria.vehicleSection": "Vehicle and operator contact",
"aria.legend": "Card colours by route group",
"aria.sponsors": "Sponsors and partners",
"aria.networkMapAlt": "Atroute stop network map",
"aria.stopRoutesMap": "Routes through this stop map",
"route.kpiNext": "Next trip",
"route.mapSection": "Route map",
"route.summarySection": "Route summary",
"credits.lead": "Every resource used on this site, with the licence required by each owner",
"credits.src": "Source:",
"credits.lic": "Licence:",
"credits.iconsCount": "15 icons in use, stored at",
"credits.iconsUsage": "Usage: sprite",
"credits.iconNames": "alarm-clock, arrow-right, bus, bus-front, check, clock, globe, hourglass, map, map-pin, message-circle, phone, refresh-cw, search, triangle-alert",
"credits.mitStrong": "MIT License (summary):",
"credits.mitText": "Permission is granted, free of charge, to any person obtaining a copy of this software to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies, subject to the copyright and permission notice above being included in all copies or substantial portions of the software. The software is provided \"as is\", without warranty of any kind.",
"credits.fontK2D": "Primary typeface for body and headings · Thai looped style, weights 300–800",
"credits.fontNoto": "Body fallback (loaded via Google Fonts CDN)",
"credits.fontPrompt": "Heading / bold fallback",
"credits.fontMono": "Times, route numbers and figures (tabular alignment)",
"credits.mapLeaflet": "Leaflet — open-source mapping library",
"credits.mapOSM": "OpenStreetMap — map tiles and map data rendered here",
"credits.mapGIS": "Bus routes, stops and station pins are drawn from the team's own GIS data (GeoJSON) layered over the map",
"credits.photosLead": "Bus photos on the route detail pages come from the public sources below — thanks to every photographer and compiler",
"credits.breadHome": "Home",
"credits.breadSelf": "Credits",
"credits.lineRed": "SRT Red Line",
"visitors.label": "Visitors",
"visitors.tip": "Site visitor count",
"pwa.install": "Install app",
"aria.brandHome": "Atroute — home",
"aria.mainMenu": "Main menu",
"aria.langSwitch": "Language",
"credits.iconsFree": "— free for personal and commercial use without attribution, credited here for transparency",
"credits.tiles": "Map tiles:",
"credits.osmCredit": "OpenStreetMap © contributors (ODbL)",
"credits.facebookGroup": "Facebook group (web.facebook.com)",
"credits.from": "from",
"credits.routeN": "Route {n}"
}
+89 -2
View File
@@ -131,7 +131,10 @@
"stops.noOffset": "ยังไม่ระบุเวลาเดินทางจากจุดแรก",
"stops.noBusLine": "ยังไม่ระบุสายรถ",
"stops.modeCode": "ค้นหาด้วยรหัสป้าย",
"stops.modePlace": "ค้นหาด้วยชื่อสถานที่",
"stops.modeNear": "ป้ายใกล้ฉัน",
"stops.nearCta": "ขอพิกัดและหาป้ายใกล้ฉัน",
"stops.nearHint": "ระบบจะขอตำแหน่งจากเครื่อง แล้วคำนวณระยะจากพิกัดป้าย/ศาลารถ เรียงจากใกล้ไปไกล",
"stops.modePlace": "ค้นหาด้วยชื่อสถานที่",
"stops.codePh": "3+000",
"stops.codeHint": "พิมพ์ตัวเลข 4 หลัก ระบบจะเติมเครื่องหมาย + ให้อัตโนมัติ (เช่น 3000 → 3+000)",
"stops.codeHintBox": "พิมพ์ตัวเลขในช่อง ระบบจะเติม 0 ให้อัตโนมัติเมื่อเว้นว่าง และถ้าเจอรหัส 4 หลัก เช่น 8+591 ให้กรอก 08+591",
@@ -265,5 +268,89 @@
"check.noMoreToday": "ไม่มีรถเหลือในวันนี้แล้ว",
"check.stopsCount": "จุดจอด",
"check.toStopDetail": "ไปหน้ารายละเอียดจุดจอด",
"common.routes": "เส้นทาง"
"common.routes": "เส้นทาง",
"page.home": "หน้าแรก | Atroute",
"page.stops": "ป้ายหยุดรถ | Atroute",
"page.routes": "รายละเอียดสายรถ | Atroute",
"page.check": "เช็กเวลาเดินรถ | Atroute",
"page.stop": "รายละเอียดป้าย | Atroute",
"page.credits": "เครดิต | Atroute",
"page.about": "เกี่ยวกับเรา | Atroute",
"page.blog": "บ่นไปเรื่อย | Atroute",
"router.loadFail": "โหลดเนื้อหาไม่สำเร็จ — กรุณาเปิดผ่าน HTTP server (เช่น python3 -m http.server)",
"common.routePrefix": "สาย {n}",
"common.stopPrefix": "ป้าย {n}",
"route.qrAlt": "LINE QR สาย {n}",
"route.vehicleAlt": "รถของสาย {n}",
"check.fromName": "จาก {name}",
"check.stopNameN": "จุดจอด {n}",
"map.mUnit": "ม.",
"map.originShort": "ต้นทาง",
"day.sun": "อาทิตย์",
"day.mon": "จันทร์",
"day.tue": "อังคาร",
"day.wed": "พุธ",
"day.thu": "พฤหัสบดี",
"day.fri": "ศุกร์",
"day.sat": "เสาร์",
"day.sunS": "อา",
"day.monS": "จ",
"day.tueS": "อ.",
"day.wedS": "พ.",
"day.thuS": "พฤ.",
"day.friS": "ศ.",
"day.satS": "ส.",
"visitors.resetTitle": "รีเซ็ตจำนวนผู้เข้าชม",
"visitors.resetPass": "รหัสรีเซ็ต",
"visitors.cancel": "ยกเลิก",
"visitors.confirm": "รีเซ็ต",
"visitors.done": "รีเซ็ตแล้ว — เริ่มนับใหม่จาก 0",
"visitors.unsupported": "เบราว์เซอร์ไม่รองรับ — ต้องเปิดผ่าน https หรือ localhost",
"visitors.badPass": "รหัสไม่ถูกต้อง",
"aria.mapsView": "มุมมอง",
"aria.searchMode": "รูปแบบการค้นหา",
"aria.stopCode": "รหัสป้าย",
"aria.digitN": "หลักที่ {n}",
"aria.routeSummary": "สรุปเส้นทาง",
"aria.routeMap": "แผนที่เส้นทาง",
"aria.routeGeom": "แผนที่เส้นทางเดินรถ",
"aria.vehicleSection": "รถประจำสายและติดต่อผู้ประกอบการ",
"aria.legend": "คำอธิบายสีการ์ดตามหมวดเส้นทาง",
"aria.sponsors": "ผู้สนับสนุนและพาร์ทเนอร์",
"aria.networkMapAlt": "แผนที่เครือข่ายป้าย Atroute",
"aria.stopRoutesMap": "แผนที่เส้นทางที่ผ่านป้ายนี้",
"route.kpiNext": "รอบถัดไป",
"route.mapSection": "แผนที่เส้นทาง",
"route.summarySection": "สรุปเส้นทาง",
"credits.lead": "รายการทรัพยากรทั้งหมดที่ใช้ในเว็บนี้ พร้อมใบอนุญาต (license) ตามข้อกำหนดของเจ้าของแต่ละราย",
"credits.src": "แหล่งที่มา:",
"credits.lic": "ใบอนุญาต:",
"credits.iconsCount": "ไอคอนที่ใช้ทั้งหมด 15 รายการ เก็บที่",
"credits.iconsUsage": "วิธีใช้งาน: sprite",
"credits.iconNames": "alarm-clock, arrow-right, bus, bus-front, check, clock, globe, hourglass, map, map-pin, message-circle, phone, refresh-cw, search, triangle-alert",
"credits.mitStrong": "MIT License (สรุป):",
"credits.mitText": "อนุญาตให้ใช้ คัดลอก แก้ไข ผสาน เผยแพร่ แจกจ่าย ขาย และ/หรือให้สิทธิ์ใช้งานซอฟต์แวร์นี้ โดยมีเงื่อนไขให้ข้อความแสดงลิขสิทธิ์และข้อความอนุญาตข้างต้นปรากฏอยู่ในสำเนาทั้งหมดหรือส่วนสำคัญของซอฟต์แวร์ ซอฟต์แวร์นี้ให้บริการ \"ตามสภาพ\" โดยไม่มีการรับประกันใด ๆ",
"credits.fontK2D": "ฟอนต์หลักของเว็บ (เนื้อหา + หัวเรื่อง) · มีหัวแบบไทย น้ำหนัก 300–800",
"credits.fontNoto": "ตัวสำรองเนื้อหา (โหลดผ่าน Google Fonts CDN)",
"credits.fontPrompt": "ตัวสำรองหัวเรื่อง/ตัวหนา",
"credits.fontMono": "เวลา · เลขสาย · ตัวเลข (เรียงตรงกัน)",
"credits.mapLeaflet": "Leaflet — ไลบรารีแผนที่แบบ open-source",
"credits.mapOSM": "OpenStreetMap — ภาพ tiles และข้อมูลแผนที่ที่ใช้แสดงผล",
"credits.mapGIS": "เส้นทางเดินรถ จุดจอด และหมุดสถานี วาดจากข้อมูล GIS ของทีม (GeoJSON) ทับบนแผนที่",
"credits.photosLead": "ภาพรถโดยสารประจำทางที่แสดงในหน้ารายละเอียดสาย มาจากแหล่งข้อมูลสาธารณะด้านล่างนี้ — ขอบคุณเจ้าของภาพและผู้รวบรวมทุกท่าน",
"credits.breadHome": "หน้าแรก",
"credits.breadSelf": "เครดิต",
"credits.lineRed": "รถไฟฟ้าสายสีแดง",
"visitors.label": "ผู้เข้าชม",
"visitors.tip": "จำนวนผู้เข้าชมเว็บไซต์",
"pwa.install": "ติดตั้งแอป",
"aria.brandHome": "Atroute — หน้าแรก",
"aria.mainMenu": "เมนูหลัก",
"aria.langSwitch": "ภาษา / Language",
"credits.iconsFree": "— ใช้ได้ฟรีทั้งส่วนบุคคลและเชิงพาณิชย์ โดยไม่ต้องระบุเครดิต แต่เราระบุไว้เพื่อความโปร่งใส",
"credits.tiles": "ชุดแผนที่ (tiles):",
"credits.osmCredit": "OpenStreetMap © ผู้มีส่วนร่วม (ODbL)",
"credits.facebookGroup": "กลุ่ม Facebook (web.facebook.com)",
"credits.from": "จาก",
"credits.routeN": "สาย {n}"
}
+8 -6
View File
@@ -286,14 +286,14 @@ window.ATMap = (function () {
var s = h.stop, pt = pointOf(s);
if (!pt) return;
var short = [];
if (s.kilometer) short.push('กม. ' + s.kilometer);
if (s.kilometer) short.push(t('map.km') + ' ' + s.kilometer);
if (s.position) short.push(s.position);
if (s.type) short.push(s.type);
var html = '<div class="at-pop">';
html += '<b>' + esc(s.place || s.type || t('map.legendStop')) + '</b>';
var meta = [];
if (s.kilometer) meta.push('กม. ' + s.kilometer);
if (s.kilometer) meta.push(t('map.km') + ' ' + s.kilometer);
if (s.position) meta.push(s.position);
if (s.type && s.place) meta.push(s.type); /* ซ้ำกับหัวข้อเมื่อไม่มีชื่อสถานที่ */
if (meta.length) html += '<span>' + esc(meta.join(' · ')) + '</span>';
@@ -316,7 +316,7 @@ window.ATMap = (function () {
(rows || []).forEach(function (r) {
if (!r.sub || !r.pt) return;
var html = '<div class="at-pop"><b>' + esc(r.name) + '</b>';
html += '<span>' + esc(t('map.subStop')) + (r.km != null && r.km !== '' ? ' · ' + esc(r.km) + ' กม.' : '') + '</span>';
html += '<span>' + esc(t('map.subStop')) + (r.km != null && r.km !== '' ? ' · ' + esc(r.km) + ' ' + esc(t('map.km')) : '') + '</span>';
if (r.href) html += '<a href="' + esc(r.href) + '">' + esc(t('map.viewBoardingPoints')) + '</a>';
html += '</div>';
L.marker([r.pt[1], r.pt[0]], { icon: pinIcon('sub'), zIndexOffset: 400 })
@@ -594,6 +594,8 @@ window.ATMap = (function () {
items.sort(function (a, b) { return a.d - b.d; });
var near = items.slice(0, opts.limit || 8);
renderNear(resultEl, near, me, opts);
/* ปลดล็อกปุ่มหลังหาป้ายเสร็จ — ผู้ใช้เดินไปที่ใหม่แล้วกดซ้ำได้ */
button.disabled = false;
});
}, function () {
button.disabled = false;
@@ -623,7 +625,7 @@ window.ATMap = (function () {
var meta = [];
if (x.kind === 'station') meta.push(t('map.legendTerminal'));
else {
if (x.o.kilometer) meta.push('กม. ' + x.o.kilometer);
if (x.o.kilometer) meta.push(t('map.km') + ' ' + x.o.kilometer);
if (x.o.position) meta.push(x.o.position);
if (x.o.type && x.o.place) meta.push(x.o.type);
}
@@ -636,7 +638,7 @@ window.ATMap = (function () {
if (x.kind === 'stop') { link.target = '_blank'; link.rel = 'noopener'; }
link.innerHTML = '<span class="at-near-name">' + esc(name || t('map.legendStop')) + '</span>' +
'<span class="at-near-meta">' + esc(meta.join(' · ')) + '</span>' +
'<span class="at-near-dist">' + (x.d < 1000 ? Math.round(x.d) + ' ม.' : (x.d / 1000).toFixed(1) + ' ' + esc(t('map.km'))) + '</span>';
'<span class="at-near-dist">' + (x.d < 1000 ? Math.round(x.d) + ' ' + esc(t('map.mUnit')) : (x.d / 1000).toFixed(1) + ' ' + esc(t('map.km'))) + '</span>';
li.appendChild(link);
ul.appendChild(li);
});
@@ -691,7 +693,7 @@ window.ATMap = (function () {
if (!org) { return { map: map, empty: true }; }
pts.push(org);
L.circleMarker(org, { radius: 8, color: '#fff', weight: 3, fillColor: '#1f2a44', fillOpacity: 1 })
.bindTooltip(esc(o.label || 'ต้นทาง'), { permanent: true, direction: 'top', offset: [0, -8], className: 'at-tip-org' })
.bindTooltip(esc(o.label || t('map.originShort')), { permanent: true, direction: 'top', offset: [0, -8], className: 'at-tip-org' })
.addTo(group);
var pending = []; /* เส้นที่พิกัดปลายทางมาจาก geojson (โหลด async) */
+1 -1
View File
@@ -235,7 +235,7 @@
<div class="mu-container">
<div class="mu-blog-bar" id="blog-bar" hidden>
<p class="mu-blog-count" id="blog-count"></p>
<div class="mu-view-switch" role="group" aria-label="มุมมอง">
<div class="mu-view-switch" role="group" aria-label="มุมมอง" data-i18n-attr="aria-label:aria.mapsView">
<button type="button" class="mu-view-btn" data-view="grid">
<svg class="ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/></svg>
<span data-i18n="blog.viewGrid">ตาราง</span>
+10 -10
View File
@@ -162,17 +162,17 @@
<main class="mu-page">
<div class="mu-container">
<p class="mu-breadcrumb"><a href="#/">หน้าแรก</a>/ <span data-i18n="nav.routes">รายละเอียดสายรถ</span></p>
<p class="mu-breadcrumb"><a href="#/" data-i18n="nav.home">หน้าแรก</a>/ <span data-i18n="nav.routes">รายละเอียดสายรถ</span></p>
<h1 class="mu-page-title"><span class="mu-route-chip" id="route-chip"></span> <span id="route-title"></span></h1>
<!-- ตัวเลือกสายรถ: เติมจาก resource/data/routes.json (busDetail.init.js) -->
<form class="mu-toolbar" onsubmit="return false">
<select aria-label="เลือกสายรถ" id="route-select"></select>
<select aria-label="เลือกสายรถ" data-i18n-attr="aria-label:route.selectRoute" id="route-select"></select>
</form>
<!-- ============ รถประจำสาย + ติดต่อผู้ประกอบการ (การ์ดเดียว) ============ -->
<!-- รูปรถ/คำอธิบาย/QR/เบอร์โทร: เติมจาก resource/data/captions/caption<รหัสสาย>.json + routes.json -->
<section class="mu-vehicle-card" aria-label="รถประจำสายและติดต่อผู้ประกอบการ" id="route-vehicle-card">
<section class="mu-vehicle-card" aria-label="รถประจำสายและติดต่อผู้ประกอบการ" data-i18n-attr="aria-label:aria.vehicleSection" id="route-vehicle-card">
<img id="route-vehicle-img" alt="" loading="lazy" decoding="async" hidden>
<div class="meta">
<p class="label" data-i18n="route.vehicle">รถประจำสาย</p>
@@ -183,25 +183,25 @@
</section>
<!-- ============ สรุปเส้นทาง ============ -->
<section class="mu-summary" aria-label="สรุปเส้นทาง">
<section class="mu-summary" aria-label="สรุปเส้นทาง" data-i18n-attr="aria-label:aria.routeSummary">
<div class="mu-container">
<div class="mu-summary-grid">
<div class="mu-stat tag-purple"><h3 id="stat-stops">–</h3><p>จุดจอดหลัก</p></div>
<div class="mu-stat tag-sky"><h3 id="stat-provinces">–</h3><p>จังหวัดที่ผ่าน</p></div>
<div class="mu-stat tag-mint"><h3 id="stat-trips">–</h3><p>รอบต่อวัน</p></div>
<div class="mu-stat tag-pink"><h3 id="stat-next">–</h3><p>รอบถัดไป</p></div>
<div class="mu-stat tag-purple"><h3 id="stat-stops">–</h3><p data-i18n="route.kpiStops">จุดจอดหลัก</p></div>
<div class="mu-stat tag-sky"><h3 id="stat-provinces">–</h3><p data-i18n="route.kpiProvince">จังหวัดที่ผ่าน</p></div>
<div class="mu-stat tag-mint"><h3 id="stat-trips">–</h3><p data-i18n="route.kpiTrips">รอบต่อวัน</p></div>
<div class="mu-stat tag-pink"><h3 id="stat-next">–</h3><p data-i18n="route.kpiNext">รอบถัดไป</p></div>
</div>
</div>
</section>
<!-- ============ แผนที่เส้นทาง (Leaflet + GeoJSON จาก QGIS) ============ -->
<section class="mu-zone" aria-label="แผนที่เส้นทาง">
<section class="mu-zone" aria-label="แผนที่เส้นทาง" data-i18n-attr="aria-label:aria.routeMap">
<div class="mu-zone-head">
<span class="mu-zone-tag tag-sky" data-i18n="route.mapTitle">เส้นทางเดินรถ</span>
<p class="mu-zone-desc" data-i18n="route.mapDesc">เส้นทางจริงจากข้อมูล GIS · ป้ายหยุดรถตามเส้นทาง</p>
</div>
<div class="mu-map-card">
<div class="at-map" id="route-map" role="region" aria-label="แผนที่เส้นทางเดินรถ"></div>
<div class="at-map" id="route-map" role="region" aria-label="แผนที่เส้นทางเดินรถ" data-i18n-attr="aria-label:aria.routeGeom"></div>
<p class="at-map-caption" id="route-map-caption"></p>
<div class="at-km-wrap" hidden>
<h3><span data-i18n="map.alongRoute">จุดจอดตามเส้นทาง (กม. จากต้นทาง)</span></h3>
+6 -5
View File
@@ -21,6 +21,7 @@
function $(id) { return document.getElementById(id); }
function t(k, v) { return window.I18N ? I18N.t(k, v) : k; }
function nm(o, base) { return (window.I18N && I18N.name) ? I18N.name(o, base) : ((o && o[base + '_th']) || ''); }
function esc(s) {
return String(s == null ? '' : s).replace(/&/g, '&amp;').replace(/</g, '&lt;')
.replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
@@ -164,7 +165,7 @@
var note = (cap && cap.line_note) ? String(cap.line_note).trim() : '';
setText('route-line-note', note);
var phones = (route.phone || []).filter(Boolean);
tryImage(qr, qrUrls(rid, cap), 'LINE QR สาย ' + rid, function (ok) {
tryImage(qr, qrUrls(rid, cap), t('route.qrAlt', { n: rid }), function (ok) {
qrBtn.hidden = !ok; /* ไม่มีรูป = ไม่มีปุ่มขยาย */
if (ok) {
var label = (kind ? t('route.link.' + kind.key) : 'LINE Official');
@@ -307,7 +308,7 @@
var img = $('route-vehicle-img');
var card = $('route-vehicle-card');
if (img) {
tryImage(img, vehicleUrls(rid, cap), 'รถของสาย ' + rid, function (ok) {
tryImage(img, vehicleUrls(rid, cap), t('route.vehicleAlt', { n: rid }), function (ok) {
if (card) card.classList.toggle('no-photo', !ok);
});
}
@@ -333,8 +334,8 @@
if (chipEl) {
chipEl.className = 'mu-route-chip' + (route.route_group ? ' grp-' + route.route_group : '');
}
setText('route-title', route.route_name_th);
document.title = 'Atroute — สาย ' + rid + (route.route_name_th ? ' ' + route.route_name_th : '');
setText('route-title', nm(route, 'route_name'));
document.title = 'Atroute — ' + t('common.routePrefix', { n: rid }) + (nm(route, 'route_name') ? ' ' + nm(route, 'route_name') : '');
/* dropdown: เติมจาก routes.json (ลำดับตามไฟล์) + เปลี่ยนแล้วไปสายนั้น */
var sel = $('route-select');
@@ -343,7 +344,7 @@
list.forEach(function (r) {
var o = document.createElement('option');
o.value = r.route_id;
o.textContent = 'สาย ' + r.route_id + (r.route_name_th ? ' - ' + r.route_name_th : '');
o.textContent = t('common.routePrefix', { n: r.route_id }) + (nm(r, 'route_name') ? ' - ' + nm(r, 'route_name') : '');
sel.appendChild(o);
});
sel.value = rid;
+40 -26
View File
@@ -379,14 +379,14 @@
<div class="mu-hero-map">
<p class="mu-hero-map-title"><span data-i18n="stops.mapTitle">แผนที่ย่อของเครือข่ายป้าย</span></p>
<div class="mu-hero-map-box">
<img class="mu-hero-map-photo" src="../.image/network/overview-map.png" alt="แผนที่เครือข่ายป้าย Atroute" loading="lazy" decoding="async">
<img class="mu-hero-map-photo" src="../.image/network/overview-map.png" alt="แผนที่เครือข่ายป้าย Atroute" data-i18n-attr="alt:aria.networkMapAlt" loading="lazy" decoding="async">
</div>
</div>
</section>
<form class="mu-toolbar" id="stops-form" onsubmit="return false">
<!-- โหมดค้นหา: เลือกอย่างใดอย่างหนึ่ง (ห้ามชนกัน) -->
<div class="mu-search-tabs" role="tablist" aria-label="รูปแบบการค้นหา">
<div class="mu-search-tabs" role="tablist" aria-label="รูปแบบการค้นหา" data-i18n-attr="aria-label:aria.searchMode">
<button type="button" class="mu-search-tab" data-mode="code" role="tab" aria-selected="true">
<svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg>
<span data-i18n="stops.modeCode">ค้นหาด้วยรหัสป้าย</span>
@@ -395,6 +395,11 @@
<svg class="ic" aria-hidden="true"><use href="#ic-landmark"/></svg>
<span data-i18n="stops.modePlace">ค้นหาด้วยชื่อสถานที่</span>
</button>
<!-- หมวดที่ 3: ป้ายใกล้ฉัน — แสดงเฉพาะเมื่อเป็น secure context (ดูสคริปต์ท้ายไฟล์) -->
<button type="button" class="mu-search-tab" data-mode="near" role="tab" aria-selected="false" id="stops-near-tab" hidden>
<svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg>
<span data-i18n="stops.modeNear">ป้ายใกล้ฉัน</span>
</button>
</div>
<!-- โหมด 1: รหัสป้าย (5 ช่อง: 2 หน้า + 3 หลัง) -->
@@ -402,32 +407,19 @@
<div class="mu-code-boxes" id="stops-code-boxes" role="group"
data-i18n-attr="aria-label:stops.codePh" aria-label="รหัสป้าย">
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
autocomplete="off" aria-label="หลักที่ 1" placeholder="0">
autocomplete="off" aria-label="หลักที่ 1" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="1" placeholder="0">
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
autocomplete="off" aria-label="หลักที่ 2" placeholder="0">
autocomplete="off" aria-label="หลักที่ 2" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="2" placeholder="0">
<span class="mu-code-plus" aria-hidden="true">+</span>
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
autocomplete="off" aria-label="หลักที่ 3" placeholder="0">
autocomplete="off" aria-label="หลักที่ 3" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="3" placeholder="0">
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
autocomplete="off" aria-label="หลักที่ 4" placeholder="0">
autocomplete="off" aria-label="หลักที่ 4" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="4" placeholder="0">
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
autocomplete="off" aria-label="หลักที่ 5" placeholder="0">
autocomplete="off" aria-label="หลักที่ 5" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="5" placeholder="0">
</div>
<p class="mu-code-display" id="stops-code-display" hidden></p>
<p class="mu-search-hint" data-i18n="stops.codeHintBox">พิมพ์ตัวเลขในช่อง ระบบจะเติม 0 ให้อัตโนมัติเมื่อเว้นว่าง</p>
<div class="mu-numpad" id="stops-numpad">
<button type="button" data-key="1">1</button>
<button type="button" data-key="2">2</button>
<button type="button" data-key="3">3</button>
<button type="button" data-key="4">4</button>
<button type="button" data-key="5">5</button>
<button type="button" data-key="6">6</button>
<button type="button" data-key="7">7</button>
<button type="button" data-key="8">8</button>
<button type="button" data-key="9">9</button>
<button type="button" data-key="0">0</button>
<button type="button" data-key="back"><span data-i18n="stops.padDelete">ลบ</span></button>
</div>
</div>
<!-- โหมด 2: ชื่อสถานที่ -->
@@ -441,21 +433,25 @@
<p class="mu-search-hint" data-i18n="stops.placeHint">พิมพ์ชื่อสถานที่สำคัญ เช่น โรงพยาบาล สำนักงานที่ดิน แล้วเลือกรายการที่ตรงกัน</p>
</div>
<!-- หมวดที่ 3: ป้ายใกล้ฉัน — ขอพิกัดจากเครื่อง แล้วเรียงป้ายตามระยะจริง -->
<div class="mu-search-mode" id="stops-near-wrap" hidden>
<button type="button" class="mu-btn primary" id="near-me-btn">
<svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg>
<span data-i18n="stops.nearCta">ขอพิกัดและหาป้ายใกล้ฉัน</span>
</button>
<p class="mu-search-hint" data-i18n="stops.nearHint">ระบบจะขอตำแหน่งจากเครื่อง แล้วคำนวณระยะจากพิกัดป้าย/ศาลารถ เรียงจากใกล้ไปไกล</p>
<div id="near-me-result" class="mu-near-wrap" hidden></div>
</div>
<div class="mu-toolbar-actions">
<button type="button" class="mu-btn primary" id="stops-search-btn"><span data-i18n="common.search">ค้นหา</span></button>
<button type="button" class="mu-btn ghost" id="stops-reset-btn"><span data-i18n="stops.reset">ล้างค่า</span></button>
<button type="button" class="mu-btn ghost" id="near-me-btn">
<svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg>
<span data-i18n="map.useMyLocation">ป้ายใกล้ฉัน</span>
</button>
<a class="mu-btn ghost" href="#/"><span data-i18n="common.back">ย้อนกลับ</span></a>
</div>
<p class="mu-toolbar-count" id="stops-count" hidden></p>
</form>
<div id="near-me-result" class="mu-near-wrap" hidden></div>
<ul class="mu-stop-grid" id="stops-list"></ul>
<div class="mu-show-more">
@@ -465,10 +461,28 @@
</main>
<script>
/* ป้ายใกล้ฉัน — หมวดที่ 3 ของการค้นหา
ต้องมี secure context (HTTPS หรือ localhost) เบราว์เซอร์จึงยอมให้ geolocation
ไม่ผ่านเงื่อนไข → ซ่อนแท็บทั้งแท็บ (กดไปก็ได้แต่ error) */
(function () {
var SECURE = (typeof window !== 'undefined') &&
window.isSecureContext === true &&
typeof navigator !== 'undefined' && !!navigator.geolocation;
var tab = document.getElementById('stops-near-tab');
if (tab) tab.hidden = !SECURE;
if (!SECURE) {
var wrap0 = document.getElementById('stops-near-wrap');
if (wrap0) wrap0.hidden = true;
return;
}
var btn = document.getElementById('near-me-btn');
var out = document.getElementById('near-me-result');
if (!btn || !out || !window.ATMap) return;
if (btn.dataset.nearBound === '1') return;
btn.dataset.nearBound = '1';
ATMap.nearMe(btn, out, { limit: 8 });
})();
</script>
+1 -1
View File
@@ -108,7 +108,7 @@
{ label: t('stops.kpi.total'), value: stops.length + ' ' + t('stops.unitPoints') },
{ label: t('stops.kpi.routes'), value: Object.keys(routes).length + ' ' + t('stops.unitRoutes') },
{ label: t('stops.kpi.types'), value: Object.keys(types).length + ' ' + t('stops.unitTypes') },
{ label: t('stops.kpi.buses'), value: topBus ? ('สาย ' + topBus) : '—' }
{ label: t('stops.kpi.buses'), value: topBus ? t('common.routePrefix', { n: topBus }) : '—' }
];
host.innerHTML = '';
+28 -48
View File
@@ -13,6 +13,7 @@
var MODE_CODE = 'code';
var MODE_PLACE = 'place';
var MODE_NEAR = 'near'; /* หมวดที่ 3: ป้ายใกล้ฉัน (ต้องมี HTTPS) */
var state = {
mode: MODE_CODE,
@@ -90,6 +91,10 @@
}
function currentFilter() {
// โหมดใกล้ฉัน: ไม่กรองรายการ (ผลลัพธ์แสดงในโซนของตัวเอง)
if (state.mode === MODE_NEAR) {
return { fn: function () { return true; }, value: '' };
}
// โหมดรหัส: ถ้ายังไม่กรอกช่องไหนเลย → ไม่กรอง (แสดงทั้งหมด)
if (state.mode === MODE_CODE && !state.codeTouched) {
return { fn: function () { return true; }, value: '' };
@@ -206,23 +211,33 @@
/* ---------- สลับโหมด (หัวใจของการกันชน) ---------- */
function setMode(mode) {
if (mode !== MODE_CODE && mode !== MODE_PLACE) return;
if (mode !== MODE_CODE && mode !== MODE_PLACE && mode !== MODE_NEAR) return;
/* โหมดใกล้ฉันใช้ได้เฉพาะ secure context */
if (mode === MODE_NEAR && !(window.isSecureContext && navigator.geolocation)) return;
state.mode = mode;
var codeWrap = document.getElementById('stops-code-wrap');
var placeWrap = document.getElementById('stops-place-wrap');
var nearWrap = document.getElementById('stops-near-wrap');
var placeInput = document.getElementById('stops-place-input');
var suggest = document.getElementById('stops-suggest');
var pad = document.getElementById('stops-numpad');
var cells = codeCells();
var isCode = mode === MODE_CODE;
var isPlace = mode === MODE_PLACE;
var isNear = mode === MODE_NEAR;
// แสดง/ซ่อนช่องกรอก
// แสดง/ซ่อนช่องกรอก — เลือกได้ทีละโหมดเท่านั้น
if (codeWrap) codeWrap.hidden = !isCode;
if (placeWrap) placeWrap.hidden = isCode;
if (pad) pad.hidden = !isCode;
if (suggest) suggest.hidden = isCode;
if (placeWrap) placeWrap.hidden = !isPlace;
if (nearWrap) nearWrap.hidden = !isNear;
if (suggest) suggest.hidden = !isPlace;
// โหมดใกล้ฉัน: ซ่อนรายการป้ายทั้งหมด (ผลลัพธ์หลักคือการ์ดเรียงตามระยะ)
var stopList = document.getElementById('stops-list');
if (stopList) stopList.hidden = isNear;
var showAllBtn = document.getElementById('stops-show-all');
if (showAllBtn && isNear) showAllBtn.hidden = true;
// ปิดการใช้งานช่องของโหมดที่ไม่ได้เลือก + ล้างค่า → กันการค้น 2 ทางพร้อมกัน
Array.prototype.forEach.call(cells, function (c) {
@@ -236,8 +251,8 @@
updateCodeDisplay();
}
if (placeInput) {
placeInput.disabled = isCode;
if (isCode) { placeInput.value = ''; state.placeQuery = ''; }
placeInput.disabled = !isPlace;
if (!isPlace) { placeInput.value = ''; state.placeQuery = ''; }
}
// ไฮไลต์ปุ่ม toggle
@@ -249,7 +264,11 @@
// โฟกัสช่องที่เพิ่งเปิด
if (isCode) focusCell(0);
if (!isCode && placeInput) placeInput.focus();
if (isPlace && placeInput) placeInput.focus();
if (isNear) {
var nearBtn = document.getElementById('near-me-btn');
if (nearBtn) nearBtn.focus();
}
apply();
}
@@ -352,44 +371,6 @@
}
/* ---------- numpad (ใช้กับ 5 ช่อง) ---------- */
function initNumpad() {
var pad = document.getElementById('stops-numpad');
if (!pad) return;
pad.addEventListener('click', function (e) {
var key = e.target.closest('[data-key]');
if (!key) return;
e.preventDefault();
var k = key.getAttribute('data-key');
var cells = codeCells();
if (!cells.length) return;
/* ตำแหน่งเป้าหมาย = ช่องแรกที่ว่าง (ช่องท้ายสุดถ้าเต็มหมด) */
var idx = CODE_CELLS - 1;
for (var i = 0; i < CODE_CELLS; i++) {
if (!cells[i].value) { idx = i; break; }
}
if (k === 'back') {
// ถอยจากท้าย: ล้างช่องขวาสุดที่มีค่า แล้วเลื่อนเป้าไปช่องนั้น
var last = -1;
for (var j = CODE_CELLS - 1; j >= 0; j--) {
if (cells[j].value) { last = j; break; }
}
idx = last === -1 ? 0 : last;
cells[idx].value = '';
} else {
cells[idx].value = k;
}
syncCodeFromCells();
updateCodeDisplay();
apply();
// โฟกัสช่องถัดไป (ไม่ select — กันกด numpad แล้วทับค่าเดิม)
var next = Math.min(idx + (k === 'back' ? 0 : 1), CODE_CELLS - 1);
if (cells[next]) cells[next].focus();
});
}
/* ---------- init ---------- */
function init(stops) {
@@ -481,7 +462,6 @@
suggest.hidden = true;
});
initNumpad();
setMode(MODE_CODE); // เริ่มที่โหมดรหัส
}
+2 -2
View File
@@ -147,7 +147,7 @@
</section>
<!-- ============ สรุปเส้นทาง (สถิติแบบ index) ============ -->
<section class="mu-summary" aria-label="สรุปเส้นทาง">
<section class="mu-summary" aria-label="สรุปเส้นทาง" data-i18n-attr="aria-label:aria.routeSummary">
<div class="mu-container">
<div class="mu-summary-grid">
<div class="mu-stat tag-purple"><h3 id="check-stat-stops">–</h3><p data-i18n="check.kpiStops">จุดจอดหลัก</p></div>
@@ -159,7 +159,7 @@
</section>
<!-- ============ ตารางเวลาเดินรถ ============ -->
<section class="mu-schedule" aria-label="ตารางเวลาเดินรถ">
<section class="mu-schedule" aria-label="ตารางเวลาเดินรถ" data-i18n-attr="aria-label:check.title">
<div class="mu-container">
<div class="mu-zone">
<div class="mu-zone-head">
+6 -6
View File
@@ -318,7 +318,7 @@
var head = document.createElement('p');
head.className = 'mu-stop-sub';
head.textContent = (r.direction_label || r.dir_label) || r.direction_note || ('จาก ' + first);
head.textContent = (r.direction_label || r.dir_label) || r.direction_note || t('check.fromName', { name: first });
body.appendChild(head);
var grid = document.createElement('div');
@@ -425,7 +425,7 @@
routes.forEach(function (r) {
var o = document.createElement('option');
o.value = r.route_id;
o.textContent = 'สาย ' + r.route_id + (r.route_name_th ? ' - ' + r.route_name_th : '');
o.textContent = t('common.routePrefix', { n: r.route_id }) + (r.route_name_th ? ' - ' + r.route_name_th : '');
sel.appendChild(o);
});
sel.value = rid;
@@ -436,7 +436,7 @@
/* Hero + คำอธิบายโซน */
var hero = $('check-hero-route');
if (hero) hero.textContent = 'สาย ' + rid + (route.route_name_th ? ' · ' + route.route_name_th : '');
if (hero) hero.textContent = t('common.routePrefix', { n: rid }) + (route.route_name_th ? ' · ' + route.route_name_th : '');
/* "อัปเดตล่าสุด N วันที่แล้ว" — วันที่จากฟิลด์ updated ของไฟล์ตารางสายนี้ (Schedules.updatedOf)
แยกบรรทัดของตัวเอง (#check-updated-line) เพราะ #check-now-line แสดงเวลาปัจจุบันอยู่แล้ว */
@@ -470,7 +470,7 @@
return {
sid: sid,
st: st,
name: isOtherHub && firstSubName ? firstSubName : (st ? st.station_name_th : 'จุดจอด ' + sid),
name: isOtherHub && firstSubName ? firstSubName : (st ? st.station_name_th : t('check.stopNameN', { n: sid })),
city: st ? st.city_th : '',
code: st ? st.station_code : '',
recs: recs.filter(function (r) { return String(r.route_id) === rid && r.station_id === sid; })
@@ -506,11 +506,11 @@
dayText = t('check.dayMixed');
} else if (selectedByDay) {
dayText = t(di.dayType === 'holiday' ? 'check.dayHoliday' : 'check.dayWeekday') +
' (' + t('check.dayOfWeek') + ' ' + di.weekday_th + ')';
' (' + t('check.dayOfWeek') + ' ' + (window.Schedules && Schedules.dayName ? Schedules.dayName(di.weekday) : di.weekday_th) + ')';
}
}
/* แยกเป็นชิ้น ๆ เพื่อให้ตัดบรรทัดได้เป็นหน่วย (ไม่ตัดกลางชื่อสถานี/ชื่อวัน) */
var segs = ['สาย ' + rid];
var segs = [t('common.routePrefix', { n: rid })];
if (names.length > 1) segs.push(names[0] + ' \u2192 ' + names[names.length - 1]);
segs.push(groups.length + ' ' + t('check.stopsCount'));
if (dayText) segs.push(dayText);
+18 -18
View File
@@ -19,53 +19,53 @@
<main class="mu-page">
<div class="mu-credit-wrap">
<div class="mu-credit-hero">
<p class="mu-breadcrumb"><a href="#/">หน้าแรก</a>/ เครดิต</p>
<p class="mu-breadcrumb"><a href="#/" data-i18n="credits.breadHome">หน้าแรก</a>/ <span data-i18n="credits.breadSelf">เครดิต</span></p>
<h1><span data-i18n="credits.title">เครดิตและแหล่งที่มา</span></h1>
<p>รายการทรัพยากรทั้งหมดที่ใช้ในเว็บนี้ พร้อมใบอนุญาต (license) ตามข้อกำหนดของเจ้าของแต่ละราย</p>
<p data-i18n="credits.lead">รายการทรัพยากรทั้งหมดที่ใช้ในเว็บนี้ พร้อมใบอนุญาต (license) ตามข้อกำหนดของเจ้าของแต่ละราย</p>
</div>
<section class="mu-credit-section">
<h2><span data-i18n="credits.icons">ไอคอน — Lucide</span></h2>
<p class="src">แหล่งที่มา: <a href="https://lucide.dev" rel="noopener">lucide.dev</a> · ใบอนุญาต: <a href="https://github.com/lucide-icons/lucide/blob/main/LICENSE" rel="noopener">MIT License</a> — ใช้ได้ฟรีทั้งส่วนบุคคลและเชิงพาณิชย์ โดยไม่ต้องระบุเครดิต แต่เราระบุไว้เพื่อความโปร่งใส</p>
<p class="src"><span data-i18n="credits.src">แหล่งที่มา:</span> <a href="https://lucide.dev" rel="noopener">lucide.dev</a> · <span data-i18n="credits.lic">ใบอนุญาต:</span> <a href="https://github.com/lucide-icons/lucide/blob/main/LICENSE" rel="noopener">MIT License</a> — ใช้ได้ฟรีทั้งส่วนบุคคลและเชิงพาณิชย์ โดยไม่ต้องระบุเครดิต แต่เราระบุไว้เพื่อความโปร่งใส</p>
<ul>
<li>ไอคอนที่ใช้ทั้งหมด 15 รายการ เก็บที่ <code>.image/icons/lucide/</code></li>
<li>alarm-clock, arrow-right, bus, bus-front, check, clock, globe, hourglass, map, map-pin, message-circle, phone, refresh-cw, search, triangle-alert</li>
<li>วิธีใช้งาน: sprite <code>ui/partials/icons-sprite.svg</code> + <code>&lt;svg class="ic"&gt;&lt;use href="#ic-ชื่อ"&gt;</code></li>
<li><span data-i18n="credits.iconsCount">ไอคอนที่ใช้ทั้งหมด 15 รายการ เก็บที่</span> <code>.image/icons/lucide/</code></li>
<li data-i18n="credits.iconNames">alarm-clock, arrow-right, bus, bus-front, check, clock, globe, hourglass, map, map-pin, message-circle, phone, refresh-cw, search, triangle-alert</li>
<li><span data-i18n="credits.iconsUsage">วิธีใช้งาน: sprite</span> <code>ui/partials/icons-sprite.svg</code> + <code>&lt;svg class="ic"&gt;&lt;use href="#ic-ชื่อ"&gt;</code></li>
</ul>
<div class="mu-license">
<strong>MIT License (สรุป):</strong> อนุญาตให้ใช้ คัดลอก แก้ไข ผสาน เผยแพร่ แจกจ่าย ขาย และ/หรือให้สิทธิ์ใช้งานซอฟต์แวร์นี้ โดยมีเงื่อนไขให้ข้อความแสดงลิขสิทธิ์และข้อความอนุญาตข้างต้นปรากฏอยู่ในสำเนาทั้งหมดหรือส่วนสำคัญของซอฟต์แวร์ ซอฟต์แวร์นี้ให้บริการ "ตามสภาพ" โดยไม่มีการรับประกันใด ๆ
<strong data-i18n="credits.mitStrong">MIT License (สรุป):</strong> <span data-i18n="credits.mitText">อนุญาตให้ใช้ คัดลอก แก้ไข ผสาน เผยแพร่ แจกจ่าย ขาย และ/หรือให้สิทธิ์ใช้งานซอฟต์แวร์นี้ โดยมีเงื่อนไขให้ข้อความแสดงลิขสิทธิ์และข้อความอนุญาตข้างต้นปรากฏอยู่ในสำเนาทั้งหมดหรือส่วนสำคัญของซอฟต์แวร์ ซอฟต์แวร์นี้ให้บริการ "ตามสภาพ" โดยไม่มีการรับประกันใด ๆ</span>
</div>
</section>
<section class="mu-credit-section">
<h2><span data-i18n="credits.fonts">ฟอนต์ — Google Fonts</span></h2>
<p class="src">แหล่งที่มา: <a href="https://fonts.google.com" rel="noopener">fonts.google.com</a> · ใบอนุญาต: <a href="https://openfontlicense.org" rel="noopener">SIL Open Font License 1.1</a></p>
<p class="src"><span data-i18n="credits.src">แหล่งที่มา:</span> <a href="https://fonts.google.com" rel="noopener">fonts.google.com</a> · <span data-i18n="credits.lic">ใบอนุญาต:</span> <a href="https://openfontlicense.org" rel="noopener">SIL Open Font License 1.1</a></p>
<ul>
<li><strong>K2D</strong> — ฟอนต์หลักของเว็บ (เนื้อหา + หัวเรื่อง) · มีหัวแบบไทย น้ำหนัก 300–800</li>
<li><strong>Noto Sans Thai</strong> — ตัวสำรองเนื้อหา (โหลดผ่าน Google Fonts CDN)</li>
<li><strong>Prompt</strong> — ตัวสำรองหัวเรื่อง/ตัวหนา</li>
<li><strong>IBM Plex Mono</strong> — เวลา · เลขสาย · ตัวเลข (เรียงตรงกัน)</li>
<li><strong>K2D</strong> — <span data-i18n="credits.fontK2D">ฟอนต์หลักของเว็บ (เนื้อหา + หัวเรื่อง) · มีหัวแบบไทย น้ำหนัก 300–800</span></li>
<li><strong>Noto Sans Thai</strong> — <span data-i18n="credits.fontNoto">ตัวสำรองเนื้อหา (โหลดผ่าน Google Fonts CDN)</span></li>
<li><strong>Prompt</strong> — <span data-i18n="credits.fontPrompt">ตัวสำรองหัวเรื่อง/ตัวหนา</span></li>
<li><strong>IBM Plex Mono</strong> — <span data-i18n="credits.fontMono">เวลา · เลขสาย · ตัวเลข (เรียงตรงกัน)</span></li>
</ul>
</section>
<section class="mu-credit-section">
<h2><span data-i18n="credits.map">แผนที่</span></h2>
<p class="src">ใบอนุญาต: Leaflet <a href="https://github.com/Leaflet/Leaflet/blob/main/LICENSE" rel="noopener">BSD-2-Clause</a> · ชุดแผนที่ (tiles): <a href="https://www.openstreetmap.org/copyright" rel="noopener">OpenStreetMap © ผู้มีส่วนร่วม (ODbL)</a></p>
<p class="src"><span data-i18n="credits.lic">ใบอนุญาต:</span> Leaflet <a href="https://github.com/Leaflet/Leaflet/blob/main/LICENSE" rel="noopener">BSD-2-Clause</a> · ชุดแผนที่ (tiles): <a href="https://www.openstreetmap.org/copyright" rel="noopener">OpenStreetMap © ผู้มีส่วนร่วม (ODbL)</a></p>
<ul>
<li>Leaflet — ไลบรารีแผนที่แบบ open-source</li>
<li>OpenStreetMap — ภาพ tiles และข้อมูลแผนที่ที่ใช้แสดงผล</li>
<li>เส้นทางเดินรถ จุดจอด และหมุดสถานี วาดจากข้อมูล GIS ของทีม (<code>GeoJSON</code>) ทับบนแผนที่</li>
<li data-i18n="credits.mapLeaflet">Leaflet — ไลบรารีแผนที่แบบ open-source</li>
<li data-i18n="credits.mapOSM">OpenStreetMap — ภาพ tiles และข้อมูลแผนที่ที่ใช้แสดงผล</li>
<li><span data-i18n="credits.mapGIS">เส้นทางเดินรถ จุดจอด และหมุดสถานี วาดจากข้อมูล GIS ของทีม</span> (<code>GeoJSON</code>)</li>
</ul>
</section>
<section class="mu-credit-section">
<h2><span data-i18n="credits.photos">ขอขอบคุณภาพรถประจำทาง</span></h2>
<p class="src">ภาพรถโดยสารประจำทางที่แสดงในหน้ารายละเอียดสาย มาจากแหล่งข้อมูลสาธารณะด้านล่างนี้ — ขอบคุณเจ้าของภาพและผู้รวบรวมทุกท่าน</p>
<p class="src" data-i18n="credits.photosLead">ภาพรถโดยสารประจำทางที่แสดงในหน้ารายละเอียดสาย มาจากแหล่งข้อมูลสาธารณะด้านล่างนี้ — ขอบคุณเจ้าของภาพและผู้รวบรวมทุกท่าน</p>
<ul>
<li><strong>สาย 2194</strong> หัวเวียง-อยุธยา — จาก <a href="http://www.bangkokbusclub.com/cms/showthread.php?t=4968" rel="noopener">bangkokbusclub.com</a></li>
<li><strong>สาย 8</strong> กรุงเทพ-สรรคบุรี-ชัยนาท — จาก <a href="https://web.facebook.com/groups/431811197419587/posts/2006978336569524/" rel="noopener">กลุ่ม Facebook (web.facebook.com)</a></li>
<li><strong>สาย 954</strong> กรุงเทพ-ท่าช้าง — จาก <a href="https://gogo.town/route/bangkok-rangsit-angthong-thachang/" rel="noopener">gogo.town</a></li>
<li><strong>รถไฟฟ้าสายสีแดง </strong> กรุงเทพ-ชุมทางบ้านภาชี — จาก <a href="https://thelist.group/realist/blog/%E0%B8%A3%E0%B8%96%E0%B9%84%E0%B8%9F%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%AA%E0%B8%B2%E0%B8%A2%E0%B8%AA%E0%B8%B5%E0%B9%81%E0%B8%94%E0%B8%87/" rel="noopener">thelist.group</a></li>
<li><strong data-i18n="credits.lineRed">รถไฟฟ้าสายสีแดง</strong> กรุงเทพ-ชุมทางบ้านภาชี — จาก <a href="https://thelist.group/realist/blog/%E0%B8%A3%E0%B8%96%E0%B9%84%E0%B8%9F%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%AA%E0%B8%B2%E0%B8%A2%E0%B8%AA%E0%B8%B5%E0%B9%81%E0%B8%94%E0%B8%87/" rel="noopener">thelist.group</a></li>
</ul>
<p class="mu-license">
<span data-i18n="credits.photosNote">และสายอื่น ๆ ที่ไม่ได้ระบุ ขอขอบคุณมา ณ ที่นี้</span>
+2 -2
View File
@@ -60,7 +60,7 @@
</div>
</section>
<section class="mu-sponsor-marquee" aria-label="ผู้สนับสนุนและพาร์ทเนอร์">
<section class="mu-sponsor-marquee" aria-label="ผู้สนับสนุนและพาร์ทเนอร์" data-i18n-attr="aria-label:aria.sponsors">
<div class="mu-sponsor-head">
<h4 data-i18n="footer.sponsors">ผู้สนับสนุน &amp; พาร์ทเนอร์</h4>
<p class="lead" data-i18n="footer.sponsorsLead">ร่วมเป็นผู้สนับสนุนเราได้ เมื่อซื้อของออนไลน์ หรือซื้อตั๋วรถทัวร์ เครื่องบิน ออนไลน์กดเลือกสินค้า หรือบริการผ่านลิงค์นายหน้าของเราไม่มีค่าใช้จ่ายเพิ่ม</p>
@@ -83,7 +83,7 @@
<div class="mu-container">
<!-- คำอธิบายสีการ์ดตามหมวดเส้นทาง -->
<section class="mu-legend" aria-label="คำอธิบายสีการ์ดตามหมวดเส้นทาง">
<section class="mu-legend" aria-label="คำอธิบายสีการ์ดตามหมวดเส้นทาง" data-i18n-attr="aria-label:aria.legend">
<h2 class="mu-legend-title" data-i18n="legend.title">คำอธิบายสีการ์ดตามหมวดเส้นทาง</h2>
<ul class="mu-legend-list">
<li><span class="sw sw-bangkok" aria-hidden="true"></span><span data-i18n="legend.bangkok">หมวดเส้นทางเข้ากรุงเทพฯ — การ์ดสีน้ำเงิน</span></li>
+5 -3
View File
@@ -1,6 +1,8 @@
(function () {
'use strict';
function nm(o, base) { return (window.I18N && I18N.name) ? I18N.name(o, base) : ((o && o[base + '_th']) || ''); }
// แหล่งข้อมูลเดียว (source of truth) — อย่า hardcode รายชื่อจังหวัด/สถานีไว้ในไฟล์นี้
var DATA_URL = {
provinces: '../resource/data/provinces.json',
@@ -65,14 +67,14 @@
PROVINCES.forEach(function (p) {
var opt = document.createElement('option');
opt.value = p.province_id;
opt.textContent = p.province_name_th;
opt.textContent = nm(p, 'province_name');
if (p.province_id === startProvinceId) opt.selected = true;
provinceSelect.appendChild(opt);
});
function provinceName(id) {
var p = PROVINCES.filter(function (x) { return x.province_id === id; })[0];
return p ? p.province_name_th : '';
return p ? nm(p, 'province_name') : '';
}
function stationsFor(provinceId) {
@@ -90,7 +92,7 @@
list.forEach(function (st) {
var opt = document.createElement('option');
opt.value = st.station_code; /* ใช้รหัสสถานี = ลิงก์สั้น อ่านง่าย */
opt.textContent = st.station_name_th;
opt.textContent = nm(st, 'station_name');
stationSelect.appendChild(opt);
});
+8 -1
View File
@@ -189,6 +189,11 @@
var DAYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; /* ตรงกับ Date.getDay() */
var DAY_TH = { sun: 'อาทิตย์', mon: 'จันทร์', tue: 'อังคาร', wed: 'พุธ', thu: 'พฤหัสบดี', fri: 'ศุกร์', sat: 'เสาร์' };
var DAY_ABBR = { sun: 'อา', mon: 'จ', tue: 'อ', wed: 'พ', thu: 'พฤ', fri: 'ศ', sat: 'ส' };
/* ชื่อวันแบบหลายภาษา — ใช้แสดงผลเท่านั้น (การตรวจคำยังใช้ค่าภาษาไทยข้างบน) */
function dayName(key, short) {
var k = 'day.' + key + (short ? 'S' : '');
return (window.I18N && I18N.t) ? I18N.t(k) : (short ? DAY_ABBR[key] : DAY_TH[key]);
}
var DAY_ALIAS = { /* รับได้หลายชื่อ */
weekday: 'weekday', workday: 'weekday', 'วันทำงาน': 'weekday', 'จ-ศ': 'weekday', 'จ–ศ': 'weekday',
holiday: 'holiday', weekend: 'holiday', 'วันหยุด': 'holiday', 'ส-อา': 'holiday', 'ส–อา': 'holiday', 'เสาร์-อาทิตย์': 'holiday',
@@ -214,7 +219,8 @@
var d = date || new Date();
var t = dayTypeOf(d);
return { dayType: t, weekday: DAYS[d.getDay()], weekday_th: DAY_TH[DAYS[d.getDay()]], date: ymd(d),
label_th: t === 'holiday' ? 'วันหยุด (ส–อา/นักขัตฤกษ์)' : 'วันทำงาน (จ–ศ)' };
label_th: t === 'holiday' ? 'วันหยุด (ส–อา/นักขัตฤกษ์)' : 'วันทำงาน (จ–ศ)',
labelKey: t === 'holiday' ? 'dayHoliday' : 'dayWeekday' };
}
/* ตรวจคำในข้อความ (direction_label / direction_note / note) ว่าหมายถึงวันไหน */
function detectDay(text) {
@@ -600,6 +606,7 @@
todayType: todayType,
dayTypeOf: dayTypeOf,
dayInfo: dayInfo,
dayName: dayName,
dayKey: dayKey,
DAYS: DAYS,
DAY_TH: DAY_TH,
+3 -3
View File
@@ -436,7 +436,7 @@
</div>
</section>
<section class="mu-nearby" id="stop-nearby" aria-label="สถานที่ใกล้เคียง" hidden>
<section class="mu-nearby" id="stop-nearby" aria-label="สถานที่ใกล้เคียง" data-i18n-attr="aria-label:stop.nearby" hidden>
<h2><span data-i18n="stop.nearby">ใกล้เคียงป้าย</span></h2>
<p class="sub" id="stop-nearby-sub"></p>
<div class="mu-nearby-grid" id="stop-nearby-grid"></div>
@@ -450,7 +450,7 @@
<div class="mu-card-panel">
<h2><span data-i18n="stop.routes">สายรถที่ผ่านจุดนี้</span></h2>
<div class="mu-route-tools">
<input id="mu-route-filter" class="mu-route-filter" type="text" placeholder="ค้นหาสายรถหรือปลายทาง" data-i18n-attr="placeholder:stop.searchRoute,aria-label:stop.searchRoute">
<input id="mu-route-filter" class="mu-route-filter" type="text" placeholder="ค้นหาสายรถหรือปลายทาง" data-i18n-attr="placeholder:stop.searchRoute" data-i18n-attr="placeholder:stop.searchRoute,aria-label:stop.searchRoute">
<span class="mu-route-count" id="mu-route-count"></span>
</div>
<ul class="mu-list mu-stop-list" id="stop-routes"></ul>
@@ -458,7 +458,7 @@
<aside class="mu-card-panel">
<h2><span data-i18n="stop.mapInfo">แผนที่และข้อมูลป้าย</span></h2>
<div class="at-map" id="stop-map" role="region" aria-label="แผนที่เส้นทางที่ผ่านป้ายนี้"></div>
<div class="at-map" id="stop-map" role="region" aria-label="แผนที่เส้นทางที่ผ่านป้ายนี้" data-i18n-attr="aria-label:aria.stopRoutesMap"></div>
<p class="at-map-caption" id="stop-map-caption"></p>
<div id="stop-chips" style="display:flex; flex-wrap:wrap; gap:8px; margin-top:14px;"></div>
</aside>
+2 -2
View File
@@ -119,7 +119,7 @@
/* ---------- เรนเดอร์: หัวป้าย ---------- */
function renderHero(st, sum, photo, place) {
var baseName = st.station_name_th || ('ป้าย ' + st.station_code);
var baseName = st.station_name_th || ('' + t('common.stopPrefix', { n: st.station_code }));
/* จุดขึ้นรถประจำทางอื่นๆ: ต่อท้ายด้วยชื่อสถานที่จริงของสายที่กำลังดูอยู่ */
var placeName = (place && window.OtherStop && OtherStop.firstName) ? OtherStop.firstName(place)
: (place && place.station_name_th) ? place.station_name_th : null;
@@ -246,7 +246,7 @@
'<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> ' +
esc(r.vehicle_type_th || t('type.terminal')) + '</span>' +
'<span class="mu-stop-summary-main">' +
'<strong>' + esc(r.route_name_th || ('สาย ' + r.route_id)) + '</strong>' +
'<strong>' + esc(r.route_name_th || t('common.routePrefix', { n: r.route_id })) + '</strong>' +
'<span class="mu-stop-summary-meta">' + esc(metaText) + '</span>' +
'</span>' +
'<span class="mu-stop-summary-rail">' +
+1 -1
View File
@@ -109,7 +109,7 @@
var li = document.createElement('li');
var a = document.createElement('a');
a.href = '#/routes/' + id;
a.textContent = 'สาย ' + id + (r.route_name_th ? ' · ' + r.route_name_th : '');
a.textContent = (window.I18N ? I18N.t('common.routePrefix', { n: id }) : ('สาย ' + id)) + (r.route_name_th ? ' · ' + r.route_name_th : '');
li.appendChild(a);
ul.appendChild(li);
});
+10 -1
View File
@@ -20,7 +20,7 @@
var btn = document.createElement("button");
btn.type = "button";
btn.className = "mu-install-btn";
btn.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/></svg> ติดตั้งแอป';
btn.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/></svg> ' + ((window.I18N && I18N.t) ? I18N.t('pwa.install') : 'ติดตั้งแอป');
btn.addEventListener("click", function () {
if (!deferredPrompt) return;
deferredPrompt.prompt();
@@ -30,6 +30,15 @@
});
});
document.body.appendChild(btn);
/* เปลี่ยนภาษาแล้ว → อัปเดตข้อความบนปุ่ม */
window.addEventListener('langchange', function () {
if (!installBtn) return;
var svg = installBtn.querySelector('svg');
installBtn.textContent = '';
if (svg) installBtn.appendChild(svg);
installBtn.appendChild(document.createTextNode(
(window.I18N && I18N.t) ? I18N.t('pwa.install') : 'ติดตั้งแอป'));
});
return btn;
}
+10 -10
View File
@@ -17,14 +17,14 @@
'use strict';
var VIEWS = {
home: { partial: 'partials/home.html', nav: '/', title: 'หน้าแรก' },
stops: { partial: 'partials/busStop.html', nav: '/stops', title: 'ป้ายหยุดรถ' },
routes: { partial: 'partials/busDetail.html', nav: '/routes', title: 'รายละเอียดสายรถ' },
check: { partial: 'partials/checkSchedule.html', nav: '/check', title: 'เช็กเวลาเดินรถ' },
stop: { partial: 'partials/stopDetail.html', nav: '/stops/', title: 'รายละเอียดป้าย' },
credits: { partial: 'partials/credits.html', nav: '/credits', title: 'เครดิต' },
about: { partial: 'partials/about.html', nav: '/about', title: 'เกี่ยวกับเรา' },
blog: { partial: 'partials/blog.html', nav: '/blog', title: 'บ่นไปเรื่อย' },
home: { partial: 'partials/home.html', nav: '/', title: 'หน้าแรก', tkey: 'page.home' },
stops: { partial: 'partials/busStop.html', nav: '/stops', title: 'ป้ายหยุดรถ', tkey: 'page.stops' },
routes: { partial: 'partials/busDetail.html', nav: '/routes', title: 'รายละเอียดสายรถ', tkey: 'page.routes' },
check: { partial: 'partials/checkSchedule.html', nav: '/check', title: 'เช็กเวลาเดินรถ', tkey: 'page.check' },
stop: { partial: 'partials/stopDetail.html', nav: '/stops/', title: 'รายละเอียดป้าย', tkey: 'page.stop' },
credits: { partial: 'partials/credits.html', nav: '/credits', title: 'เครดิต', tkey: 'page.credits' },
about: { partial: 'partials/about.html', nav: '/about', title: 'เกี่ยวกับเรา', tkey: 'page.about' },
blog: { partial: 'partials/blog.html', nav: '/blog', title: 'บ่นไปเรื่อย', tkey: 'page.blog' },
};
function parseHash() {
@@ -137,7 +137,7 @@
var stateEl = viewEl.querySelector('.mu-inline-context strong');
if (stateEl) stateEl.textContent = '?route=' + route.params.routeId;
}
document.title = 'Atroute — ' + view.title;
document.title = (window.I18N && view.tkey) ? I18N.t(view.tkey) : ('Atroute — ' + view.title);
window.scrollTo(0, 0);
/* footer "สายที่เปิดดูบ่อย" — เรนเดอร์ทุกครั้ง (ตามภาษา + อันดับล่าสุด) */
@@ -146,7 +146,7 @@
.catch(function () {
viewEl.innerHTML =
'<div class="mu-container" style="padding:64px 28px;text-align:center;color:#6f7b95;">' +
'โหลดเนื้อหาไม่สำเร็จ — กรุณาเปิดผ่าน HTTP server (เช่น python3 -m http.server)</div>';
(window.I18N ? I18N.t('router.loadFail') : 'โหลดเนื้อหาไม่สำเร็จ') + '</div>';
});
}
+1 -1
View File
@@ -13,7 +13,7 @@
- ขั้นตอนอัปเดต: ดู AGENTS.md หัวข้อ PWA
============================================================ */
const VERSION = "2026.09.27.94"; // ← bump ทุกครั้งที่แก้ SW เอง
const VERSION = "2026.09.27.98"; // ← bump ทุกครั้งที่แก้ SW เอง
const CACHE = `at-transit-${VERSION}`;
const PRECACHE = [
+13 -7
View File
@@ -26,6 +26,12 @@
var TAPS = 5; /* จำนวนครั้งที่ต้องกดตัวเลข */
var TAP_WINDOW = 2000; /* ต้องกดรัวภายใน 2 วิต่อครั้ง */
/* แปลข้อความ (ถ้าโหลดคำแปลไม่ทัน/ไม่มีคีย์ → ใช้ข้อความไทยที่ฝังไว้) */
function vt(key, fallback) {
var v = (window.I18N && I18N.t) ? I18N.t(key) : key;
return (!v || v === key) ? fallback : v;
}
/* SHA-256 ของรหัสรีเซ็ต — เก็บเฉพาะ hash (ไม่เก็บรหัสจริงในไฟล์นี้) */
var PASS_HASH = '4f23cd6ac8e7da56b92974cd0cf146eee9d995208a6645ed17eba91813c1d323';
@@ -169,13 +175,13 @@
wrap.className = 'mu-vreset';
wrap.innerHTML =
'<div class="mu-vreset-card" role="dialog" aria-modal="true" aria-labelledby="vreset-title">' +
'<h4 id="vreset-title">รีเซ็ตจำนวนผู้เข้าชม</h4>' +
'<label for="vreset-pass">รหัสรีเซ็ต</label>' +
'<h4 id="vreset-title">' + vt('visitors.resetTitle', 'รีเซ็ตจำนวนผู้เข้าชม') + '</h4>' +
'<label for="vreset-pass">' + vt('visitors.resetPass', 'รหัสรีเซ็ต') + '</label>' +
'<input id="vreset-pass" type="password" autocomplete="off" inputmode="text">' +
'<p class="mu-vreset-msg" role="status"></p>' +
'<div class="mu-vreset-row">' +
'<button type="button" class="mu-vreset-cancel">ยกเลิก</button>' +
'<button type="button" class="mu-vreset-ok">รีเซ็ต</button>' +
'<button type="button" class="mu-vreset-cancel">' + vt('visitors.cancel', 'ยกเลิก') + '</button>' +
'<button type="button" class="mu-vreset-ok">' + vt('visitors.confirm', 'รีเซ็ต') + '</button>' +
'</div>' +
'</div>';
@@ -188,14 +194,14 @@
Visitors.resetWith(input.value, function (ok, why) {
if (ok) {
msg.className = 'mu-vreset-msg is-ok';
msg.textContent = 'รีเซ็ตแล้ว — เริ่มนับใหม่จาก 0';
msg.textContent = vt('visitors.done', 'รีเซ็ตแล้ว — เริ่มนับใหม่จาก 0');
input.value = '';
setTimeout(close, 1200);
} else if (why === 'unsupported') {
msg.textContent = 'เบราว์เซอร์ไม่รองรับ — ต้องเปิดผ่าน https หรือ localhost';
msg.textContent = vt('visitors.unsupported', 'เบราว์เซอร์ไม่รองรับ');
} else {
msg.className = 'mu-vreset-msg is-bad';
msg.textContent = 'รหัสไม่ถูกต้อง';
msg.textContent = vt('visitors.badPass', 'รหัสไม่ถูกต้อง');
input.value = '';
input.focus();
}