Remove the on-screen numpad from the bus stop code search

The five code cells are now the only way to enter a stop code. The numpad
was redundant on touch devices (the cells use inputMode=numeric, so the
system keyboard already switches to digits) and it crowded the 375px
layout.

- StopsView.tsx: drop the .mu-numpad markup.
- stops.search.ts: drop initNumpad(), its call and the pad show/hide toggle.
- stops.css: drop all .mu-numpad rules.

tsc clean, npm run build passes.
This commit is contained in:
Bkk1234 committed 2026-10-23 22:49:13 +07:00
1 parent 092f551b7d
commit 4c444b3d8d
4 files changed
+4 -80

No files matched your search

+3 -46
View File
@@ -3,7 +3,7 @@
/* ============================================================
ระบบค้นหาป้ายหยุดรถ — 2 โหมด (เลือกอย่างใดอย่างหนึ่ง)
------------------------------------------------------------
โหมด 1 "รหัสป้าย" : พิมพ์/กด numpad → auto-insert "+" → 00+000
โหมด 1 "รหัสป้าย" : พิมพ์ในช่อง 5 ช่อง → auto-insert "+" → 00+000
โหมด 2 "ชื่อสถานที่" : พิมพ์หา → จับคู่ place/route_name ใน JSON + suggest
กติกากันการชนกัน:
@@ -59,7 +59,7 @@
return (head + tail).split('');
}
/* เก็บของเดิมไว้ใช้กับ numpad/plantext เดิม (ถ้ามีคนเรียก) */
/* เก็บของเดิมไว้ใช้กับ plantext เดิม (ถ้ามีคนเรียก) */
/* พิมพ์ "3000" → "3+000" · "5005" → "5+005" */
function formatCode(raw) {
var digits = String(raw || '').replace(/\D/g, '').slice(0, 4);
@@ -215,7 +215,6 @@
var placeWrap = document.getElementById('stops-place-wrap');
var placeInput = document.getElementById('stops-place-input');
var suggest = document.getElementById('stops-suggest');
var pad = document.getElementById('stops-numpad');
var cells = codeCells();
var isCode = mode === MODE_CODE;
@@ -223,7 +222,6 @@
// แสดง/ซ่อนช่องกรอก
if (codeWrap) codeWrap.hidden = !isCode;
if (placeWrap) placeWrap.hidden = isCode;
if (pad) pad.hidden = !isCode;
if (suggest) suggest.hidden = isCode;
// ปิดการใช้งานช่องของโหมดที่ไม่ได้เลือก + ล้างค่า → กันการค้น 2 ทางพร้อมกัน
@@ -281,7 +279,7 @@
return state.codeValue;
}
/* เขียน digits[] กลับลงช่อง (ใช้ตอน paste / ล้างค่า / numpad) */
/* เขียน digits[] กลับลงช่อง (ใช้ตอน paste / ล้างค่า) */
function paintCells(digits) {
var cells = codeCells();
for (var i = 0; i < CODE_CELLS; i++) {
@@ -353,46 +351,6 @@
});
}
/* ---------- numpad (ใช้กับ 5 ช่อง) ---------- */
function initNumpad() {
var pad = document.getElementById('stops-numpad');
if (!pad) return;
pad.addEventListener('click', function (e) {
var key = e.target.closest('[data-key]');
if (!key) return;
e.preventDefault();
var k = key.getAttribute('data-key');
var cells = codeCells();
if (!cells.length) return;
/* ตำแหน่งเป้าหมาย = ช่องแรกที่ว่าง (ช่องท้ายสุดถ้าเต็มหมด) */
var idx = CODE_CELLS - 1;
for (var i = 0; i < CODE_CELLS; i++) {
if (!cells[i].value) { idx = i; break; }
}
if (k === 'back') {
// ถอยจากท้าย: ล้างช่องขวาสุดที่มีค่า แล้วเลื่อนเป้าไปช่องนั้น
var last = -1;
for (var j = CODE_CELLS - 1; j >= 0; j--) {
if (cells[j].value) { last = j; break; }
}
idx = last === -1 ? 0 : last;
cells[idx].value = '';
} else {
cells[idx].value = k;
}
syncCodeFromCells();
updateCodeDisplay();
apply();
// โฟกัสช่องถัดไป (ไม่ select — กันกด numpad แล้วทับค่าเดิม)
var next = Math.min(idx + (k === 'back' ? 0 : 1), CODE_CELLS - 1);
if (cells[next]) cells[next].focus();
});
}
/* ---------- init ---------- */
function init(stops) {
if (stops) state.stops = stops;
@@ -483,7 +441,6 @@
suggest.hidden = true;
});
initNumpad();
setMode(MODE_CODE); // เริ่มที่โหมดรหัส
}