footer: remove visitor counter (12,834) and its reset dialog

- drop .mu-visitor markup + styles from ui/index.html
- delete ui/visitors.js (unused), remove from shell + sw PRECACHE
- drop unused visitors.* i18n keys (th/en)
- VERSION 2026.09.27.106
This commit is contained in:
Bkk1234 committed 2026-11-03 00:15:54 +07:00
1 parent 2504c39305
commit 4acb43ff45
5 files changed
+7 -306

No files matched your search

+6 -56
View File
@@ -12,8 +12,8 @@
<link href="./_shared.css" rel="stylesheet">
<link href="./vendor/leaflet/leaflet.css" rel="stylesheet">
<link href="./map.css" rel="stylesheet">
<meta name="app-version" content="2026.09.27.105">
<link rel="icon" type="image/png" href="../.image/icons/minibus-512x512.png?v=2026.09.27.105">
<meta name="app-version" content="2026.09.27.106">
<link rel="icon" type="image/png" href="../.image/icons/minibus-512x512.png?v=2026.09.27.106">
<style>
.mu-card.empty { width: 100%; padding: 16px; text-align: center; color: #6f7b95; background: #fff7fb; border: 1px dashed #f4c7df; }
a.mu-card { text-decoration: none; color: inherit; display: block; }
@@ -237,52 +237,8 @@
.mu-stat.tag-purple { background: #ede9fe; }
.mu-stat.tag-mint { background: #d1fae5; }
/* ===== Visitor counter (footer bottom bar) ===== */
/* ===== Footer bottom bar ===== */
.mu-footer-bottom { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.mu-visitor {
display: inline-flex;
align-items: center;
gap: 7px;
margin: 0;
padding: 5px 12px;
border-radius: 999px;
background: rgba(255,255,255,.06);
border: 1px solid rgba(255,255,255,.1);
color: #b6bdda;
font-size: .78rem;
font-weight: 600;
letter-spacing: .01em;
line-height: 1;
}
.mu-visitor svg { width: 14px; height: 14px; color: #b694f6; flex: none; }
.mu-visitor strong { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
/* ปุ่ม/ช่องรีเซ็ตผู้เข้าชม (ซ่อน — กดตัวเลข 5 ครั้ง) */
#visitor-count { cursor: pointer; }
.mu-vreset {
position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center;
padding: 20px; background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px);
}
.mu-vreset-card {
width: 100%; max-width: 340px; background: #fff; border-radius: 16px; padding: 20px;
box-shadow: 0 18px 50px rgba(15, 23, 42, .28);
}
.mu-vreset-card h4 { margin: 0 0 12px; font-size: 1rem; color: #1f2a44; }
.mu-vreset-card label { display: block; font-size: .8rem; color: #6b7a94; margin-bottom: 6px; }
.mu-vreset-card input {
width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: .95rem;
border: 1px solid #d9d3e8; border-radius: 10px; color: #1f2a44; background: #fbfaff;
}
.mu-vreset-card input:focus { outline: 2px solid #7a4cc0; outline-offset: 1px; border-color: #7a4cc0; }
.mu-vreset-msg { margin: 10px 0 0; min-height: 18px; font-size: .8rem; color: #b3261e; }
.mu-vreset-msg.is-ok { color: #1f7a3d; }
.mu-vreset-row { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.mu-vreset-row button {
padding: 9px 16px; font-size: .85rem; font-weight: 700; border-radius: 10px; cursor: pointer;
border: 1px solid #d9d3e8; background: #fff; color: #3d4a63;
}
.mu-vreset-row button:hover { background: #fbfaff; }
.mu-vreset-ok { border-color: #7a4cc0 !important; background: #7a4cc0 !important; color: #fff !important; }
.mu-vreset-ok:hover { background: #6a3fb0 !important; }
/* ===== Sponsor marquee (between hero and main) ===== */
.mu-sponsor-marquee { padding: 26px 0 6px; background: #fff; border-bottom: 1px solid #f0f2f8; }
@@ -349,13 +305,12 @@
</script>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="apple-touch-icon" href="../.image/icons/minibus-192x192.png?v=2026.09.27.105">
<link rel="apple-touch-icon" href="../.image/icons/minibus-192x192.png?v=2026.09.27.106">
<script src="./imageurl.js" defer></script>
<script src="./pwa.js" defer></script>
<script src="./i18n.js" defer></script>
<script src="./analytics.js" defer></script>
<script src="./popular.js" defer></script>
<script src="./visitors.js" defer></script>
<script src="./vendor/leaflet/leaflet.js" defer></script>
<script src="./map.js" defer></script>
<script src="./partials/schedules.js" defer></script>
@@ -456,7 +411,7 @@
<header class="mu-topbar">
<div class="mu-container mu-topbar-inner">
<a class="mu-brand" href="#/" aria-label="Atroute — หน้าแรก" data-i18n-attr="aria-label:aria.brandHome">
<img class="mu-logo-img" src="../.image/icons/minibus-512x512.png?v=2026.09.27.105" alt="Atroute logo" width="44" height="44" decoding="async">
<img class="mu-logo-img" src="../.image/icons/minibus-512x512.png?v=2026.09.27.106" alt="Atroute logo" width="44" height="44" decoding="async">
<span>
<span class="mu-brand-title">Atroute</span>
<span class="mu-brand-subtitle" data-i18n="brand.subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
@@ -499,7 +454,7 @@
<div class="mu-footer-grid">
<div class="mu-footer-brand">
<div class="mu-footer-brand-row">
<img src="../.image/icons/minibus-512x512.png?v=2026.09.27.105" alt="Atroute">
<img src="../.image/icons/minibus-512x512.png?v=2026.09.27.106" alt="Atroute">
<div>
<strong>Atroute</strong>
<span data-i18n="brand.subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
@@ -536,11 +491,6 @@
<div class="mu-footer-bottom">
<p>© 2026 Atroute</p>
<span class="mu-visitor" title="จำนวนผู้เข้าชมเว็บไซต์" data-i18n-attr="title:visitors.tip">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/></svg>
<span data-i18n="visitors.label">ผู้เข้าชม</span>
<strong id="visitor-count">12,834</strong>
</span>
</div>
</div>
</footer>
-9
View File
@@ -300,13 +300,6 @@
"day.thuS": "Thu",
"day.friS": "Fri",
"day.satS": "Sat",
"visitors.resetTitle": "Reset visitor counter",
"visitors.resetPass": "Reset code",
"visitors.cancel": "Cancel",
"visitors.confirm": "Reset",
"visitors.done": "Reset done — counting restarts from 0",
"visitors.unsupported": "Browser not supported — needs https or localhost",
"visitors.badPass": "Incorrect code",
"aria.mapsView": "View",
"aria.searchMode": "Search mode",
"aria.stopCode": "Stop code",
@@ -341,8 +334,6 @@
"credits.breadHome": "Home",
"credits.breadSelf": "Credits",
"credits.lineRed": "SRT Red Line",
"visitors.label": "Visitors",
"visitors.tip": "Site visitor count",
"pwa.install": "Install app",
"aria.brandHome": "Atroute — home",
"aria.mainMenu": "Main menu",
-9
View File
@@ -300,13 +300,6 @@
"day.thuS": "พฤ.",
"day.friS": "ศ.",
"day.satS": "ส.",
"visitors.resetTitle": "รีเซ็ตจำนวนผู้เข้าชม",
"visitors.resetPass": "รหัสรีเซ็ต",
"visitors.cancel": "ยกเลิก",
"visitors.confirm": "รีเซ็ต",
"visitors.done": "รีเซ็ตแล้ว — เริ่มนับใหม่จาก 0",
"visitors.unsupported": "เบราว์เซอร์ไม่รองรับ — ต้องเปิดผ่าน https หรือ localhost",
"visitors.badPass": "รหัสไม่ถูกต้อง",
"aria.mapsView": "มุมมอง",
"aria.searchMode": "รูปแบบการค้นหา",
"aria.stopCode": "รหัสป้าย",
@@ -341,8 +334,6 @@
"credits.breadHome": "หน้าแรก",
"credits.breadSelf": "เครดิต",
"credits.lineRed": "รถไฟฟ้าสายสีแดง",
"visitors.label": "ผู้เข้าชม",
"visitors.tip": "จำนวนผู้เข้าชมเว็บไซต์",
"pwa.install": "ติดตั้งแอป",
"aria.brandHome": "Atroute — หน้าแรก",
"aria.mainMenu": "เมนูหลัก",
+1 -2
View File
@@ -13,7 +13,7 @@
- ขั้นตอนอัปเดต: ดู AGENTS.md หัวข้อ PWA
============================================================ */
const VERSION = "2026.09.27.105"; // ← bump ทุกครั้งที่แก้ SW เอง
const VERSION = "2026.09.27.106"; // ← bump ทุกครั้งที่แก้ SW เอง
const CACHE = `at-transit-${VERSION}`;
const PRECACHE = [
@@ -31,7 +31,6 @@ const PRECACHE = [
"./pwa.js",
"./i18n.js",
"./popular.js",
"./visitors.js",
"./analytics.js",
"./router.js",
"./motion.js",
-230
View File
@@ -1,230 +0,0 @@
/* visitors.js — นับผู้เข้าชมจริง (ฝั่งเบราว์เซอร์ ไม่มี backend) + รีเซ็ตด้วยรหัส
แนวคิด
แสดงผล = ฐาน + จำนวนผู้เข้าชมจริง (unique)
ฐานเริ่มต้น = 12,834 (แสดงเมื่อยังไม่เคยรีเซ็ต)
รีเซ็ต (รหัส) = ล้างฐานทิ้งด้วย → เริ่มนับใหม่จาก 0
กันจำนวนเฟ้อ 3 ชั้น
1. sessionStorage → 1 รอบการเข้าชม (เปิดแท็บใหม่) นับ 1 · กด F5 ไม่นับ
2. localStorage → 1 ครั้ง/วัน/เครื่อง (วันเดียวกันนับครั้งเดียว)
3. dayKey กำกับ → ล้าง session/incognito เปิดซ้ำวันเดิม = ไม่นับ (เพดาน/วัน)
ประหยัดพื้นที่
เก็บแค่ {"v": <จำนวนจริง>, "d": <วัน YYYY-MM-DD>} ≈ 35 ไบต์ · ไม่เก็บ log/IP/UA
รีเซ็ต
กดที่ตัวเลขผู้เข้าชม 5 ครั้งติด → เปิดช่องกรอกรหัส (ซ่อน ไม่มีปุ่มให้คนอื่นกด)
รหัสตรวจแบบ SHA-256 (ไม่เก็บรหัสจริงในโค้ด — เปิด view-source ไม่เจอ)
*/
(function () {
'use strict';
var KEY = 'at_visitors'; /* { v: จำนวนจริง, d: 'YYYY-MM-DD' } */
var SESSION_KEY = 'at_visitors_seen';
var BASE = 12834; /* ฐานตั้งต้น — รีเซ็ตแล้วกลับมาที่นี่ */
var TAPS = 5; /* จำนวนครั้งที่ต้องกดตัวเลข */
var TAP_WINDOW = 2000; /* ต้องกดรัวภายใน 2 วิต่อครั้ง */
/* แปลข้อความ (ถ้าโหลดคำแปลไม่ทัน/ไม่มีคีย์ → ใช้ข้อความไทยที่ฝังไว้) */
function vt(key, fallback) {
var v = (window.I18N && I18N.t) ? I18N.t(key) : key;
return (!v || v === key) ? fallback : v;
}
/* SHA-256 ของรหัสรีเซ็ต — เก็บเฉพาะ hash (ไม่เก็บรหัสจริงในไฟล์นี้) */
var PASS_HASH = '4f23cd6ac8e7da56b92974cd0cf146eee9d995208a6645ed17eba91813c1d323';
function today() {
var d = new Date();
var m = String(d.getMonth() + 1);
var day = String(d.getDate());
if (m.length < 2) m = '0' + m;
if (day.length < 2) day = '0' + day;
return d.getFullYear() + '-' + m + '-' + day;
}
function read() {
try {
var raw = localStorage.getItem(KEY);
var d = raw ? JSON.parse(raw) : null;
if (!d || typeof d !== 'object') return { b: null, v: 0, d: '' };
return {
b: (d.b === undefined || d.b === null) ? null : Math.max(0, Number(d.b) || 0),
v: Math.max(0, Number(d.v) || 0),
d: String(d.d || '')
};
} catch (e) { return { b: null, v: 0, d: '' }; }
}
function write(d) {
try { localStorage.setItem(KEY, JSON.stringify(d)); } catch (e) { /* เงียบ */ }
}
/* ตรวจว่ารอบการเข้าชมนี้ "ควรนับ" — ผ่านครบ 3 ชั้น */
function shouldCount(store) {
/* ชั้น 1: sessionStorage — รอบนี้เคยนับแล้ว? (F5 ไม่นับ) */
var seen = null;
try { seen = sessionStorage.getItem(SESSION_KEY); } catch (e) { /* เงียบ */ }
if (seen) return false;
/* ชั้น 2+3: วันเดียวกันห้ามเพิ่ม (แม้ sessionStorage ถูกล้าง) */
if (store.d === today()) return false;
return true;
}
function fmt(n) { return Number(n).toLocaleString('en-US'); }
/* ── รหัส: SHA-256 ผ่าน SubtleCrypto (มีในทุกเบราว์เซอร์สมัยใหม่) ── */
function hash(text, cb) {
if (window.crypto && crypto.subtle && crypto.subtle.digest) {
crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))
.then(function (buf) {
var b = new Uint8Array(buf), s = '';
for (var i = 0; i < b.length; i++) s += ('0' + b[i].toString(16)).slice(-2);
cb(s);
})
.catch(function () { cb(null); });
} else {
cb(null); /* เบราว์เซอร์เก่า/ไม่มี https → กรุณาใช้ http://localhost */
}
}
/* เทียบแบบ constant-time (กัน timing attack) */
function safeEqual(a, b) {
if (typeof a !== 'string' || typeof b !== 'string' || a.length !== b.length) return false;
var diff = 0;
for (var i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
return diff === 0;
}
var Visitors = {
BASE: BASE, /* ฐานตั้งต้น (ค่าคงที่) — ดู Visitors._base สำหรับฐานที่ใช้จริง */
_base: BASE,
/* เรียกครั้งเดียวตอนโหลดหน้า — นับ (ถ้าควรนับ) แล้วคืนค่าที่จะแสดง */
init: function () {
var store = read();
if (shouldCount(store)) {
store.v = (Number(store.v) || 0) + 1;
store.d = today();
write(store);
try { sessionStorage.setItem(SESSION_KEY, '1'); } catch (e) { /* เงียบ */ }
}
/* ฐาน: ยังไม่เคยรีเซ็ต → BASE · เคยรีเซ็ต → ค่าที่บันทึกไว้ (0) */
var base = (store.b === null) ? BASE : store.b;
var el = document.getElementById('visitor-count');
if (el) el.textContent = fmt(base + store.v);
Visitors._base = base;
Visitors._store = store;
return base + store.v;
},
/* จำนวนจริง (ไม่รวม BASE) */
actual: function () { return read().v; },
/* รีเซ็ต: ล้างฐานทิ้งด้วย → เริ่มนับใหม่จาก 0 (ตามที่เลือก) */
reset: function () {
write({ b: 0, v: 0, d: today() });
/* ไม่ล้าง sessionStorage — กันการนับซ้ำทันทีหลังรีเซ็ตในรอบเดียวกัน */
Visitors._base = 0;
var el = document.getElementById('visitor-count');
if (el) el.textContent = fmt(0);
return 0;
},
/* ตรวจรหัสแล้วรีเซ็ต (async — SHA-256) */
resetWith: function (pass, done) {
hash(String(pass == null ? '' : pass), function (h) {
if (!h) { done(false, 'unsupported'); return; }
if (!safeEqual(h, PASS_HASH)) { done(false, 'wrong'); return; }
Visitors.reset();
done(true, 'ok');
});
},
_hash: hash,
_key: KEY
};
window.Visitors = Visitors;
/* ── ช่องทางลับ: กดที่ตัวเลข 5 ครั้งติด → เปิดช่องกรอกรหัส ── */
function mountTap() {
var el = document.getElementById('visitor-count');
if (!el) return;
var taps = 0, timer = null;
el.style.cursor = 'pointer';
el.addEventListener('click', function () {
taps++;
if (timer) clearTimeout(timer);
timer = setTimeout(function () { taps = 0; }, TAP_WINDOW);
if (taps >= TAPS) {
taps = 0;
clearTimeout(timer);
openDialog();
}
});
}
function openDialog() {
if (document.querySelector('.mu-vreset')) return;
var wrap = document.createElement('div');
wrap.className = 'mu-vreset';
wrap.innerHTML =
'<div class="mu-vreset-card" role="dialog" aria-modal="true" aria-labelledby="vreset-title">' +
'<h4 id="vreset-title">' + vt('visitors.resetTitle', 'รีเซ็ตจำนวนผู้เข้าชม') + '</h4>' +
'<label for="vreset-pass">' + vt('visitors.resetPass', 'รหัสรีเซ็ต') + '</label>' +
'<input id="vreset-pass" type="password" autocomplete="off" inputmode="text">' +
'<p class="mu-vreset-msg" role="status"></p>' +
'<div class="mu-vreset-row">' +
'<button type="button" class="mu-vreset-cancel">' + vt('visitors.cancel', 'ยกเลิก') + '</button>' +
'<button type="button" class="mu-vreset-ok">' + vt('visitors.confirm', 'รีเซ็ต') + '</button>' +
'</div>' +
'</div>';
var input = wrap.querySelector('#vreset-pass');
var msg = wrap.querySelector('.mu-vreset-msg');
function close() { wrap.remove(); }
function submit() {
msg.textContent = '';
Visitors.resetWith(input.value, function (ok, why) {
if (ok) {
msg.className = 'mu-vreset-msg is-ok';
msg.textContent = vt('visitors.done', 'รีเซ็ตแล้ว — เริ่มนับใหม่จาก 0');
input.value = '';
setTimeout(close, 1200);
} else if (why === 'unsupported') {
msg.textContent = vt('visitors.unsupported', 'เบราว์เซอร์ไม่รองรับ');
} else {
msg.className = 'mu-vreset-msg is-bad';
msg.textContent = vt('visitors.badPass', 'รหัสไม่ถูกต้อง');
input.value = '';
input.focus();
}
});
}
wrap.querySelector('.mu-vreset-ok').addEventListener('click', submit);
wrap.querySelector('.mu-vreset-cancel').addEventListener('click', close);
wrap.addEventListener('click', function (e) { if (e.target === wrap) close(); });
input.addEventListener('keydown', function (e) {
if (e.key === 'Enter') submit();
if (e.key === 'Escape') close();
});
document.body.appendChild(wrap);
input.focus();
}
/* ── nับตอนโหลด + ติดช่องทางลับ ── */
function boot() {
Visitors.init();
mountTap();
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot);
else boot();
})();