add schudual function
This commit is contained in:
1 parent
d198430310
commit
88311326e6
252 files changed
+4803
-579
No files matched your search
+106
-2
@@ -43,6 +43,47 @@
|
||||
'blog.backList': 'กลับไปรายการบ่นไปเรื่อย',
|
||||
'blog.empty': 'ยังไม่มีเรื่องบ่น — เพิ่มไฟล์ใน ui/partials/blog-data/ ได้เลย',
|
||||
'blog.notFound': 'ไม่พบเรื่องบ่นนี้',
|
||||
// คำอธิบายสีการ์ดตามหมวดเส้นทาง
|
||||
'legend.title': 'คำอธิบายสีการ์ดตามหมวดเส้นทาง',
|
||||
'legend.bangkok': 'หมวดเส้นทางเข้ากรุงเทพฯ — การ์ดสีน้ำเงิน',
|
||||
'legend.interprov': 'หมวดเส้นทางระหว่างจังหวัด — การ์ดสีม่วง',
|
||||
'legend.inprov': 'หมวดเส้นทางภายในจังหวัด — การ์ดสีชมพู',
|
||||
'legend.municipal': 'หมวดเส้นทางภายในเทศบาล — การ์ดสีเหลืองอ่อน',
|
||||
'legend.empty': 'ยังไม่มีข้อมูล — การ์ดสีเทา แสดง N/A แทนเลขสาย',
|
||||
'legend.note': 'อ่างทองยังไม่มีรถหมวด 1 (เส้นทางภายในเทศบาล) จึงแสดงการ์ดสีเทาและใช้ N/A แทนตัวเลขสายเส้นทาง',
|
||||
'zone.municipal': 'หมวดเส้นทางภายในเทศบาล',
|
||||
'zone.municipalDesc': 'เส้นทางภายในเขตเทศบาล',
|
||||
'zone.municipalNA': 'ยังไม่มีเส้นทางหมวดเทศบาลในอ่างทอง',
|
||||
'card.noData': 'ยังไม่มีข้อมูล',
|
||||
// แผนที่เส้นทาง (Leaflet + GeoJSON)
|
||||
'route.mapDesc': 'เส้นทางจริงจากข้อมูล GIS · ป้ายหยุดรถตามเส้นทาง',
|
||||
'map.origin': 'ต้นทาง',
|
||||
'map.destination': 'ปลายทาง',
|
||||
'map.offline': 'ออฟไลน์ — แสดงเฉพาะเส้นทาง',
|
||||
'map.empty': 'ยังไม่มีข้อมูลเส้นทางสายนี้ในระบบ',
|
||||
'map.legendRoute': 'เส้นทาง',
|
||||
'map.legendStop': 'ป้ายหยุดรถ',
|
||||
'map.legendTerminal': 'สถานีขนส่ง',
|
||||
'map.route': 'สาย',
|
||||
'map.noStationPin': 'พิกัดป้ายนี้ยังไม่มีในระบบ — แสดงเส้นทางที่ผ่าน',
|
||||
'map.captionRoute': 'ความยาวเส้นทาง {km} กม. · ป้ายตามเส้นทาง {n} แห่ง',
|
||||
'map.captionStop': 'เส้นทางที่ผ่านป้ายนี้ {r} · ป้ายตามเส้นทาง {n} แห่ง',
|
||||
'map.stations': 'สถานีขนส่งตามเส้นทาง',
|
||||
'map.stationPinned': 'ปักหมุดตำแหน่งป้ายแล้ว',
|
||||
'map.thisStop': 'ป้ายที่กำลังดูอยู่',
|
||||
'map.legendHere': 'ป้ายที่กำลังดู',
|
||||
'map.noRoutesHere': 'ยังไม่มีข้อมูลสายรถที่ผ่านป้ายนี้ในระบบ',
|
||||
'map.servedBy': 'สายที่ผ่าน',
|
||||
'map.openInMaps': 'เปิดใน Google Maps',
|
||||
'map.viewStopPage': 'ดูรายละเอียดป้ายนี้',
|
||||
'map.km': 'กม.',
|
||||
'map.alongRoute': 'จุดจอดตามเส้นทาง (กม. จากต้นทาง)',
|
||||
'map.useMyLocation': 'ป้ายใกล้ฉัน',
|
||||
'map.locating': 'กำลังหาตำแหน่งของคุณ…',
|
||||
'map.geoDenied': 'ไม่ได้รับอนุญาตให้เข้าถึงตำแหน่ง — เปิดสิทธิ์ตำแหน่งในเบราว์เซอร์แล้วลองใหม่',
|
||||
'map.noGeo': 'เบราว์เซอร์นี้ไม่รองรับการระบุตำแหน่ง',
|
||||
'map.nearestTitle': 'ป้ายที่ใกล้คุณที่สุด',
|
||||
'map.youAreHere': 'ตำแหน่งของคุณ',
|
||||
'cta.check': 'เช็กเวลาเดินรถ',
|
||||
'footer.menu': 'เมนู',
|
||||
'footer.popular': 'สายที่ค้นหาบ่อยที่สุด',
|
||||
@@ -59,6 +100,11 @@
|
||||
'home.lead': 'ดูสายรถ, ค้นหาป้าย และเปิดตัวอย่างเส้นทางได้ทันทีจากหน้าแรก',
|
||||
'home.chooseProvince': 'เลือกจังหวัด',
|
||||
'home.chooseStation': 'เลือกสถานีขนส่งผู้โดยสาร',
|
||||
'home.allStations': 'ทุกสถานีในจังหวัดนี้',
|
||||
'share.label': 'แชร์ลิงก์สั้น',
|
||||
'share.copied': 'คัดลอกลิงก์แล้ว',
|
||||
'share.short': 'ลิงก์สั้น',
|
||||
'share.line': 'แชร์ผ่าน LINE',
|
||||
'home.stationEmpty': '— ยังไม่มีสถานีขนส่งในจังหวัดนี้ —',
|
||||
'home.stationEmptyHint': 'ยังไม่มีสถานีขนส่งผู้โดยสารในจังหวัด',
|
||||
'home.stationCount': 'มี <b>{n}</b> สถานีขนส่งในจังหวัด',
|
||||
@@ -121,6 +167,7 @@
|
||||
'route.kpiTrips': 'รอบเวลา',
|
||||
'route.overview': 'ภาพรวมของสาย',
|
||||
'route.contact': 'ติดต่อผู้ประกอบการ',
|
||||
'route.call': 'โทรสอบถาม',
|
||||
'route.vehicle': 'รถบัสประจำสาย',
|
||||
'route.mapTitle': 'เส้นทางเดินรถ',
|
||||
'route.photos': 'รูปรถประจำเส้นทางในเครือข่าย',
|
||||
@@ -177,12 +224,17 @@
|
||||
'common.back': 'ย้อนกลับ',
|
||||
'check.scheduleAll': 'ตารางเวลาเดินรถทุกจุดจอด',
|
||||
'check.title': 'ตารางเวลาเดินรถ',
|
||||
'check.lead': 'เลือกสายรถและสถานี แล้วดูรอบรถทุกจุดจอดในหน้าเดียว',
|
||||
'check.lead': 'เลือกสายรถ แล้วดูรอบรถทุกจุดจอดในหน้าเดียว',
|
||||
'check.kpiStops': 'จุดจอดหลัก',
|
||||
'check.kpiProvince': 'จังหวัดที่ผ่าน',
|
||||
'check.kpiTrips': 'รอบต่อวัน',
|
||||
'check.kpiNext': 'รอบถัดไป',
|
||||
'check.direction': 'ทิศทาง',
|
||||
'check.atStop': 'ตารางเดินรถ ณ',
|
||||
'check.now': 'เวลาปัจจุบัน',
|
||||
'check.nextAt': 'เที่ยวถัดไป',
|
||||
'check.noMoreToday': 'ไม่มีรถเหลือในวันนี้แล้ว',
|
||||
'check.stopsCount': 'จุดจอด',
|
||||
'check.toStopDetail': 'ไปหน้ารายละเอียดจุดจอด',
|
||||
'common.routes': 'เส้นทาง',
|
||||
},
|
||||
@@ -212,6 +264,47 @@
|
||||
'blog.backList': 'Back to all posts',
|
||||
'blog.empty': 'No posts yet — add files under ui/partials/blog-data/',
|
||||
'blog.notFound': 'Post not found',
|
||||
// Card colours by route group
|
||||
'legend.title': 'Card colours by route group',
|
||||
'legend.bangkok': 'Bangkok routes — blue card',
|
||||
'legend.interprov': 'Inter-provincial routes — purple card',
|
||||
'legend.inprov': 'In-province routes — pink card',
|
||||
'legend.municipal': 'Municipal routes — light yellow card',
|
||||
'legend.empty': 'No data yet — grey card showing N/A instead of a route number',
|
||||
'legend.note': 'Ang Thong has no group 1 (municipal) services yet, so the card is grey and shows N/A in place of the route number',
|
||||
'zone.municipal': 'Municipal routes',
|
||||
'zone.municipalDesc': 'Routes inside municipal areas',
|
||||
'zone.municipalNA': 'No municipal routes in Ang Thong yet',
|
||||
'card.noData': 'No data yet',
|
||||
// Route map (Leaflet + GeoJSON)
|
||||
'route.mapDesc': 'Real geometry from our GIS data · stops along the route',
|
||||
'map.origin': 'Origin',
|
||||
'map.destination': 'Destination',
|
||||
'map.offline': 'Offline — route only',
|
||||
'map.empty': 'No route geometry for this service yet',
|
||||
'map.legendRoute': 'Route',
|
||||
'map.legendStop': 'Bus stop',
|
||||
'map.legendTerminal': 'Bus terminal',
|
||||
'map.route': 'Route',
|
||||
'map.noStationPin': 'stop coordinates not in the system yet — showing serving routes',
|
||||
'map.captionRoute': 'Route length {km} km · {n} stops along the route',
|
||||
'map.captionStop': 'Routes serving this stop: {r} · {n} stops along the route',
|
||||
'map.stations': 'terminals along route',
|
||||
'map.stationPinned': 'stop location pinned on the map',
|
||||
'map.thisStop': 'the stop you are viewing',
|
||||
'map.legendHere': 'This stop',
|
||||
'map.noRoutesHere': 'No routes recorded for this stop yet',
|
||||
'map.servedBy': 'Routes served',
|
||||
'map.openInMaps': 'Open in Google Maps',
|
||||
'map.viewStopPage': 'View this stop',
|
||||
'map.km': 'km',
|
||||
'map.alongRoute': 'Stops along the route (km from origin)',
|
||||
'map.useMyLocation': 'Stops near me',
|
||||
'map.locating': 'Finding your location…',
|
||||
'map.geoDenied': 'Location permission denied — allow it in your browser and try again',
|
||||
'map.noGeo': 'This browser does not support geolocation',
|
||||
'map.nearestTitle': 'Stops closest to you',
|
||||
'map.youAreHere': 'Your location',
|
||||
'cta.check': 'Check Schedules',
|
||||
'footer.menu': 'Menu',
|
||||
'footer.popular': 'Most Searched Routes',
|
||||
@@ -227,6 +320,11 @@
|
||||
'home.lead': 'Browse routes, find stops, and preview a route right from this page',
|
||||
'home.chooseProvince': 'Select Province',
|
||||
'home.chooseStation': 'Select Terminal',
|
||||
'home.allStations': 'All terminals in this province',
|
||||
'share.label': 'Share short link',
|
||||
'share.copied': 'Link copied',
|
||||
'share.short': 'Short link',
|
||||
'share.line': 'Share on LINE',
|
||||
'home.stationEmpty': '— No terminals in this province —',
|
||||
'home.stationEmptyHint': 'No bus terminal in',
|
||||
'home.stationCount': '<b>{n}</b> terminals in',
|
||||
@@ -287,6 +385,7 @@
|
||||
'route.kpiTrips': 'trips',
|
||||
'route.overview': 'Route overview',
|
||||
'route.contact': 'Contact operator',
|
||||
'route.call': 'Call us',
|
||||
'route.vehicle': 'Route vehicle',
|
||||
'route.mapTitle': 'Route map',
|
||||
'route.photos': 'Buses on this network',
|
||||
@@ -341,12 +440,17 @@
|
||||
'common.back': 'Back',
|
||||
'check.scheduleAll': 'Departure times at every stop',
|
||||
'check.title': 'Departure Schedule',
|
||||
'check.lead': 'Pick a route and station to see every stop\u2019s departures on one page',
|
||||
'check.lead': 'Pick a route to see every stop\u2019s departures on one page',
|
||||
'check.kpiStops': 'Main stops',
|
||||
'check.kpiProvince': 'Provinces',
|
||||
'check.kpiTrips': 'Trips per day',
|
||||
'check.kpiNext': 'Next departure',
|
||||
'check.direction': 'Direction',
|
||||
'check.atStop': 'Departures at',
|
||||
'check.now': 'Current time',
|
||||
'check.nextAt': 'Next departure',
|
||||
'check.noMoreToday': 'No departures left today',
|
||||
'check.stopsCount': 'stops',
|
||||
'check.toStopDetail': 'View stop detail',
|
||||
'common.routes': 'routes',
|
||||
},
|
||||
|
||||
+44
-14
@@ -7,6 +7,8 @@
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&family=Prompt:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<link href="../../frontend-web-transit/web-transit/css/main-theme.css" rel="stylesheet">
|
||||
<link href="./_shared.css" rel="stylesheet">
|
||||
<link href="./vendor/leaflet/leaflet.css" rel="stylesheet">
|
||||
<link href="./map.css" rel="stylesheet">
|
||||
<link rel="icon" type="image/png" href="../.image/icons/minibus-512x512.png">
|
||||
<style>
|
||||
.mu-card.empty { width: 100%; padding: 16px; text-align: center; color: #6f7b95; background: #fff7fb; border: 1px dashed #f4c7df; }
|
||||
@@ -24,7 +26,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #7a4cc0 0%, #b07ce0 100%);
|
||||
background: linear-gradient(135deg, #8b5cf6 0%, #c084fc 100%);
|
||||
position: relative;
|
||||
}
|
||||
.mu-card-head::after { display: none; }
|
||||
@@ -36,12 +38,25 @@
|
||||
text-shadow: 0 4px 12px rgba(0,0,0,.25);
|
||||
letter-spacing: .02em;
|
||||
}
|
||||
/* zone tint overrides */
|
||||
.tag-sky ~ .mu-grid .mu-card-head,
|
||||
.mu-zone:has(.tag-sky) .mu-card-head { background: linear-gradient(135deg, #3071b8 0%, #6ea7e8 100%); }
|
||||
.mu-zone:has(.tag-purple) .mu-card-head { background: linear-gradient(135deg, #7a4cc0 0%, #b07ce0 100%); }
|
||||
.mu-zone:has(.tag-pink) .mu-card-head { background: linear-gradient(135deg, #bb3a78 0%, #f08bb9 100%); }
|
||||
.mu-zone:has(.tag-mint) .mu-card-head { background: linear-gradient(135deg, #1f8765 0%, #51c39c 100%); }
|
||||
/* zone tint — พื้นหลังการ์ดตามหมวดเส้นทาง (ตัวการ์ด = เฉดอ่อน / หัวการ์ด = เฉดสด) */
|
||||
.mu-zone:has(.tag-sky) { --zone-tint: #eff6ff; }
|
||||
.mu-zone:has(.tag-purple) { --zone-tint: #f5f3ff; }
|
||||
.mu-zone:has(.tag-pink) { --zone-tint: #fdf2f8; }
|
||||
.mu-zone:has(.tag-yellow) { --zone-tint: #fffbeb; }
|
||||
.mu-zone .mu-card,
|
||||
.mu-zone .mu-route-info { background: var(--zone-tint, #fff); }
|
||||
|
||||
.mu-zone:has(.tag-sky) .mu-card-head { background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%); }
|
||||
.mu-zone:has(.tag-purple) .mu-card-head { background: linear-gradient(135deg, #8b5cf6 0%, #c084fc 100%); }
|
||||
.mu-zone:has(.tag-pink) .mu-card-head { background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%); }
|
||||
.mu-zone:has(.tag-yellow) .mu-card-head { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); }
|
||||
/* การ์ดที่ยังไม่มีข้อมูล (is-empty): พื้นเทา + N/A แทนเลขสาย ไม่มีเงาตัวอักษร */
|
||||
.mu-card.is-empty,
|
||||
.mu-card.is-empty .mu-route-info { background: #f0f2f5; }
|
||||
.mu-card.is-empty .mu-card-head { background: #e4e7eb; }
|
||||
.mu-card.is-empty .mu-route-number { color: #5b636e !important; text-shadow: none !important; font-size: 42px !important; }
|
||||
.mu-card.is-empty { cursor: default; }
|
||||
.mu-card.is-empty:hover { transform: none; box-shadow: 0 4px 14px rgba(20,40,90,.06); }
|
||||
|
||||
.mu-route-info { padding: 14px 16px 16px; background: #fff; }
|
||||
.mu-route-name { margin: 0 0 10px; font-size: .95rem; color: #1f2a44; font-weight: 700; }
|
||||
@@ -87,6 +102,7 @@
|
||||
margin: 2px auto 0;
|
||||
}
|
||||
.mu-select-field { flex: 1 1 250px; min-width: 240px; text-align: left; }
|
||||
.mu-route-selector.single { max-width: 440px; }
|
||||
.mu-select-field > label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -163,17 +179,26 @@
|
||||
.mu-zone-tag.tag-sky { background: #dbeafe; color: #1d4ed8; }
|
||||
.mu-zone-tag.tag-pink { background: #fce7f3; color: #be185d; }
|
||||
.mu-zone-tag.tag-purple { background: #ede9fe; color: #6d28d9; }
|
||||
.mu-zone-tag.tag-mint { background: #d1fae5; color: #047857; }
|
||||
.mu-zone-tag.tag-yellow { background: #fdf1d3; color: #8a6100; }
|
||||
|
||||
/* คำอธิบายสีการ์ดตามหมวดเส้นทาง */
|
||||
.mu-legend { background: #fff; border: 1px solid #e9eef7; border-radius: 14px; padding: 16px 18px; margin-bottom: 26px; box-shadow: 0 4px 14px rgba(20,40,90,.05); }
|
||||
.mu-legend-title { margin: 0 0 12px; font-size: .95rem; font-weight: 800; color: #1f2a44; }
|
||||
.mu-legend-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 18px; }
|
||||
.mu-legend-list li { display: flex; align-items: center; gap: 9px; font-size: .86rem; color: #3d4a63; }
|
||||
.mu-legend-list .sw { width: 26px; height: 16px; border-radius: 4px; flex: none; border: 1px solid rgba(20,40,90,.12); }
|
||||
.sw-bangkok { background: linear-gradient(135deg, #3b82f6, #60a5fa); }
|
||||
.sw-interprov { background: linear-gradient(135deg, #8b5cf6, #c084fc); }
|
||||
.sw-inprov { background: linear-gradient(135deg, #ec4899, #f472b6); }
|
||||
.sw-municipal { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
|
||||
.sw-empty { background: #e4e7eb; }
|
||||
.mu-legend-note { margin: 12px 0 0; color: #6f7b95; font-size: .82rem; }
|
||||
.mu-zone-sub, .mu-zone-desc { color: #6f7b95; font-size: .88rem; margin: 0; }
|
||||
.mu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
|
||||
|
||||
/* Cards */
|
||||
a.mu-card { display: block; text-decoration: none; color: inherit; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 14px rgba(20,40,90,.06); transition: transform .15s, box-shadow .15s; }
|
||||
a.mu-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(20,40,90,.1); }
|
||||
/* Zone tints — apply via nth pattern using zone tag presence */
|
||||
.mu-zone:nth-of-type(1) .mu-card-head { background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%) !important; }
|
||||
.mu-zone:nth-of-type(2) .mu-card-head { background: linear-gradient(135deg, #8b5cf6 0%, #c084fc 100%) !important; }
|
||||
.mu-zone:nth-of-type(3) .mu-card-head { background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%) !important; }
|
||||
.mu-card { display: block; text-decoration: none; color: inherit; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 14px rgba(20,40,90,.06); transition: transform .15s, box-shadow .15s; }
|
||||
.mu-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(20,40,90,.1); }
|
||||
.mu-card-head { aspect-ratio: auto !important; height: 130px !important; display: flex !important; align-items: center; justify-content: center; position: relative; }
|
||||
.mu-card-head::after { display: none !important; }
|
||||
.mu-card-head .mu-route-number { position: static !important; color: #fff !important; font-size: 52px !important; font-weight: 900; text-shadow: 0 4px 12px rgba(0,0,0,.2) !important; letter-spacing: .02em; margin: 0; }
|
||||
@@ -185,6 +210,7 @@
|
||||
.badge-sky { background: #dbeafe; color: #1d4ed8; }
|
||||
.badge-pink { background: #fce7f3; color: #be185d; }
|
||||
.badge-mint { background: #d1fae5; color: #047857; }
|
||||
.badge-gray { background: #e8eaed; color: #5b636e; }
|
||||
.mu-route-chip-wrap { display:flex; gap: 8px; }
|
||||
|
||||
/* Summary stats */
|
||||
@@ -276,6 +302,8 @@
|
||||
<link rel="apple-touch-icon" href="../.image/icons/minibus-192x192.png">
|
||||
<script src="./pwa.js" defer></script>
|
||||
<script src="./i18n.js" defer></script>
|
||||
<script src="./vendor/leaflet/leaflet.js" defer></script>
|
||||
<script src="./map.js" defer></script>
|
||||
<script src="./router.js" defer></script>
|
||||
<link rel="stylesheet" href="./responsive.css">
|
||||
</head>
|
||||
@@ -361,6 +389,8 @@
|
||||
<path d="M12 9v4" />
|
||||
<path d="M12 17h.01" />
|
||||
</symbol>
|
||||
<symbol id="ic-share-2" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></symbol>
|
||||
<symbol id="ic-link" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></symbol>
|
||||
</svg>
|
||||
|
||||
<header class="mu-topbar">
|
||||
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/* =========================================================
|
||||
Atroute — แผนที่เส้นทาง (Leaflet)
|
||||
ธีมตาม DESIGN.md §5: เส้นทาง --green-700 หนา 5px · หมุดสี่เหลี่ยมมน
|
||||
เขียว = ป้ายตามเส้นทาง · อำพัน = ต้นทาง/ปลายทาง · ไม่มี drop shadow
|
||||
========================================================= */
|
||||
|
||||
.at-map {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
border: 1px solid #ddd5c0;
|
||||
border-radius: 8px;
|
||||
background: #f7f1e2; /* --paper — พื้นตอน tile ยังไม่มา/ออฟไลน์ */
|
||||
overflow: hidden;
|
||||
}
|
||||
.at-map.is-offline { background: repeating-linear-gradient(45deg, #f7f1e2 0 12px, #f2ebd8 12px 24px); }
|
||||
.at-map .leaflet-container { background: transparent; font-family: inherit; }
|
||||
|
||||
/* ปุ่ม zoom — ให้เข้าธีม (ขอบบาง ไม่มีเงา) */
|
||||
.at-map .leaflet-control-zoom a {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd5c0;
|
||||
background: #fffdf6;
|
||||
color: #14211a;
|
||||
font-weight: 700;
|
||||
box-shadow: none;
|
||||
}
|
||||
.at-map .leaflet-control-zoom a:hover { background: #e4efe4; color: #14532d; }
|
||||
.at-map .leaflet-bar { border: 0; box-shadow: none; }
|
||||
|
||||
/* attribution — เล็ก อ่านได้ ไม่ทับข้อมูล */
|
||||
.at-map .leaflet-control-attribution {
|
||||
background: rgba(255, 253, 246, .88);
|
||||
border-top-left-radius: 4px;
|
||||
font-size: .68rem;
|
||||
color: #6b7268;
|
||||
}
|
||||
|
||||
/* ---------- หมุด: สี่เหลี่ยมมน (ไม่ใช่หยดน้ำ ไม่มีเงา) ---------- */
|
||||
.at-pin-wrap { background: none; border: 0; }
|
||||
.at-pin {
|
||||
display: block;
|
||||
width: 14px; height: 14px;
|
||||
border-radius: 4px;
|
||||
border: 2px solid #fffdf6;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.at-pin.stop { background: #1f7a3d; } /* --green-500 */
|
||||
.at-pin.term { background: #f2a900; } /* --amber */
|
||||
.at-pin.mute { background: #6b7268; } /* --muted */
|
||||
/* ป้ายที่กำลังเปิดดูอยู่ — ใหญ่กว่าเพื่อให้เห็นชัด */
|
||||
.at-pin.here { background: #f2a900; width: 18px; height: 18px; border-width: 3px; }
|
||||
|
||||
.at-map .leaflet-tooltip {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd5c0;
|
||||
background: #fffdf6;
|
||||
color: #14211a;
|
||||
box-shadow: none;
|
||||
font-size: .78rem;
|
||||
padding: 5px 8px;
|
||||
}
|
||||
.at-map .leaflet-tooltip b { color: #14532d; }
|
||||
|
||||
/* ---------- legend (มุมซ้ายล่าง) ---------- */
|
||||
.at-legend {
|
||||
position: absolute;
|
||||
left: 10px; bottom: 10px;
|
||||
z-index: 500;
|
||||
background: rgba(255, 253, 246, .94);
|
||||
border: 1px solid #ddd5c0;
|
||||
border-radius: 4px;
|
||||
padding: 7px 10px;
|
||||
font-size: .74rem;
|
||||
color: #14211a;
|
||||
line-height: 1.65;
|
||||
pointer-events: none;
|
||||
}
|
||||
.at-legend i {
|
||||
display: inline-block;
|
||||
width: 14px; height: 5px;
|
||||
border-radius: 2px;
|
||||
margin-right: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.at-legend i.sq { width: 10px; height: 10px; border-radius: 3px; border: 2px solid #fffdf6; box-sizing: border-box; }
|
||||
|
||||
/* ---------- caption ใต้แผนที่ ---------- */
|
||||
.at-map-caption {
|
||||
margin: 9px 0 0;
|
||||
color: #6b7268;
|
||||
font-size: .82rem;
|
||||
}
|
||||
.at-map-caption b { color: #14211a; }
|
||||
.at-map-caption .at-offline { color: #8a6100; }
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.at-map { height: 380px; }
|
||||
}
|
||||
|
||||
/* ---------- popup บนแผนที่ (ป้าย/สถานี) ---------- */
|
||||
.at-map .leaflet-popup-content-wrapper {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd5c0;
|
||||
background: #fffdf6;
|
||||
box-shadow: none;
|
||||
color: #14211a;
|
||||
}
|
||||
.at-map .leaflet-popup-tip { background: #fffdf6; box-shadow: none; }
|
||||
.at-map .leaflet-popup-content { margin: 10px 12px; font-size: .8rem; }
|
||||
.at-pop { display: flex; flex-direction: column; gap: 3px; min-width: 150px; }
|
||||
.at-pop b { font-size: .86rem; color: #14532d; }
|
||||
.at-pop span { color: #6b7268; }
|
||||
.at-pop a { margin-top: 4px; color: #14532d; font-weight: 700; text-decoration: none; border-bottom: 1px solid #1f7a3d; align-self: flex-start; }
|
||||
.at-pop a:hover { color: #1f7a3d; }
|
||||
|
||||
/* ---------- รายการจุดจอดตามเส้นทาง + กม. จากต้นทาง ---------- */
|
||||
.at-km-wrap { margin-top: 14px; border-top: 1px solid #ddd5c0; padding-top: 12px; }
|
||||
.at-km-wrap > h3 { margin: 0 0 8px; font-size: .9rem; font-weight: 800; color: #14211a; }
|
||||
.at-km-wrap ul { list-style: none; margin: 0; padding: 0; }
|
||||
.at-km-wrap li + li { border-top: 1px dashed #ddd5c0; }
|
||||
.at-km-row { display: flex; align-items: center; gap: 9px; padding: 7px 2px; text-decoration: none; color: #14211a; font-size: .86rem; }
|
||||
.at-km-row:hover .at-km-name { color: #1f7a3d; text-decoration: underline; }
|
||||
.at-km-dot { width: 9px; height: 9px; border-radius: 3px; background: #f2a900; flex: none; }
|
||||
.at-km-name { flex: 1; font-weight: 600; }
|
||||
.at-km-val { font-variant-numeric: tabular-nums; font-weight: 700; color: #14532d; }
|
||||
|
||||
/* ---------- ป้ายใกล้ฉัน ---------- */
|
||||
.at-near-msg { margin: 14px 0 0; color: #6b7268; font-size: .86rem; }
|
||||
.at-near-err { color: #8a6100; }
|
||||
.at-near-list { list-style: none; margin: 12px 0 0; padding: 0; }
|
||||
.at-near-list li + li { border-top: 1px dashed #ddd5c0; }
|
||||
.at-near-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 2px; text-decoration: none; color: #14211a; align-items: center; }
|
||||
.at-near-row:hover .at-near-name { color: #1f7a3d; text-decoration: underline; }
|
||||
.at-near-name { font-weight: 700; font-size: .9rem; }
|
||||
.at-near-meta { grid-column: 1; color: #6b7268; font-size: .76rem; }
|
||||
.at-near-dist { grid-column: 2; grid-row: 1 / span 2; font-variant-numeric: tabular-nums; font-weight: 800; color: #14532d; white-space: nowrap; }
|
||||
@@ -0,0 +1,499 @@
|
||||
/* ============================================================
|
||||
Atroute — แผนที่เส้นทาง (Leaflet, vanilla)
|
||||
------------------------------------------------------------
|
||||
ข้อมูล:
|
||||
<base>geojson-web/<route_id>.geojson เส้นทางจริงจาก QGIS (WGS84)
|
||||
<base>busstop_list.json 154 ป้าย (มีพิกัด + buses-line)
|
||||
<base>stations.json 19 สถานีของเรา (13 มีพิกัด)
|
||||
<base>routes.json สาย ↔ สถานี
|
||||
|
||||
ธีม DESIGN.md §5: เส้นทาง --green-700 หนา 5px · หมุดสี่เหลี่ยมมน
|
||||
ออฟไลน์: ยังวาดเส้นทาง/หมุดจากข้อมูลในเครื่องได้โดยไม่ต้องมี tile
|
||||
|
||||
API:
|
||||
ATMap.route(el, '101') #/routes/:id
|
||||
ATMap.forStop(el, 'at_main_terminal') #/stops/:code
|
||||
ATMap.nearMe(button, resultEl) #/stops (ป้ายใกล้ฉัน)
|
||||
ทุกตัวรับ opts = { base, stopHref } (สำหรับหน้า static นอก SPA)
|
||||
============================================================ */
|
||||
window.ATMap = (function () {
|
||||
'use strict';
|
||||
|
||||
var DEF_BASE = '../resource/data/';
|
||||
var TILES = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
var ATTRIB = '© OpenStreetMap';
|
||||
var NEAR_M = 40; /* ป้ายอยู่ "บนเส้นทาง" ถ้าใกล้ ≤ 40 ม. */
|
||||
var STATION_NEAR_M = 80; /* สถานีอยู่ "ตามเส้นทาง" ถ้าใกล้ ≤ 80 ม. */
|
||||
var LINE_W = 5;
|
||||
var LINE_MAIN = '#14532d'; /* --green-700 */
|
||||
var SHADES = ['#14532d', '#1f7a3d', '#2f8f5b', '#4a7c59', '#166534'];
|
||||
var TH = { minLng: 97, maxLng: 103, minLat: 12, maxLat: 17.5 };
|
||||
var cache = {};
|
||||
|
||||
/* ---------- พื้นฐาน ---------- */
|
||||
function t(k, vars) { return window.I18N ? I18N.t(k, vars) : k; }
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
function num(v) {
|
||||
var n = typeof v === 'number' ? v : parseFloat(v);
|
||||
return isFinite(n) ? n : null;
|
||||
}
|
||||
function pointOf(o) {
|
||||
var lat = num(o && o.latitude), lng = num(o && o.longitude);
|
||||
return (lat === null || lng === null) ? null : [lng, lat];
|
||||
}
|
||||
function url(o, path) { return ((o && o.base) || DEF_BASE) + path; }
|
||||
function href(o, code) {
|
||||
return (o && o.stopHref) ? o.stopHref(code) : '#/stops/' + encodeURIComponent(code);
|
||||
}
|
||||
function fetchJSON(u) {
|
||||
return fetch(u, { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; });
|
||||
}
|
||||
|
||||
/* ---------- เรขาคณิต ---------- */
|
||||
function hav(a, b) {
|
||||
var R = 6371000, p1 = a[1] * Math.PI / 180, p2 = b[1] * Math.PI / 180;
|
||||
var dp = p2 - p1, dl = (b[0] - a[0]) * Math.PI / 180;
|
||||
var x = Math.sin(dp / 2) * Math.sin(dp / 2) + Math.cos(p1) * Math.cos(p2) * Math.sin(dl / 2) * Math.sin(dl / 2);
|
||||
return 2 * R * Math.asin(Math.sqrt(x));
|
||||
}
|
||||
function segDist(p, a, b) {
|
||||
var lat0 = (a[1] + b[1]) / 2 * Math.PI / 180, k = 111320;
|
||||
var ax = a[0] * Math.cos(lat0) * k, ay = a[1] * k;
|
||||
var bx = b[0] * Math.cos(lat0) * k, by = b[1] * k;
|
||||
var px = p[0] * Math.cos(lat0) * k, py = p[1] * k;
|
||||
var dx = bx - ax, dy = by - ay, L2 = dx * dx + dy * dy;
|
||||
if (!L2) return { d: Math.hypot(px - ax, py - ay), t: 0 };
|
||||
var u = Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / L2));
|
||||
return { d: Math.hypot(px - (ax + u * dx), py - (ay + u * dy)), t: u };
|
||||
}
|
||||
function linesOf(geom) {
|
||||
if (!geom) return [];
|
||||
var out = geom.type === 'LineString' ? [geom.coordinates] : (geom.coordinates || []);
|
||||
return out.map(function (l) {
|
||||
return l.filter(function (c) { return c[0] > TH.minLng && c[0] < TH.maxLng && c[1] > TH.minLat && c[1] < TH.maxLat; });
|
||||
}).filter(function (l) { return l.length >= 2; });
|
||||
}
|
||||
function flatten(geo) {
|
||||
return geo ? geo.features.reduce(function (a, f) { return a.concat(linesOf(f.geometry)); }, []) : [];
|
||||
}
|
||||
function lineLengthKm(lines) {
|
||||
var m = 0;
|
||||
lines.forEach(function (l) { for (var i = 1; i < l.length; i++) m += hav(l[i - 1], l[i]); });
|
||||
return m / 1000;
|
||||
}
|
||||
function toLatLngs(lines) {
|
||||
return lines.map(function (l) { return l.map(function (c) { return [c[1], c[0]]; }); });
|
||||
}
|
||||
/* ระยะสะสม (กม.) จากต้นทางถึงจุดที่ใกล้จุด p ที่สุด บนเส้นที่ยาวที่สุด */
|
||||
function kmFromStart(mainLine, p) {
|
||||
var best = { d: Infinity, km: 0 }, cum = 0;
|
||||
for (var i = 1; i < mainLine.length; i++) {
|
||||
var a = mainLine[i - 1], b = mainLine[i], seg = hav(a, b), r = segDist(p, a, b);
|
||||
if (r.d < best.d) best = { d: r.d, km: (cum + r.t * seg) / 1000 };
|
||||
cum += seg;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
function longest(lines) {
|
||||
return lines.slice().sort(function (a, b) {
|
||||
var la = 0, lb = 0;
|
||||
for (var i = 1; i < a.length; i++) la += hav(a[i - 1], a[i]);
|
||||
for (var j = 1; j < b.length; j++) lb += hav(b[j - 1], b[j]);
|
||||
return lb - la;
|
||||
})[0];
|
||||
}
|
||||
|
||||
/* ---------- โหลดข้อมูล (cache) ---------- */
|
||||
function loadGeo(id, o) {
|
||||
var key = 'geo:' + id;
|
||||
if (cache[key] === undefined) cache[key] = fetchJSON(url(o, 'geojson-web/' + id + '.geojson'));
|
||||
return Promise.resolve(cache[key]);
|
||||
}
|
||||
function loadJson(file, key, o) {
|
||||
if (cache[key] === undefined) cache[key] = fetchJSON(url(o, file));
|
||||
return Promise.resolve(cache[key]);
|
||||
}
|
||||
function stops(o) { return loadJson('busstop_list.json', 'stops', o).then(function (d) { return d || []; }); }
|
||||
function stationList(o) { return loadJson('stations.json', 'stations', o).then(function (d) { return (d || {}).stations || []; }); }
|
||||
|
||||
/* ---------- องค์ประกอบแผนที่ ---------- */
|
||||
function makeMap(el) {
|
||||
var offline = navigator.onLine === false;
|
||||
if (offline) el.classList.add('is-offline');
|
||||
var map = L.map(el, { zoomControl: true, attributionControl: true, scrollWheelZoom: false });
|
||||
map.setView([14.588, 100.455], 11);
|
||||
if (!offline) L.tileLayer(TILES, { maxZoom: 18, minZoom: 8, attribution: ATTRIB }).addTo(map);
|
||||
return { map: map, offline: offline };
|
||||
}
|
||||
function pinIcon(kind) {
|
||||
return L.divIcon({ className: 'at-pin-wrap', html: '<span class="at-pin ' + kind + '"></span>', iconSize: [16, 16], iconAnchor: [8, 8] });
|
||||
}
|
||||
function legend(el, rows) {
|
||||
var box = document.createElement('div');
|
||||
box.className = 'at-legend';
|
||||
rows.forEach(function (r) {
|
||||
var d = document.createElement('div'), sw = document.createElement('i');
|
||||
if (r.square) sw.className = 'sq';
|
||||
sw.style.background = r.color;
|
||||
d.appendChild(sw);
|
||||
d.appendChild(document.createTextNode(r.label));
|
||||
box.appendChild(d);
|
||||
});
|
||||
el.appendChild(box);
|
||||
}
|
||||
function caption(el, html) {
|
||||
var c = el.parentNode && el.parentNode.querySelector('.at-map-caption');
|
||||
if (c) c.innerHTML = html;
|
||||
}
|
||||
function fitAll(map, latlngs) {
|
||||
var all = [];
|
||||
latlngs.forEach(function (l) { all = all.concat(l); });
|
||||
if (!all.length) return;
|
||||
if (all.length === 1) { map.setView(all[0], 14); return; }
|
||||
map.fitBounds(L.latLngBounds(all), { padding: [24, 24] });
|
||||
}
|
||||
function mapsLink(lat, lng) {
|
||||
return 'https://www.google.com/maps/search/?api=1&query=' + lat + ',' + lng;
|
||||
}
|
||||
|
||||
/* ป้ายหยุดรถ: hover = ข้อมูลย่อ · คลิก = popup (ประเภท/กม./ด้านทาง/สายที่ผ่าน + Google Maps) */
|
||||
function drawShelters(map, hits, group) {
|
||||
hits.forEach(function (h) {
|
||||
var s = h.stop, pt = pointOf(s);
|
||||
if (!pt) return;
|
||||
var short = [];
|
||||
if (s.kilometer) short.push('กม. ' + 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.position) meta.push(s.position);
|
||||
if (s.type && s.place) meta.push(s.type); /* ซ้ำกับหัวข้อเมื่อไม่มีชื่อสถานที่ */
|
||||
if (meta.length) html += '<span>' + esc(meta.join(' · ')) + '</span>';
|
||||
var bl = s['buses-line'] || [];
|
||||
if (bl.length) html += '<span>' + esc(t('map.servedBy')) + ': <b>' + esc(bl.join(', ')) + '</b></span>';
|
||||
html += '<a href="' + mapsLink(s.latitude, s.longitude) + '" target="_blank" rel="noopener">' + esc(t('map.openInMaps')) + '</a>';
|
||||
html += '</div>';
|
||||
|
||||
L.marker([pt[1], pt[0]], { icon: pinIcon('stop') })
|
||||
.bindTooltip(esc(short.join(' · ')), { direction: 'top', offset: [0, -8] })
|
||||
.bindPopup(html, { closeButton: false, offset: [0, -6] })
|
||||
.addTo(group);
|
||||
});
|
||||
}
|
||||
|
||||
/* สถานีของเรา: ชื่อ + คลิกไปหน้ารายละเอียดป้าย (opts.stopHref) */
|
||||
function drawStations(map, hits, opts, group) {
|
||||
hits.forEach(function (h) {
|
||||
var s = h.station, pt = pointOf(s);
|
||||
if (!pt) return;
|
||||
var html = '<div class="at-pop"><b>' + esc(s.station_name_th) + '</b>';
|
||||
html += '<span>' + esc([s.city_th, s.province_th].filter(Boolean).join(' · ')) + '</span>';
|
||||
if (s.station_code) html += '<a href="' + esc(href(opts, s.station_code)) + '">' + esc(t('map.viewStopPage')) + '</a>';
|
||||
html += '</div>';
|
||||
L.marker([pt[1], pt[0]], { icon: pinIcon('term') })
|
||||
.bindTooltip('<b>' + esc(s.station_name_th) + '</b><br>' + esc(s.province_th || ''), { direction: 'top', offset: [0, -9] })
|
||||
.bindPopup(html, { closeButton: false, offset: [0, -6] })
|
||||
.addTo(group);
|
||||
});
|
||||
}
|
||||
|
||||
function stationsNear(lines, maxM, o) {
|
||||
return stationList(o).then(function (list) {
|
||||
var hits = [];
|
||||
list.forEach(function (s) {
|
||||
var pt = pointOf(s);
|
||||
if (!pt) return;
|
||||
var best = Infinity;
|
||||
for (var i = 0; i < lines.length && best > maxM; i++) {
|
||||
var l = lines[i];
|
||||
for (var j = 1; j < l.length; j++) {
|
||||
var r = segDist(pt, l[j - 1], l[j]);
|
||||
if (r.d < best) best = r.d;
|
||||
}
|
||||
}
|
||||
if (best <= maxM) hits.push({ station: s, dist: best });
|
||||
});
|
||||
return hits;
|
||||
});
|
||||
}
|
||||
function stopsNear(lines, o) {
|
||||
return stops(o).then(function (list) {
|
||||
var hits = [];
|
||||
list.forEach(function (s) {
|
||||
var pt = pointOf(s);
|
||||
if (!pt) return;
|
||||
var best = Infinity;
|
||||
for (var i = 0; i < lines.length && best > NEAR_M; i++) {
|
||||
var l = lines[i];
|
||||
for (var j = 1; j < l.length; j++) {
|
||||
var r = segDist(pt, l[j - 1], l[j]);
|
||||
if (r.d < best) best = r.d;
|
||||
}
|
||||
}
|
||||
if (best <= NEAR_M) hits.push({ stop: s, dist: Math.round(best) });
|
||||
});
|
||||
return hits;
|
||||
});
|
||||
}
|
||||
|
||||
/* รายการสถานีตามเส้นทาง พร้อม กม. จากต้นทาง */
|
||||
function renderKmList(el, list) {
|
||||
var host = document.getElementById(el);
|
||||
if (!host) return;
|
||||
host.innerHTML = '';
|
||||
if (!list.length) return;
|
||||
list.forEach(function (x) {
|
||||
var li = document.createElement('li');
|
||||
var a = document.createElement('a');
|
||||
a.href = x.href;
|
||||
a.className = 'at-km-row';
|
||||
a.innerHTML = '<span class="at-km-dot" aria-hidden="true"></span>' +
|
||||
'<span class="at-km-name">' + esc(x.name) + '</span>' +
|
||||
'<span class="at-km-val">' + x.km + ' ' + esc(t('map.km')) + '</span>';
|
||||
li.appendChild(a);
|
||||
host.appendChild(li);
|
||||
});
|
||||
var wrap = host.closest('.at-km-wrap');
|
||||
if (wrap) wrap.hidden = false;
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
#/routes/:id — เส้นทาง + สถานีตามเส้นทาง (พร้อม กม.) + ป้าย
|
||||
============================================================ */
|
||||
function route(el, routeId, opts) {
|
||||
if (!el || !window.L) return;
|
||||
opts = opts || {};
|
||||
|
||||
loadGeo(routeId, opts).then(function (geo) {
|
||||
var lines = flatten(geo);
|
||||
if (!lines.length) {
|
||||
el.classList.add('is-offline');
|
||||
caption(el, '<span class="at-offline">' + esc(t('map.empty')) + '</span>');
|
||||
return;
|
||||
}
|
||||
|
||||
var m = makeMap(el), map = m.map, group = L.layerGroup().addTo(map);
|
||||
var latlngs = toLatLngs(lines);
|
||||
|
||||
latlngs.forEach(function (l) {
|
||||
L.polyline(l, { color: LINE_MAIN, weight: LINE_W, opacity: 1, lineJoin: 'round', lineCap: 'round' }).addTo(group);
|
||||
});
|
||||
/* ต้นทาง/ปลายทาง */
|
||||
[[latlngs[0][0], t('map.origin')], [latlngs[latlngs.length - 1][latlngs[latlngs.length - 1].length - 1], t('map.destination')]]
|
||||
.forEach(function (e) {
|
||||
L.marker(e[0], { icon: pinIcon('term') })
|
||||
.bindTooltip(esc(e[1]), { direction: 'top', offset: [0, -8] }).addTo(group);
|
||||
});
|
||||
|
||||
Promise.all([stopsNear(lines, opts), stationsNear(lines, STATION_NEAR_M, opts)]).then(function (res) {
|
||||
var shelters = res[0], sts = res[1];
|
||||
drawShelters(map, shelters, group);
|
||||
drawStations(map, sts, opts, group);
|
||||
fitAll(map, latlngs);
|
||||
|
||||
/* รายการสถานี + กม. จากต้นทาง (เรียงตามเส้นทาง) */
|
||||
var main = longest(lines);
|
||||
var rows = sts.map(function (h) {
|
||||
var pt = pointOf(h.station);
|
||||
var k = kmFromStart(main, pt);
|
||||
return { name: h.station.station_name_th, km: k.km.toFixed(1), href: href(opts, h.station.station_code), _sort: k.km };
|
||||
}).sort(function (a, b) { return a._sort - b._sort; });
|
||||
renderKmList('route-map-list', rows);
|
||||
|
||||
var parts = ['<b>' + esc(routeId) + '</b> · ' + esc(t('map.captionRoute', { km: lineLengthKm(lines).toFixed(1), n: shelters.length }))];
|
||||
if (sts.length) parts.push(esc(t('map.stations')) + ' <b>' + sts.length + '</b>');
|
||||
if (m.offline) parts.push('<span class="at-offline">' + esc(t('map.offline')) + '</span>');
|
||||
caption(el, parts.join(' · '));
|
||||
});
|
||||
|
||||
legend(el, [
|
||||
{ color: LINE_MAIN, label: t('map.legendRoute') },
|
||||
{ color: '#1f7a3d', square: true, label: t('map.legendStop') },
|
||||
{ color: '#f2a900', square: true, label: t('map.legendTerminal') }
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
#/stops/:code — เส้นทางที่ผ่านป้ายนี้ + หมุดตัวป้าย
|
||||
============================================================ */
|
||||
function forStop(el, code, opts) {
|
||||
if (!el || !window.L) return;
|
||||
opts = opts || {};
|
||||
|
||||
Promise.all([stationList(opts), loadJson('routes.json', 'routes', opts)]).then(function (res) {
|
||||
var list = res[0], routes = (res[1] || {}).routes || [];
|
||||
var st = list.filter(function (s) { return s.station_code === code; })[0];
|
||||
var serving = st ? routes.filter(function (r) { return (r.station_ids || []).indexOf(st.station_id) !== -1; }) : [];
|
||||
var ids = serving.map(function (r) { return r.route_id; });
|
||||
|
||||
if (!st || !ids.length) {
|
||||
el.classList.add('is-offline');
|
||||
caption(el, '<span class="at-offline">' + esc(t(st ? 'map.noRoutesHere' : 'map.empty')) + '</span>');
|
||||
return;
|
||||
}
|
||||
|
||||
Promise.all(ids.map(function (id) { return loadGeo(id, opts); })).then(function (geos) {
|
||||
var m = makeMap(el), map = m.map, group = L.layerGroup().addTo(map);
|
||||
var all = [], allLines = [], legendRows = [], drawn = 0;
|
||||
|
||||
geos.forEach(function (g, idx) {
|
||||
var lines = flatten(g);
|
||||
if (!lines.length) return;
|
||||
var color = SHADES[drawn % SHADES.length];
|
||||
drawn++;
|
||||
allLines = allLines.concat(lines);
|
||||
toLatLngs(lines).forEach(function (l) {
|
||||
L.polyline(l, { color: color, weight: LINE_W, opacity: 1, lineJoin: 'round', lineCap: 'round' }).addTo(group);
|
||||
all.push(l);
|
||||
});
|
||||
legendRows.push({ color: color, label: t('map.route') + ' ' + ids[idx] });
|
||||
});
|
||||
|
||||
if (!all.length) {
|
||||
el.classList.add('is-offline');
|
||||
caption(el, '<span class="at-offline">' + esc(t('map.empty')) + '</span>');
|
||||
return;
|
||||
}
|
||||
|
||||
stopsNear(allLines, opts).then(function (shelters) {
|
||||
drawShelters(map, shelters, group);
|
||||
var stPt = pointOf(st);
|
||||
if (stPt) {
|
||||
L.marker([stPt[1], stPt[0]], { icon: pinIcon('here'), zIndexOffset: 1000 })
|
||||
.bindTooltip('<b>' + esc(st.station_name_th) + '</b><br>' + esc(t('map.thisStop')), { direction: 'top', offset: [0, -11] })
|
||||
.addTo(group);
|
||||
all.push([[stPt[1], stPt[0]]]);
|
||||
}
|
||||
fitAll(map, all);
|
||||
|
||||
var parts = [esc(t('map.captionStop', { r: drawn, n: shelters.length }))];
|
||||
parts.push(stPt ? esc(t('map.stationPinned')) : esc(t('map.noStationPin')));
|
||||
if (m.offline) parts.push('<span class="at-offline">' + esc(t('map.offline')) + '</span>');
|
||||
caption(el, parts.join(' · '));
|
||||
});
|
||||
|
||||
legendRows.push({ color: '#1f7a3d', square: true, label: t('map.legendStop') });
|
||||
legendRows.push({ color: '#f2a900', square: true, label: t('map.legendHere') });
|
||||
legend(el, legendRows);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
ป้ายใกล้ฉัน — geolocation → ป้ายที่ใกล้ที่สุด + แผนที่
|
||||
============================================================ */
|
||||
function nearMe(button, resultEl, opts) {
|
||||
if (!button || !resultEl) return;
|
||||
opts = opts || {};
|
||||
|
||||
if (!navigator.geolocation) {
|
||||
button.disabled = true;
|
||||
resultEl.innerHTML = '<p class="at-near-msg">' + esc(t('map.noGeo')) + '</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
button.addEventListener('click', function () {
|
||||
button.disabled = true;
|
||||
resultEl.hidden = false;
|
||||
resultEl.innerHTML = '<p class="at-near-msg">' + esc(t('map.locating')) + '</p>';
|
||||
|
||||
navigator.geolocation.getCurrentPosition(function (pos) {
|
||||
var me = [pos.coords.longitude, pos.coords.latitude];
|
||||
Promise.all([stops(opts), stationList(opts)]).then(function (res) {
|
||||
var items = [];
|
||||
res[0].forEach(function (s) {
|
||||
var pt = pointOf(s);
|
||||
if (pt) items.push({ kind: 'stop', o: s, pt: pt, d: hav(me, pt) });
|
||||
});
|
||||
res[1].forEach(function (s) {
|
||||
var pt = pointOf(s);
|
||||
if (pt) items.push({ kind: 'station', o: s, pt: pt, d: hav(me, pt) });
|
||||
});
|
||||
items.sort(function (a, b) { return a.d - b.d; });
|
||||
var near = items.slice(0, opts.limit || 8);
|
||||
renderNear(resultEl, near, me, opts);
|
||||
});
|
||||
}, function () {
|
||||
button.disabled = false;
|
||||
resultEl.innerHTML = '<p class="at-near-msg at-near-err">' + esc(t('map.geoDenied')) + '</p>';
|
||||
}, { enableHighAccuracy: true, timeout: 10000, maximumAge: 60000 });
|
||||
});
|
||||
}
|
||||
|
||||
function renderNear(host, near, me, opts) {
|
||||
host.hidden = false;
|
||||
host.innerHTML = '';
|
||||
|
||||
var box = document.createElement('div');
|
||||
box.className = 'at-map';
|
||||
box.id = 'near-me-map';
|
||||
host.appendChild(box);
|
||||
var cap = document.createElement('p');
|
||||
cap.className = 'at-map-caption';
|
||||
cap.textContent = t('map.nearestTitle');
|
||||
host.appendChild(cap);
|
||||
|
||||
var ul = document.createElement('ul');
|
||||
ul.className = 'at-near-list';
|
||||
near.forEach(function (x) {
|
||||
var li = document.createElement('li');
|
||||
var name = x.kind === 'station' ? x.o.station_name_th : (x.o.place || x.o.type);
|
||||
var meta = [];
|
||||
if (x.kind === 'station') meta.push(t('map.legendTerminal'));
|
||||
else {
|
||||
if (x.o.kilometer) meta.push('กม. ' + x.o.kilometer);
|
||||
if (x.o.position) meta.push(x.o.position);
|
||||
if (x.o.type && x.o.place) meta.push(x.o.type);
|
||||
}
|
||||
var bl = x.o['buses-line'] || [];
|
||||
if (bl.length) meta.push(t('map.servedBy') + ' ' + bl.join(', '));
|
||||
|
||||
var link = document.createElement('a');
|
||||
link.className = 'at-near-row';
|
||||
link.href = x.kind === 'station' ? href(opts, x.o.station_code) : mapsLink(x.o.latitude, x.o.longitude);
|
||||
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>';
|
||||
li.appendChild(link);
|
||||
ul.appendChild(li);
|
||||
});
|
||||
host.appendChild(ul);
|
||||
|
||||
drawNearMap(box, near, me);
|
||||
}
|
||||
|
||||
function drawNearMap(box, near, me) {
|
||||
var offline = navigator.onLine === false;
|
||||
var map = L.map(box, { zoomControl: true, attributionControl: true, scrollWheelZoom: false });
|
||||
map.setView([me[1], me[0]], 13);
|
||||
if (!offline) L.tileLayer(TILES, { maxZoom: 18, minZoom: 8, attribution: ATTRIB }).addTo(map);
|
||||
else box.classList.add('is-offline');
|
||||
|
||||
L.marker([me[1], me[0]], { icon: L.divIcon({ className: 'at-pin-wrap', html: '<span class="at-pin here"></span>', iconSize: [18, 18], iconAnchor: [9, 9] }) })
|
||||
.bindTooltip(esc(t('map.youAreHere')), { direction: 'top', offset: [0, -11] }).addTo(map);
|
||||
|
||||
var pts = [[me[1], me[0]]];
|
||||
near.forEach(function (x) {
|
||||
var kind = x.kind === 'station' ? 'term' : 'stop';
|
||||
L.marker([x.pt[1], x.pt[0]], { icon: pinIcon(kind) })
|
||||
.bindTooltip(esc(x.kind === 'station' ? x.o.station_name_th : (x.o.place || x.o.type)), { direction: 'top', offset: [0, -8] })
|
||||
.addTo(map);
|
||||
pts.push([x.pt[1], x.pt[0]]);
|
||||
});
|
||||
map.fitBounds(L.latLngBounds(pts), { padding: [28, 28] });
|
||||
}
|
||||
|
||||
return {
|
||||
route: route, forStop: forStop, nearMe: nearMe,
|
||||
NEAR_M: NEAR_M, LINE_MAIN: LINE_MAIN
|
||||
};
|
||||
})();
|
||||
+26
-85
@@ -43,6 +43,9 @@
|
||||
grid-template-columns: 1.3fr 1fr;
|
||||
margin-bottom: 26px;
|
||||
}
|
||||
/* ไม่มีรูปรถใน .image/routes/<รหัส>/ → การ์ดไม่เว้นช่องว่าง */
|
||||
#route-vehicle-card.no-photo { grid-template-columns: 1fr; }
|
||||
#route-vehicle-card.no-photo > .meta { grid-column: 1 / -1; }
|
||||
.mu-vehicle-card > img {
|
||||
grid-column: 1; width: 100%; height: 100%; min-height: 240px;
|
||||
object-fit: cover; display: block;
|
||||
@@ -119,115 +122,53 @@
|
||||
<main class="mu-page">
|
||||
<div class="mu-container">
|
||||
<p class="mu-breadcrumb"><a href="#/">หน้าแรก</a>/ <span data-i18n="nav.routes">รายละเอียดสายรถ</span></p>
|
||||
<h1 class="mu-page-title"><span class="mu-route-chip">101</span> อ่างทอง - ป่าโมก - อยุธยา</h1>
|
||||
<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="เลือกสายรถ">
|
||||
<option>สาย 101 - อ่างทอง-ป่าโมก-อยุธยา</option>
|
||||
<option>สาย 902 - กรุงเทพ-อ่างทอง สายเอเซีย</option>
|
||||
<option>สาย 15 - กรุงเทพ-อ่างทอง สายใน</option>
|
||||
<option>สาย 951 - กรุงเทพ-วิเศษ-สุพรรณ</option>
|
||||
<option>สาย 952 - กรุงเทพ-วิเศษชัยชาญ</option>
|
||||
<option>สาย 954 - กรุงเทพ-ท่าช้าง</option>
|
||||
<option>สาย 8 - กรุงเทพ-สรรคบุรี-ชัยนาท</option>
|
||||
<option>สาย 464 - สุพรรณ-อ่างทอง-สระบุรี</option>
|
||||
<option>สาย 641 - อ่างทอง-บ้านแพรก-ลพบุรี</option>
|
||||
<option>สาย 2194 - หัวเวียง-อยุธยา</option>
|
||||
<option>สาย 324 - อ่างทอง-วัดพิกุลทอง</option>
|
||||
<option>สาย 1011 - อ่างทอง-สีบัวทอง</option>
|
||||
<option>สาย 2231 - อ่างทอง-มหานาม</option>
|
||||
<option>สาย 999 - บขส.อ่างทอง สายเอเชีย-เหนือ</option>
|
||||
</select>
|
||||
<select aria-label="เลือกสถานี">
|
||||
<option>บขส.อ่างทอง</option>
|
||||
<option>สถานีขนส่งป่าโมก</option>
|
||||
<option>จุดขึ้นลงรถสองแถว 101 อยุธยา</option>
|
||||
<option>ตลาดเจ้าพรหม</option>
|
||||
</select>
|
||||
<select aria-label="เลือกสายรถ" id="route-select"></select>
|
||||
</form>
|
||||
|
||||
<!-- ============ รถประจำสาย + ติดต่อผู้ประกอบการ (การ์ดเดียว) ============ -->
|
||||
<section class="mu-vehicle-card" aria-label="รถประจำสายและติดต่อผู้ประกอบการ">
|
||||
<img src="../.image/routes/101/car.jpeg" alt="รถของสาย 101" loading="lazy" decoding="async">
|
||||
<!-- รูปรถ/คำอธิบาย/QR/เบอร์โทร: เติมจาก resource/data/captions/caption<รหัสสาย>.json + routes.json -->
|
||||
<section class="mu-vehicle-card" aria-label="รถประจำสายและติดต่อผู้ประกอบการ" 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>
|
||||
<h2>รถปรับอากาศ · ไม่สูบบุหรี่</h2>
|
||||
<p>40 ที่นั่ง · ให้บริการตลอดเส้นทางอ่างทอง–ป่าโมก–อยุธยา พร้อมที่วางสัมภาระและแอร์เย็นฉ่ำ</p>
|
||||
</div>
|
||||
<div class="mu-vehicle-contact">
|
||||
<div class="mu-contact-item">
|
||||
<span class="ic-wrap tone-green"><svg class="ic" aria-hidden="true"><use href="#ic-message-circle"/></svg></span>
|
||||
<div class="txt">
|
||||
<strong>LINE Official</strong>
|
||||
<span>ติดตามข่าวสาย 101 · เลื่อนเวลา · ไม่มีรถ</span>
|
||||
</div>
|
||||
<img class="mu-qr-img" src="../.image/qrcode/101.png" alt="LINE QR สาย 101" loading="lazy" decoding="async">
|
||||
</div>
|
||||
<a class="mu-contact-item" href="tel:+66649639025">
|
||||
<span class="ic-wrap"><svg class="ic" aria-hidden="true"><use href="#ic-phone"/></svg></span>
|
||||
<div class="txt">
|
||||
<strong>โทรสอบถาม</strong>
|
||||
<span>+66 64 963 9025</span>
|
||||
</div>
|
||||
</a>
|
||||
<h2 id="route-vehicle-title" hidden></h2>
|
||||
<p id="route-vehicle-desc" hidden></p>
|
||||
</div>
|
||||
<div class="mu-vehicle-contact" id="route-contact"></div>
|
||||
</section>
|
||||
|
||||
<!-- ============ สรุปเส้นทาง ============ -->
|
||||
<section class="mu-summary" aria-label="สรุปเส้นทาง">
|
||||
<div class="mu-container">
|
||||
<div class="mu-summary-grid">
|
||||
<div class="mu-stat tag-purple"><h3>4</h3><p>จุดจอดหลัก</p></div>
|
||||
<div class="mu-stat tag-sky"><h3>2</h3><p>จังหวัดที่ผ่าน</p></div>
|
||||
<div class="mu-stat tag-mint"><h3>15</h3><p>รอบต่อวัน</p></div>
|
||||
<div class="mu-stat tag-pink"><h3>09:10</h3><p>รอบถัดไป</p></div>
|
||||
<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>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ============ แผนที่เส้นทาง ============ -->
|
||||
<!-- ============ แผนที่เส้นทาง (Leaflet + GeoJSON จาก QGIS) ============ -->
|
||||
<section class="mu-zone" aria-label="แผนที่เส้นทาง">
|
||||
<div class="mu-zone-head">
|
||||
<span class="mu-zone-tag tag-sky" data-i18n="route.mapTitle">เส้นทางเดินรถ</span>
|
||||
<p class="mu-zone-desc">สาย 101 · บขส.อ่างทอง → ตลาดเจ้าพรหม</p>
|
||||
<p class="mu-zone-desc" data-i18n="route.mapDesc">เส้นทางจริงจากข้อมูล GIS · ป้ายหยุดรถตามเส้นทาง</p>
|
||||
</div>
|
||||
<div class="mu-map-card">
|
||||
<svg viewBox="0 0 400 190" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="แผนที่เส้นทางสาย 101">
|
||||
<defs>
|
||||
<linearGradient id="mapBg" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#f0ebff"/>
|
||||
<stop offset="100%" stop-color="#eef6ff"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="400" height="190" fill="url(#mapBg)" rx="12"/>
|
||||
<path d="M 60 110 C 130 40 200 160 340 80" stroke="#d8c7f8" stroke-width="9" fill="none" stroke-linecap="round" opacity=".35"/>
|
||||
<path d="M 60 110 C 130 40 200 160 340 80" stroke="#7a4cc0" stroke-width="4" fill="none" stroke-linecap="round"/>
|
||||
<g>
|
||||
<circle cx="60" cy="110" r="16" fill="#7a4cc0"/>
|
||||
<circle cx="60" cy="110" r="10" fill="#fff"/>
|
||||
<text x="60" y="145" text-anchor="middle" font-size="12" fill="#1f2a44" font-weight="700">บขส.อ่างทอง</text>
|
||||
<text x="60" y="160" text-anchor="middle" font-size="10" fill="#6f7b95">ต้นทาง</text>
|
||||
</g>
|
||||
<g>
|
||||
<circle cx="170" cy="70" r="16" fill="#3071b8"/>
|
||||
<circle cx="170" cy="70" r="10" fill="#fff"/>
|
||||
<text x="170" y="45" text-anchor="middle" font-size="12" fill="#1f2a44" font-weight="700">สถานีป่าโมก</text>
|
||||
<text x="170" y="30" text-anchor="middle" font-size="10" fill="#6f7b95">จุดเปลี่ยน</text>
|
||||
</g>
|
||||
<g>
|
||||
<circle cx="270" cy="130" r="16" fill="#1f8765"/>
|
||||
<circle cx="270" cy="130" r="10" fill="#fff"/>
|
||||
<text x="270" y="165" text-anchor="middle" font-size="12" fill="#1f2a44" font-weight="700">จุดขึ้นลงรถสองแถว</text>
|
||||
<text x="270" y="180" text-anchor="middle" font-size="10" fill="#6f7b95">ผ่านทาง</text>
|
||||
</g>
|
||||
<g>
|
||||
<circle cx="340" cy="80" r="16" fill="#bb3a78"/>
|
||||
<circle cx="340" cy="80" r="10" fill="#fff"/>
|
||||
<text x="340" y="55" text-anchor="middle" font-size="12" fill="#1f2a44" font-weight="700">ตลาดเจ้าพรหม</text>
|
||||
<text x="340" y="40" text-anchor="middle" font-size="10" fill="#6f7b95">ปลายทาง</text>
|
||||
</g>
|
||||
</svg>
|
||||
<div class="at-map" id="route-map" role="region" aria-label="แผนที่เส้นทางเดินรถ"></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>
|
||||
<ul id="route-map-list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script src="./partials/busDetail.init.js"></script>
|
||||
@@ -0,0 +1,216 @@
|
||||
/* ============================================================
|
||||
busDetail.init.js — เติมข้อมูลหน้า #/routes/<รหัสสาย> จาก JSON
|
||||
------------------------------------------------------------
|
||||
ชื่อสาย/ตัวเลือก/เบอร์โทร resource/data/routes.json
|
||||
รูปรถ/คำอธิบาย/QR resource/data/captions/caption<รหัส>.json
|
||||
รอบต่อวัน/รอบถัดไป resource/data/schedules.json
|
||||
แผนที่ resource/data/geojson-web/<รหัส>.geojson (ATMap)
|
||||
รูปรถ: .image/routes/<รหัส>/ ตั้งชื่อไฟล์ขึ้นต้นด้วย car หรือ boat
|
||||
QR: .image/qrcode/<รหัส>.png
|
||||
============================================================ */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var DATA = '../resource/data/';
|
||||
var IMG_ROUTES = '../.image/routes/';
|
||||
var IMG_QR = '../.image/qrcode/';
|
||||
var CAR_NAMES = ['car', 'boat']; /* ลำดับชื่อไฟล์รูปรถที่ยอมรับ */
|
||||
var CAR_EXTS = ['jpeg', 'jpg', 'webp', 'png'];
|
||||
var QR_EXTS = ['png', 'PNG', 'jpg', 'JPG', 'jpeg', 'JPEG', 'webp'];
|
||||
var FALLBACK_ID = '101'; /* เข้า #/routes ตรง ๆ ไม่มีรหัสสาย */
|
||||
|
||||
function $(id) { return document.getElementById(id); }
|
||||
function t(k, v) { return window.I18N ? I18N.t(k, v) : k; }
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
function fetchJSON(u) {
|
||||
return fetch(u, { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; });
|
||||
}
|
||||
function setText(id, s) {
|
||||
var el = $(id);
|
||||
if (!el) return;
|
||||
var v = (s == null ? '' : String(s)).trim();
|
||||
el.textContent = v;
|
||||
el.hidden = !v;
|
||||
}
|
||||
/* ตัวเลขสรุป: ไม่มีข้อมูลให้แสดง – เพื่อให้การ์ดทั้ง 4 ช่องเท่ากัน */
|
||||
function setStat(id, s) {
|
||||
var el = $(id);
|
||||
if (!el) return;
|
||||
var v = (s == null ? '' : String(s)).trim();
|
||||
el.textContent = v || '–';
|
||||
el.hidden = false;
|
||||
}
|
||||
function uniq(a) { return a.filter(function (u, i) { return u && a.indexOf(u) === i; }); }
|
||||
|
||||
/* ลองโหลดรูปตามลำดับ — พลาดก็ลองตัวถัดไป ไม่มีเลยก็ซ่อน (ไม่ทิ้งไอคอนรูปแตก) */
|
||||
function tryImage(img, urls, alt, onDone) {
|
||||
var i = 0;
|
||||
img.alt = alt || '';
|
||||
img.loading = 'eager'; /* ห้าม lazy: รูปที่ซ่อนอยู่จะไม่ถูกโหลด แล้ว onload ไม่ยิง */
|
||||
img.onload = function () { img.hidden = false; if (onDone) onDone(true); };
|
||||
img.onerror = function () {
|
||||
if (i >= urls.length) { img.hidden = true; if (onDone) onDone(false); return; }
|
||||
img.src = urls[i++];
|
||||
};
|
||||
img.onerror();
|
||||
}
|
||||
function vehicleUrls(rid, cap) {
|
||||
var base = IMG_ROUTES + encodeURIComponent(rid) + '/', out = [];
|
||||
if (cap && cap.vehicle_image) out.push(base + cap.vehicle_image);
|
||||
CAR_NAMES.forEach(function (n) { CAR_EXTS.forEach(function (e) { out.push(base + n + '.' + e); }); });
|
||||
return uniq(out);
|
||||
}
|
||||
function qrUrls(rid, cap) {
|
||||
var out = [];
|
||||
if (cap && cap.qr_image) out.push(IMG_QR + cap.qr_image);
|
||||
QR_EXTS.forEach(function (e) { out.push(IMG_QR + encodeURIComponent(rid) + '.' + e); });
|
||||
return uniq(out);
|
||||
}
|
||||
|
||||
/* จัดรูปแบบเบอร์ให้อ่านง่าย — รองรับทั้งมือถือ (+66xx xxx xxxx) และเบอร์บ้าน (0-xxxx-xxxx) */
|
||||
function fmtPhone(p) {
|
||||
var raw = String(p == null ? '' : p).trim();
|
||||
var digits = raw.replace(/[^\d+]/g, '');
|
||||
if (!digits) return '';
|
||||
var intl = /^\+?66/.test(digits);
|
||||
var nat = intl ? digits.replace(/^\+?66/, '') : digits;
|
||||
if (nat.charAt(0) === '0') return nat.slice(0, 1) + ' ' + nat.slice(1, 5) + ' ' + nat.slice(5);
|
||||
if (nat.length === 9) return '+66 ' + nat.slice(0, 2) + ' ' + nat.slice(2, 5) + ' ' + nat.slice(5);
|
||||
if (nat.length === 8) return '+66 ' + nat.slice(0, 2) + ' ' + nat.slice(2);
|
||||
return raw;
|
||||
}
|
||||
function telHref(p) { return 'tel:' + String(p == null ? '' : p).replace(/[^\d+]/g, ''); }
|
||||
|
||||
/* ---------- การ์ดติดต่อ (LINE + QR + เบอร์โทรทุกเบอร์จาก routes.json) ---------- */
|
||||
function buildContact(rid, route, cap) {
|
||||
var host = $('route-contact');
|
||||
if (!host) return;
|
||||
host.innerHTML = '';
|
||||
|
||||
var line = document.createElement('div');
|
||||
line.className = 'mu-contact-item';
|
||||
line.innerHTML =
|
||||
'<span class="ic-wrap tone-green"><svg class="ic" aria-hidden="true"><use href="#ic-message-circle"/></svg></span>' +
|
||||
'<div class="txt"><strong>LINE Official</strong><span id="route-line-note"></span></div>';
|
||||
var qr = document.createElement('img');
|
||||
qr.className = 'mu-qr-img';
|
||||
qr.loading = 'lazy';
|
||||
qr.decoding = 'async';
|
||||
qr.hidden = true;
|
||||
line.appendChild(qr);
|
||||
host.appendChild(line);
|
||||
|
||||
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) {
|
||||
line.hidden = !ok && !note; /* ไม่มีทั้ง QR และข้อความ = ไม่ต้องแสดงแถวนี้ */
|
||||
host.hidden = line.hidden && !phones.length; /* ไม่มีอะไรจะแสดงเลย */
|
||||
});
|
||||
|
||||
phones.forEach(function (p) {
|
||||
var a = document.createElement('a');
|
||||
a.className = 'mu-contact-item';
|
||||
a.href = telHref(p);
|
||||
a.innerHTML =
|
||||
'<span class="ic-wrap"><svg class="ic" aria-hidden="true"><use href="#ic-phone"/></svg></span>' +
|
||||
'<div class="txt"><strong>' + esc(t('route.call')) + '</strong><span>' + esc(fmtPhone(p)) + '</span></div>';
|
||||
host.appendChild(a);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- รอบต่อวัน / รอบถัดไป จาก schedules.json ---------- */
|
||||
function toMin(hhmm) {
|
||||
var a = String(hhmm).split(':');
|
||||
return (parseInt(a[0], 10) || 0) * 60 + (parseInt(a[1], 10) || 0);
|
||||
}
|
||||
function nextTrip(times) {
|
||||
if (!times.length) return null;
|
||||
var uniqTimes = times.slice().sort();
|
||||
var now = new Date(), mins = now.getHours() * 60 + now.getMinutes();
|
||||
for (var i = 0; i < uniqTimes.length; i++) {
|
||||
if (toMin(uniqTimes[i]) >= mins) return uniqTimes[i];
|
||||
}
|
||||
return uniqTimes[0]; /* หมดรอบของวันนี้ → รอบแรกของวันถัดไป */
|
||||
}
|
||||
function loadTrips(rid) {
|
||||
return fetchJSON(DATA + 'schedules.json').then(function (d) {
|
||||
var recs = (d && (d.schedules || d)) || [];
|
||||
var out = [];
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) === String(rid)) out = out.concat(r.departure_times || []);
|
||||
});
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
||||
function fillVehicle(rid, route, cap) {
|
||||
cap = cap || {};
|
||||
var img = $('route-vehicle-img');
|
||||
var card = $('route-vehicle-card');
|
||||
if (img) {
|
||||
tryImage(img, vehicleUrls(rid, cap), 'รถของสาย ' + rid, function (ok) {
|
||||
if (card) card.classList.toggle('no-photo', !ok);
|
||||
});
|
||||
}
|
||||
setText('route-vehicle-title', cap.vehicle_title);
|
||||
setText('route-vehicle-desc', cap.vehicle_desc);
|
||||
buildContact(rid, route, cap);
|
||||
}
|
||||
|
||||
function init() {
|
||||
var params = (window.__route && window.__route.params) || {};
|
||||
fetchJSON(DATA + 'routes.json').then(function (d) {
|
||||
var list = (d && d.routes) || [];
|
||||
if (!list.length) return;
|
||||
|
||||
var want = String(params.routeId || '');
|
||||
var route = list.filter(function (r) { return String(r.route_id) === want; })[0] ||
|
||||
list.filter(function (r) { return String(r.route_id) === FALLBACK_ID; })[0] || list[0];
|
||||
var rid = String(route.route_id);
|
||||
|
||||
/* หัวเรื่อง (chip + ชื่อสาย) */
|
||||
setText('route-chip', rid);
|
||||
setText('route-title', route.route_name_th);
|
||||
document.title = 'Atroute — สาย ' + rid + (route.route_name_th ? ' ' + route.route_name_th : '');
|
||||
|
||||
/* dropdown: เติมจาก routes.json (ลำดับตามไฟล์) + เปลี่ยนแล้วไปสายนั้น */
|
||||
var sel = $('route-select');
|
||||
if (sel) {
|
||||
sel.innerHTML = '';
|
||||
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 : '');
|
||||
sel.appendChild(o);
|
||||
});
|
||||
sel.value = rid;
|
||||
sel.addEventListener('change', function () {
|
||||
window.location.hash = '#/routes/' + encodeURIComponent(sel.value);
|
||||
});
|
||||
}
|
||||
|
||||
/* สรุปเส้นทาง */
|
||||
setStat('stat-stops', route.station_ids ? route.station_ids.length : '');
|
||||
setStat('stat-provinces', route.province_ids ? route.province_ids.length : '');
|
||||
loadTrips(rid).then(function (times) {
|
||||
setStat('stat-trips', times.length ? String(times.length) : '');
|
||||
setStat('stat-next', nextTrip(times) || '');
|
||||
});
|
||||
|
||||
/* รูปรถ/คำอธิบาย/QR/เบอร์โทร */
|
||||
fetchJSON(DATA + 'captions/caption' + encodeURIComponent(rid) + '.json').then(function (cap) {
|
||||
fillVehicle(rid, route, cap);
|
||||
});
|
||||
|
||||
/* แผนที่เส้นทาง */
|
||||
var mapEl = $('route-map');
|
||||
if (mapEl && window.ATMap) ATMap.route(mapEl, rid);
|
||||
});
|
||||
}
|
||||
|
||||
init();
|
||||
})();
|
||||
@@ -78,12 +78,6 @@
|
||||
<option>สาย 2231 - อ่างทอง-มหานาม</option>
|
||||
<option>สาย 999 - บขส.อ่างทอง สายเอเชีย-เหนือ</option>
|
||||
</select>
|
||||
<select aria-label="เลือกสถานี">
|
||||
<option>บขส.อ่างทอง</option>
|
||||
<option>สถานีขนส่งป่าโมก</option>
|
||||
<option>จุดขึ้นลงรถสองแถว 101 อยุธยา</option>
|
||||
<option>ตลาดเจ้าพรหม</option>
|
||||
</select>
|
||||
<a class="mu-back-btn" href="#/"><span data-i18n="common.backHome">← กลับหน้าแรก</span></a>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -436,15 +436,29 @@
|
||||
<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>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var btn = document.getElementById('near-me-btn');
|
||||
var out = document.getElementById('near-me-result');
|
||||
if (!btn || !out || !window.ATMap) return;
|
||||
ATMap.nearMe(btn, out, { limit: 8 });
|
||||
})();
|
||||
</script>
|
||||
<script src="./partials/busStop.search.js"></script>
|
||||
<script src="./partials/busStop.init.js"></script>
|
||||
+14
-163
@@ -127,10 +127,10 @@
|
||||
<div class="mu-blob three"></div>
|
||||
<div class="mu-container mu-hero-content">
|
||||
<span class="mu-badge"><svg class="ic" aria-hidden="true"><use href="#ic-clock"/></svg> <span data-i18n="cta.check">เช็กเวลาเดินรถ</span></span>
|
||||
<h1><span data-i18n="check.title">ตารางเวลาเดินรถ</span><br><span class="mu-gradient-text">สาย 101 · อ่างทอง–อยุธยา</span></h1>
|
||||
<p class="mu-hero-lead" data-i18n="check.lead">เลือกสายรถและสถานี แล้วดูรอบรถทุกจุดจอดในหน้าเดียว</p>
|
||||
<h1><span data-i18n="check.title">ตารางเวลาเดินรถ</span><br><span class="mu-gradient-text" id="check-hero-route"></span></h1>
|
||||
<p class="mu-hero-lead" data-i18n="check.lead">เลือกสายรถ แล้วดูรอบรถทุกจุดจอดในหน้าเดียว</p>
|
||||
|
||||
<div class="mu-route-selector">
|
||||
<div class="mu-route-selector single">
|
||||
<div class="mu-select-field">
|
||||
<label for="check-route-select">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><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"/></svg>
|
||||
@@ -138,46 +138,11 @@
|
||||
</label>
|
||||
<div class="mu-select-box">
|
||||
<svg class="mu-select-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><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"/></svg>
|
||||
<select id="check-route-select" data-i18n-attr="aria-label:route.selectRoute">
|
||||
<option>สาย 101 - อ่างทอง-ป่าโมก-อยุธยา</option>
|
||||
<option>สาย 902 - กรุงเทพ-อ่างทอง สายเอเซีย</option>
|
||||
<option>สาย 15 - กรุงเทพ-อ่างทอง สายใน</option>
|
||||
<option>สาย 951 - กรุงเทพ-วิเศษ-สุพรรณ</option>
|
||||
<option>สาย 952 - กรุงเทพ-วิเศษชัยชาญ</option>
|
||||
<option>สาย 954 - กรุงเทพ-ท่าช้าง</option>
|
||||
<option>สาย 8 - กรุงเทพ-สรรคบุรี-ชัยนาท</option>
|
||||
<option>สาย 464 - สุพรรณ-อ่างทอง-สระบุรี</option>
|
||||
<option>สาย 641 - อ่างทอง-บ้านแพรก-ลพบุรี</option>
|
||||
<option>สาย 2194 - หัวเวียง-อยุธยา</option>
|
||||
<option>สาย 324 - อ่างทอง-วัดพิกุลทอง</option>
|
||||
<option>สาย 1011 - อ่างทอง-สีบัวทอง</option>
|
||||
<option>สาย 2231 - อ่างทอง-มหานาม</option>
|
||||
<option>สาย 999 - บขส.อ่างทอง สายเอเชีย-เหนือ</option>
|
||||
</select>
|
||||
<svg class="mu-select-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span class="mu-select-arrow" aria-hidden="true"><svg class="ic"><use href="#ic-arrow-right"/></svg></span>
|
||||
|
||||
<div class="mu-select-field">
|
||||
<label for="check-station-select">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><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"/></svg>
|
||||
<span data-i18n="route.selectStation">เลือกสถานี</span>
|
||||
</label>
|
||||
<div class="mu-select-box">
|
||||
<svg class="mu-select-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><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"/></svg>
|
||||
<select id="check-station-select" data-i18n-attr="aria-label:route.selectStation">
|
||||
<option>บขส.อ่างทอง</option>
|
||||
<option>สถานีขนส่งป่าโมก</option>
|
||||
<option>จุดขึ้นลงรถสองแถว 101 อยุธยา</option>
|
||||
<option>ตลาดเจ้าพรหม</option>
|
||||
</select>
|
||||
<select id="check-route-select" data-i18n-attr="aria-label:route.selectRoute"></select>
|
||||
<svg class="mu-select-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mu-select-hint" id="check-hint" aria-live="polite"></p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -185,10 +150,10 @@
|
||||
<section class="mu-summary" aria-label="สรุปเส้นทาง">
|
||||
<div class="mu-container">
|
||||
<div class="mu-summary-grid">
|
||||
<div class="mu-stat tag-purple"><h3>4</h3><p data-i18n="check.kpiStops">จุดจอดหลัก</p></div>
|
||||
<div class="mu-stat tag-sky"><h3>2</h3><p data-i18n="check.kpiProvince">จังหวัดที่ผ่าน</p></div>
|
||||
<div class="mu-stat tag-mint"><h3>15</h3><p data-i18n="check.kpiTrips">รอบต่อวัน</p></div>
|
||||
<div class="mu-stat tag-pink"><h3>09:10</h3><p data-i18n="check.kpiNext">รอบถัดไป</p></div>
|
||||
<div class="mu-stat tag-purple"><h3 id="check-stat-stops">–</h3><p data-i18n="check.kpiStops">จุดจอดหลัก</p></div>
|
||||
<div class="mu-stat tag-sky"><h3 id="check-stat-provinces">–</h3><p data-i18n="check.kpiProvince">จังหวัดที่ผ่าน</p></div>
|
||||
<div class="mu-stat tag-mint"><h3 id="check-stat-trips">–</h3><p data-i18n="check.kpiTrips">รอบต่อวัน</p></div>
|
||||
<div class="mu-stat tag-pink"><h3 id="check-stat-next">–</h3><p data-i18n="check.kpiNext">รอบถัดไป</p></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -199,128 +164,14 @@
|
||||
<div class="mu-zone">
|
||||
<div class="mu-zone-head">
|
||||
<span class="mu-zone-tag tag-purple" data-i18n="check.scheduleAll">ตารางเวลาเดินรถทุกจุดจอด</span>
|
||||
<p class="mu-zone-desc">สาย 101 · บขส.อ่างทอง → ตลาดเจ้าพรหม · 4 จุดจอด</p>
|
||||
<p class="mu-zone-desc" id="check-zone-desc"></p>
|
||||
<p class="mu-zone-desc" id="check-now-line"></p>
|
||||
</div>
|
||||
|
||||
<ul class="mu-schedule-list">
|
||||
<li>
|
||||
<details class="mu-stop-card" open>
|
||||
<summary>
|
||||
<span class="mu-stop-head tone-purple">
|
||||
<span class="mu-stop-kind"><svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg> <span data-i18n="route.origin">ต้นทาง</span></span>
|
||||
<span class="mu-stop-title">
|
||||
<strong>บขส.อ่างทอง</strong>
|
||||
<small>อ่างทอง</small>
|
||||
</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-body">
|
||||
<p class="mu-stop-sub">ตารางเดินรถ ณ บขส.อ่างทอง</p>
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">07:30</div><div class="mu-time-chip">08:20</div>
|
||||
<div class="mu-time-chip next">09:10</div><div class="mu-time-chip">10:00</div>
|
||||
<div class="mu-time-chip">10:50</div><div class="mu-time-chip">11:50</div>
|
||||
<div class="mu-time-chip">13:00</div><div class="mu-time-chip">14:00</div>
|
||||
<div class="mu-time-chip">15:00</div>
|
||||
</div>
|
||||
<div class="mu-inline-actions">
|
||||
<a class="mu-btn ghost" href="#/stops/at_main_terminal?route=101" data-i18n="check.toStopDetail">ไปหน้ารายละเอียดจุดจอด</a>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<details class="mu-stop-card" open>
|
||||
<summary>
|
||||
<span class="mu-stop-head tone-sky">
|
||||
<span class="mu-stop-kind"><svg class="ic" aria-hidden="true"><use href="#ic-refresh-cw"/></svg> <span data-i18n="route.transfer">จุดเปลี่ยน</span></span>
|
||||
<span class="mu-stop-title">
|
||||
<strong>สถานีขนส่งป่าโมก</strong>
|
||||
<small>อ่างทอง</small>
|
||||
</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-body">
|
||||
<p class="mu-stop-sub">ไปอ่างทอง <span class="mu-direction-tag" data-i18n="check.direction">ทิศทาง</span></p>
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">07:30</div><div class="mu-time-chip">08:20</div>
|
||||
<div class="mu-time-chip">09:10</div><div class="mu-time-chip">10:00</div>
|
||||
<div class="mu-time-chip">10:50</div><div class="mu-time-chip">11:40</div>
|
||||
<div class="mu-time-chip">12:30</div><div class="mu-time-chip">13:20</div>
|
||||
<div class="mu-time-chip">14:10</div><div class="mu-time-chip">15:00</div>
|
||||
<div class="mu-time-chip">15:50</div><div class="mu-time-chip">16:40</div>
|
||||
<div class="mu-time-chip">17:30</div><div class="mu-time-chip">18:30</div>
|
||||
</div>
|
||||
<p class="mu-stop-sub" style="margin-top:14px;">ไปอยุธยา <span class="mu-direction-tag" data-i18n="check.direction">ทิศทาง</span></p>
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">08:00</div><div class="mu-time-chip">08:50</div>
|
||||
<div class="mu-time-chip">09:40</div><div class="mu-time-chip">10:30</div>
|
||||
<div class="mu-time-chip">11:20</div><div class="mu-time-chip">12:20</div>
|
||||
<div class="mu-time-chip">13:30</div><div class="mu-time-chip">14:30</div>
|
||||
<div class="mu-time-chip">15:30</div>
|
||||
</div>
|
||||
<p class="mu-schedule-note"><svg class="ic" aria-hidden="true"><use href="#ic-triangle-alert"/></svg> เวลารถเปลี่ยนทุกวัน โดยเฉพาะวันหยุด</p>
|
||||
<div class="mu-inline-actions">
|
||||
<a class="mu-btn ghost" href="#/stops/pa_mok_terminal?route=101" data-i18n="check.toStopDetail">ไปหน้ารายละเอียดจุดจอด</a>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<details class="mu-stop-card" open>
|
||||
<summary>
|
||||
<span class="mu-stop-head tone-mint">
|
||||
<span class="mu-stop-kind"><svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg> <span data-i18n="route.pass">ผ่านทาง</span></span>
|
||||
<span class="mu-stop-title">
|
||||
<strong>จุดขึ้นลงรถสองแถว 101 อยุธยา-ป่าโมก-อ่างทอง</strong>
|
||||
<small>อยุธยา</small>
|
||||
</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-body">
|
||||
<p class="mu-stop-sub" data-i18n="route.empty">ยังไม่มีข้อมูลตารางเวลา</p>
|
||||
<div class="mu-inline-actions">
|
||||
<a class="mu-btn ghost" href="#/stops/route_101_stop_ayutthaya?route=101" data-i18n="check.toStopDetail">ไปหน้ารายละเอียดจุดจอด</a>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<details class="mu-stop-card" open>
|
||||
<summary>
|
||||
<span class="mu-stop-head tone-pink">
|
||||
<span class="mu-stop-kind"><svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg> <span data-i18n="route.destination">ปลายทาง</span></span>
|
||||
<span class="mu-stop-title">
|
||||
<strong>ตลาดเจ้าพรหม</strong>
|
||||
<small>อยุธยา</small>
|
||||
</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-body">
|
||||
<p class="mu-stop-sub">ตารางเดินรถ ณ ตลาดเจ้าพรหม (อยุธยา)</p>
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">06:30</div><div class="mu-time-chip">07:20</div>
|
||||
<div class="mu-time-chip">08:10</div><div class="mu-time-chip next">09:00</div>
|
||||
<div class="mu-time-chip">09:50</div><div class="mu-time-chip">10:40</div>
|
||||
<div class="mu-time-chip">11:30</div><div class="mu-time-chip">12:20</div>
|
||||
<div class="mu-time-chip">13:10</div><div class="mu-time-chip">14:00</div>
|
||||
<div class="mu-time-chip">14:50</div><div class="mu-time-chip">15:40</div>
|
||||
<div class="mu-time-chip">16:30</div><div class="mu-time-chip">17:30</div>
|
||||
</div>
|
||||
<div class="mu-inline-actions">
|
||||
<a class="mu-btn ghost" href="#/stops/jaoprom_market?route=101" data-i18n="check.toStopDetail">ไปหน้ารายละเอียดจุดจอด</a>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- การ์ดจุดจอด + ชิปเวลา: สร้างจาก resource/data/schedules.json (checkSchedule.init.js) -->
|
||||
<ul class="mu-schedule-list" id="check-schedule-list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script src="./partials/checkSchedule.init.js"></script>
|
||||
@@ -0,0 +1,277 @@
|
||||
/* ============================================================
|
||||
checkSchedule.init.js — หน้า #/check/<รหัสสาย>
|
||||
------------------------------------------------------------
|
||||
ดึงข้อมูลจริง:
|
||||
resource/data/routes.json ชื่อสาย / ตัวเลือก / station_ids / province_ids
|
||||
resource/data/stations.json ชื่อจุดจอด + จังหวัด + รหัสป้าย
|
||||
resource/data/schedules.json เวลาออกรถ (แยกตามจุดจอด/ทิศทาง) + หมายเหตุ
|
||||
|
||||
การไฮไลต์ (ตามเวลาบนเครื่องผู้ใช้):
|
||||
- ไฮไลต์ "เที่ยวถัดไป" = เที่ยวแรกที่เวลายังไม่ผ่าน (>= เวลาปัจจุบัน)
|
||||
- เลยเที่ยวสุดท้ายของวันแล้ว → ไม่ไฮไลต์เลย
|
||||
- หลังเที่ยงคืน เวลาปัจจุบันน้อยกว่าเที่ยวแรก → เที่ยวแรกของวันถูกไฮไลต์เอง
|
||||
- ตรวจซ้ำทุก 30 วินาที (และตอนสลับสาย/กลับเข้าแท็บ)
|
||||
============================================================ */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var DATA = '../resource/data/';
|
||||
var FALLBACK_ID = '101';
|
||||
var REFRESH_MS = 30000;
|
||||
var TONES = { origin: 'tone-purple', transfer: 'tone-sky', pass: 'tone-mint', destination: 'tone-pink' };
|
||||
|
||||
/* นโยบายการแสดงจุดจอดบนหน้าเช็กเวลา
|
||||
false = แสดงทุกจุดใน routes.json → station_ids (จุดที่ยังไม่มีตารางจะขึ้นการ์ด "ยังไม่มีข้อมูลตารางเวลา")
|
||||
← ค่าเริ่มต้น: ตรงกับดีไซน์เดิม (หน้าเดิมโชว์จุดที่ยังไม่มีตารางพร้อมข้อความนี้)
|
||||
true = แสดงเฉพาะจุดที่มี record ใน schedules.json (กระดานเวลาล้วน ๆ) */
|
||||
var ONLY_STOPS_WITH_SCHEDULE = false;
|
||||
|
||||
var sections = []; /* [{ chips:[], times:[], station }] */
|
||||
var netRoute = null; /* routes.json ของสายที่แสดงอยู่ */
|
||||
var timer = null;
|
||||
|
||||
function $(id) { return document.getElementById(id); }
|
||||
function t(k, v) { return window.I18N ? I18N.t(k, v) : k; }
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
function fetchJSON(u) {
|
||||
return fetch(u, { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; });
|
||||
}
|
||||
function toMin(hhmm) {
|
||||
var a = String(hhmm).split(':');
|
||||
return (parseInt(a[0], 10) || 0) * 60 + (parseInt(a[1], 10) || 0);
|
||||
}
|
||||
function nowMin() { var d = new Date(); return d.getHours() * 60 + d.getMinutes(); }
|
||||
function hhmm(min) {
|
||||
var h = Math.floor(min / 60), m = min % 60;
|
||||
return (h < 10 ? '0' : '') + h + ':' + (m < 10 ? '0' : '') + m;
|
||||
}
|
||||
function setStat(id, s) {
|
||||
var el = $(id);
|
||||
if (!el) return;
|
||||
var v = (s == null ? '' : String(s)).trim();
|
||||
el.textContent = v || '–';
|
||||
}
|
||||
|
||||
/* ---------- จำแนกประเภทจุดจอดจากข้อมูล + ลำดับในเส้นทาง ---------- */
|
||||
function kindOf(st, i, n) {
|
||||
if (i === 0) return { key: 'route.origin', icon: 'ic-map-pin', tone: TONES.origin };
|
||||
if (i === n - 1) return { key: 'route.destination', icon: 'ic-map-pin', tone: TONES.destination };
|
||||
if (st && st.station_type === 'main_terminal') return { key: 'route.transfer', icon: 'ic-refresh-cw', tone: TONES.transfer };
|
||||
return { key: 'route.pass', icon: 'ic-map-pin', tone: TONES.pass };
|
||||
}
|
||||
|
||||
/* ---------- สร้างการ์ดจุดจอด ---------- */
|
||||
function renderList(listEl, route, groups) {
|
||||
listEl.innerHTML = '';
|
||||
sections = [];
|
||||
|
||||
groups.forEach(function (g, i) {
|
||||
var kind = kindOf(g.st, i, groups.length);
|
||||
var li = document.createElement('li');
|
||||
var det = document.createElement('details');
|
||||
det.className = 'mu-stop-card';
|
||||
det.open = true;
|
||||
|
||||
var sum = document.createElement('summary');
|
||||
sum.innerHTML =
|
||||
'<span class="mu-stop-head ' + kind.tone + '">' +
|
||||
'<span class="mu-stop-kind"><svg class="ic" aria-hidden="true"><use href="#' + kind.icon + '"/></svg> <span>' + esc(t(kind.key)) + '</span></span>' +
|
||||
'<span class="mu-stop-title"><strong>' + esc(g.name) + '</strong><small>' + esc(g.city) + '</small></span>' +
|
||||
'<span class="mu-stop-chevron">\u2304</span>' +
|
||||
'</span>';
|
||||
det.appendChild(sum);
|
||||
|
||||
var body = document.createElement('div');
|
||||
body.className = 'mu-stop-body';
|
||||
|
||||
if (!g.recs.length) {
|
||||
var none = document.createElement('p');
|
||||
none.className = 'mu-stop-sub';
|
||||
none.textContent = t('route.empty');
|
||||
body.appendChild(none);
|
||||
}
|
||||
|
||||
g.recs.forEach(function (r) {
|
||||
var times = (r.departure_times || []).slice();
|
||||
|
||||
/* ไม่มีเวลาเลย (เช่น สาย 999: departure_times = []) → บอกว่าไม่มีข้อมูล ไม่ต้องมีบรรทัดลอย */
|
||||
if (!times.length) {
|
||||
var empty = document.createElement('p');
|
||||
empty.className = 'mu-stop-sub';
|
||||
empty.textContent = t('route.empty');
|
||||
body.appendChild(empty);
|
||||
return;
|
||||
}
|
||||
|
||||
var sub = document.createElement('p');
|
||||
sub.className = 'mu-stop-sub';
|
||||
sub.innerHTML = r.direction_note
|
||||
? esc(r.direction_note) + ' <span class="mu-direction-tag">' + esc(t('check.direction')) + '</span>'
|
||||
: esc(t('check.atStop')) + ' ' + esc(g.name);
|
||||
body.appendChild(sub);
|
||||
|
||||
var grid = document.createElement('div');
|
||||
grid.className = 'mu-time-grid';
|
||||
var chips = [];
|
||||
times.forEach(function (tm) {
|
||||
var c = document.createElement('div');
|
||||
c.className = 'mu-time-chip';
|
||||
c.textContent = tm;
|
||||
grid.appendChild(c);
|
||||
chips.push(c);
|
||||
});
|
||||
body.appendChild(grid);
|
||||
sections.push({ chips: chips, times: times, station: g.name });
|
||||
|
||||
if (r.schedule_note) {
|
||||
var note = document.createElement('p');
|
||||
note.className = 'mu-schedule-note';
|
||||
note.innerHTML = '<svg class="ic" aria-hidden="true"><use href="#ic-triangle-alert"/></svg> ' + esc(r.schedule_note);
|
||||
body.appendChild(note);
|
||||
}
|
||||
});
|
||||
|
||||
if (g.code) {
|
||||
var act = document.createElement('div');
|
||||
act.className = 'mu-inline-actions';
|
||||
var a = document.createElement('a');
|
||||
a.className = 'mu-btn ghost';
|
||||
a.href = '#/stops/' + encodeURIComponent(g.code) + '?route=' + encodeURIComponent(route.route_id);
|
||||
a.textContent = t('check.toStopDetail');
|
||||
act.appendChild(a);
|
||||
body.appendChild(act);
|
||||
}
|
||||
|
||||
det.appendChild(body);
|
||||
li.appendChild(det);
|
||||
listEl.appendChild(li);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- ไฮไลต์เที่ยวถัดไป + บรรทัดเวลาปัจจุบัน ---------- */
|
||||
function refreshHighlights() {
|
||||
var nowm = nowMin();
|
||||
var next = null; /* เที่ยวถัดไปที่เร็วที่สุดในทุกจุดจอด */
|
||||
|
||||
sections.forEach(function (sec) {
|
||||
sec.chips.forEach(function (c) { c.classList.remove('next'); });
|
||||
for (var i = 0; i < sec.times.length; i++) {
|
||||
var m = toMin(sec.times[i]);
|
||||
if (m >= nowm) { /* เที่ยวแรกที่ยังไม่ผ่าน */
|
||||
sec.chips[i].classList.add('next');
|
||||
if (next === null || m < next.m) next = { m: m, time: sec.times[i], station: sec.station };
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setStat('check-stat-next', next ? next.time : '');
|
||||
|
||||
var line = $('check-now-line');
|
||||
if (!line) return;
|
||||
var clock = '<svg class="ic" aria-hidden="true"><use href="#ic-clock"/></svg> ';
|
||||
var body = esc(t('check.now')) + ' <b>' + hhmm(nowm) + '</b>';
|
||||
if (next) body += ' · ' + esc(t('check.nextAt')) + ' <b>' + esc(next.time) + '</b> (' + esc(next.station) + ')';
|
||||
else if (sections.length) body += ' · <b>' + esc(t('check.noMoreToday')) + '</b>';
|
||||
line.innerHTML = clock + body;
|
||||
}
|
||||
|
||||
/* ---------- โหลด + แสดงผล ---------- */
|
||||
function init() {
|
||||
var params = (window.__route && window.__route.params) || {};
|
||||
var query = (window.__route && window.__route.query) || {};
|
||||
var want = String(params.routeId || query.route || '');
|
||||
|
||||
Promise.all([
|
||||
fetchJSON(DATA + 'routes.json'),
|
||||
fetchJSON(DATA + 'stations.json'),
|
||||
fetchJSON(DATA + 'schedules.json')
|
||||
]).then(function (res) {
|
||||
var routes = (res[0] || {}).routes || [];
|
||||
var sts = (res[1] || {}).stations || [];
|
||||
var recs = (res[2] || {}).schedules || res[2] || [];
|
||||
if (!routes.length) return;
|
||||
|
||||
var route = routes.filter(function (r) { return String(r.route_id) === want; })[0] ||
|
||||
routes.filter(function (r) { return String(r.route_id) === FALLBACK_ID; })[0] || routes[0];
|
||||
var rid = String(route.route_id);
|
||||
netRoute = route;
|
||||
|
||||
var byId = {};
|
||||
sts.forEach(function (s) { byId[s.station_id] = s; });
|
||||
|
||||
/* ตัวเลือกสายรถ (จาก routes.json) */
|
||||
var sel = $('check-route-select');
|
||||
if (sel) {
|
||||
sel.innerHTML = '';
|
||||
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 : '');
|
||||
sel.appendChild(o);
|
||||
});
|
||||
sel.value = rid;
|
||||
sel.addEventListener('change', function () {
|
||||
window.location.hash = '#/check/' + encodeURIComponent(sel.value);
|
||||
});
|
||||
}
|
||||
|
||||
/* Hero + คำอธิบายโซน */
|
||||
var hero = $('check-hero-route');
|
||||
if (hero) hero.textContent = 'สาย ' + rid + (route.route_name_th ? ' · ' + route.route_name_th : '');
|
||||
|
||||
/* จัดกลุ่มตามลำดับจุดจอดของสาย แล้วต่อด้วยจุดที่เหลือ (ถ้ามีข้อมูล) */
|
||||
var order = (route.station_ids || []).slice();
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) === rid && order.indexOf(r.station_id) === -1) order.push(r.station_id);
|
||||
});
|
||||
|
||||
var groups = order.map(function (sid) {
|
||||
var st = byId[sid] || null;
|
||||
return {
|
||||
sid: sid,
|
||||
st: st,
|
||||
name: st ? st.station_name_th : 'จุดจอด ' + 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; })
|
||||
};
|
||||
}).filter(function (g) {
|
||||
return !ONLY_STOPS_WITH_SCHEDULE || g.recs.length;
|
||||
});
|
||||
|
||||
var listEl = $('check-schedule-list');
|
||||
if (listEl) renderList(listEl, route, groups);
|
||||
|
||||
var desc = $('check-zone-desc');
|
||||
if (desc) {
|
||||
var names = groups.map(function (g) { return g.name; });
|
||||
desc.textContent = 'สาย ' + rid + ' · ' +
|
||||
(names.length > 1 ? names[0] + ' \u2192 ' + names[names.length - 1] + ' · ' : '') +
|
||||
groups.length + ' ' + t('check.stopsCount');
|
||||
}
|
||||
|
||||
/* KPI */
|
||||
setStat('check-stat-stops', groups.length); /* นับจุดจอดที่แสดงจริง (ให้ตรงกับรายการด้านล่าง) */
|
||||
setStat('check-stat-provinces', route.province_ids ? route.province_ids.length : '');
|
||||
var trips = 0;
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) === rid) trips += (r.departure_times || []).length;
|
||||
});
|
||||
setStat('check-stat-trips', trips ? String(trips) : '');
|
||||
|
||||
refreshHighlights();
|
||||
if (timer) clearInterval(timer);
|
||||
timer = setInterval(refreshHighlights, REFRESH_MS);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('visibilitychange', function () {
|
||||
if (!document.hidden) refreshHighlights();
|
||||
});
|
||||
|
||||
init();
|
||||
})();
|
||||
+45
-125
@@ -1,3 +1,26 @@
|
||||
<style>
|
||||
/* ปุ่มแชร์ลิงก์สั้น — มุมล่างขวา ต่อจากการ์ดหมวดเส้นทาง */
|
||||
.mu-share-row { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin: 22px 0 44px; }
|
||||
.mu-share-btn {
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
padding: 10px 16px; border: 1px solid #7a4cc0; border-radius: 8px;
|
||||
background: #7a4cc0; color: #fff; font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer;
|
||||
}
|
||||
.mu-share-btn:hover { background: #6a3cae; }
|
||||
.mu-share-btn:focus-visible { outline: 2px solid #2b2f42; outline-offset: 2px; }
|
||||
.mu-share-btn .ic { width: 18px; height: 18px; }
|
||||
.mu-share-status { margin: 0; font-size: .82rem; line-height: 1.7; color: #4b5570; text-align: right; }
|
||||
.mu-share-status:empty { display: none; }
|
||||
.mu-share-url { display: inline-block; padding: 2px 6px; border: 1px solid #e7e2f6; border-radius: 8px; background: #faf9ff; font-size: .8rem; }
|
||||
.mu-share-line { display: inline-block; margin-left: 6px; font-weight: 700; color: #06c755; text-decoration: none; }
|
||||
.mu-share-line:hover { text-decoration: underline; }
|
||||
@media (max-width: 560px) {
|
||||
.mu-share-row { align-items: stretch; }
|
||||
.mu-share-btn { justify-content: center; }
|
||||
.mu-share-status { text-align: left; }
|
||||
}
|
||||
</style>
|
||||
|
||||
<section class="mu-hero">
|
||||
<img class="mu-hero-map" src="../.image/network/overview-map.png" alt="" aria-hidden="true" fetchpriority="high" decoding="async">
|
||||
<div class="mu-blob one"></div>
|
||||
@@ -59,134 +82,31 @@
|
||||
<main class="mu-main">
|
||||
<div class="mu-container">
|
||||
|
||||
<!-- หมวด 1: เข้ากรุงเทพฯ -->
|
||||
<section class="mu-zone">
|
||||
<div class="mu-zone-head">
|
||||
<span class="mu-zone-tag tag-sky" data-i18n="zone.bangkok">หมวดเส้นทางเข้ากรุงเทพฯ</span>
|
||||
<p class="mu-zone-desc"><span data-i18n="zone.bangkokDesc">เส้นทางเชื่อมต่อกรุงเทพมหานคร</span> · 6 <span data-i18n="common.routes">เส้นทาง</span></p>
|
||||
</div>
|
||||
<div class="mu-grid">
|
||||
<a class="mu-card" data-route="902" href="#/routes/902">
|
||||
<div class="mu-card-head"><p class="mu-route-number">902</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">กรุงเทพ-อ่างทอง สายเอเซีย</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-purple"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="15" href="#/routes/15">
|
||||
<div class="mu-card-head"><p class="mu-route-number">15</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">กรุงเทพ-อ่างทอง สายใน</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-sky"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="951" href="#/routes/951">
|
||||
<div class="mu-card-head"><p class="mu-route-number">951</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">กรุงเทพ-วิเศษ-สุพรรณ</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-pink"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="952" href="#/routes/952">
|
||||
<div class="mu-card-head"><p class="mu-route-number">952</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">กรุงเทพ-วิเศษชัยชาญ</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-mint"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="954" href="#/routes/954">
|
||||
<div class="mu-card-head"><p class="mu-route-number">954</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">กรุงเทพ-ท่าช้าง</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-purple"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="8" href="#/routes/8">
|
||||
<div class="mu-card-head"><p class="mu-route-number">8</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">กรุงเทพ-สรรคบุรี-ชัยนาท</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-sky"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- คำอธิบายสีการ์ดตามหมวดเส้นทาง -->
|
||||
<section class="mu-legend" aria-label="คำอธิบายสีการ์ดตามหมวดเส้นทาง">
|
||||
<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>
|
||||
<li><span class="sw sw-interprov" aria-hidden="true"></span><span data-i18n="legend.interprov">หมวดเส้นทางระหว่างจังหวัด — การ์ดสีม่วง</span></li>
|
||||
<li><span class="sw sw-inprov" aria-hidden="true"></span><span data-i18n="legend.inprov">หมวดเส้นทางภายในจังหวัด — การ์ดสีชมพู</span></li>
|
||||
<li><span class="sw sw-municipal" aria-hidden="true"></span><span data-i18n="legend.municipal">หมวดเส้นทางภายในเทศบาล — การ์ดสีเหลืองอ่อน</span></li>
|
||||
<li><span class="sw sw-empty" aria-hidden="true"></span><span data-i18n="legend.empty">ยังไม่มีข้อมูล — การ์ดสีเทา แสดง N/A แทนเลขสาย</span></li>
|
||||
</ul>
|
||||
<p class="mu-legend-note" data-i18n="legend.note">อ่างทองยังไม่มีรถหมวด 1 (เส้นทางภายในเทศบาล) จึงแสดงการ์ดสีเทาและใช้ N/A แทนตัวเลขสายเส้นทาง</p>
|
||||
</section>
|
||||
|
||||
<!-- หมวด 3: ระหว่างจังหวัด -->
|
||||
<section class="mu-zone">
|
||||
<div class="mu-zone-head">
|
||||
<span class="mu-zone-tag tag-purple" data-i18n="zone.interprov">หมวดเส้นทางระหว่างจังหวัด</span>
|
||||
<p class="mu-zone-desc"><span data-i18n="zone.interprovDesc">เส้นทางเชื่อมต่อจังหวัดใกล้เคียง</span> · 4 <span data-i18n="common.routes">เส้นทาง</span></p>
|
||||
</div>
|
||||
<div class="mu-grid">
|
||||
<a class="mu-card" data-route="101" href="#/routes/101">
|
||||
<div class="mu-card-head"><p class="mu-route-number">101</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">อ่างทอง-ป่าโมก-อยุธยา</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-purple"><svg class="ic" aria-hidden="true"><use href="#ic-alarm-clock"/></svg> <span data-i18n="card.nextTrip">เที่ยวถัดไป</span> 09:30</span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="464" href="#/routes/464">
|
||||
<div class="mu-card-head"><p class="mu-route-number">464</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">สุพรรณ-อ่างทอง-สระบุรี</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-sky"><svg class="ic" aria-hidden="true"><use href="#ic-alarm-clock"/></svg> <span data-i18n="card.nextTrip">เที่ยวถัดไป</span> 18:00</span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="641" href="#/routes/641">
|
||||
<div class="mu-card-head"><p class="mu-route-number">641</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">อ่างทอง-บ้านแพรก-ลพบุรี</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-pink"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="2194" href="#/routes/2194">
|
||||
<div class="mu-card-head"><p class="mu-route-number">2194</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">หัวเวียง-อยุธยา</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-mint"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- หมวด 4: ภายในจังหวัด -->
|
||||
<section class="mu-zone">
|
||||
<div class="mu-zone-head">
|
||||
<span class="mu-zone-tag tag-pink" data-i18n="zone.inprov">หมวดเส้นทางภายในจังหวัด</span>
|
||||
<p class="mu-zone-desc"><span data-i18n="zone.inprovDesc">เส้นทางภายในจังหวัดอ่างทอง</span> · 4 <span data-i18n="common.routes">เส้นทาง</span></p>
|
||||
</div>
|
||||
<div class="mu-grid">
|
||||
<a class="mu-card" data-route="324" href="#/routes/324">
|
||||
<div class="mu-card-head"><p class="mu-route-number">324</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">อ่างทอง-วัดพิกุลทอง</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-pink"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="1011" href="#/routes/1011">
|
||||
<div class="mu-card-head"><p class="mu-route-number">1011</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">อ่างทอง-สีบัวทอง</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-mint"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="2231" href="#/routes/2231">
|
||||
<div class="mu-card-head"><p class="mu-route-number">2231</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">อ่างทอง-มหานาม</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-purple"><svg class="ic" aria-hidden="true"><use href="#ic-check"/></svg> <span data-i18n="card.schedule">ดูตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
<a class="mu-card" data-route="999" href="#/routes/999">
|
||||
<div class="mu-card-head"><p class="mu-route-number">999</p></div>
|
||||
<div class="mu-route-info">
|
||||
<p class="mu-route-name">บขส.อ่างทอง สายเอเชีย-เหนือ</p>
|
||||
<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-sky"><svg class="ic" aria-hidden="true"><use href="#ic-hourglass"/></svg> <span data-i18n="card.noSchedule">ยังไม่มีตาราง</span></span></div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
<!-- หมวดเส้นทางทั้งหมด: สร้างจาก resource/data/route_groups.json + routes.json (+ routes_municipal.json)
|
||||
ที่มา: ui/partials/home.init.js → initRouteZones() — ห้าม hardcode การ์ดในไฟล์นี้ -->
|
||||
<div id="route-zones"></div>
|
||||
|
||||
<!-- ปุ่มแชร์ลิงก์สั้น (มุมล่างขวา ต่อจากการ์ดหมวดเส้นทางภายในจังหวัด) -->
|
||||
<div class="mu-share-row">
|
||||
<button type="button" class="mu-share-btn" id="share-btn">
|
||||
<svg class="ic" aria-hidden="true"><use href="#ic-share-2"/></svg>
|
||||
<span data-i18n="share.label">แชร์ลิงก์สั้น</span>
|
||||
</button>
|
||||
<p class="mu-share-status" id="share-status" aria-live="polite"></p>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
+341
-50
@@ -4,7 +4,11 @@
|
||||
// แหล่งข้อมูลเดียว (source of truth) — อย่า hardcode รายชื่อจังหวัด/สถานีไว้ในไฟล์นี้
|
||||
var DATA_URL = {
|
||||
provinces: '../resource/data/provinces.json',
|
||||
stations: '../resource/data/stations.json'
|
||||
stations: '../resource/data/stations.json',
|
||||
routeGroups: '../resource/data/route_groups.json',
|
||||
routes: '../resource/data/routes.json',
|
||||
routesMunicipal: '../resource/data/routes_municipal.json',
|
||||
schedules: '../resource/data/schedules.json'
|
||||
};
|
||||
|
||||
// จังหวัดเริ่มต้น (home province ของเว็บนี้) — ใช้เป็นค่า default ของ hero + ตัวเลือก
|
||||
@@ -16,6 +20,11 @@
|
||||
.catch(function () { return null; });
|
||||
}
|
||||
|
||||
/* สถานะที่ผู้ใช้เลือก (ใช้กรองการ์ด + สร้างลิงก์แชร์) */
|
||||
var state = { provinceId: null, provinceName: DEFAULT_PROVINCE, stationCode: '', stationId: null };
|
||||
var PROVINCES = []; /* [{ province_id, province_name_th }] */
|
||||
var STATIONS = []; /* [{ station_id, station_code, station_name_th, province_th }] */
|
||||
|
||||
function initHomeSelectors() {
|
||||
var provinceSelect = document.getElementById('province-select');
|
||||
var stationSelect = document.getElementById('station-select');
|
||||
@@ -24,80 +33,117 @@
|
||||
if (!provinceSelect || !stationSelect) return;
|
||||
|
||||
var tr = window.I18N ? window.I18N.t : function (k) { return k; };
|
||||
var q = (window.__route && window.__route.query) || {}; /* ลิงก์สั้น: #/?s=<รหัสสถานี> หรือ #/?p=<province_id> */
|
||||
|
||||
// โหลดจังหวัด + สถานี จาก resource/data/*.json (โหลดพร้อมกันรอบเดียว)
|
||||
Promise.all([
|
||||
fetchJSON(DATA_URL.provinces),
|
||||
fetchJSON(DATA_URL.stations)
|
||||
]).then(function (results) {
|
||||
var provincesData = results[0];
|
||||
var stationsData = results[1];
|
||||
PROVINCES = ((results[0] || {}).provinces) || [];
|
||||
STATIONS = ((results[1] || {}).stations) || [];
|
||||
if (!PROVINCES.length) return; // โหลดข้อมูลไม่สำเร็จ → ปล่อย select ว่างไว้
|
||||
|
||||
var provinces = ((provincesData && provincesData.provinces) || [])
|
||||
.map(function (p) { return p.province_name_th; })
|
||||
.filter(Boolean);
|
||||
|
||||
var stations = (stationsData && stationsData.stations) || [];
|
||||
|
||||
if (!provinces.length) return; // โหลดข้อมูลไม่สำเร็จ → ปล่อย select ว่างไว้
|
||||
|
||||
var selectedProvince = provinces.indexOf(DEFAULT_PROVINCE) !== -1
|
||||
? DEFAULT_PROVINCE
|
||||
: provinces[0];
|
||||
/* เลือกจังหวัดเริ่มต้น: จากลิงก์ (?p= / ?s=) → ไม่งั้นใช้จังหวัดหลักของเว็บ */
|
||||
var startProvinceId = null;
|
||||
var startStationCode = q.s ? String(q.s) : '';
|
||||
if (startStationCode) {
|
||||
var st0 = STATIONS.filter(function (s) { return s.station_code === startStationCode; })[0];
|
||||
if (st0) {
|
||||
var pr0 = PROVINCES.filter(function (p) { return p.province_name_th === (st0.province_th || DEFAULT_PROVINCE); })[0];
|
||||
if (pr0) startProvinceId = pr0.province_id;
|
||||
}
|
||||
}
|
||||
if (startProvinceId === null && q.p) startProvinceId = parseInt(q.p, 10);
|
||||
if (startProvinceId === null) {
|
||||
var def = PROVINCES.filter(function (p) { return p.province_name_th === DEFAULT_PROVINCE; })[0];
|
||||
startProvinceId = def ? def.province_id : PROVINCES[0].province_id;
|
||||
}
|
||||
|
||||
provinceSelect.innerHTML = '';
|
||||
provinces.forEach(function (name) {
|
||||
PROVINCES.forEach(function (p) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = name;
|
||||
opt.textContent = name;
|
||||
if (name === selectedProvince) opt.selected = true;
|
||||
opt.value = p.province_id;
|
||||
opt.textContent = p.province_name_th;
|
||||
if (p.province_id === startProvinceId) opt.selected = true;
|
||||
provinceSelect.appendChild(opt);
|
||||
});
|
||||
|
||||
function stationsFor(province) {
|
||||
return stations
|
||||
.filter(function (s) {
|
||||
// สถานีที่ไม่มี province (เช่น "จุดขึ้นรถประจำทางอื่นๆ") ให้ถือว่าอยู่ในจังหวัดหลัก
|
||||
var p = s.province_th || DEFAULT_PROVINCE;
|
||||
return p === province;
|
||||
})
|
||||
.map(function (s) { return s.station_name_th; })
|
||||
.filter(Boolean);
|
||||
function provinceName(id) {
|
||||
var p = PROVINCES.filter(function (x) { return x.province_id === id; })[0];
|
||||
return p ? p.province_name_th : '';
|
||||
}
|
||||
|
||||
function populateStations(province) {
|
||||
function stationsFor(provinceId) {
|
||||
var name = provinceName(provinceId);
|
||||
return STATIONS.filter(function (s) {
|
||||
// สถานีที่ไม่มี province (เช่น "จุดขึ้นรถประจำทางอื่นๆ") ให้ถือว่าอยู่ในจังหวัดหลัก
|
||||
return (s.province_th || DEFAULT_PROVINCE) === name;
|
||||
});
|
||||
}
|
||||
|
||||
function populateStations(provinceId, preferredCode) {
|
||||
stationSelect.innerHTML = '';
|
||||
var list = stationsFor(province);
|
||||
if (list.length === 0) {
|
||||
var empty = document.createElement('option');
|
||||
empty.value = '';
|
||||
empty.textContent = tr('home.stationEmpty');
|
||||
empty.disabled = true;
|
||||
empty.selected = true;
|
||||
stationSelect.appendChild(empty);
|
||||
if (stationHint) stationHint.textContent = tr('home.stationEmptyHint') + ' ' + province;
|
||||
} else {
|
||||
list.forEach(function (name) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = name;
|
||||
opt.textContent = name;
|
||||
stationSelect.appendChild(opt);
|
||||
});
|
||||
if (stationHint) stationHint.innerHTML = tr('home.stationCount', { n: list.length }) + ' ' + province;
|
||||
var list = stationsFor(provinceId);
|
||||
|
||||
/* ตัวเลือกแรก = ทุกสถานีในจังหวัด (ค่าเริ่มต้น → แสดงทุกสาย) */
|
||||
var all = document.createElement('option');
|
||||
all.value = '';
|
||||
all.textContent = tr('home.allStations');
|
||||
stationSelect.appendChild(all);
|
||||
|
||||
list.forEach(function (st) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = st.station_code; /* ใช้รหัสสถานี = ลิงก์สั้น อ่านง่าย */
|
||||
opt.textContent = st.station_name_th;
|
||||
stationSelect.appendChild(opt);
|
||||
});
|
||||
|
||||
if (!list.length) {
|
||||
all.textContent = tr('home.stationEmpty');
|
||||
all.disabled = true;
|
||||
if (stationHint) stationHint.textContent = tr('home.stationEmptyHint') + ' ' + provinceName(provinceId);
|
||||
} else if (stationHint) {
|
||||
stationHint.innerHTML = tr('home.stationCount', { n: list.length }) + ' ' + provinceName(provinceId);
|
||||
}
|
||||
|
||||
/* คืนค่าที่เลือกไว้ (จากลิงก์) ถ้ามีในจังหวัดนี้ */
|
||||
if (preferredCode && list.some(function (s) { return s.station_code === preferredCode; })) {
|
||||
stationSelect.value = preferredCode;
|
||||
} else {
|
||||
stationSelect.value = '';
|
||||
}
|
||||
|
||||
var prefix = tr('home.provincePrefix');
|
||||
var pname = provinceName(provinceId);
|
||||
// กรุงเทพมหานครเป็นเขตปกครองพิเศษ ไม่ใช่ "จังหวัด" → ไม่เติมคำนำหน้า
|
||||
var label = (prefix && province !== 'กรุงเทพมหานคร')
|
||||
? prefix + ' ' + province
|
||||
: province;
|
||||
var label = (prefix && pname !== 'กรุงเทพมหานคร') ? prefix + ' ' + pname : pname;
|
||||
if (heroProvince) heroProvince.textContent = label;
|
||||
}
|
||||
|
||||
/* อ่านสถานะจาก select แล้ววาดการ์ดใหม่ */
|
||||
function syncState() {
|
||||
state.provinceId = parseInt(provinceSelect.value, 10);
|
||||
state.provinceName = provinceName(state.provinceId);
|
||||
state.stationCode = stationSelect.value || '';
|
||||
var st = STATIONS.filter(function (s) { return s.station_code === state.stationCode; })[0];
|
||||
state.stationId = st ? st.station_id : null;
|
||||
}
|
||||
|
||||
provinceSelect.addEventListener('change', function () {
|
||||
populateStations(provinceSelect.value);
|
||||
populateStations(parseInt(provinceSelect.value, 10));
|
||||
syncState();
|
||||
renderZones();
|
||||
});
|
||||
|
||||
populateStations(selectedProvince);
|
||||
stationSelect.addEventListener('change', function () {
|
||||
syncState();
|
||||
renderZones();
|
||||
});
|
||||
|
||||
populateStations(startProvinceId, startStationCode);
|
||||
syncState();
|
||||
renderZones();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,6 +157,251 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
การ์ดหมวดเส้นทาง — สร้างจาก route_groups.json + routes.json
|
||||
(หมวดเทศบาลอ่านเพิ่มจาก routes_municipal.json ซึ่งเป็นไฟล์เปล่า
|
||||
พร้อมคีย์ครบ — เติมเมื่อไหร่การ์ดก็ขึ้นเอง)
|
||||
============================================================ */
|
||||
var GROUP_META = {
|
||||
municipal: { tag: 'tag-yellow', i18n: 'zone.municipal', desc: 'zone.municipalDesc', empty: 'zone.municipalNA' },
|
||||
bangkok: { tag: 'tag-sky', i18n: 'zone.bangkok', desc: 'zone.bangkokDesc' },
|
||||
interprovincial: { tag: 'tag-purple', i18n: 'zone.interprov', desc: 'zone.interprovDesc' },
|
||||
in_province: { tag: 'tag-pink', i18n: 'zone.inprov', desc: 'zone.inprovDesc' }
|
||||
};
|
||||
/* สีชิปหมุนวนตามลำดับการ์ด; ค่าที่เคยกำหนดเฉพาะสายไว้เดิมอยู่ใน FIXED_BADGE
|
||||
(ถ้าต้องการย้ายมาคุมจาก JSON ให้ใส่คีย์ "badge" ใน routes.json) */
|
||||
var BADGE_CYCLE = ['badge-purple', 'badge-sky', 'badge-pink', 'badge-mint'];
|
||||
var FIXED_BADGE = { '324': 'badge-pink', '1011': 'badge-mint', '2231': 'badge-purple', '999': 'badge-sky' };
|
||||
var ICON = { next: 'ic-alarm-clock', schedule: 'ic-check', none: 'ic-hourglass' };
|
||||
var chipSlots = []; /* { wrap, routeId } ไว้รีเฟรชทุกนาที */
|
||||
|
||||
function toMin(hhmm) {
|
||||
var a = String(hhmm).split(':');
|
||||
return (parseInt(a[0], 10) || 0) * 60 + (parseInt(a[1], 10) || 0);
|
||||
}
|
||||
function nowMin() { var d = new Date(); return d.getHours() * 60 + d.getMinutes(); }
|
||||
|
||||
/* เที่ยวถัดไปของสาย = เที่ยวแรกที่ยังไม่ผ่าน (ไม่วนไปพรุ่งนี้ — ตรงกับหน้าเช็กเวลา) */
|
||||
function nextTripOf(times) {
|
||||
var now = nowMin();
|
||||
var sorted = times.slice().sort();
|
||||
for (var i = 0; i < sorted.length; i++) {
|
||||
if (toMin(sorted[i]) >= now) return sorted[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* โหลดข้อมูลหมวด/เส้นทาง/เวลา ครั้งเดียว แล้วเก็บไว้ใช้ซ้ำ */
|
||||
var ZDATA = { loaded: false, groups: [], routes: [], timesByRoute: {} };
|
||||
|
||||
function loadZoneData() {
|
||||
if (ZDATA.loaded) return Promise.resolve();
|
||||
return Promise.all([
|
||||
fetchJSON(DATA_URL.routeGroups),
|
||||
fetchJSON(DATA_URL.routes),
|
||||
fetchJSON(DATA_URL.routesMunicipal),
|
||||
fetchJSON(DATA_URL.schedules)
|
||||
]).then(function (res) {
|
||||
var groups = ((res[0] || {}).route_groups) || [];
|
||||
var routes = ((res[1] || {}).routes) || [];
|
||||
var municipal = ((res[2] || {}).routes) || [];
|
||||
var recs = (res[3] || {}).schedules || res[3] || [];
|
||||
if (!groups.length || !routes.length) return;
|
||||
|
||||
/* รวมเส้นทางหมวดเทศบาลจากไฟล์แยก (ข้ามแถวที่ยังไม่ได้กรอก) */
|
||||
ZDATA.groups = groups.filter(function (g) { return g.is_active !== false; })
|
||||
.slice()
|
||||
.sort(function (a, b) { return (a.display_order || 0) - (b.display_order || 0); });
|
||||
ZDATA.routes = routes.concat(municipal.filter(function (r) { return r && r.route_id; }));
|
||||
|
||||
var t = {};
|
||||
recs.forEach(function (r) {
|
||||
var k = String(r.route_id);
|
||||
t[k] = (t[k] || []).concat(r.departure_times || []);
|
||||
});
|
||||
ZDATA.timesByRoute = t;
|
||||
ZDATA.loaded = true;
|
||||
});
|
||||
}
|
||||
|
||||
/* กรองเส้นทางตามที่เลือก: สถานี → จังหวัด → ทั้งหมด */
|
||||
function routesForSelection() {
|
||||
if (state.stationId) {
|
||||
return ZDATA.routes.filter(function (r) {
|
||||
return (r.station_ids || []).indexOf(state.stationId) !== -1;
|
||||
});
|
||||
}
|
||||
if (state.provinceId) {
|
||||
return ZDATA.routes.filter(function (r) {
|
||||
return (r.province_ids || []).indexOf(state.provinceId) !== -1;
|
||||
});
|
||||
}
|
||||
return ZDATA.routes;
|
||||
}
|
||||
|
||||
function renderZones() {
|
||||
var host = document.getElementById('route-zones');
|
||||
if (!host) return;
|
||||
var tr = window.I18N ? window.I18N.t : function (k) { return k; };
|
||||
|
||||
loadZoneData().then(function () {
|
||||
if (!ZDATA.loaded) return;
|
||||
var mine = routesForSelection();
|
||||
|
||||
host.innerHTML = '';
|
||||
chipSlots = []; /* กันชิปซ้ำหลังวาดใหม่ */
|
||||
ZDATA.groups.forEach(function (g) {
|
||||
host.appendChild(zoneSection(g, mine, ZDATA.timesByRoute, tr));
|
||||
});
|
||||
|
||||
if (shareRefresh) shareRefresh(); /* อัปเดตลิงก์สั้นตามที่เลือก */
|
||||
if (!zoneTimer && chipSlots.length) {
|
||||
zoneTimer = setInterval(refreshChips, 60000);
|
||||
document.addEventListener('visibilitychange', function () {
|
||||
if (!document.hidden) refreshChips();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var zoneTimer = null;
|
||||
var shareRefresh = null;
|
||||
|
||||
function zoneSection(group, allRoutes, timesByRoute, tr) {
|
||||
var meta = GROUP_META[group.route_group] || {};
|
||||
var mine = allRoutes.filter(function (r) { return r.route_group === group.route_group; });
|
||||
|
||||
var sec = document.createElement('section');
|
||||
sec.className = 'mu-zone';
|
||||
sec.setAttribute('data-group', group.route_group);
|
||||
|
||||
/* หมวดใหม่ที่ยังไม่มีคีย์แปล → ใช้ชื่อจาก route_groups.json ตรง ๆ */
|
||||
var label = meta.i18n ? tr(meta.i18n) : (group.route_group_label || group.route_group);
|
||||
var labelAttr = meta.i18n ? ' data-i18n="' + meta.i18n + '"' : '';
|
||||
var desc = meta.desc ? tr(meta.desc) : '';
|
||||
var descAttr = meta.desc ? ' data-i18n="' + meta.desc + '"' : '';
|
||||
|
||||
var head = document.createElement('div');
|
||||
head.className = 'mu-zone-head';
|
||||
head.innerHTML =
|
||||
'<span class="mu-zone-tag ' + (meta.tag || 'tag-sky') + '"' + labelAttr + '>' + esc(label) + '</span>' +
|
||||
'<p class="mu-zone-desc">' + (desc ? '<span' + descAttr + '>' + esc(desc) + '</span> · ' : '') +
|
||||
mine.length + ' <span data-i18n="common.routes">' + esc(tr('common.routes')) + '</span></p>';
|
||||
sec.appendChild(head);
|
||||
|
||||
var grid = document.createElement('div');
|
||||
grid.className = 'mu-grid';
|
||||
|
||||
if (!mine.length) {
|
||||
grid.innerHTML =
|
||||
'<div class="mu-card is-empty">' +
|
||||
'<div class="mu-card-head"><p class="mu-route-number">N/A</p></div>' +
|
||||
'<div class="mu-route-info">' +
|
||||
'<p class="mu-route-name" data-i18n="' + (meta.empty || 'card.noData') + '">' + esc(tr(meta.empty || 'card.noData')) + '</p>' +
|
||||
'<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-gray" data-i18n="card.noData">' + esc(tr('card.noData')) + '</span></div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
} else {
|
||||
mine.forEach(function (r, i) {
|
||||
var badge = r.badge ? 'badge-' + r.badge : (FIXED_BADGE[r.route_id] || BADGE_CYCLE[i % BADGE_CYCLE.length]);
|
||||
var a = document.createElement('a');
|
||||
a.className = 'mu-card';
|
||||
a.setAttribute('data-route', r.route_id);
|
||||
a.href = '#/routes/' + encodeURIComponent(r.route_id);
|
||||
a.innerHTML =
|
||||
'<div class="mu-card-head"><p class="mu-route-number">' + esc(r.route_id) + '</p></div>' +
|
||||
'<div class="mu-route-info">' +
|
||||
'<p class="mu-route-name">' + esc(r.route_name_th || '') + '</p>' +
|
||||
'<div class="mu-route-chip-wrap"></div>' +
|
||||
'</div>';
|
||||
var wrap = a.querySelector('.mu-route-chip-wrap');
|
||||
var times = timesByRoute[String(r.route_id)] || [];
|
||||
wrap.appendChild(chipNode(chipState(times), badge, tr));
|
||||
chipSlots.push({ wrap: wrap, badge: badge, times: times });
|
||||
grid.appendChild(a);
|
||||
});
|
||||
}
|
||||
|
||||
sec.appendChild(grid);
|
||||
return sec;
|
||||
}
|
||||
|
||||
/* 3 สถานะของชิป (ตรงกับที่ออกแบบไว้เดิม): มีเที่ยวถัดไป → ดูตาราง → ยังไม่มีตาราง */
|
||||
function chipState(times) {
|
||||
var next = nextTripOf(times);
|
||||
if (next) return { icon: ICON.next, key: 'card.nextTrip', next: next };
|
||||
if (times.length) return { icon: ICON.schedule, key: 'card.schedule', next: null };
|
||||
return { icon: ICON.none, key: 'card.noSchedule', next: null };
|
||||
}
|
||||
|
||||
function chipNode(state, badge, tr) {
|
||||
var span = document.createElement('span');
|
||||
span.className = 'mu-next-trip ' + badge;
|
||||
span.innerHTML = '<svg class="ic" aria-hidden="true"><use href="#' + state.icon + '"/></svg> ' +
|
||||
'<span data-i18n="' + state.key + '">' + esc(tr(state.key)) + '</span>' + (state.next ? ' ' + esc(state.next) : '');
|
||||
return span;
|
||||
}
|
||||
|
||||
/* รีเฟรชชิปทุกนาที ให้เวลา "เที่ยวถัดไป" ตรงกับเวลาจริง */
|
||||
function refreshChips() {
|
||||
var tr = window.I18N ? window.I18N.t : function (k) { return k; };
|
||||
chipSlots.forEach(function (slot) {
|
||||
if (!slot.wrap.isConnected || !slot.times.length) return;
|
||||
slot.wrap.innerHTML = '';
|
||||
slot.wrap.appendChild(chipNode(chipState(slot.times), slot.badge, tr));
|
||||
});
|
||||
}
|
||||
|
||||
function esc(v) {
|
||||
return String(v == null ? '' : v).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
ลิงก์สั้นสำหรับแชร์ (ส่งไลน์หากัน)
|
||||
#/?s=<รหัสสถานี> = เปิดหน้าแรกพร้อมเลือกสถานีนั้น
|
||||
#/?p=<province_id> = เปิดพร้อมเลือกจังหวัด
|
||||
============================================================ */
|
||||
function shortUrl() {
|
||||
var base = location.origin + location.pathname.replace(/index\.html$/, '');
|
||||
var q = state.stationCode ? 's=' + encodeURIComponent(state.stationCode)
|
||||
: (state.provinceId ? 'p=' + state.provinceId : '');
|
||||
return base + (q ? '#/?' + q : '#/');
|
||||
}
|
||||
|
||||
function initShare() {
|
||||
var btn = document.getElementById('share-btn');
|
||||
var status = document.getElementById('share-status');
|
||||
if (!btn) return;
|
||||
var tr = window.I18N ? window.I18N.t : function (k) { return k; };
|
||||
|
||||
function paint(msg) {
|
||||
if (!status) return;
|
||||
status.innerHTML = esc(msg) + ' <code class="mu-share-url">' + esc(shortUrl()) + '</code> ' +
|
||||
'<a class="mu-share-line" href="https://social-plugins.line.me/lineit/share?url=' +
|
||||
encodeURIComponent(shortUrl()) + '" target="_blank" rel="noopener">' + esc(tr('share.line')) + '</a>';
|
||||
}
|
||||
|
||||
shareRefresh = function () { if (status && status.dataset.shown) paint(status.dataset.msg || ''); };
|
||||
|
||||
btn.addEventListener('click', function () {
|
||||
var url = shortUrl();
|
||||
if (navigator.share) {
|
||||
navigator.share({ title: document.title, url: url }).catch(function () { /* ผู้ใช้ยกเลิก */ });
|
||||
}
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(url).then(function () {
|
||||
status.dataset.shown = '1'; status.dataset.msg = tr('share.copied'); paint(tr('share.copied'));
|
||||
}, function () {
|
||||
status.dataset.shown = '1'; status.dataset.msg = tr('share.short'); paint(tr('share.short'));
|
||||
});
|
||||
} else {
|
||||
status.dataset.shown = '1'; status.dataset.msg = tr('share.short'); paint(tr('share.short'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
initHomeSelectors();
|
||||
initMarquee();
|
||||
initShare();
|
||||
})();
|
||||
@@ -682,7 +682,8 @@
|
||||
|
||||
<aside class="mu-card-panel">
|
||||
<h2><span data-i18n="stop.mapInfo">แผนที่และข้อมูลป้าย</span></h2>
|
||||
<div class="mu-map-mock" style="border-radius: 12px; background: linear-gradient(145deg, #f4f8ff 0%, #effaf5 100%); border: 1px solid #d7e5f2; padding: 20px; min-height: 200px; display:flex; align-items:center; justify-content:center; color:#66728f; font-weight:700; text-align:center;"><svg class="ic" aria-hidden="true"><use href="#ic-map"/></svg> แผนที่ตำแหน่งป้ายและช่องจอด</div>
|
||||
<div class="at-map" id="stop-map" role="region" aria-label="แผนที่เส้นทางที่ผ่านป้ายนี้"></div>
|
||||
<p class="at-map-caption" id="stop-map-caption"></p>
|
||||
<div style="display:flex; flex-wrap:wrap; gap:8px; margin-top:14px;">
|
||||
<span class="mu-chip" style="background: rgba(255,255,255,.9); border:1px solid rgba(231, 224, 246, 0.95); color:#5b3b71;">เปิด 04:30</span>
|
||||
<span class="mu-chip" style="background: rgba(255,255,255,.9); border:1px solid rgba(231, 224, 246, 0.95); color:#5b3b71;">ปิด 21:00</span>
|
||||
@@ -816,3 +817,11 @@
|
||||
setInterval(tick, 30000);
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var r = window.__route || { params: {} };
|
||||
var el = document.getElementById('stop-map');
|
||||
if (el && window.ATMap && r.params.code) ATMap.forStop(el, r.params.code);
|
||||
})();
|
||||
</script>
|
||||
+4
-1
@@ -56,7 +56,10 @@
|
||||
if (seg[1]) return { name: 'blog', params: { postId: decodeURIComponent(seg[1]) }, query: query };
|
||||
return { name: 'blog', params: {}, query: query };
|
||||
}
|
||||
if (seg[0] === 'check') return { name: 'check', params: {}, query: query };
|
||||
if (seg[0] === 'check') {
|
||||
if (seg[1]) return { name: 'check', params: { routeId: decodeURIComponent(seg[1]) }, query: query };
|
||||
return { name: 'check', params: {}, query: query };
|
||||
}
|
||||
return { name: 'home', params: {}, query: query };
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
<meta property="og:description" content="สาย 15 และ 902 จากจตุจักรไปอ่างทอง พร้อมตารางเวลาทั้งวัน">
|
||||
<meta property="og:locale" content="th_TH">
|
||||
<meta name="theme-color" content="#7a4cc0">
|
||||
<link rel="stylesheet" href="../vendor/leaflet/leaflet.css">
|
||||
<link rel="stylesheet" href="../map.css">
|
||||
<link rel="icon" href="../../.image/icons/minibus-512x512.png">
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Prompt:wght@400;500;600;700;800&family=Noto+Sans+Thai:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600;700&display=swap" rel="stylesheet">
|
||||
@@ -325,6 +327,14 @@
|
||||
</section>
|
||||
|
||||
<!-- 4. การเดินทางมาสถานี -->
|
||||
<section class="block">
|
||||
<h2 class="sec"><svg class="ic" aria-hidden="true"><use href="#ic-map"/></svg> เส้นทางบนแผนที่</h2>
|
||||
<div class="at-map-wrap">
|
||||
<div class="at-map" id="stop-map" role="region" aria-label="แผนที่เส้นทางที่ผ่านสถานีนี้"></div>
|
||||
<p class="at-map-caption" id="stop-map-caption">กำลังโหลดแผนที่…</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="block">
|
||||
<h2 class="sec"><svg class="ic" aria-hidden="true"><use href="#ic-navigation"/></svg> การเดินทางมาสถานี</h2>
|
||||
<div class="ways">
|
||||
@@ -353,5 +363,45 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
/* หน้านี้เป็น static/SEO (ไทยล้วน) — ประกาศคำแปลเฉพาะที่แผนที่ใช้ ไม่ต้องโหลด i18n.js */
|
||||
window.I18N = {
|
||||
t: function (k, v) {
|
||||
var TH = {
|
||||
'map.route': 'สาย',
|
||||
'map.km': 'กม.',
|
||||
'map.legendRoute': 'เส้นทาง',
|
||||
'map.legendStop': 'ป้ายหยุดรถ',
|
||||
'map.legendTerminal': 'สถานีขนส่ง',
|
||||
'map.legendHere': 'ป้ายที่กำลังดู',
|
||||
'map.captionStop': 'เส้นทางที่ผ่านป้ายนี้ {r} · ป้ายตามเส้นทาง {n} แห่ง',
|
||||
'map.stationPinned': 'ปักหมุดตำแหน่งป้ายแล้ว',
|
||||
'map.noStationPin': 'พิกัดป้ายนี้ยังไม่มีในระบบ — แสดงเส้นทางที่ผ่าน',
|
||||
'map.noRoutesHere': 'ยังไม่มีข้อมูลสายรถที่ผ่านป้ายนี้ในระบบ',
|
||||
'map.empty': 'ยังไม่มีข้อมูลเส้นทางสายนี้ในระบบ',
|
||||
'map.offline': 'ออฟไลน์ — แสดงเฉพาะเส้นทาง',
|
||||
'map.thisStop': 'ป้ายที่กำลังดูอยู่',
|
||||
'map.servedBy': 'สายที่ผ่าน',
|
||||
'map.openInMaps': 'เปิดใน Google Maps',
|
||||
'map.viewStopPage': 'ดูรายละเอียดป้ายนี้'
|
||||
};
|
||||
var out = TH[k] || k;
|
||||
if (v) Object.keys(v).forEach(function (x) { out = out.split('{' + x + '}').join(v[x]); });
|
||||
return out;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../vendor/leaflet/leaflet.js"></script>
|
||||
<script src="../map.js"></script>
|
||||
<script>
|
||||
(function () {
|
||||
var el = document.getElementById('stop-map');
|
||||
if (!el || !window.ATMap) return;
|
||||
ATMap.forStop(el, 'chatuchak_minibus_terminal', {
|
||||
base: '../../resource/data/',
|
||||
stopHref: function (code) { return '../index.html#/stops/' + code; }
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -13,7 +13,7 @@
|
||||
- ขั้นตอนอัปเดต: ดู AGENTS.md หัวข้อ PWA
|
||||
============================================================ */
|
||||
|
||||
const VERSION = "2026.09.22.1"; // ← bump ทุกครั้งที่แก้ SW เอง
|
||||
const VERSION = "2026.09.22.5"; // ← bump ทุกครั้งที่แก้ SW เอง
|
||||
const CACHE = `at-transit-${VERSION}`;
|
||||
|
||||
const PRECACHE = [
|
||||
@@ -43,6 +43,13 @@ const PRECACHE = [
|
||||
"./partials/about.init.js",
|
||||
"./partials/blog.html",
|
||||
"./partials/blog.init.js",
|
||||
"./partials/busDetail.init.js",
|
||||
"./partials/checkSchedule.init.js",
|
||||
"./vendor/leaflet/leaflet.js",
|
||||
"./vendor/leaflet/leaflet.css",
|
||||
"./map.js",
|
||||
"./map.css",
|
||||
"./stops/chatuchak-minibus-terminal.html",
|
||||
"./partials/icons-sprite.svg",
|
||||
"../.image/icons/minibus-512x512.png",
|
||||
];
|
||||
@@ -106,6 +113,7 @@ self.addEventListener("fetch", (event) => {
|
||||
url.pathname.endsWith(".js") ||
|
||||
url.pathname.endsWith(".html") ||
|
||||
url.pathname.endsWith(".json") ||
|
||||
url.pathname.endsWith(".geojson") ||
|
||||
url.pathname.includes("/partials/")
|
||||
) {
|
||||
event.respondWith(networkFirst(request));
|
||||
|
||||
Vendored
+661
@@ -0,0 +1,661 @@
|
||||
/* required styles */
|
||||
|
||||
.leaflet-pane,
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-tile-container,
|
||||
.leaflet-pane > svg,
|
||||
.leaflet-pane > canvas,
|
||||
.leaflet-zoom-box,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-layer {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-container {
|
||||
overflow: hidden;
|
||||
}
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
/* Prevents IE11 from highlighting tiles in blue */
|
||||
.leaflet-tile::selection {
|
||||
background: transparent;
|
||||
}
|
||||
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
|
||||
.leaflet-safari .leaflet-tile {
|
||||
image-rendering: -webkit-optimize-contrast;
|
||||
}
|
||||
/* hack that prevents hw layers "stretching" when loading new tiles */
|
||||
.leaflet-safari .leaflet-tile-container {
|
||||
width: 1600px;
|
||||
height: 1600px;
|
||||
-webkit-transform-origin: 0 0;
|
||||
}
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
display: block;
|
||||
}
|
||||
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
|
||||
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
|
||||
.leaflet-container .leaflet-overlay-pane svg {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
}
|
||||
.leaflet-container .leaflet-marker-pane img,
|
||||
.leaflet-container .leaflet-shadow-pane img,
|
||||
.leaflet-container .leaflet-tile-pane img,
|
||||
.leaflet-container img.leaflet-image-layer,
|
||||
.leaflet-container .leaflet-tile {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
width: auto;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.leaflet-container img.leaflet-tile {
|
||||
/* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */
|
||||
mix-blend-mode: plus-lighter;
|
||||
}
|
||||
|
||||
.leaflet-container.leaflet-touch-zoom {
|
||||
-ms-touch-action: pan-x pan-y;
|
||||
touch-action: pan-x pan-y;
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag {
|
||||
-ms-touch-action: pinch-zoom;
|
||||
/* Fallback for FF which doesn't support pinch-zoom */
|
||||
touch-action: none;
|
||||
touch-action: pinch-zoom;
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
|
||||
-ms-touch-action: none;
|
||||
touch-action: none;
|
||||
}
|
||||
.leaflet-container {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.leaflet-container a {
|
||||
-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
|
||||
}
|
||||
.leaflet-tile {
|
||||
filter: inherit;
|
||||
visibility: hidden;
|
||||
}
|
||||
.leaflet-tile-loaded {
|
||||
visibility: inherit;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
width: 0;
|
||||
height: 0;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
z-index: 800;
|
||||
}
|
||||
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
|
||||
.leaflet-overlay-pane svg {
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.leaflet-pane { z-index: 400; }
|
||||
|
||||
.leaflet-tile-pane { z-index: 200; }
|
||||
.leaflet-overlay-pane { z-index: 400; }
|
||||
.leaflet-shadow-pane { z-index: 500; }
|
||||
.leaflet-marker-pane { z-index: 600; }
|
||||
.leaflet-tooltip-pane { z-index: 650; }
|
||||
.leaflet-popup-pane { z-index: 700; }
|
||||
|
||||
.leaflet-map-pane canvas { z-index: 100; }
|
||||
.leaflet-map-pane svg { z-index: 200; }
|
||||
|
||||
.leaflet-vml-shape {
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
.lvml {
|
||||
behavior: url(#default#VML);
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
/* control positioning */
|
||||
|
||||
.leaflet-control {
|
||||
position: relative;
|
||||
z-index: 800;
|
||||
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
||||
pointer-events: auto;
|
||||
}
|
||||
.leaflet-top,
|
||||
.leaflet-bottom {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
pointer-events: none;
|
||||
}
|
||||
.leaflet-top {
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-right {
|
||||
right: 0;
|
||||
}
|
||||
.leaflet-bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
.leaflet-left {
|
||||
left: 0;
|
||||
}
|
||||
.leaflet-control {
|
||||
float: left;
|
||||
clear: both;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
float: right;
|
||||
}
|
||||
.leaflet-top .leaflet-control {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.leaflet-left .leaflet-control {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
|
||||
/* zoom and fade animations */
|
||||
|
||||
.leaflet-fade-anim .leaflet-popup {
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
-moz-transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
opacity: 1;
|
||||
}
|
||||
.leaflet-zoom-animated {
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
}
|
||||
svg.leaflet-zoom-animated {
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-hide {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* cursors */
|
||||
|
||||
.leaflet-interactive {
|
||||
cursor: pointer;
|
||||
}
|
||||
.leaflet-grab {
|
||||
cursor: -webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
cursor: grab;
|
||||
}
|
||||
.leaflet-crosshair,
|
||||
.leaflet-crosshair .leaflet-interactive {
|
||||
cursor: crosshair;
|
||||
}
|
||||
.leaflet-popup-pane,
|
||||
.leaflet-control {
|
||||
cursor: auto;
|
||||
}
|
||||
.leaflet-dragging .leaflet-grab,
|
||||
.leaflet-dragging .leaflet-grab .leaflet-interactive,
|
||||
.leaflet-dragging .leaflet-marker-draggable {
|
||||
cursor: move;
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* marker & overlays interactivity */
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-pane > svg path,
|
||||
.leaflet-tile-container {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.leaflet-marker-icon.leaflet-interactive,
|
||||
.leaflet-image-layer.leaflet-interactive,
|
||||
.leaflet-pane > svg path.leaflet-interactive,
|
||||
svg.leaflet-image-layer.leaflet-interactive path {
|
||||
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* visual tweaks */
|
||||
|
||||
.leaflet-container {
|
||||
background: #ddd;
|
||||
outline-offset: 1px;
|
||||
}
|
||||
.leaflet-container a {
|
||||
color: #0078A8;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
border: 2px dotted #38f;
|
||||
background: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
|
||||
/* general typography */
|
||||
.leaflet-container {
|
||||
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
|
||||
/* general toolbar styles */
|
||||
|
||||
.leaflet-bar {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a {
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #ccc;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
display: block;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
.leaflet-bar a,
|
||||
.leaflet-control-layers-toggle {
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
display: block;
|
||||
}
|
||||
.leaflet-bar a:hover,
|
||||
.leaflet-bar a:focus {
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
.leaflet-bar a:first-child {
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a:last-child {
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-bottom: none;
|
||||
}
|
||||
.leaflet-bar a.leaflet-disabled {
|
||||
cursor: default;
|
||||
background-color: #f4f4f4;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-bar a {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar a:first-child {
|
||||
border-top-left-radius: 2px;
|
||||
border-top-right-radius: 2px;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar a:last-child {
|
||||
border-bottom-left-radius: 2px;
|
||||
border-bottom-right-radius: 2px;
|
||||
}
|
||||
|
||||
/* zoom control */
|
||||
|
||||
.leaflet-control-zoom-in,
|
||||
.leaflet-control-zoom-out {
|
||||
font: bold 18px 'Lucida Console', Monaco, monospace;
|
||||
text-indent: 1px;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
|
||||
/* layers control */
|
||||
|
||||
.leaflet-control-layers {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
|
||||
background: #fff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers.png);
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
.leaflet-retina .leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers-2x.png);
|
||||
background-size: 26px 26px;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers-toggle {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
.leaflet-control-layers .leaflet-control-layers-list,
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
|
||||
display: none;
|
||||
}
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-list {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
.leaflet-control-layers-expanded {
|
||||
padding: 6px 10px 6px 6px;
|
||||
color: #333;
|
||||
background: #fff;
|
||||
}
|
||||
.leaflet-control-layers-scrollbar {
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.leaflet-control-layers-selector {
|
||||
margin-top: 2px;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
.leaflet-control-layers label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-size: 1.08333em;
|
||||
}
|
||||
.leaflet-control-layers-separator {
|
||||
height: 0;
|
||||
border-top: 1px solid #ddd;
|
||||
margin: 5px -10px 5px -6px;
|
||||
}
|
||||
|
||||
/* Default icon URLs */
|
||||
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
|
||||
background-image: url(images/marker-icon.png);
|
||||
}
|
||||
|
||||
|
||||
/* attribution and scale controls */
|
||||
|
||||
.leaflet-container .leaflet-control-attribution {
|
||||
background: #fff;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
margin: 0;
|
||||
}
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-scale-line {
|
||||
padding: 0 5px;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.leaflet-control-attribution a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.leaflet-control-attribution a:hover,
|
||||
.leaflet-control-attribution a:focus {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.leaflet-attribution-flag {
|
||||
display: inline !important;
|
||||
vertical-align: baseline !important;
|
||||
width: 1em;
|
||||
height: 0.6669em;
|
||||
}
|
||||
.leaflet-left .leaflet-control-scale {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control-scale {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.leaflet-control-scale-line {
|
||||
border: 2px solid #777;
|
||||
border-top: none;
|
||||
line-height: 1.1;
|
||||
padding: 2px 5px 1px;
|
||||
white-space: nowrap;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
text-shadow: 1px 1px #fff;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child) {
|
||||
border-top: 2px solid #777;
|
||||
border-bottom: none;
|
||||
margin-top: -2px;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
|
||||
border-bottom: 2px solid #777;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-attribution,
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
box-shadow: none;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
border: 2px solid rgba(0,0,0,0.2);
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
|
||||
/* popup */
|
||||
|
||||
.leaflet-popup {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.leaflet-popup-content-wrapper {
|
||||
padding: 1px;
|
||||
text-align: left;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.leaflet-popup-content {
|
||||
margin: 13px 24px 13px 20px;
|
||||
line-height: 1.3;
|
||||
font-size: 13px;
|
||||
font-size: 1.08333em;
|
||||
min-height: 1px;
|
||||
}
|
||||
.leaflet-popup-content p {
|
||||
margin: 17px 0;
|
||||
margin: 1.3em 0;
|
||||
}
|
||||
.leaflet-popup-tip-container {
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
margin-top: -1px;
|
||||
margin-left: -20px;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
.leaflet-popup-tip {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
padding: 1px;
|
||||
|
||||
margin: -10px auto 0;
|
||||
pointer-events: auto;
|
||||
|
||||
-webkit-transform: rotate(45deg);
|
||||
-moz-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.leaflet-popup-content-wrapper,
|
||||
.leaflet-popup-tip {
|
||||
background: white;
|
||||
color: #333;
|
||||
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
border: none;
|
||||
text-align: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font: 16px/24px Tahoma, Verdana, sans-serif;
|
||||
color: #757575;
|
||||
text-decoration: none;
|
||||
background: transparent;
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button:hover,
|
||||
.leaflet-container a.leaflet-popup-close-button:focus {
|
||||
color: #585858;
|
||||
}
|
||||
.leaflet-popup-scrolled {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper {
|
||||
-ms-zoom: 1;
|
||||
}
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
width: 24px;
|
||||
margin: 0 auto;
|
||||
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
|
||||
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-control-zoom,
|
||||
.leaflet-oldie .leaflet-control-layers,
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper,
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
|
||||
/* div icon */
|
||||
|
||||
.leaflet-div-icon {
|
||||
background: #fff;
|
||||
border: 1px solid #666;
|
||||
}
|
||||
|
||||
|
||||
/* Tooltip */
|
||||
/* Base styles for the element that has a tooltip */
|
||||
.leaflet-tooltip {
|
||||
position: absolute;
|
||||
padding: 6px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #fff;
|
||||
border-radius: 3px;
|
||||
color: #222;
|
||||
white-space: nowrap;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-tooltip.leaflet-interactive {
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.leaflet-tooltip-top:before,
|
||||
.leaflet-tooltip-bottom:before,
|
||||
.leaflet-tooltip-left:before,
|
||||
.leaflet-tooltip-right:before {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
border: 6px solid transparent;
|
||||
background: transparent;
|
||||
content: "";
|
||||
}
|
||||
|
||||
/* Directions */
|
||||
|
||||
.leaflet-tooltip-bottom {
|
||||
margin-top: 6px;
|
||||
}
|
||||
.leaflet-tooltip-top {
|
||||
margin-top: -6px;
|
||||
}
|
||||
.leaflet-tooltip-bottom:before,
|
||||
.leaflet-tooltip-top:before {
|
||||
left: 50%;
|
||||
margin-left: -6px;
|
||||
}
|
||||
.leaflet-tooltip-top:before {
|
||||
bottom: 0;
|
||||
margin-bottom: -12px;
|
||||
border-top-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-bottom:before {
|
||||
top: 0;
|
||||
margin-top: -12px;
|
||||
margin-left: -6px;
|
||||
border-bottom-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-left {
|
||||
margin-left: -6px;
|
||||
}
|
||||
.leaflet-tooltip-right {
|
||||
margin-left: 6px;
|
||||
}
|
||||
.leaflet-tooltip-left:before,
|
||||
.leaflet-tooltip-right:before {
|
||||
top: 50%;
|
||||
margin-top: -6px;
|
||||
}
|
||||
.leaflet-tooltip-left:before {
|
||||
right: 0;
|
||||
margin-right: -12px;
|
||||
border-left-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-right:before {
|
||||
left: 0;
|
||||
margin-left: -12px;
|
||||
border-right-color: #fff;
|
||||
}
|
||||
|
||||
/* Printing */
|
||||
|
||||
@media print {
|
||||
/* Prevent printers from removing background-images of controls. */
|
||||
.leaflet-control {
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
/* @preserve
|
||||
* Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
|
||||
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
|
||||
*/
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).leaflet={})}(this,function(t){"use strict";function l(t){for(var e,i,n=1,o=arguments.length;n<o;n++)for(e in i=arguments[n])t[e]=i[e];return t}var R=Object.create||function(t){return N.prototype=t,new N};function N(){}function a(t,e){var i,n=Array.prototype.slice;return t.bind?t.bind.apply(t,n.call(arguments,1)):(i=n.call(arguments,2),function(){return t.apply(e,i.length?i.concat(n.call(arguments)):arguments)})}var D=0;function h(t){return"_leaflet_id"in t||(t._leaflet_id=++D),t._leaflet_id}function j(t,e,i){var n,o,s=function(){n=!1,o&&(r.apply(i,o),o=!1)},r=function(){n?o=arguments:(t.apply(i,arguments),setTimeout(s,e),n=!0)};return r}function H(t,e,i){var n=e[1],e=e[0],o=n-e;return t===n&&i?t:((t-e)%o+o)%o+e}function u(){return!1}function i(t,e){return!1===e?t:(e=Math.pow(10,void 0===e?6:e),Math.round(t*e)/e)}function W(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function F(t){return W(t).split(/\s+/)}function c(t,e){for(var i in Object.prototype.hasOwnProperty.call(t,"options")||(t.options=t.options?R(t.options):{}),e)t.options[i]=e[i];return t.options}function U(t,e,i){var n,o=[];for(n in t)o.push(encodeURIComponent(i?n.toUpperCase():n)+"="+encodeURIComponent(t[n]));return(e&&-1!==e.indexOf("?")?"&":"?")+o.join("&")}var V=/\{ *([\w_ -]+) *\}/g;function q(t,i){return t.replace(V,function(t,e){e=i[e];if(void 0===e)throw new Error("No value provided for variable "+t);return e="function"==typeof e?e(i):e})}var d=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function G(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return i;return-1}var K="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Y(t){return window["webkit"+t]||window["moz"+t]||window["ms"+t]}var X=0;function J(t){var e=+new Date,i=Math.max(0,16-(e-X));return X=e+i,window.setTimeout(t,i)}var $=window.requestAnimationFrame||Y("RequestAnimationFrame")||J,Q=window.cancelAnimationFrame||Y("CancelAnimationFrame")||Y("CancelRequestAnimationFrame")||function(t){window.clearTimeout(t)};function x(t,e,i){if(!i||$!==J)return $.call(window,a(t,e));t.call(e)}function r(t){t&&Q.call(window,t)}var tt={__proto__:null,extend:l,create:R,bind:a,get lastId(){return D},stamp:h,throttle:j,wrapNum:H,falseFn:u,formatNum:i,trim:W,splitWords:F,setOptions:c,getParamString:U,template:q,isArray:d,indexOf:G,emptyImageUrl:K,requestFn:$,cancelFn:Q,requestAnimFrame:x,cancelAnimFrame:r};function et(){}et.extend=function(t){function e(){c(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()}var i,n=e.__super__=this.prototype,o=R(n);for(i in(o.constructor=e).prototype=o,this)Object.prototype.hasOwnProperty.call(this,i)&&"prototype"!==i&&"__super__"!==i&&(e[i]=this[i]);if(t.statics&&l(e,t.statics),t.includes){var s=t.includes;if("undefined"!=typeof L&&L&&L.Mixin){s=d(s)?s:[s];for(var r=0;r<s.length;r++)s[r]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",(new Error).stack)}l.apply(null,[o].concat(t.includes))}return l(o,t),delete o.statics,delete o.includes,o.options&&(o.options=n.options?R(n.options):{},l(o.options,t.options)),o._initHooks=[],o.callInitHooks=function(){if(!this._initHooksCalled){n.callInitHooks&&n.callInitHooks.call(this),this._initHooksCalled=!0;for(var t=0,e=o._initHooks.length;t<e;t++)o._initHooks[t].call(this)}},e},et.include=function(t){var e=this.prototype.options;return l(this.prototype,t),t.options&&(this.prototype.options=e,this.mergeOptions(t.options)),this},et.mergeOptions=function(t){return l(this.prototype.options,t),this},et.addInitHook=function(t){var e=Array.prototype.slice.call(arguments,1),i="function"==typeof t?t:function(){this[t].apply(this,e)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(i),this};var e={on:function(t,e,i){if("object"==typeof t)for(var n in t)this._on(n,t[n],e);else for(var o=0,s=(t=F(t)).length;o<s;o++)this._on(t[o],e,i);return this},off:function(t,e,i){if(arguments.length)if("object"==typeof t)for(var n in t)this._off(n,t[n],e);else{t=F(t);for(var o=1===arguments.length,s=0,r=t.length;s<r;s++)o?this._off(t[s]):this._off(t[s],e,i)}else delete this._events;return this},_on:function(t,e,i,n){"function"!=typeof e?console.warn("wrong listener type: "+typeof e):!1===this._listens(t,e,i)&&(e={fn:e,ctx:i=i===this?void 0:i},n&&(e.once=!0),this._events=this._events||{},this._events[t]=this._events[t]||[],this._events[t].push(e))},_off:function(t,e,i){var n,o,s;if(this._events&&(n=this._events[t]))if(1===arguments.length){if(this._firingCount)for(o=0,s=n.length;o<s;o++)n[o].fn=u;delete this._events[t]}else"function"!=typeof e?console.warn("wrong listener type: "+typeof e):!1!==(e=this._listens(Line truncated
|
||||
//# sourceMappingURL=leaflet.js.map
|
||||
Reference in new issue
Block a user