From 656f65b41cffedbdfc970a99eca57755e9f1f8dd Mon Sep 17 00:00:00 2001 From: Bkk1234 Date: Mon, 5 Oct 2026 03:55:09 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=9C=E0=B8=99=E0=B8=97=E0=B8=B5?= =?UTF-8?q?=E0=B9=88=E0=B8=88=E0=B8=B2=E0=B8=81=20GPKG=20+=20=E0=B8=9A?= =?UTF-8?q?=E0=B8=97=E0=B8=84=E0=B8=A7=E0=B8=B2=E0=B8=A1=206=20=E0=B8=8A?= =?UTF-8?q?=E0=B8=B4=E0=B9=89=E0=B8=99=20+=20=E0=B8=A5=E0=B8=94=E0=B8=84?= =?UTF-8?q?=E0=B8=A7=E0=B8=B2=E0=B8=A1=E0=B8=AB=E0=B8=99=E0=B8=B2=20footer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit == แผนที่ / GIS == - qgis-to-web.py: อ่าน GPKG ได้ (--from gpkg) + เพิ่ม dream-Watcharapol - เพิ่ม dream-*.geojson 6 ไฟล์ (เส้นทางที่เสนอ: บ้านภาชี · ชานเมืองอยุธยา · HSR · เมืองทองธานี · ปากเกร็ด · วัชรพล) - map.js: ATMap.proposal() วาดเส้นจริงจาก geojson (ไม่ใช่เส้นตรง) · smoothFactor 0.5 · coordOf() รับ coords=[lat,lng] · fitAll รับได้ทั้งจุดเดี่ยวและเส้น · setStyle บน featureGroup == บทความ (blog) == - text3: ถ้าผมได้ออกแบบสายเดินรถเอง (จาก mydream.html) TH+EN - text4: วิธีเดินทางไปสถานีรถไฟ และสนามบิน (จาก train-airplane.html) TH+EN - text5/text6: โครงเปล่ารอเติมเนื้อหา (แสวงหา-โพธิ์ทอง · อำเภอเข้าเมือง) - แผนที่ความฝัน: map.groups 3 กลุ่ม · คลิกเส้น/หมุด/แถวได้ · ป้ายที่มา - ย่อหน้า: ระยะห่าง 20px + ย่อหน้าหน้าบรรทัด 1.5em == ตารางเดินรถ == - เปลี่ยนชื่อคีย์ dir_* -> direction_* ทุกไฟล์ (backward-compat ในโค้ด) - 1011: จุดย่อย 2 ทิศ + offsets [0,25,55] - 954/2194: จุดย่อย station 8 + offsets - refreshHighlights: วนข้ามวันเมื่อเลยเที่ยวสุดท้าย + ไฮเทลต์ชิปทุกจุด - 8 other_stop.md: อัปเดตตรงข้อมูลจริง 8 รายการ == i18n == - แยกไฟล์ต่อภาษา ui/locales/{th,en}.json + i18n.js = loader (ลด 28KB -> 6.5KB) - resource/tools/check-i18n.py ตรวจคีย์ขาด/ซ้ำ - ข้อความผู้สนับสนุนหน้าแรก + คำแปล EN == UI == - ฝังฟอนต์ K2D (ui/vendor/fonts/) ออฟไลน์ 100% - cache busting ?v= ทุกรูป (ui/imageurl.js) - footer: ลดความหนา 468 -> 349px + line-height 1.5 กันสระ/วรรณยุกต์ซ้อน - QR modal + ปุ่มคัดลอกลิงก์ · หน้าอัปเดตล่าสุดใน #/check - credits: ขอขอบคุณภาพรถ 3 สาย == เครื่องมือ == - bump-version.py · stamp-schedules.py · derive-times.py (จุดอ้างอิง ± นาที) --- AGENTS.md | 139 ++++- DESIGN.md | 73 ++- resource/data/8 other_stop.json | 40 +- resource/data/8 other_stop.md | 60 +- .../data/QGIS Project/Sawangha-bangkok.qgz | Bin 0 -> 10998 bytes .../data/QGIS Project/angthongtoanytrain.qgz | Bin 0 -> 14681 bytes .../อ่างทอง-บ้านภาชี(สายสีแดงเข้ม).gpkg | Bin 0 -> 106496 bytes ...อ่างทอง-รถไฟฟ้าชานเมืองอยุธยา(สายสีแดงเข้ม).gpkg | Bin 0 -> 106496 bytes .../angthongtoanytrain/อ่างทอง-วัชรพล.gpkg | Bin 0 -> 106496 bytes .../อ่างทอง-สถานีรถไฟความเร็วสูงอยุธยา.gpkg | Bin 0 -> 110592 bytes .../angthongtoanytrain/อ่างทอง-เมืองทองธานี.gpkg | Bin 0 -> 106496 bytes .../angthongtoanytrain/อ่างทอง-แยกปากเกร็ด.gpkg | Bin 0 -> 106496 bytes .../Sawangha-bangkok station.dbf | Bin 0 -> 371 bytes .../Sawangha-bangkok station.prj | 1 + .../Sawangha-bangkok station.shp | Bin 0 -> 292 bytes .../Sawangha-bangkok station.shx | Bin 0 -> 124 bytes .../รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok.dbf | Bin 0 -> 189 bytes .../รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok.prj | 1 + .../รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok.shp | Bin 0 -> 5676 bytes .../รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok.shx | Bin 0 -> 108 bytes resource/data/captions/caption101.json | 6 +- resource/data/captions/caption1011.json | 4 +- resource/data/captions/caption15.json | 4 +- resource/data/captions/caption2194.json | 4 +- resource/data/captions/caption2231.json | 4 +- resource/data/captions/caption324.json | 4 +- .../geojson-web/dream-Watcharapol.geojson | 1 + .../geojson-web/dream-ayutthaya-hsr.geojson | 1 + .../dream-ayutthaya-redline.geojson | 1 + .../data/geojson-web/dream-banchang.geojson | 1 + .../data/geojson-web/dream-muangthong.geojson | 1 + .../data/geojson-web/dream-pakkret.geojson | 1 + resource/data/routes.json | 16 +- resource/data/schedules-editor.html | 74 +-- resource/data/scheduleslist/schedules101.json | 2 + .../data/scheduleslist/schedules1011.json | 24 +- resource/data/scheduleslist/schedules15.json | 14 +- .../data/scheduleslist/schedules2194.json | 19 +- .../data/scheduleslist/schedules2231.json | 16 +- resource/data/scheduleslist/schedules324.json | 16 +- resource/data/scheduleslist/schedules464.json | 82 +-- resource/data/scheduleslist/schedules641.json | 49 +- resource/data/scheduleslist/schedules8.json | 24 +- resource/data/scheduleslist/schedules902.json | 14 +- resource/data/scheduleslist/schedules951.json | 14 +- resource/data/scheduleslist/schedules952.json | 12 +- resource/data/scheduleslist/schedules954.json | 48 +- resource/data/scheduleslist/schedules999.json | 6 +- resource/tools/bump-version.py | 116 ++++ resource/tools/check-i18n.py | 119 ++++ resource/tools/derive-times.py | 4 +- resource/tools/qgis-to-web.py | 111 +++- resource/tools/schedules-to-grouped.py | 22 +- resource/tools/stamp-schedules.py | 105 ++++ ui/_shared.css | 26 +- ui/busDetailExpanded.html | 13 - ui/i18n.js | 575 ++---------------- ui/imageurl.js | 31 + ui/index.html | 31 +- ui/locales/en.json | 269 ++++++++ ui/locales/th.json | 269 ++++++++ ui/map.css | 3 + ui/map.js | 156 ++++- ui/offline.html | 5 +- ui/partials/blog-data/README.md | 62 ++ ui/partials/blog-data/pic1.jpg | Bin 13529 -> 238232 bytes ui/partials/blog-data/pic2.jpg | Bin 13529 -> 93282 bytes ui/partials/blog-data/text1.json | 24 +- ui/partials/blog-data/text2.json | 256 +++++++- ui/partials/blog-data/text3.json | 46 +- ui/partials/blog-data/text4.json | 38 +- ui/partials/blog-data/text5.json | 25 + ui/partials/blog-data/text6.json | 25 + ui/partials/blog.html | 76 ++- ui/partials/blog.init.js | 364 ++++++++++- ui/partials/busDetail.html | 40 +- ui/partials/busDetail.init.js | 143 ++++- ui/partials/busDetailExpanded.html | 244 -------- ui/partials/busStop.init.js | 3 +- ui/partials/checkSchedule.html | 5 +- ui/partials/checkSchedule.init.js | 266 +++++++- ui/partials/credits.html | 20 +- ui/partials/home.html | 2 +- ui/partials/schedules.js | 53 +- ui/partials/stopDetail.html | 2 +- ui/partials/stopDetail.init.js | 7 +- ui/responsive.css | 25 +- ui/router.js | 8 +- ui/stops/chatuchak-minibus-terminal.html | 7 +- ui/sw.js | 27 +- ui/vendor/fonts/k2d-300-latin-ext.woff2 | Bin 0 -> 12264 bytes ui/vendor/fonts/k2d-300-latin.woff2 | Bin 0 -> 14288 bytes ui/vendor/fonts/k2d-300-thai.woff2 | Bin 0 -> 11184 bytes ui/vendor/fonts/k2d-400-latin-ext.woff2 | Bin 0 -> 11988 bytes ui/vendor/fonts/k2d-400-latin.woff2 | Bin 0 -> 13840 bytes ui/vendor/fonts/k2d-400-thai.woff2 | Bin 0 -> 10720 bytes ui/vendor/fonts/k2d-500-latin-ext.woff2 | Bin 0 -> 12296 bytes ui/vendor/fonts/k2d-500-latin.woff2 | Bin 0 -> 14404 bytes ui/vendor/fonts/k2d-500-thai.woff2 | Bin 0 -> 11108 bytes ui/vendor/fonts/k2d-600-latin-ext.woff2 | Bin 0 -> 12232 bytes ui/vendor/fonts/k2d-600-latin.woff2 | Bin 0 -> 14308 bytes ui/vendor/fonts/k2d-600-thai.woff2 | Bin 0 -> 10944 bytes ui/vendor/fonts/k2d-700-latin-ext.woff2 | Bin 0 -> 12392 bytes ui/vendor/fonts/k2d-700-latin.woff2 | Bin 0 -> 14512 bytes ui/vendor/fonts/k2d-700-thai.woff2 | Bin 0 -> 11004 bytes ui/vendor/fonts/k2d-800-latin-ext.woff2 | Bin 0 -> 12032 bytes ui/vendor/fonts/k2d-800-latin.woff2 | Bin 0 -> 13688 bytes ui/vendor/fonts/k2d-800-thai.woff2 | Bin 0 -> 10320 bytes ui/vendor/fonts/k2d.css | 161 +++++ 109 files changed, 3335 insertions(+), 1225 deletions(-) create mode 100644 resource/data/QGIS Project/Sawangha-bangkok.qgz create mode 100644 resource/data/QGIS Project/angthongtoanytrain.qgz create mode 100644 resource/data/QGIS Project/angthongtoanytrain/อ่างทอง-บ้านภาชี(สายสีแดงเข้ม).gpkg create mode 100644 resource/data/QGIS Project/angthongtoanytrain/อ่างทอง-รถไฟฟ้าชานเมืองอยุธยา(สายสีแดงเข้ม).gpkg create mode 100644 resource/data/QGIS Project/angthongtoanytrain/อ่างทอง-วัชรพล.gpkg create mode 100644 resource/data/QGIS Project/angthongtoanytrain/อ่างทอง-สถานีรถไฟความเร็วสูงอยุธยา.gpkg create mode 100644 resource/data/QGIS Project/angthongtoanytrain/อ่างทอง-เมืองทองธานี.gpkg create mode 100644 resource/data/QGIS Project/angthongtoanytrain/อ่างทอง-แยกปากเกร็ด.gpkg create mode 100644 resource/data/QGIS Project/รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok station.dbf create mode 100644 resource/data/QGIS Project/รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok station.prj create mode 100644 resource/data/QGIS Project/รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok station.shp create mode 100644 resource/data/QGIS Project/รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok station.shx create mode 100644 resource/data/QGIS Project/รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok.dbf create mode 100644 resource/data/QGIS Project/รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok.prj create mode 100644 resource/data/QGIS Project/รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok.shp create mode 100644 resource/data/QGIS Project/รถมินิบัส แสวงหา-กรุงเทพ/Sawangha-bangkok.shx create mode 100644 resource/data/geojson-web/dream-Watcharapol.geojson create mode 100644 resource/data/geojson-web/dream-ayutthaya-hsr.geojson create mode 100644 resource/data/geojson-web/dream-ayutthaya-redline.geojson create mode 100644 resource/data/geojson-web/dream-banchang.geojson create mode 100644 resource/data/geojson-web/dream-muangthong.geojson create mode 100644 resource/data/geojson-web/dream-pakkret.geojson create mode 100644 resource/tools/bump-version.py create mode 100644 resource/tools/check-i18n.py create mode 100644 resource/tools/stamp-schedules.py delete mode 100644 ui/busDetailExpanded.html create mode 100644 ui/imageurl.js create mode 100644 ui/locales/en.json create mode 100644 ui/locales/th.json create mode 100644 ui/partials/blog-data/text5.json create mode 100644 ui/partials/blog-data/text6.json delete mode 100644 ui/partials/busDetailExpanded.html create mode 100644 ui/vendor/fonts/k2d-300-latin-ext.woff2 create mode 100644 ui/vendor/fonts/k2d-300-latin.woff2 create mode 100644 ui/vendor/fonts/k2d-300-thai.woff2 create mode 100644 ui/vendor/fonts/k2d-400-latin-ext.woff2 create mode 100644 ui/vendor/fonts/k2d-400-latin.woff2 create mode 100644 ui/vendor/fonts/k2d-400-thai.woff2 create mode 100644 ui/vendor/fonts/k2d-500-latin-ext.woff2 create mode 100644 ui/vendor/fonts/k2d-500-latin.woff2 create mode 100644 ui/vendor/fonts/k2d-500-thai.woff2 create mode 100644 ui/vendor/fonts/k2d-600-latin-ext.woff2 create mode 100644 ui/vendor/fonts/k2d-600-latin.woff2 create mode 100644 ui/vendor/fonts/k2d-600-thai.woff2 create mode 100644 ui/vendor/fonts/k2d-700-latin-ext.woff2 create mode 100644 ui/vendor/fonts/k2d-700-latin.woff2 create mode 100644 ui/vendor/fonts/k2d-700-thai.woff2 create mode 100644 ui/vendor/fonts/k2d-800-latin-ext.woff2 create mode 100644 ui/vendor/fonts/k2d-800-latin.woff2 create mode 100644 ui/vendor/fonts/k2d-800-thai.woff2 create mode 100644 ui/vendor/fonts/k2d.css diff --git a/AGENTS.md b/AGENTS.md index ad08ee0..6bff5a6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -216,7 +216,7 @@ URL ที่ใช้ได้: `#/stops/` และ `#/stops/` และ `#/stops/` @@ -261,10 +261,36 @@ URL ที่ใช้ได้: `#/stops/` และ `#/stops/` ปุ่ม "ดูตารางเวลาสาย N" ยังใช้ `#/check/<รหัส>` ตามเดิม — คนละบริบท) +## สีของเลขสายตามหมวดเส้นทาง (`#/routes/`) + +เลขสายในหัวเรื่อง (`.mu-route-chip #route-chip`) เปลี่ยน**สีพื้นหลังตามหมวดเส้นทาง** +โดยอ่านจาก `routes.json → route_group` (นิยามหมวดอยู่ที่ `route_groups.json`) + +| `route_group` | สี | คลาส | สายที่ใช้ตอนนี้ | +|---|---|---|---| +| `bangkok` | น้ำเงิน `#1f5fbf` | `.grp-bangkok` | 902, 15, 951, 952, 954, 8, 999 | +| `interprovincial` | ม่วง `#7a4cc0` | `.grp-interprovincial` | 101, 464, 641, 2194 | +| `in_province` | ชมพู `#d6388f` | `.grp-in_province` | 324, 1011, 2231 | +| `municipal` | เทา `#6b7268` | `.grp-municipal` | *(สำรอง — ยังไม่มีสายใช้)* | +| ไม่ระบุ | ม่วงแบรนด์ (ค่าเริ่มต้น) | — | — | + +**วิธีทำงาน:** `busDetail.init.js` → `chipEl.className = 'mu-route-chip' + (route.route_group ? ' grp-' + route.route_group : '')` +→ กฎ CSS `.mu-route-chip.grp-` อยู่ใน `busDetail.html` + +**เพิ่มหมวดใหม่ (3 ขั้น):** +1. เพิ่มหมวดใน `resource/data/route_groups.json` (+ ใส่ `route_group` ให้สายใน `routes.json`) +2. เพิ่มโทเคนสีใน `DESIGN.md §3` และกฎใน `DESIGN.md §5` (หัวข้อ "เลขสายหน้า `#/routes/:id`") +3. เพิ่มกฎ `.mu-route-chip.grp-` ใน `ui/partials/busDetail.html` + +⚠️ ไม่แตะ CSS ของ chip หน้า `#/stops` (คนละบริบท ยังใช้ม่วงแบรนด์) + ## ลิงก์ติดต่อผู้ประกอบการ (หน้ารายละเอียดสาย `#/routes/`) ใช้ฟิลด์ **`web_url`** ใน `routes.json` (มีอยู่เดิม) — ไม่ต้องแก้โค้ดเวลาเพิ่ม/เปลี่ยนลิงก์ +- **`web_url` เก็บเป็นอาร์เรย์ `[ชนิดลิงก์, URL]`** เช่น `["facebook", "https://www.facebook.com/..."]` + → อ่านด้วย `parseWebUrl()` ใน `busDetail.init.js` (รับสตริงเดี่ยวได้ด้วย เผื่อไฟล์เก่า) + → **ใช้ `kind` ที่ระบุในไฟล์ก่อน** ถ้าไม่มีจึงเดาจาก URL · ⚠️ ห้ามใช้ `String(web_url)` ตรง ๆ (จะได้ `"line,https://..."` แล้วลิงก์เสีย) - **ไอคอน + ชื่อ + สี เปลี่ยนตามชนิด URL อัตโนมัติ** (`linkKind()` ใน `busDetail.init.js`): | ตรวจพบ | ไอคอน | โทนสี | ชื่อที่แสดง | |---|---|---|---| @@ -304,3 +330,106 @@ route_id,station_id,from_station_id,offset_min,note ``` - `--check` ดูก่อน · รันเปล่า = เขียนจริง · `--audit` = ตรวจว่าไฟล์ตรงตาราง + **ชี้จุดที่เวลาซ้ำแต่ยังไม่มีกฎ** ✓ - รันซ้ำได้ (idempotent) · จุดอ้างอิงต้องมีเวลาจริง · เขียนไฟล์คง CRLF เดิม + +## บทความ (`#/blog`) — แผนที่ในบทความ 2 โหมด (`textN.json` → `map`) + +**โหมด 1 · เส้นทางจริง** `"map": {"route_id":"101"}` → ใช้ `ATMap.route()` + geojson +- ขึ้นเฉพาะหน้าอ่าน · ไม่มีไฟล์ geojson → คงรูป + ป้าย `blog.noGeo` + +**โหมด 2 · เส้นทางที่เสนอ ("ความฝัน")** `"map": {"origin":{…}, "routes":[…]}` +- เข้าโหมดนี้ทันทีเมื่อมี `routes` (อาร์เรย์) · ใช้ `ATMap.proposal(el, spec, onPick)` ใน `ui/map.js` +- วาดเส้นต้นทาง → ปลายทาง (เส้นประ สีตาม `line_color`) + หมุดสีเดียวกัน · **คลิกได้ทั้งเส้น หมุด และแถวรายการ** +- แผงรายละเอียดอยู่ใน blog (`buildProposal()` ใน `blog.init.js`) — map.js แค่เรียก `onPick(route)` กลับมา +- **`dest.lat/lng` ต้องเป็นตัวเลข** → ถ้า `null` ไม่วาด แต่ขึ้นในรายการพร้อมป้าย `blog.mapNoCoord` +- `distance_km`/`duration_min`/`fare_thb` = `null` → **ซ่อนในแผง** (ห้ามโชว์ 0 หรือเดาค่า) +- พิกัดต้นทาง: `station_code` → ค้นจาก `stations.json` หรือใส่ `lat`/`lng` ตรง ๆ +- ค่าทุกอย่างเป็น WGS84 · รายการ `routes[]` ใช้ `__layer` ที่ `proposal()` แนบไว้เพื่อไฮไลต์เส้นที่เลือก + +**ร่วมทั้ง 2 โหมด** +- แผนที่ขึ้นเฉพาะหน้าอ่าน — การ์ดในรายการยังใช้รูป `picN.*` (ไม่โหลด Leaflet หลายใบ) +- รูปใน blog เติม `?v=` ผ่าน `ImgURL.of()` · เรียก `invalidateSize()` หลังวาด (กันแผนที่ 0×0) +- เอกสาร schema เต็ม: `ui/partials/blog-data/README.md` + +## ระบบภาษา (i18n) — ไฟล์ต่อภาษา + fallback chain + +**สถาปัตยกรรม (แนวทาง A2):** คำแปล **ไม่ได้อยู่ใน `i18n.js` แล้ว** — แยกเป็นไฟล์ต่อภาษา + +| ส่วน | ที่อยู่ | หน้าที่ | +|---|---|---| +| ไฟล์คำแปล | `ui/locales/th.json` · `en.json` | แบน `"key": "ข้อความ"` (256 คีย์/ภาษา) | +| ตัวโหลด | `ui/i18n.js` | `SUPPORTED` · `BASE='th'` · cache ต่อภาษา · `t()` · `apply()` · `setLang()` · **`ready`** | +| จุดรอโหลด | `ui/router.js` ท้ายไฟล์ | `I18N.ready.then(render)` — รอคำแปลก่อนวาดหน้าแรก | +| precache | `ui/sw.js` | `./locales/th.json` + `./locales/en.json` (ออฟไลน์ใช้ได้) | +| เครื่องมือตรวจ | `resource/tools/check-i18n.py` | ดูหัวข้อท้าย | + +**กติกาเหล็ก** +- เพิ่มคีย์ = ใส่ **ทุกไฟล์ภาษา** ในคำสั่งเดียว · คีย์ที่ขาดจะถอยไปใช้ `BASE` (คำไทยโผล่ในหน้า EN) +- **ห้ามคีย์ซ้ำในไฟล์เดียวกัน** — JSON เก็บตัวหลังเงียบ ๆ (เคยเกิดจริง: ค่าอังกฤษทับค่าไทย ทำให้โหมดไทยแสดงอังกฤษ) +- ข้อความใน HTML คือ **fallback** → ถ้าโหลดไฟล์ภาษาไม่ได้ `apply()` จะ **ไม่แตะ DOM** (ผู้ใช้เห็นข้อความเดิม ไม่เห็น key) +- `t()` คืน **key เดิม** เมื่อไม่พบทั้งภาษาปัจจุบันและ BASE (ใช้ตรวจว่าลืมแปล) +- ข้อความ JS ใช้ `I18N.t(...)` เท่านั้น · ข้อความล้วนใส่ `textContent` · ถ้าต้องมี HTML → `data-i18n-attr="html:key"` +- ชื่อเฉพาะ (สถานี/จังหวัด/สายรถ) **ไม่แปล** +- เพิ่มภาษาใหม่ 4 ขั้น: ไฟล์ `locales/<รหัส>.json` → `SUPPORTED` → PRECACHE ใน `sw.js` → รัน `check-i18n.py` + +**ตรวจก่อน commit** +``` +python resource/tools/check-i18n.py +``` +ERROR = คีย์ขาด · คีย์ซ้ำ · ไฟล์ภาษาไม่ตรง `SUPPORTED` → exit 1 ห้าม commit +WARN = ค่าว่างเปล่า (อาจตั้งใจ) · คีย์ที่ไม่พบที่ใช้ (อาจใช้ไดนามิก) + +## หัวโซน (`.mu-zone-head`) — ป้ายหัวข้อ + บรรทัดข้อมูลที่ตัดคำถูกต้อง + +**ปัญหาเดิม:** `.mu-zone-head` เป็น `display:flex` **ไม่มี `flex-wrap`** แต่ลูก ๆ เป็น `flex-basis:100%` +→ ทุกบรรทัดถูกย่อรวมในแถวเดียว ข้อความไทยถูกตัดกลางคำ (แย่มากบนมือถือ) + +**แก้แล้ว:** +| ส่วน | ที่อยู่ | ทำอะไร | +|---|---|---| +| โครง flex/grid | `ui/index.html` (§.mu-zone-head) | `flex-wrap: wrap` + `.mu-zone-head .mu-zone-desc { flex-basis:100%; min-width:0; line-height:1.65 }` | +| กฎจริง (ต้องชนะ partial) | `ui/responsive.css` (`#view …`) | `.mu-zone-meta` / `.mu-zone-seg` / ตัวคั่น `::after` · ≥768px เปลี่ยนเป็น grid 2 คอลัมน์ + `max-width:82ch` | +| สร้างชิ้น | `ui/partials/checkSchedule.init.js` → `setSegments(host, segs)` | รับ `"ข้อความ"` หรือ `{ html, icon }` · ข้อความล้วนใช้ `textContent` (กัน HTML หลุด) | +| HTML | `ui/partials/checkSchedule.html` | `#check-zone-desc` = `mu-zone-desc mu-zone-meta` · `#check-now-line` เพิ่ม `mu-zone-now` | + +**กติกาสำคัญ** +- **ห้าม** สร้างบรรทัดข้อมูลด้วยสตริงเดียวที่ต่อ `' · '` เอง → ให้ส่ง array เข้า `setSegments()` เสมอ +- ตัวคั่น `·` **ห้าม** ใส่ในข้อความ — CSS `(.mu-zone-seg:not(:last-child)::after)` วาดให้ (ชิ้นสุดท้ายไม่มีจุด) +- ต้องการสไตล์ใหม่ → ใส่ที่ `responsive.css` **พร้อม prefix `#view`** (เพราะ ` - -
-
-

หน้าแรก/ รายละเอียดสายรถ

-

101 อ่างทอง - ป่าโมก - อยุธยา

- -
- ภาพบรรยากาศริมทางของสาย 101 -
- ขยายข้อมูล · 4 จุดจอดหลัก -

ตารางเวลาแบบขยายทุกจุดจอด

-

เชื่อมต่ออ่างทอง → ป่าโมก → อยุธยา · ดูตารางรถของทุกป้ายอย่างละเอียด

-
-
- -
- หมวดเส้นทางระหว่างจังหวัด - รถบัส - 2 จังหวัด · อ่างทอง · อยุธยา - 4 จุดจอด -
-

mock state: ?route=101&origin=at_main_terminal&view=expanded

- -
- - ← กลับหน้าแรก -
- -
-

ติดต่อผู้ประกอบการ

-
- +66 64 963 9025 - ยังไม่ระบุเว็บไซต์ -
-
- LINE QR สาย 101 -
- ติดตามข่าวสาย 101 - สแกน QR รับข่าวสาร · เลื่อนเวลา · ไม่มีรถ - LINE Official -
-
-
- รถของสาย 101 -
-

รถบัสประจำสาย

-

รถปรับอากาศ · ไม่สูบบุหรี่ · 40 ที่นั่ง
ออกรอบละ 24 เที่ยว · ช่วง 04:30-21:00

-
-
-
- -
-

จุดจอดสำคัญบนเส้นทาง

-
    -
  • -
    - - ต้นทาง - - บขส.อ่างทอง - อ่างทอง - - - ⌄ - - -
    - บขส.อ่างทอง -

    ตารางเดินรถ ณ บขส.อ่างทอง

    -
    -
    07:30
    08:20
    -
    10:00
    -
    10:50
    11:50
    -
    13:00
    14:00
    -
    15:00
    -
    - -
    -
    -
  • -
  • -
    - - จุดเปลี่ยน - - สถานีขนส่งป่าโมก - อ่างทอง - - - ⌄ - - -
    - สถานีขนส่งป่าโมก -

    ไปอ่างทอง ทิศทาง

    -
    -
    07:30
    08:20
    -
    09:10
    10:00
    -
    10:50
    11:40
    -
    12:30
    13:20
    -
    14:10
    15:00
    -
    15:50
    16:40
    -
    17:30
    18:30
    -
    -

    ไปอยุธยา ทิศทาง

    -
    -
    08:00
    08:50
    -
    09:40
    10:30
    -
    11:20
    12:20
    -
    13:30
    14:30
    -
    15:30
    -
    -

    เวลารถเปลี่ยนทุกวัน โดยเฉพาะวันหยุด

    - -
    -
    -
  • -
  • -
    - - ผ่านทาง - - จุดขึ้นลงรถสองแถว 101 อยุธยา-ป่าโมก-อ่างทอง - อยุธยา - - - ⌄ - - -
    - จุดขึ้นลงรถสองแถว -

    ยังไม่มีข้อมูลตารางอัปเดต

    - -
    -
    -
  • -
  • -
    - - ปลายทาง - - ตลาดเจ้าพรหม - อยุธยา - - - ⌄ - - -
    - ตลาดเจ้าพรหม อยุธยา -

    ตารางเดินรถ ณ ตลาดเจ้าพรหม (อยุธยา)

    -
    -
    06:30
    07:20
    -
    08:10
    -
    09:50
    10:40
    -
    11:30
    12:20
    -
    13:10
    14:00
    -
    14:50
    15:40
    -
    16:30
    17:30
    -
    - -
    -
    -
  • -
-
- -
-

เลือกสายรถอื่น

- -
-
-
diff --git a/ui/partials/busStop.init.js b/ui/partials/busStop.init.js index 1c30853..ce69075 100644 --- a/ui/partials/busStop.init.js +++ b/ui/partials/busStop.init.js @@ -63,7 +63,8 @@ function next() { if (i >= IMG_EXTS.length) return Promise.resolve(null); var url = base + '.' + IMG_EXTS[i++]; - return exists(url).then(function (u) { return u || next(); }); + var bu = (window.ImgURL && ImgURL.of) ? ImgURL.of(url) : url; /* ?v= กัน cache-first ของ SW */ + return exists(bu).then(function (u) { return u || next(); }); } return next(); } diff --git a/ui/partials/checkSchedule.html b/ui/partials/checkSchedule.html index 151af5c..3e98bbe 100644 --- a/ui/partials/checkSchedule.html +++ b/ui/partials/checkSchedule.html @@ -164,8 +164,9 @@
ตารางเวลาเดินรถทุกจุดจอด -

-

+

+

+

diff --git a/ui/partials/checkSchedule.init.js b/ui/partials/checkSchedule.init.js index f4ed1a8..284050d 100644 --- a/ui/partials/checkSchedule.init.js +++ b/ui/partials/checkSchedule.init.js @@ -27,7 +27,9 @@ var ONLY_STOPS_WITH_SCHEDULE = false; var sections = []; /* [{ chips:[], times:[], station }] */ - var netRoute = null; /* routes.json ของสายที่แสดงอยู่ */ + var netRoute = null; + var OTHER_ENTRIES = []; + var ROUTE_IDS = []; /* routes.json ของสายที่แสดงอยู่ */ var timer = null; function $(id) { return document.getElementById(id); } @@ -56,10 +58,15 @@ } /* ---------- จำแนกประเภทจุดจอดจากข้อมูล + ลำดับในเส้นทาง ---------- */ + /* บทบาทของจุดในการ์ด: + index 0 = ต้นทาง · index สุดท้าย = ปลายทาง + ระหว่างนั้น: จุดที่เป็น "สถานีขนส่งหลัก" = กลางทาง (จุดพักรถที่คนขึ้น/ลงได้) + จุดป้ายริมทางทั่วไป = ผ่านทาง + ⚠️ ใช้กับ "ลำดับที่แสดงในหน้านี้" เท่านั้น — ลำดับมาอยู่ที่ station_order ไม่ใช่บทบาทถาวร */ 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 }; + if (st && st.station_type === 'main_terminal') return { key: 'route.transfer', icon: 'ic-map-pin', tone: TONES.transfer }; return { key: 'route.pass', icon: 'ic-map-pin', tone: TONES.pass }; } @@ -111,12 +118,12 @@ return; } - /* หัวแถว = ชื่อทิศ (dir_label) → ไม่มีค่อยใช้ dir_note → ไม่มีอีกค่อยบอกว่าอยู่ที่จุดนี้ + /* หัวแถว = ชื่อทิศ (direction_label) → ไม่มีค่อยใช้ direction_note → ไม่มีอีกค่อยบอกว่าอยู่ที่จุดนี้ ทิศที่ไปคนละทางจากจุดเดียวกัน (ป่าโมกไปอ่างทอง / ป่าโมกไปอยุธยา) จึงแยกให้เห็นชัด */ var sub = document.createElement('p'); sub.className = 'mu-stop-sub'; - if (r.dir_label) { - sub.innerHTML = esc(r.dir_label) + + if ((r.direction_label || r.dir_label)) { + sub.innerHTML = esc((r.direction_label || r.dir_label)) + (r.direction_note ? ' ' + esc(r.direction_note) + '' : ''); } else if (r.direction_note) { sub.innerHTML = esc(r.direction_note) + ' ' + esc(t('check.direction')) + ''; @@ -175,32 +182,212 @@ }); } + /* ---------- แถวข้อมูลแบบ "ชิ้น" (segment) ---------- + แต่ละชิ้นเป็น flex item → ตัดบรรทัดเป็นหน่วย ไม่ตัดกลางคำ + (สำคัญกับข้อความไทยที่ไม่มีเว้นวรรค เช่น "บขส.อ่างทอง → สถานีเดินรถโดยสารขนาดเล็ก (จตุจักร)" + จะไม่ถูกตัดกลางชื่อสถานี) · ตัวคั่น "·" วาดด้วย CSS (.mu-zone-seg + .mu-zone-seg::before) */ + function icSvg(name) { + return ''; + } + /* seg = "ข้อความล้วน" หรือ { html: "...", icon: "ic-xxx" } (html ต้อง esc() มาก่อน) */ + function setSegments(host, segs) { + if (!host) return; + host.innerHTML = ''; + segs.forEach(function (s) { + var seg = document.createElement('span'); + seg.className = 'mu-zone-seg'; + if (s && typeof s === 'object') { + seg.innerHTML = (s.icon ? icSvg(s.icon) : '') + (s.html || ''); + } else { + seg.textContent = String(s == null ? '' : s); /* ข้อความล้วน — ปลอดภัยจาก HTML */ + } + host.appendChild(seg); + }); + } + + /* ---------- "อัปเดตล่าสุด N วันที่แล้ว" จากฟิลด์ updated (ISO) ---------- + เทียบ "วันนี้" กับวันที่ในฟิลด์ updated (ไม่ใช้เวลา → ไม่มีปัญหา timezone) + วันเดียวกัน → "วันนี้" · เมื่อวาน → "เมื่อวาน" + < 7 วัน → N วันที่แล้ว · < 30 วัน → N สัปดาห์ที่แล้ว + < 365 วัน → N เดือนที่แล้ว · มากกว่า → N ปี M เดือนที่แล้ว + หมายเหตุ: ใช้ mtime/Last-Modified จากเบราว์เซอร์ไม่ได้ (fetch ข้ามโดเมนไม่ให้อ่าน) + → ค่ามาจาก resource/tools/stamp-schedules.py ที่เติมจาก mtime จริง */ + function daysAgo(iso) { + var m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '').trim()); + if (!m) return null; + var then = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3])); + if (isNaN(then.getTime())) return null; + var now = new Date(); + var today = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())); + return Math.round((today - then) / 86400000); + } + function agoLabel(days) { + if (days == null) return ''; + if (days <= 0) return t('check.agoToday'); + if (days === 1) return t('check.agoYesterday'); + if (days < 7) return t('check.agoDays', { n: days }); + if (days < 30) return t('check.agoWeeks', { n: Math.floor(days / 7) }); + if (days < 365) return t('check.agoMonths', { n: Math.floor(days / 30) }); + var y = Math.floor(days / 365), mo = Math.floor((days % 365) / 30); + return mo ? t('check.agoYearsMonths', { y: y, m: mo }) : t('check.agoYears', { y: y }); + } + + function appendSubStopCards(listEl, rid, groups, schedDoc, recs) { + if (!window.OtherStop || !OtherStop.allStops || !window.Schedules) return; + /* allStops() คืน "รายการแบน": [{ index, name, city_th, province_th, lat, lng, offsetMin, hasCoord, entry }] */ + var sub = OtherStop.allStops(OTHER_ENTRIES, rid, ROUTE_IDS); + if (!sub || sub.length < 2) return; /* มีจุดเดียว = การ์ดหลักแสดงอยู่แล้ว */ + + var first = sub[0].name; + + /* จุดอ้างอิง = จุดแรกของจุดย่อย (index 0 · offset = 0) ซึ่งตรงกับการ์ดหลัก (station 8) + แต่ละทิศมี "จุดอ้างอิงของตัวเอง" — ทิศที่มีข้อมูล (station_id = จุดอ้างอิง) ให้ offset คงที่ (+0) + สายที่วิ่ง 2 ทาง (ไป-กลับ) จึงแสดงครบทั้ง 2 ทิศในทุกจุดย่อย + ทิศที่ยังไม่มีตาราง (แค่ชื่อทิศ) → ไม่แสดง (ห้ามเดาเวลาที่ไม่มีต้นทาง) */ + /* จุดอ้างอิง = "จุดขึ้นรถประจำทางอื่นๆ" (station 8) — จุดแรกของ other_stop คือจุดที่มีตารางจริง + ไม่ใช้ "record แรก" เพราะ recs เรียงตาม station_order (บขส.อ่างทองมาก่อน) จะได้จุดอ้างอิงผิด */ + var hubSid = null, hubDir = null; /* hubDir = ชื่อทิศ "ของจุดอ้างอิง" (ตัวตั้งเวลา) */ + groups.forEach(function (g) { + if (String(g.sid) === '8') hubSid = '8'; + }); + if (hubSid === null) { /* ไม่มี station 8 → ใช้จุดแรกที่มีเวลาตามเดิม */ + groups.forEach(function (g) { + g.recs.forEach(function (r) { + if ((r.departure_times || []).length && hubSid === null) hubSid = String(r.station_id); + }); + }); + } + /* ทิศตั้งต้น = ทิศที่ "เริ่มจากจุดอ้างอิง" (จุดแรกของ other_stop = วัดสีบัวทอง) + ตัวชี้ที่ใช้ได้: ชื่อทิศตรงกับ "จาก<ชื่อจุดแรก>" หรือ note ของจุดย่อย */ + var hubName = sub[0].name; + recs.forEach(function (r) { + if (String(r.route_id) !== rid) return; + if (hubDir !== null || !(r.departure_times || []).length) return; + var lbl = String((r.direction_label || r.dir_label) || ''); + var note = String((r.direction_note || r.dir_note) || ''); + if (lbl.indexOf(hubName) !== -1 || note.indexOf(hubName) === 0) hubDir = (r.direction_label || r.dir_label); + }); + if (hubSid === null) return; /* ไม่มีตารางจริงเลย → คำนวณไม่ได้ */ + + /* ทุกทิศของสายนี้: ทิศของจุดอ้างอิง = เวลาต้นทาง · ทิศอื่น = จุดอ้างอิง + offset ของจุดนี้ */ + var legs = []; + recs.forEach(function (r) { + if (String(r.route_id) !== rid) return; /* เฉพาะสายนี้ — recs มีทุกสาย */ + if (!(r.departure_times || []).length) return; /* ทิศนี้ยังไม่มีตาราง → ข้าม */ + legs.push({ rec: r, fixed: ((r.direction_label || r.dir_label) === hubDir) ? 0 : null }); + }); + if (!legs.length) return; /* ไม่มีทิศที่คำนวณได้ → ไม่แสดงการ์ดย่อย */ + + /* จุดแรกของจุดย่อย = จุดอ้างอิงเอง (แสดงเป็นการ์ดหลักอยู่แล้ว) → เริ่มที่จุดที่ 2 + และข้ามจุดที่พิกัด/ชื่อซ้ำกับจุดอ้างอิง */ + sub.slice(1).forEach(function (x) { + if (x.name === hubName) return; /* ชื่อซ้ำกับการ์ดต้นทาง → ไม่แสดงซ้ำ */ + var off = (x.offsetMin == null ? null : Number(x.offsetMin)); + var li = document.createElement('li'); + var det = document.createElement('details'); + det.className = 'mu-stop-card'; + det.open = true; + var where = [x.city_th, x.province_th].filter(Boolean).join(' · '); + var sum = document.createElement('summary'); + sum.innerHTML = + '' + + ' ' + + esc(t('stops.subStop')) + '' + + '' + esc(x.name) + '' + esc(where) + '' + + '\u2304' + + ''; + det.appendChild(sum); + + var body = document.createElement('div'); + body.className = 'mu-stop-body'; + + if (off == null) { /* ยังไม่ระบุเวลาเดินทาง → คำนวณไม่ได้ */ + var na = document.createElement('p'); + na.className = 'mu-stop-sub'; + na.textContent = t('stops.noOffset'); + body.appendChild(na); + } else { + legs.forEach(function (leg) { + var r = leg.rec; + var raw = (r.departure_times || []).length ? r.departure_times : []; + if (!raw.length) return; /* ทิศนี้ยังไม่มีตารางจริง → ข้าม */ + + /* ทิศของจุดอ้างอิงเอง (fixed = 0) → เวลาเท่าต้นทาง · ทิศอื่น → บวก offset ของจุดนี้ */ + var o = (leg.fixed === 0) ? 0 : off; + var times = (o === 0) ? raw.slice() : Schedules.shiftTimes(raw, o); + + var head = document.createElement('p'); + head.className = 'mu-stop-sub'; + head.textContent = (r.direction_label || r.dir_label) || r.direction_note || ('จาก ' + first); + body.appendChild(head); + + var grid = document.createElement('div'); + grid.className = 'mu-time-grid' + (o === 0 ? '' : ' is-est'); + var chips = []; + times.forEach(function (tm) { + var chip = document.createElement('div'); + chip.className = 'mu-time-chip'; + chip.textContent = tm; + grid.appendChild(chip); + chips.push(chip); + }); + body.appendChild(grid); + /* ให้จุดย่อยอยู่ในระบบ "รอบถัดไป" ด้วย (refreshHighlights วน sections[]) + ไม่งั้นชิปของจุดย่อยไม่ถูกไฮไลต์ และรอบถัดไปมองไม่เห็นเวลาของจุดนี้ */ + sections.push({ chips: chips, times: times, station: x.name }); + + if (o !== 0) { + var note = document.createElement('p'); + note.className = 'mu-est-note'; + note.textContent = t('time.derived', { base: first, n: Schedules.offsetLabel(o) }); + body.appendChild(note); + } + }); + } + + det.appendChild(body); + li.appendChild(det); + listEl.appendChild(li); + }); + } + /* ---------- ไฮไลต์เที่ยวถัดไป + บรรทัดเวลาปัจจุบัน ---------- */ function refreshHighlights() { var nowm = nowMin(); var next = null; /* เที่ยวถัดไปที่เร็วที่สุดในทุกจุดจอด */ + /* เลือกเที่ยวถัดไปของจุดหนึ่ง ๆ + - ถ้ามีเที่ยวที่ยังไม่ผ่านวันนี้ → ใช้ตัวแรกนั้น + - ถ้าหมดทุกเที่ยวของวันแล้ว → วนไปเที่ยวแรกของ "วันถัดไป" (+1440 เพื่อเทียบลำดับข้ามวันได้) + หน้าจอแสดงแค่ HH:MM (ไม่ติดป้าย "พรุ่งนี้" — เจ้าของข้อมูลกำหนด) แต่ไฮไลต์ชิปแบบเดียวกัน */ + function pick(sec, idx, m) { + if (idx < 0 || !sec.chips[idx]) return; + sec.chips[idx].classList.add('next'); + if (next === null || m < next.m) next = { m: m, time: sec.times[idx], station: sec.station }; + } + sections.forEach(function (sec) { sec.chips.forEach(function (c) { c.classList.remove('next'); }); + if (!sec.times.length) return; 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; - } + if (m >= nowm) { pick(sec, i, m); return; } } + pick(sec, 0, toMin(sec.times[0]) + 1440); /* หมดวัน → เที่ยวแรกพรุ่งนี้ */ }); setStat('check-stat-next', next ? next.time : ''); var line = $('check-now-line'); if (!line) return; - var clock = ' '; - var body = esc(t('check.now')) + ' ' + hhmm(nowm) + ''; - if (next) body += ' · ' + esc(t('check.nextAt')) + ' ' + esc(next.time) + ' (' + esc(next.station) + ')'; - else if (sections.length) body += ' · ' + esc(t('check.noMoreToday')) + ''; - line.innerHTML = clock + body; + var nowSegs = [{ icon: 'ic-clock', html: esc(t('check.now')) + ' ' + hhmm(nowm) + '' }]; + if (next) { + nowSegs.push({ html: esc(t('check.nextAt')) + ' ' + esc(next.time) + ' ' + + '(' + esc(next.station) + ')' }); + } else if (sections.length) { + nowSegs.push({ html: '' + esc(t('check.noMoreToday')) + '' }); + } + setSegments(line, nowSegs); } /* ---------- โหลด + แสดงผล ---------- */ @@ -212,9 +399,12 @@ Promise.all([ fetchJSON(DATA + 'routes.json'), fetchJSON(DATA + 'stations.json'), - Schedules.load().then(function (sd) { return Schedules.normSub(sd); }) + Schedules.load().then(function (sd) { return Schedules.normSub(sd); }), + fetchJSON(DATA + '8 other_stop.json').catch(function () { return null; }) /* จุดย่อยของ "จุดขึ้นรถอื่นๆ" */ ]).then(function (res) { var routes = (res[0] || {}).routes || []; + OTHER_ENTRIES = (res[3] || {}).other_stop || []; + ROUTE_IDS = routes.map(function (r) { return String(r.route_id); }); var sts = (res[1] || {}).stations || []; if (window.Schedules && Schedules.setStationNames) Schedules.setStationNames(sts); /* ให้ข้อความ "คำนวณจาก ..." มีชื่อจุด */ var recs = window.Schedules ? Schedules.records(res[2]) : ((res[2] || {}).schedules || res[2] || []); @@ -248,6 +438,15 @@ var hero = $('check-hero-route'); if (hero) hero.textContent = 'สาย ' + rid + (route.route_name_th ? ' · ' + route.route_name_th : ''); + /* "อัปเดตล่าสุด N วันที่แล้ว" — วันที่จากฟิลด์ updated ของไฟล์ตารางสายนี้ (Schedules.updatedOf) + แยกบรรทัดของตัวเอง (#check-updated-line) เพราะ #check-now-line แสดงเวลาปัจจุบันอยู่แล้ว */ + var updLine = $('check-updated-line'); + if (updLine) { + var upd = (window.Schedules && Schedules.updatedOf) ? Schedules.updatedOf(rid) : null; + var nDays = daysAgo(upd); + updLine.textContent = nDays == null ? '' : t('check.updatedAgo', { ago: agoLabel(nDays) }); + } + /* จัดกลุ่มตามลำดับจุดจอดของสาย แล้วต่อด้วยจุดที่เหลือ (ถ้ามีข้อมูล) */ var order = (route.station_ids || []).slice(); /* schema 2: ใช้ station_order ที่ตรวจทิศทางมาแล้วจากไฟล์ (ถ้ามี) */ @@ -257,12 +456,21 @@ if (String(r.route_id) === rid && order.indexOf(r.station_id) === -1) order.push(r.station_id); }); + /* จุดที่เป็น "จุดขึ้นรถประจำทางอื่นๆ" (station 8) ให้ใช้ชื่อจริงของสายนั้น + จาก 8 other_stop.json (จุดแรก) เช่น 954 → "ตลาดท่าช้าง" แทนชื่อกลาง ๆ */ + var firstSubName = null; + if (window.OtherStop && OtherStop.allStops) { + var allSub = OtherStop.allStops(OTHER_ENTRIES, rid, ROUTE_IDS); + if (allSub.length) firstSubName = allSub[0].name; /* จุดแรกของจุดย่อย = ชื่อจริงของสายนี้ */ + } + var groups = order.map(function (sid) { var st = byId[sid] || null; + var isOtherHub = String(sid) === '8'; /* จุดรวม "จุดขึ้นรถอื่นๆ" */ return { sid: sid, st: st, - name: st ? st.station_name_th : 'จุดจอด ' + sid, + name: isOtherHub && firstSubName ? firstSubName : (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; }) @@ -272,7 +480,12 @@ }); var listEl = $('check-schedule-list'); - if (listEl) renderList(listEl, route, groups); + if (listEl) { + renderList(listEl, route, groups); + /* จุดย่อยของสายนั้น (จาก 8 other_stop.json) — จุดที่ 2 เป็นต้นไปของสาย 8 + เช่น 2194: ① วัดหัวเวียง ② วัดถนน (เวลาจุดถัดไป = เวลาจุดแรก + offsets_min) */ + appendSubStopCards(listEl, rid, groups, res[2], recs); + } var desc = $('check-zone-desc'); if (desc) { @@ -280,7 +493,7 @@ /* บอกว่า "ตารางวันนี้" เป็นของวันไหน — เฉพาะสายที่มีการแยกตารางตามวัน (service) เท่านั้น สายอื่นข้อความเหมือนเดิมทุกตัวอักษร */ /* ป้ายบอกว่า "ตารางที่เห็นอยู่นี้เป็นของวันไหน" — ใช้ผลตรวจวันจากตัวอ่านกลาง (ไม่คำนวณเองในหน้านี้) */ - var dayLine = ''; + var dayText = ''; if (window.Schedules && Schedules.dayInfo && Schedules.directions) { var di = Schedules.dayInfo(); var infos = (Schedules.directions(res[2], rid) || []).map(function (d) { return d.service || { from: 'ไม่ระบุ' }; }); @@ -288,17 +501,20 @@ var unknown = infos.some(function (x) { return x.unknown; }); /* ยังไม่ระบุวันเลย */ var selectedByDay = infos.some(function (x) { return x.from === 'service' || x.from === 'ระบุตรง' || x.from === 'คำในโน้ต'; }); if (unknown) { - dayLine = ' · ' + t('check.dayUnknown'); + dayText = t('check.dayUnknown'); } else if (conflict) { - dayLine = ' · ' + t('check.dayMixed'); + dayText = t('check.dayMixed'); } else if (selectedByDay) { - dayLine = ' · ' + t(di.dayType === 'holiday' ? 'check.dayHoliday' : 'check.dayWeekday') + + dayText = t(di.dayType === 'holiday' ? 'check.dayHoliday' : 'check.dayWeekday') + ' (' + t('check.dayOfWeek') + ' ' + di.weekday_th + ')'; } } - desc.textContent = 'สาย ' + rid + ' · ' + - (names.length > 1 ? names[0] + ' \u2192 ' + names[names.length - 1] + ' · ' : '') + - groups.length + ' ' + t('check.stopsCount') + dayLine; + /* แยกเป็นชิ้น ๆ เพื่อให้ตัดบรรทัดได้เป็นหน่วย (ไม่ตัดกลางชื่อสถานี/ชื่อวัน) */ + var segs = ['สาย ' + rid]; + if (names.length > 1) segs.push(names[0] + ' \u2192 ' + names[names.length - 1]); + segs.push(groups.length + ' ' + t('check.stopsCount')); + if (dayText) segs.push(dayText); + setSegments(desc, segs); } /* KPI */ diff --git a/ui/partials/credits.html b/ui/partials/credits.html index 0ed8c42..c1397ac 100644 --- a/ui/partials/credits.html +++ b/ui/partials/credits.html @@ -41,8 +41,10 @@

ฟอนต์ — Google Fonts

แหล่งที่มา: fonts.google.com · ใบอนุญาต: SIL Open Font License 1.1

    -
  • Noto Sans Thai — ฟอนต์เนื้อหาหลัก (โหลดผ่าน Google Fonts CDN)
  • -
  • Prompt — ฟอนต์หัวเรื่อง/ตัวหนา
  • +
  • K2D — ฟอนต์หลักของเว็บ (เนื้อหา + หัวเรื่อง) · มีหัวแบบไทย น้ำหนัก 300–800
  • +
  • Noto Sans Thai — ตัวสำรองเนื้อหา (โหลดผ่าน Google Fonts CDN)
  • +
  • Prompt — ตัวสำรองหัวเรื่อง/ตัวหนา
  • +
  • IBM Plex Mono — เวลา · เลขสาย · ตัวเลข (เรียงตรงกัน)
@@ -56,5 +58,19 @@ +
+

ขอขอบคุณภาพรถประจำทาง

+

ภาพรถโดยสารประจำทางที่แสดงในหน้ารายละเอียดสาย มาจากแหล่งข้อมูลสาธารณะด้านล่างนี้ — ขอบคุณเจ้าของภาพและผู้รวบรวมทุกท่าน

+
    +
  • สาย 2194 หัวเวียง-อยุธยา — จาก bangkokbusclub.com
  • +
  • สาย 8 กรุงเทพ-สรรคบุรี-ชัยนาท — จาก กลุ่ม Facebook (web.facebook.com)
  • +
  • สาย 954 กรุงเทพ-ท่าช้าง — จาก gogo.town
  • +
  • รถไฟฟ้าสายสีแดง กรุงเทพ-ชุมทางบ้านภาชี — จาก thelist.group
  • +
+

+ และสายอื่น ๆ ที่ไม่ได้ระบุ ขอขอบคุณมา ณ ที่นี้ +

+
+
diff --git a/ui/partials/home.html b/ui/partials/home.html index 73d1afa..38a2baa 100644 --- a/ui/partials/home.html +++ b/ui/partials/home.html @@ -63,7 +63,7 @@

ผู้สนับสนุน & พาร์ทเนอร์

-

จองตั๋ว · สั่งของ · เช็กของฝาก ที่ร้านค้าและบริการพันธมิตรของเรา

+

ร่วมเป็นผู้สนับสนุนเราได้ เมื่อซื้อของออนไลน์ หรือซื้อตั๋วรถทัวร์ เครื่องบิน ออนไลน์กดเลือกสินค้า หรือบริการผ่านลิงค์นายหน้าของเราไม่มีค่าใช้จ่ายเพิ่ม

diff --git a/ui/partials/schedules.js b/ui/partials/schedules.js index 033739b..0376462 100644 --- a/ui/partials/schedules.js +++ b/ui/partials/schedules.js @@ -7,7 +7,7 @@ รองรับ schedules.json 2 รูปแบบ: schema 1 (เดิม): { "schedules": [ { route_id, station_id, direction_note, departure_times[], schedule_note } ] } schema 2 (ใหม่): { "schema": 2, "routes": [ { route_id, station_order[], directions: [ - { dir_id, dir_label, service?, stops: [ { station_id, times[], dir_note?, note?, groups? } ] } ] } ] } + { direction_id, direction_label, service?, stops: [ { station_id, times[], direction_note?, note?, groups? } ] } ] } ] } ── เรื่องวันทำงาน / วันหยุด (ไม่ต้องแก้โค้ดหน้าไหนเลย) ──────────────── เพิ่มฟิลด์ "ไม่บังคับ" 2 ระดับ: @@ -24,7 +24,7 @@ API: Schedules.records(doc, opts) → record แบน (schema เดิม) สำหรับโค้ดเดิม Schedules.route(doc, routeId, opts) → { route_id, station_order[], directions[], entries[] } - Schedules.directions(doc, routeId, opts) → [{ dir_id, dir_label, service, dayType, fallback, stops[] }] + Schedules.directions(doc, routeId, opts) → [{ direction_id, direction_label, service, dayType, fallback, stops[] }] Schedules.times(doc, routeId, opts) → เวลาทั้งหมดของสาย (เรียงแล้ว) Schedules.countTrips(doc, routeId, opts) → จำนวนเที่ยวของสาย Schedules.todayType() → 'weekday' | 'holiday' @@ -118,13 +118,13 @@ var from = (src.from_station_id != null) ? Number(src.from_station_id) : null; var stops = []; if (from != null && times.length) { - stops.push({ station_id: from, times: times, dir_note: grp.label || null }); + stops.push({ station_id: from, times: times, direction_note: grp.label || null }); } else if (from != null) { - stops.push({ station_id: from, times: [], dir_note: grp.label || null }); + stops.push({ station_id: from, times: [], direction_note: grp.label || null }); } out.push({ - dir_id: kind + ':' + name, - dir_label: name, + direction_id: kind + ':' + name, + direction_label: name, service: { day: kind, from: 'schema 3', matches: kind === todayType() }, station_order: doc.station_order || [], stops: stops, @@ -184,7 +184,7 @@ ลำดับการตัดสิน: 1) ถ้าทิศมี "days" ระบุตรง ๆ (อา จ อ พ พฤ ศ ส) → ใช้ตามนั้น (แม่นสุด) 2) ถ้ามี service = weekday/holiday → เทียบกับวันนี้ - 3) ถ้าไม่มีอะไรระบุ → อ่านคำใน dir_label / dir_note / note ของสายนั้น (ตรวจคำอัตโนมัติ) + 3) ถ้าไม่มีอะไรระบุ → อ่านคำใน direction_label / direction_note / note ของสายนั้น (ตรวจคำอัตโนมัติ) 4) ตัดสินไม่ได้ → แสดงทุกวัน (ไม่ซ่อนข้อมูล) พร้อมป้ายว่า "ยังไม่ระบุวัน" */ var DAYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; /* ตรงกับ Date.getDay() */ var DAY_TH = { sun: 'อาทิตย์', mon: 'จันทร์', tue: 'อังคาร', wed: 'พุธ', thu: 'พฤหัสบดี', fri: 'ศุกร์', sat: 'เสาร์' }; @@ -216,7 +216,7 @@ return { dayType: t, weekday: DAYS[d.getDay()], weekday_th: DAY_TH[DAYS[d.getDay()]], date: ymd(d), label_th: t === 'holiday' ? 'วันหยุด (ส–อา/นักขัตฤกษ์)' : 'วันทำงาน (จ–ศ)' }; } - /* ตรวจคำในข้อความ (dir_label / dir_note / note) ว่าหมายถึงวันไหน */ + /* ตรวจคำในข้อความ (direction_label / direction_note / note) ว่าหมายถึงวันไหน */ function detectDay(text) { var t = String(text == null ? '' : text).trim(); if (!t) return null; @@ -231,9 +231,9 @@ คืน { day, from, text } หรือ null (ยังไม่ระบุ) */ function detectDayOfDir(d) { var texts = []; - if (d && d.dir_label) texts.push(d.dir_label); + if (d && (d.direction_label || d.dir_label)) texts.push((d.direction_label || d.dir_label)); ((d && d.stops) || []).forEach(function (s) { - if (s.dir_note) texts.push(s.dir_note); + if ((s.direction_note || s.dir_note)) texts.push((s.direction_note || s.dir_note)); if (s.note) texts.push(s.note); }); var verdicts = [], conflicts = false, hasHol = false, hasWk = false, sample = null; @@ -332,7 +332,8 @@ if (!sub) return null; var dirs = isSchema3(sub) ? directionsFromSchema3(sub) : (sub.directions || []); SUBS[String(sub.route_id)] = { route_id: sub.route_id, station_order: sub.station_order || [], - directions: dirs, schema3: isSchema3(sub) }; + directions: dirs, schema3: isSchema3(sub), + updated: sub.updated || null }; return SUBS[String(sub.route_id)]; }).catch(function () { return null; }); })).then(function (list) { @@ -344,7 +345,14 @@ return subsReady; } /* โหลดสายเดียว (เร็ว — ใช้ตอนเปิดหน้า check/routes ของสายนั้น) */ - function loadRoute(rid) { +/* วันที่อัปเดตไฟล์ตารางของสาย (ฟิลด์ "updated" ใน scheduleslist/schedules.json) + — ค่ามาจาก mtime ของไฟล์จริง (เติมโดย resource/tools/stamp-schedules.py) */ + function updatedOf(rid) { + var s = SUBS[String(rid)]; + return (s && s.updated) ? String(s.updated) : null; + } + + function loadRoute(rid) { var key = String(rid); if (SUBS[key]) return Promise.resolve({ schema: 2, routes: [SUBS[key]] }); if (!subsReady) return loadSubs().then(function () { return SUBS[key] ? { schema: 2, routes: [SUBS[key]] } : null; }); @@ -416,8 +424,8 @@ if (!r) return []; list = (r.directions || []).map(function (d) { return { - dir_id: d.dir_id, - dir_label: d.dir_label, + direction_id: (d.direction_id || d.dir_id), + direction_label: (d.direction_label || d.dir_label), days: Array.isArray(d.days) ? d.days.map(String) : null, /* ระบุวันตรง ๆ (อา จ อ พ พฤ ศ ส) */ service: serviceOf(d, d), /* ตรวจวัน + เหตุผล (จากคำ/service/days) */ autoTimes: !!d.autoTimes, /* true = คำนวณจุดที่ไม่มีตารางให้ */ @@ -431,7 +439,7 @@ station_id: s.station_id, times: s.times || [], km: (typeof s.km === 'number') ? s.km : null, /* กม. จากต้นทาง (วัดโดย resource/tools/stop-km.py) */ - dir_note: s.dir_note || null, + direction_note: (s.direction_note || s.dir_note) || null, note: s.note || null, groups: s.groups || null, derive: s.derive || null /* กฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" */ @@ -441,10 +449,10 @@ }); } else { /* schema 1 → ยังใช้ได้เหมือนเดิม (ไม่แยกวัน) */ - list = [{ dir_id: 'all', dir_label: null, service: 'all', stops: (doc && doc.schedules ? doc.schedules : []).filter(function (r) { + list = [{ direction_id: 'all', direction_label: null, service: 'all', stops: (doc && doc.schedules ? doc.schedules : []).filter(function (r) { return String(r.route_id) === rid; }).map(function (r) { - return { station_id: r.station_id, times: r.departure_times || [], dir_note: r.direction_note || null, note: r.schedule_note || null, groups: null }; + return { station_id: r.station_id, times: r.departure_times || [], direction_note: r.direction_note || null, note: r.schedule_note || null, groups: null }; }) }]; } @@ -498,10 +506,10 @@ if (calc && calc.length) { t = calc; est = true; } } } - return { station_id: s.station_id, times: t, km: s.km, dir_note: s.dir_note, note: s.note, + return { station_id: s.station_id, times: t, km: s.km, direction_note: (s.direction_note || s.dir_note), note: s.note, groups: s.groups, estimated: est, estimateFrom: estFrom, derive: s.derive || null }; }); - return { dir_id: d.dir_id, dir_label: d.dir_label, service: d.service, days: d.days, autoTimes: d.autoTimes, + return { direction_id: (d.direction_id || d.dir_id), direction_label: (d.direction_label || d.dir_label), service: d.service, days: d.days, autoTimes: d.autoTimes, travelMin: d.travelMin, baseEnd: d.baseEnd, baseSid: d.baseSid, autoFor: d.autoFor, speedKmh: Math.round(speed.kmh * 10) / 10, speedFrom: speed.source, dayType: day, fallback: fallback, stops: stops }; @@ -519,14 +527,14 @@ out.push({ route_id: r.route_id, station_id: s.station_id, - direction_note: s.dir_note || null, - dir_label: d.dir_label || null, /* ชื่อทิศ (ป่าโมกไปอยุธยา ฯลฯ) — ใช้เป็นหัวแถว */ + direction_note: (s.direction_note || s.dir_note) || null, + direction_label: (d.direction_label || d.dir_label) || null, /* ชื่อทิศ (ป่าโมกไปอยุธยา ฯลฯ) — ใช้เป็นหัวแถว */ departure_times: s.times || [], schedule_note: s.note || null, estimated: !!s.estimated, /* true = เวลาคำนวณ ไม่ใช่ตารางจริง */ estimateFrom: s.estimateFrom || null, /* { station_id, name, offsetMin } เมื่อคำนวณ */ km: s.km, - dir_id: d.dir_id, + direction_id: (d.direction_id || d.dir_id), service: d.service, days: d.days, dayType: d.dayType, @@ -605,6 +613,7 @@ serviceOf: serviceOf, timesFor: timesFor, computeTimes: computeTimes, + updatedOf: updatedOf, /* วันที่อัปเดตไฟล์ตารางของสาย (ISO) — ใช้แสดง "อัปเดตล่าสุด ..." */ speedOf: speedOf, absKm: absKm, relKms: relKms, diff --git a/ui/partials/stopDetail.html b/ui/partials/stopDetail.html index 2f15ded..edf1edb 100644 --- a/ui/partials/stopDetail.html +++ b/ui/partials/stopDetail.html @@ -158,7 +158,7 @@ line-height: 1; color: #1f2a44; font-weight: 800; - font-family: "Prompt", "Noto Sans Thai", sans-serif; + font-family: "K2D", "Prompt", "Noto Sans Thai", sans-serif; } .mu-live-clock-note { margin: 0; diff --git a/ui/partials/stopDetail.init.js b/ui/partials/stopDetail.init.js index e7aea1e..91b13b4 100644 --- a/ui/partials/stopDetail.init.js +++ b/ui/partials/stopDetail.init.js @@ -73,7 +73,7 @@ Schedules.directions(sched, r.route_id).forEach(function (d) { d.stops.forEach(function (s) { if (s.station_id !== sid) return; - legs.push({ dir_id: d.dir_id, label: s.dir_note || d.dir_label || null, times: s.times || [], note: s.note || null, estimated: !!s.estimated, estimateFrom: s.estimateFrom || null }); + legs.push({ direction_id: (d.direction_id || d.dir_id), label: (s.direction_note || s.dir_note) || (d.direction_label || d.dir_label) || null, times: s.times || [], note: s.note || null, estimated: !!s.estimated, estimateFrom: s.estimateFrom || null }); }); }); var trips = legs.reduce(function (n, l) { return n + l.times.length; }, 0); @@ -93,7 +93,10 @@ if (station.photo) return station.photo; /* ระบุพาธเองได้ใน stations.json (ทับค่าเริ่มต้น) */ var n = station.__seq || 1; /* รูปเสริมของสถานีเดียวกัน: 2-2.jpg, 2-3.jpeg … */ var base = PHOTO_DIR + station.station_id + (n > 1 ? '-' + n : ''); - return PHOTO_EXTS.map(function (e) { return base + '.' + e; }); /* เรียง候选ให้ renderHero ไล่ลอง */ + return PHOTO_EXTS.map(function (e) { /* เรียงตัวเลือกให้ renderHero ไล่ลอง */ + var u = base + '.' + e; + return (window.ImgURL && ImgURL.of) ? ImgURL.of(u) : u; /* ?v= กัน cache-first ของ SW */ + }); } /* ---------- ตัวเลขสรุป ---------- */ diff --git a/ui/responsive.css b/ui/responsive.css index 7245954..fe1a262 100644 --- a/ui/responsive.css +++ b/ui/responsive.css @@ -116,7 +116,18 @@ main.mu-container { padding-top: 24px; padding-bottom: 24px; } /* --- โซนเส้นทาง + การ์ด — ระยะห่างกระชับ --- */ main.mu-container { padding-top: 14px; padding-bottom: 14px; } .mu-zone { margin-bottom: 20px; } -.mu-zone-head { margin-bottom: 10px; gap: 10px; } +.mu-zone-head { margin-bottom: 10px; gap: 4px 10px; } + +/* --- หัวโซน: ป้ายหัวข้อ + บรรทัดข้อมูล (มือถือ = เรียงลงมาเต็มความกว้าง) --- + ใช้ #view เพื่อชนะ