แผนที่จาก GPKG + บทความ 6 ชิ้น + ลดความหนา footer

== แผนที่ / 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=<SW VERSION> ทุกรูป (ui/imageurl.js)
- footer: ลดความหนา 468 -> 349px + line-height 1.5 กันสระ/วรรณยุกต์ซ้อน
- QR modal + ปุ่มคัดลอกลิงก์ · หน้าอัปเดตล่าสุดใน #/check
- credits: ขอขอบคุณภาพรถ 3 สาย

== เครื่องมือ ==
- bump-version.py · stamp-schedules.py · derive-times.py (จุดอ้างอิง ± นาที)
This commit is contained in:
Bkk1234 committed 2026-10-05 03:55:09 +07:00
1 parent 1cfaeb1526
commit 656f65b41c
109 files changed
+3335 -1225

No files matched your search

+37 -37
View File
@@ -312,17 +312,17 @@
if (t - lastSnapAt > 1200) { lastSnapAt = t; snap(); }
}
/* ตรวจจับว่าทิศนี้เป็นตารางของวันไหน (อ่านจาก dir_label + dir_note/note ของทุกจุด)
/* ตรวจจับว่าทิศนี้เป็นตารางของวันไหน (อ่านจาก direction_label + direction_note/note ของทุกจุด)
- เจอคำฝ่ายเดียว → เสนอตั้ง service ให้ (ไม่ตั้งเอง)
- เจอทั้งฝ่ายวันทำงานและวันหยุดในทิศเดียว → เตือนว่าควรแยกเป็นคนละทิศ */
var HOLIDAY_WORDS = ['วันหยุด', 'นักขัตฤกษ์', 'เสาร์อาทิตย์', 'เสาร์-อาทิตย์', 'ส-อา', 'ส–อา', 'weekend', 'holiday'];
var WEEKDAY_WORDS = ['วันทำงาน', 'จ-ศ', 'จ–ศ', 'จันทร์ถึงศุกร์', 'weekday', 'workday'];
function scanWords(d) {
var texts = [];
if (d.dir_label) texts.push(String(d.dir_label));
if (d.direction_label) texts.push(String(d.direction_label));
(d.stops || []).forEach(function (s) {
if (s.note) texts.push(String(s.note));
if (s.dir_note) texts.push(String(s.dir_note));
if (s.direction_note) texts.push(String(s.direction_note));
});
var joined = texts.join(' | ');
var low = joined.toLowerCase();
@@ -423,7 +423,7 @@
var max = known.reduce(function (a, b) { return b.k > a ? b.k : a; }, known[0].k);
rel = abs.map(function (k) { return typeof k === 'number' ? (forward ? k : (max - k)) : null; });
}
return { dir_id: d.dir_id, dir_label: d.dir_label, baseEnd: d.baseEnd, travelMin: d.travelMin, speedKmh: d.speedKmh,
return { direction_id: d.direction_id, direction_label: d.direction_label, baseEnd: d.baseEnd, travelMin: d.travelMin, speedKmh: d.speedKmh,
autoTimes: d.autoTimes, service: d.service,
stops: (d.stops || []).map(function (s, i) {
var c = {}; for (var k in s) c[k] = s[k];
@@ -646,12 +646,12 @@
var rows = [[stationName2(d.stops && d.stops[0] ? d.stops[0].station_id : '') === '—' ? '' : '']];
var header = ['station_id', 'station_name'];
for (var i = 1; i <= n; i++) header.push('t' + i);
header.push('dir_note', 'note');
header.push('direction_note', 'note');
var out = [header.join(',')];
(d.stops || []).forEach(function (s) {
var row = [s.station_id, csvCell(stationName2(s.station_id, rid))];
for (var i = 0; i < n; i++) row.push(csvCell((s.times || [])[i] || ''));
row.push(csvCell(s.dir_note || ''));
row.push(csvCell(s.direction_note || ''));
row.push(csvCell(s.note || ''));
out.push(row.join(','));
});
@@ -681,7 +681,7 @@
var rows = parseCSV(text);
if (rows.length < 2) return null;
var head = rows[0].map(function (h) { return String(h).trim().toLowerCase(); });
var iSid = head.indexOf('station_id'), iNote = head.indexOf('note'), iDir = head.indexOf('dir_note');
var iSid = head.indexOf('station_id'), iNote = head.indexOf('note'), iDir = head.indexOf('direction_note');
var timeCols = [];
head.forEach(function (h, i) { if (/^t\d+$/.test(h)) timeCols.push(i); });
if (iSid < 0 || !timeCols.length) return null;
@@ -693,7 +693,7 @@
var times = timeCols.map(function (i) { return String(row[i] || '').trim(); })
.filter(function (x) { return /^\d{1,2}:\d{2}$/.test(x); });
stops.push({ station_id: sid, times: times,
dir_note: (iDir >= 0 ? (String(row[iDir] || '').trim() || null) : null),
direction_note: (iDir >= 0 ? (String(row[iDir] || '').trim() || null) : null),
note: (iNote >= 0 ? (String(row[iNote] || '').trim() || null) : null) });
}
return stops.length ? stops : null;
@@ -705,7 +705,7 @@
var n = tableMaxCols(d);
var head = '<tr><th class="rh">จุดจอด (station_id)</th><th class="rh">กม.</th><th class="rh">ที่มา</th>';
for (var c = 1; c <= n; c++) head += '<th class="ch">t' + c + '<button class="mini x" data-act="col-del" data-di="' + di + '" data-col="' + c + '" title="ลบคอลัมน์นี้">×</button></th>';
head += '<th class="rh">dir_note</th><th class="rh">note</th><th class="rh">จัดการ</th></tr>';
head += '<th class="rh">direction_note</th><th class="rh">note</th><th class="rh">จัดการ</th></tr>';
var body = (d.stops || []).map(function (s, si) {
var km = (ann.stops[si] || {}).km;
var src = (s.times || []).filter(Boolean).length ? 'ตารางจริง' : (d.autoTimes ? 'คำนวณอัตโนมัติ' : 'ว่าง');
@@ -719,7 +719,7 @@
'<td class="rh"><select data-act="cell-sid" data-di="' + di + '" data-si="' + si + '">' + stationOptions(s.station_id, routeObj(S.routeId)) + '</select></td>' +
'<td class="mono ck">' + (typeof km === 'number' ? km : '—') + '</td>' +
'<td class="src">' + src + '</td>' + tds +
'<td><input data-act="cell-dirnote" data-di="' + di + '" data-si="' + si + '" value="' + esc(s.dir_note || '') + '"></td>' +
'<td><input data-act="cell-dirnote" data-di="' + di + '" data-si="' + si + '" value="' + esc(s.direction_note || '') + '"></td>' +
'<td><input data-act="cell-note" data-di="' + di + '" data-si="' + si + '" value="' + esc(s.note || '') + '"></td>' +
'<td class="ops"><button class="mini" data-act="row-up" data-di="' + di + '" data-si="' + si + '">↑</button>' +
'<button class="mini" data-act="row-dn" data-di="' + di + '" data-si="' + si + '">↓</button>' +
@@ -743,8 +743,8 @@
if (!r) return '<p class="empty">เลือกสายจากด้านซ้าย</p>';
return (r.directions || []).map(function (d, di) {
return '<section class="tbl-sec">' +
'<div class="tbl-head"><strong>ทิศ ' + esc(d.dir_id || ('#' + (di + 1))) + '</strong>' +
(d.dir_label ? '<span class="f">' + esc(d.dir_label) + '</span>' : '') +
'<div class="tbl-head"><strong>ทิศ ' + esc(d.direction_id || ('#' + (di + 1))) + '</strong>' +
(d.direction_label ? '<span class="f">' + esc(d.direction_label) + '</span>' : '') +
'<span class="f">' + (d.stops || []).length + ' จุด · ' + trips(d) + ' เที่ยว</span>' +
'<span class="f">ใช้กับวัน: ' + esc(d.service || 'ทุกวัน') + '</span>' +
(d.autoTimes ? '<span class="chip on">คำนวณอัตโนมัติ</span>' : '') +
@@ -998,7 +998,7 @@
'<td>' + chips + '</td><td class="f">' + esc(r.note) + '</td></tr>';
}).join('');
return '<div class="modal" data-act="calc-close"><div class="modal-box" data-stop="1">' +
'<div class="modal-head"><strong>ตารางที่คำนวณได้ — สาย ' + esc(S.routeId) + ' · ทิศ ' + esc(d.dir_id || '-') + '</strong>' +
'<div class="modal-head"><strong>ตารางที่คำนวณได้ — สาย ' + esc(S.routeId) + ' · ทิศ ' + esc(d.direction_id || '-') + '</strong>' +
'<button class="mini" data-act="calc-close">ปิด</button></div>' +
'<p class="msg">ใช้เวลาจริงจาก <b>' + esc(stationName(res.base.station_id)) + '</b> (' + res.base.times.length + ' เที่ยว) · ' +
'เวลาเดินทาง ' + esc(hm(Number(res.travelMin) || 0)) + ' · ความเร็วที่ได้ ≈ ' + (Math.round(res.kmh * 10) / 10) + ' กม./ชม.' +
@@ -1057,7 +1057,7 @@
function dirHeadLetter(di) { return String.fromCharCode(65 + di); }
function colTitle(d) {
return (d.dir_label && String(d.dir_label).trim()) ? String(d.dir_label).trim() : (d.dir_id || ('ทิศ ' + dirHeadLetter(d.directions_index || 0)));
return (d.direction_label && String(d.direction_label).trim()) ? String(d.direction_label).trim() : (d.direction_id || ('ทิศ ' + dirHeadLetter(d.directions_index || 0)));
}
function timesToText(times) { return (times || []).join(' '); }
@@ -1075,7 +1075,7 @@
var head = '<tr><th class="rh">จุดจอด (station_order)</th><th class="rh2">กม.</th>' +
dirs.map(function (d, di) {
return '<th class="ch"><div>' + esc(colTitle(d)) + '</div>' +
'<div class="ch-sub">' + esc(d.dir_id || '') + ' · ' + trips(d) + ' เที่ยว' +
'<div class="ch-sub">' + esc(d.direction_id || '') + ' · ' + trips(d) + ' เที่ยว' +
(d.autoTimes ? ' · คำนวณอัตโนมัติ' : '') + (d.service && d.service !== 'all' ? ' · ' + esc(d.service) : '') + '</div></th>';
}).join('') + '<th class="ch ops">จัดการ</th></tr>';
@@ -1121,8 +1121,8 @@
var svc = (d.service || 'all').toLowerCase();
return '<div class="dirtool" data-di="' + di + '">' +
'<span class="dt-letter">' + dirHeadLetter(di) + '</span>' +
'<input class="mono" style="width:120px" data-act="dir-label" data-di="' + di + '" value="' + esc(d.dir_label || '') + '" placeholder="ชื่อคอลัมน์">' +
'<input class="mono" style="width:104px" data-act="dir-id" data-di="' + di + '" value="' + esc(d.dir_id || '') + '" placeholder="dir_id">' +
'<input class="mono" style="width:120px" data-act="dir-label" data-di="' + di + '" value="' + esc(d.direction_label || '') + '" placeholder="ชื่อคอลัมน์">' +
'<input class="mono" style="width:104px" data-act="dir-id" data-di="' + di + '" value="' + esc(d.direction_id || '') + '" placeholder="direction_id">' +
'<select data-act="dir-service" data-di="' + di + '">' +
'<option value="all"' + (svc === 'all' ? ' selected' : '') + '>ทุกวัน</option>' +
'<option value="weekday"' + (svc === 'weekday' ? ' selected' : '') + '>วันทำงาน</option>' +
@@ -1229,16 +1229,16 @@
function directionHtml(r, d, di) {
var t = trips(d);
var svc = (d.service || 'all').toLowerCase();
var guess = guessService(d); /* เดาจากคำใน dir_label/note ว่าตารางนี้สำหรับวันไหน */
var guess = guessService(d); /* เดาจากคำใน direction_label/note ว่าตารางนี้สำหรับวันไหน */
var counts = (d.stops || []).map(function (s) { return (s.times || []).length; });
var uneven = counts.length > 1 && new Set(counts).size > 1;
return '' +
'<div class="dir" data-di="' + di + '">' +
'<div class="dir-head">' +
'<div class="f-id" style="width:150px"><label class="f">dir_id</label>' +
'<input class="mono" data-act="dir-id" data-di="' + di + '" value="' + esc(d.dir_id || '') + '"></div>' +
'<div class="grow"><label class="f">dir_label (ชื่อทิศที่แสดง เช่น ไปอยุธยา — เว้นว่างได้)</label>' +
'<input data-act="dir-label" data-di="' + di + '" value="' + esc(d.dir_label || '') + '"></div>' +
'<div class="f-id" style="width:150px"><label class="f">direction_id</label>' +
'<input class="mono" data-act="dir-id" data-di="' + di + '" value="' + esc(d.direction_id || '') + '"></div>' +
'<div class="grow"><label class="f">direction_label (ชื่อทิศที่แสดง เช่น ไปอยุธยา — เว้นว่างได้)</label>' +
'<input data-act="dir-label" data-di="' + di + '" value="' + esc(d.direction_label || '') + '"></div>' +
'<div class="f-svc"><label class="f">ใช้กับวัน (service)</label>' +
'<select data-act="dir-service" data-di="' + di + '">' +
'<option value="all"' + (svc === 'all' ? ' selected' : '') + '>ทุกวัน</option>' +
@@ -1286,8 +1286,8 @@
'<div class="stop-head">' +
'<div class="f-id"><label class="f">จุดจอด (station_id)' + (typeof s.km === 'number' ? ' · กม. ' + s.km : ' · ยังไม่มี กม.') + '</label>' +
'<select data-act="stop-sid" data-di="' + di + '" data-si="' + si + '">' + stationOptions(s.station_id, r) + '</select></div>' +
'<div class="f-dir"><label class="f">dir_note (ทิศของจุดนี้ — เว้นว่างได้)</label>' +
'<input data-act="stop-dirnote" data-di="' + di + '" data-si="' + si + '" value="' + esc(s.dir_note || '') + '"></div>' +
'<div class="f-dir"><label class="f">direction_note (ทิศของจุดนี้ — เว้นว่างได้)</label>' +
'<input data-act="stop-dirnote" data-di="' + di + '" data-si="' + si + '" value="' + esc(s.direction_note || '') + '"></div>' +
'<div class="f-note"><label class="f">note (เงื่อนไข เช่น ไม่วิ่งวันหยุด)</label>' +
'<input data-act="stop-note" data-di="' + di + '" data-si="' + si + '" value="' + esc(s.note || '') + '"></div>' +
'<button class="mini" data-act="stop-up" data-di="' + di + '" data-si="' + si + '" title="เลื่อนขึ้น">↑</button>' +
@@ -1337,24 +1337,24 @@
}
var seenStops = {};
(r.directions || []).forEach(function (d, di) {
if (!(d.stops || []).length) out.push({ lv: 'e', rid: rid, msg: 'ทิศ ' + (d.dir_id || di) + ': ไม่มีจุดจอด' });
if (!(d.stops || []).length) out.push({ lv: 'e', rid: rid, msg: 'ทิศ ' + (d.direction_id || di) + ': ไม่มีจุดจอด' });
var counts = {};
(d.stops || []).forEach(function (s, si) {
var key = d.dir_id + '#' + s.station_id;
if (seenStops[key]) out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + d.dir_id + ': จุด ' + s.station_id + ' (' + stationName(s.station_id) + ') ซ้ำในทิศเดียวกัน' });
var key = d.direction_id + '#' + s.station_id;
if (seenStops[key]) out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + d.direction_id + ': จุด ' + s.station_id + ' (' + stationName(s.station_id) + ') ซ้ำในทิศเดียวกัน' });
seenStops[key] = 1;
var p = parseTimes(fmtList(s.times));
if (p.bad.length) out.push({ lv: 'e', rid: rid, msg: 'ทิศ ' + d.dir_id + ' จุด ' + s.station_id + ': เวลาผิดรูปแบบ ' + p.bad.join(', ') });
if (p.bad.length) out.push({ lv: 'e', rid: rid, msg: 'ทิศ ' + d.direction_id + ' จุด ' + s.station_id + ': เวลาผิดรูปแบบ ' + p.bad.join(', ') });
var dup = {}, dd = [];
p.ok.forEach(function (t) { if (dup[t] && dd.indexOf(t) === -1) dd.push(t); dup[t] = 1; });
if (dd.length) out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + d.dir_id + ' จุด ' + s.station_id + ': เวลาซ้ำ ' + dd.join(', ') });
if (!p.ok.length) out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + d.dir_id + ' จุด ' + s.station_id + ' (' + stationName(s.station_id) + '): ยังไม่มีเวลา (เว็บจะขึ้น "ยังไม่มีข้อมูล")' });
if (dd.length) out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + d.direction_id + ' จุด ' + s.station_id + ': เวลาซ้ำ ' + dd.join(', ') });
if (!p.ok.length) out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + d.direction_id + ' จุด ' + s.station_id + ' (' + stationName(s.station_id) + '): ยังไม่มีเวลา (เว็บจะขึ้น "ยังไม่มีข้อมูล")' });
var inOrder = (r.station_order || []).indexOf(Number(s.station_id)) !== -1;
if (!inOrder) out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + d.dir_id + ' จุด ' + s.station_id + ': ไม่อยู่ใน station_order' });
if (!inOrder) out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + d.direction_id + ' จุด ' + s.station_id + ': ไม่อยู่ใน station_order' });
counts[(s.times || []).length] = 1;
});
if (Object.keys(counts).length > 1) {
out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + (d.dir_label || d.dir_id) + ': จำนวนเที่ยวไม่เท่ากันข้ามจุด (' + (d.stops || []).map(function (x) { return x.station_id + '×' + (x.times || []).length; }).join(' · ') + ') — อาจยังแยกทิศไม่ครบ' });
out.push({ lv: 'w', rid: rid, msg: 'ทิศ ' + (d.direction_label || d.direction_id) + ': จำนวนเที่ยวไม่เท่ากันข้ามจุด (' + (d.stops || []).map(function (x) { return x.station_id + '×' + (x.times || []).length; }).join(' · ') + ') — อาจยังแยกทิศไม่ครบ' });
}
});
});
@@ -1443,7 +1443,7 @@
var r = routeObj(S.routeId);
var src = r.directions[+t.dataset.di];
var copy = JSON.parse(JSON.stringify(src)); /* คัดลอกทั้งทิศ (จุดจอด + เวลา + หมายเหตุ) */
copy.dir_id = (src.dir_id || 'dir') + '-copy';
copy.direction_id = (src.direction_id || 'dir') + '-copy';
delete copy.service; /* ให้ผู้ใช้เลือกวันเอง ไม่เดาให้ */
r.directions.splice(+t.dataset.di + 1, 0, copy);
toast('ทำสำเนาทิศแล้ว — อย่าลืมตั้ง "ใช้กับวัน" ของทั้งสองทิศ');
@@ -1461,13 +1461,13 @@
'dir-add': function () {
var r = routeObj(S.routeId); snap();
r.directions = r.directions || [];
r.directions.push({ dir_id: 'new-' + (r.directions.length + 1), dir_label: null, stops: [] });
r.directions.push({ direction_id: 'new-' + (r.directions.length + 1), direction_label: null, stops: [] });
},
'dir-del': function (t) { var r = routeObj(S.routeId); snap(); r.directions.splice(+t.dataset.di, 1); },
'dir-up': function (t) { moveDir(+t.dataset.di, -1); },
'dir-dn': function (t) { moveDir(+t.dataset.di, 1); },
'dir-id': function (t) { var r = routeObj(S.routeId); r.directions[+t.dataset.di].dir_id = t.value; },
'dir-label': function (t) { var r = routeObj(S.routeId); var v = t.value.trim(); r.directions[+t.dataset.di].dir_label = v || null; },
'dir-id': function (t) { var r = routeObj(S.routeId); r.directions[+t.dataset.di].direction_id = t.value; },
'dir-label': function (t) { var r = routeObj(S.routeId); var v = t.value.trim(); r.directions[+t.dataset.di].direction_label = v || null; },
'stop-add': function (t) {
var r = routeObj(S.routeId); snap();
var d = r.directions[+t.dataset.di];
@@ -1479,7 +1479,7 @@
'stop-up': function (t) { moveStop(+t.dataset.di, +t.dataset.si, -1); },
'stop-dn': function (t) { moveStop(+t.dataset.di, +t.dataset.si, 1); },
'stop-sid': function (t) { var s = stop(t); s.station_id = Number(t.value); },
'stop-dirnote': function (t) { var s = stop(t); var v = t.value.trim(); s.dir_note = v || null; },
'stop-dirnote': function (t) { var s = stop(t); var v = t.value.trim(); s.direction_note = v || null; },
'stop-note': function (t) { var s = stop(t); var v = t.value.trim(); s.note = v || null; },
'stop-times': function (t, quiet) {
var s = stop(t);