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

@@ -43,19 +43,6 @@ export default function StopsView() {
</div>
<p className="mu-code-display" id="stops-code-display" hidden />
<p className="mu-search-hint" data-i18n="stops.codeHintBox">พิมพ์ตัวเลขในช่อง ระบบจะเติม 0 ให้อัตโนมัติเมื่อเว้นว่าง</p>
<div className="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: ชื่อสถานที่ */}
<div className="mu-search-mode" id="stops-place-wrap" hidden>
+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); // เริ่มที่โหมดรหัส
}
-20
View File
@@ -92,7 +92,6 @@
.mu-search-mode { display: block; }
/* กัน .display:block ทับ attribute [hidden] — โหมดที่ไม่ได้ใช้ต้องซ่อนจริง */
.mu-search-mode[hidden],
.mu-numpad[hidden] { display: none; }
.mu-search-field {
display: flex;
@@ -181,24 +180,6 @@
}
.mu-search-hint { margin: 8px 0 0; font-size: .82rem; color: #6f7b95; }
/* numpad — โชว์เฉพาะจอเล็ก */
.mu-numpad { display: none; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; max-width: 320px; }
.mu-numpad button {
font-family: "IBM Plex Mono", ui-monospace, monospace;
font-size: 1.2rem;
font-weight: 700;
padding: 14px 0;
border: 1px solid #e0d6f5;
border-radius: 8px;
background: #fff;
color: #1f2a44;
cursor: pointer;
font-variant-numeric: tabular-nums;
transition: background .12s ease, border-color .12s ease;
}
.mu-numpad button:active { background: #f3ecff; border-color: #b07ce0; }
.mu-numpad button[data-key="back"] { grid-column: span 2; font-size: 1rem; }
/* suggest */
.mu-suggest {
border: 1px solid #e0d6f5;
@@ -353,7 +334,6 @@
@media (max-width: 640px) {
.mu-kpi-grid { grid-template-columns: 1fr; }
.mu-numpad { display: grid; }
.mu-search-tabs { width: 100%; }
.mu-search-tab { flex: 1; justify-content: center; padding: 10px 12px; font-size: .84rem; }
.mu-stop-action { flex-direction: column; align-items: flex-start; }