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

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

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

No files matched your search

+8 -6
View File
@@ -286,14 +286,14 @@ window.ATMap = (function () {
var s = h.stop, pt = pointOf(s);
if (!pt) return;
var short = [];
if (s.kilometer) short.push('กม. ' + s.kilometer);
if (s.kilometer) short.push(t('map.km') + ' ' + s.kilometer);
if (s.position) short.push(s.position);
if (s.type) short.push(s.type);
var html = '<div class="at-pop">';
html += '<b>' + esc(s.place || s.type || t('map.legendStop')) + '</b>';
var meta = [];
if (s.kilometer) meta.push('กม. ' + s.kilometer);
if (s.kilometer) meta.push(t('map.km') + ' ' + s.kilometer);
if (s.position) meta.push(s.position);
if (s.type && s.place) meta.push(s.type); /* ซ้ำกับหัวข้อเมื่อไม่มีชื่อสถานที่ */
if (meta.length) html += '<span>' + esc(meta.join(' · ')) + '</span>';
@@ -316,7 +316,7 @@ window.ATMap = (function () {
(rows || []).forEach(function (r) {
if (!r.sub || !r.pt) return;
var html = '<div class="at-pop"><b>' + esc(r.name) + '</b>';
html += '<span>' + esc(t('map.subStop')) + (r.km != null && r.km !== '' ? ' · ' + esc(r.km) + ' กม.' : '') + '</span>';
html += '<span>' + esc(t('map.subStop')) + (r.km != null && r.km !== '' ? ' · ' + esc(r.km) + ' ' + esc(t('map.km')) : '') + '</span>';
if (r.href) html += '<a href="' + esc(r.href) + '">' + esc(t('map.viewBoardingPoints')) + '</a>';
html += '</div>';
L.marker([r.pt[1], r.pt[0]], { icon: pinIcon('sub'), zIndexOffset: 400 })
@@ -594,6 +594,8 @@ window.ATMap = (function () {
items.sort(function (a, b) { return a.d - b.d; });
var near = items.slice(0, opts.limit || 8);
renderNear(resultEl, near, me, opts);
/* ปลดล็อกปุ่มหลังหาป้ายเสร็จ — ผู้ใช้เดินไปที่ใหม่แล้วกดซ้ำได้ */
button.disabled = false;
});
}, function () {
button.disabled = false;
@@ -623,7 +625,7 @@ window.ATMap = (function () {
var meta = [];
if (x.kind === 'station') meta.push(t('map.legendTerminal'));
else {
if (x.o.kilometer) meta.push('กม. ' + x.o.kilometer);
if (x.o.kilometer) meta.push(t('map.km') + ' ' + x.o.kilometer);
if (x.o.position) meta.push(x.o.position);
if (x.o.type && x.o.place) meta.push(x.o.type);
}
@@ -636,7 +638,7 @@ window.ATMap = (function () {
if (x.kind === 'stop') { link.target = '_blank'; link.rel = 'noopener'; }
link.innerHTML = '<span class="at-near-name">' + esc(name || t('map.legendStop')) + '</span>' +
'<span class="at-near-meta">' + esc(meta.join(' · ')) + '</span>' +
'<span class="at-near-dist">' + (x.d < 1000 ? Math.round(x.d) + ' ม.' : (x.d / 1000).toFixed(1) + ' ' + esc(t('map.km'))) + '</span>';
'<span class="at-near-dist">' + (x.d < 1000 ? Math.round(x.d) + ' ' + esc(t('map.mUnit')) : (x.d / 1000).toFixed(1) + ' ' + esc(t('map.km'))) + '</span>';
li.appendChild(link);
ul.appendChild(li);
});
@@ -691,7 +693,7 @@ window.ATMap = (function () {
if (!org) { return { map: map, empty: true }; }
pts.push(org);
L.circleMarker(org, { radius: 8, color: '#fff', weight: 3, fillColor: '#1f2a44', fillOpacity: 1 })
.bindTooltip(esc(o.label || 'ต้นทาง'), { permanent: true, direction: 'top', offset: [0, -8], className: 'at-tip-org' })
.bindTooltip(esc(o.label || t('map.originShort')), { permanent: true, direction: 'top', offset: [0, -8], className: 'at-tip-org' })
.addTo(group);
var pending = []; /* เส้นที่พิกัดปลายทางมาจาก geojson (โหลด async) */