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:
1 parent
74d605f1c4
commit
750b4a2ea8
25 files changed
+426
-180
No files matched your search
+40
-26
@@ -379,14 +379,14 @@
|
||||
<div class="mu-hero-map">
|
||||
<p class="mu-hero-map-title"><span data-i18n="stops.mapTitle">แผนที่ย่อของเครือข่ายป้าย</span></p>
|
||||
<div class="mu-hero-map-box">
|
||||
<img class="mu-hero-map-photo" src="../.image/network/overview-map.png" alt="แผนที่เครือข่ายป้าย Atroute" loading="lazy" decoding="async">
|
||||
<img class="mu-hero-map-photo" src="../.image/network/overview-map.png" alt="แผนที่เครือข่ายป้าย Atroute" data-i18n-attr="alt:aria.networkMapAlt" loading="lazy" decoding="async">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<form class="mu-toolbar" id="stops-form" onsubmit="return false">
|
||||
<!-- โหมดค้นหา: เลือกอย่างใดอย่างหนึ่ง (ห้ามชนกัน) -->
|
||||
<div class="mu-search-tabs" role="tablist" aria-label="รูปแบบการค้นหา">
|
||||
<div class="mu-search-tabs" role="tablist" aria-label="รูปแบบการค้นหา" data-i18n-attr="aria-label:aria.searchMode">
|
||||
<button type="button" class="mu-search-tab" data-mode="code" role="tab" aria-selected="true">
|
||||
<svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg>
|
||||
<span data-i18n="stops.modeCode">ค้นหาด้วยรหัสป้าย</span>
|
||||
@@ -395,6 +395,11 @@
|
||||
<svg class="ic" aria-hidden="true"><use href="#ic-landmark"/></svg>
|
||||
<span data-i18n="stops.modePlace">ค้นหาด้วยชื่อสถานที่</span>
|
||||
</button>
|
||||
<!-- หมวดที่ 3: ป้ายใกล้ฉัน — แสดงเฉพาะเมื่อเป็น secure context (ดูสคริปต์ท้ายไฟล์) -->
|
||||
<button type="button" class="mu-search-tab" data-mode="near" role="tab" aria-selected="false" id="stops-near-tab" hidden>
|
||||
<svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg>
|
||||
<span data-i18n="stops.modeNear">ป้ายใกล้ฉัน</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- โหมด 1: รหัสป้าย (5 ช่อง: 2 หน้า + 3 หลัง) -->
|
||||
@@ -402,32 +407,19 @@
|
||||
<div class="mu-code-boxes" id="stops-code-boxes" role="group"
|
||||
data-i18n-attr="aria-label:stops.codePh" aria-label="รหัสป้าย">
|
||||
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
|
||||
autocomplete="off" aria-label="หลักที่ 1" placeholder="0">
|
||||
autocomplete="off" aria-label="หลักที่ 1" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="1" placeholder="0">
|
||||
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
|
||||
autocomplete="off" aria-label="หลักที่ 2" placeholder="0">
|
||||
autocomplete="off" aria-label="หลักที่ 2" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="2" placeholder="0">
|
||||
<span class="mu-code-plus" aria-hidden="true">+</span>
|
||||
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
|
||||
autocomplete="off" aria-label="หลักที่ 3" placeholder="0">
|
||||
autocomplete="off" aria-label="หลักที่ 3" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="3" placeholder="0">
|
||||
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
|
||||
autocomplete="off" aria-label="หลักที่ 4" placeholder="0">
|
||||
autocomplete="off" aria-label="หลักที่ 4" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="4" placeholder="0">
|
||||
<input class="mu-code-cell" type="text" inputmode="numeric" maxlength="1"
|
||||
autocomplete="off" aria-label="หลักที่ 5" placeholder="0">
|
||||
autocomplete="off" aria-label="หลักที่ 5" data-i18n-attr="aria-label:aria.digitN" data-i18n-n="5" placeholder="0">
|
||||
</div>
|
||||
<p class="mu-code-display" id="stops-code-display" hidden></p>
|
||||
<p class="mu-search-hint" data-i18n="stops.codeHintBox">พิมพ์ตัวเลขในช่อง ระบบจะเติม 0 ให้อัตโนมัติเมื่อเว้นว่าง</p>
|
||||
<div class="mu-numpad" id="stops-numpad">
|
||||
<button type="button" data-key="1">1</button>
|
||||
<button type="button" data-key="2">2</button>
|
||||
<button type="button" data-key="3">3</button>
|
||||
<button type="button" data-key="4">4</button>
|
||||
<button type="button" data-key="5">5</button>
|
||||
<button type="button" data-key="6">6</button>
|
||||
<button type="button" data-key="7">7</button>
|
||||
<button type="button" data-key="8">8</button>
|
||||
<button type="button" data-key="9">9</button>
|
||||
<button type="button" data-key="0">0</button>
|
||||
<button type="button" data-key="back"><span data-i18n="stops.padDelete">ลบ</span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- โหมด 2: ชื่อสถานที่ -->
|
||||
@@ -441,21 +433,25 @@
|
||||
<p class="mu-search-hint" data-i18n="stops.placeHint">พิมพ์ชื่อสถานที่สำคัญ เช่น โรงพยาบาล สำนักงานที่ดิน แล้วเลือกรายการที่ตรงกัน</p>
|
||||
</div>
|
||||
|
||||
<!-- หมวดที่ 3: ป้ายใกล้ฉัน — ขอพิกัดจากเครื่อง แล้วเรียงป้ายตามระยะจริง -->
|
||||
<div class="mu-search-mode" id="stops-near-wrap" hidden>
|
||||
<button type="button" class="mu-btn primary" id="near-me-btn">
|
||||
<svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg>
|
||||
<span data-i18n="stops.nearCta">ขอพิกัดและหาป้ายใกล้ฉัน</span>
|
||||
</button>
|
||||
<p class="mu-search-hint" data-i18n="stops.nearHint">ระบบจะขอตำแหน่งจากเครื่อง แล้วคำนวณระยะจากพิกัดป้าย/ศาลารถ เรียงจากใกล้ไปไกล</p>
|
||||
<div id="near-me-result" class="mu-near-wrap" hidden></div>
|
||||
</div>
|
||||
|
||||
<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 class="mu-show-more">
|
||||
@@ -465,10 +461,28 @@
|
||||
</main>
|
||||
|
||||
<script>
|
||||
/* ป้ายใกล้ฉัน — หมวดที่ 3 ของการค้นหา
|
||||
ต้องมี secure context (HTTPS หรือ localhost) เบราว์เซอร์จึงยอมให้ geolocation
|
||||
ไม่ผ่านเงื่อนไข → ซ่อนแท็บทั้งแท็บ (กดไปก็ได้แต่ error) */
|
||||
(function () {
|
||||
var SECURE = (typeof window !== 'undefined') &&
|
||||
window.isSecureContext === true &&
|
||||
typeof navigator !== 'undefined' && !!navigator.geolocation;
|
||||
|
||||
var tab = document.getElementById('stops-near-tab');
|
||||
if (tab) tab.hidden = !SECURE;
|
||||
|
||||
if (!SECURE) {
|
||||
var wrap0 = document.getElementById('stops-near-wrap');
|
||||
if (wrap0) wrap0.hidden = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var btn = document.getElementById('near-me-btn');
|
||||
var out = document.getElementById('near-me-result');
|
||||
if (!btn || !out || !window.ATMap) return;
|
||||
if (btn.dataset.nearBound === '1') return;
|
||||
btn.dataset.nearBound = '1';
|
||||
ATMap.nearMe(btn, out, { limit: 8 });
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user