ตารางเวลาคำนวณได้ + หน้ารายละเอียดป้ายขับเคลื่อนด้วยข้อมูล + แผนที่ Leaflet
Schedules — กติกา "จุดนี้ = เวลาจุดอ้างอิง ± n นาที"
- ฟิลด์ derive { from_station_id, offset_min } คำนวณที่ ui/partials/schedules.js (ท่อเดียว) รองรับอ้างจุดข้ามทิศ
- จุดย่อยของ "8 other_stop" ใช้ offsets_min จับคู่ตามลำดับ (เช่น ตลาดสามโก้ = ตลาดท่าช้าง +45 นาที)
- เครื่องมือ resource/tools/derive-times.py + ตาราง resource/data/derive-times.csv (--check / --audit ชี้จุดที่ควรตั้งกฎ)
- แยกตารางเป็นรายสาย: scheduleslist/schedules<route_id>.json และ schedules.json เป็นสารบัญ (โหลดแบบ lazy + cache)
- ตรวจจับวันทำงาน/วันหยุด + schema 3 (weekday/holiday → directions) · ไฟล์ข้อมูลเป็น CRLF ทั้งชุด
- ล้างค่าที่ไม่ใช่ HH:MM ที่ฝังใน times (ทำให้ KPI เพี้ยน) + กันค่าหลอกในตัวสรุปเวลา
UI
- หน้ารายละเอียดป้าย/ตารางเวลา ขับเคลื่อนด้วย JSON (stopDetail.init.js) · จุดขึ้นรถประจำทางอื่นๆ รองรับหลายจุดต่อสาย
- #/stops: แสดง 6 ป้ายแรก + ปุ่ม "แสดงป้ายทั้งหมด" (โหลดรูปเฉพาะที่แสดง) · ชิปสาย → #/routes/<route_id>
- หน้าแรก: ตัดตัวเลือก "ทุกสถานีในจังหวัดนี้" · ตัวกรองจังหวัด/สถานี + ปุ่มแชร์ (share URL)
- การ์ดติดต่อ: ไอคอน/ชื่อ/สีเปลี่ยนตามชนิด URL (Facebook / LINE / เว็บไซต์) + ปุ่มเปิดลิงก์จาก web_url
- รูปรองรับหลายนามสกุล (.jpg → .jpeg → .webp → .png) · ป้าย "ประมาณ" + หมายเหตุสำหรับตารางที่คำนวณ
- หน้าเครดิตเหลือ 3 หมวด · แก้ข้อความหมวดแผนที่ให้ตรงกับข้อมูลจริง
- แผนที่ Leaflet (vendor ในโปรเจกต์ ไม่ใช้ CDN): เส้นทาง + หมุด + ป๊อปอัป · แก้ CSS ที่ทำให้ SVG ยุบ 0x0
เครื่องมือและเอกสาร
- qgis-to-web.py อ่าน .shp ตรง → geojson-web (สร้างใหม่ 10 ไฟล์) + audit-geojson.py ตรวจ 3 ส่วน
- stop-km.py วัดระยะ กม. ตามเส้นจริง → stop-km.json · schedules-editor.html (แก้ทีละไฟล์ · มุมมองตารางแบบ Excel)
- AGENTS.md: กติกา derive · offsets_min · นามสกุลรูป · ชิปสาย · หน้ารายละเอียดป้ายมาจากไหน
This commit is contained in:
1 parent
88311326e6
commit
1cfaeb1526
91 files changed
+7560
-844
No files matched your search
@@ -84,17 +84,38 @@
|
||||
}
|
||||
function telHref(p) { return 'tel:' + String(p == null ? '' : p).replace(/[^\d+]/g, ''); }
|
||||
|
||||
/* ---------- การ์ดติดต่อ (LINE + QR + เบอร์โทรทุกเบอร์จาก routes.json) ---------- */
|
||||
/* ---------- ลิงก์ติดต่อ (web_url ใน routes.json) — ไอคอน/ชื่อ/สี เปลี่ยนตามชนิด URL ----------
|
||||
facebook → ไอคอน facebook + โทนฟ้า · line (line.me / lin.ee / linevoom) → LINE + โทนเขียว
|
||||
อื่น ๆ (www) → ไอคอนลูกโลก + โทนม่วง */
|
||||
var LINK_KINDS = [
|
||||
{ key: 'facebook', icon: 'ic-facebook', tone: 'tone-sky', match: /facebook\.com|fb\.(me|com)/i },
|
||||
{ key: 'line', icon: 'ic-message-circle', tone: 'tone-green', match: /line\.me|lin\.ee|linevoom|line\.at/i },
|
||||
{ key: 'www', icon: 'ic-globe', tone: 'tone-purple', match: /^https?:/i }
|
||||
];
|
||||
function linkKind(url) {
|
||||
var u = String(url || '').trim();
|
||||
if (!u) return null;
|
||||
for (var i = 0; i < LINK_KINDS.length; i++) { if (LINK_KINDS[i].match.test(u)) return LINK_KINDS[i]; }
|
||||
return { key: 'www', icon: 'ic-globe', tone: 'tone-purple' };
|
||||
}
|
||||
function prettyUrl(url) {
|
||||
return String(url || '').trim().replace(/^https?:\/\//i, '').replace(/\/+$/, '');
|
||||
}
|
||||
|
||||
/* ---------- การ์ดติดต่อ (LINE + QR + ลิงก์ + เบอร์โทรจาก routes.json) ---------- */
|
||||
function buildContact(rid, route, cap) {
|
||||
var host = $('route-contact');
|
||||
if (!host) return;
|
||||
host.innerHTML = '';
|
||||
|
||||
var kind = linkKind(route.web_url);
|
||||
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>';
|
||||
'<span class="ic-wrap ' + (kind ? kind.tone : 'tone-green') + '"><svg class="ic" aria-hidden="true">' +
|
||||
'<use href="#' + (kind ? kind.icon : 'ic-message-circle') + '"/></svg></span>' +
|
||||
'<div class="txt"><strong>' + esc(kind ? t('route.link.' + kind.key) : 'LINE Official') + '</strong>' +
|
||||
'<span id="route-line-note"></span></div>';
|
||||
var qr = document.createElement('img');
|
||||
qr.className = 'mu-qr-img';
|
||||
qr.loading = 'lazy';
|
||||
@@ -120,6 +141,21 @@
|
||||
'<div class="txt"><strong>' + esc(t('route.call')) + '</strong><span>' + esc(fmtPhone(p)) + '</span></div>';
|
||||
host.appendChild(a);
|
||||
});
|
||||
|
||||
/* ปุ่ม "เปิดลิงก์" แยกต่างหาก — ชัดเจนบนมือถือ (แสดงเมื่อ routes.json มี web_url) */
|
||||
if (kind) {
|
||||
var open = document.createElement('a');
|
||||
open.className = 'mu-contact-item';
|
||||
open.href = String(route.web_url).trim();
|
||||
open.target = '_blank';
|
||||
open.rel = 'noopener noreferrer';
|
||||
open.innerHTML =
|
||||
'<span class="ic-wrap ' + kind.tone + '"><svg class="ic" aria-hidden="true"><use href="#' + kind.icon + '"/></svg></span>' +
|
||||
'<div class="txt"><strong>' + esc(t('route.openLink')) + '</strong><span>' + esc(prettyUrl(route.web_url)) + '</span></div>' +
|
||||
'<span class="mu-link-go"><svg class="ic" aria-hidden="true"><use href="#ic-arrow-right"/></svg></span>';
|
||||
host.appendChild(open);
|
||||
host.hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- รอบต่อวัน / รอบถัดไป จาก schedules.json ---------- */
|
||||
@@ -137,8 +173,8 @@
|
||||
return uniqTimes[0]; /* หมดรอบของวันนี้ → รอบแรกของวันถัดไป */
|
||||
}
|
||||
function loadTrips(rid) {
|
||||
return fetchJSON(DATA + 'schedules.json').then(function (d) {
|
||||
var recs = (d && (d.schedules || d)) || [];
|
||||
return Schedules.load().then(function (sd) { return Schedules.normSub(sd); }).then(function (d) {
|
||||
var recs = window.Schedules ? Schedules.records(d) : ((d && (d.schedules || d)) || []);
|
||||
var out = [];
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) === String(rid)) out = out.concat(r.departure_times || []);
|
||||
|
||||
Reference in new issue
Block a user