พอร์ต UI จาก web-at-transit-mock เข้า Next.js + data sync เข้า Postgres/SeaweedFS
- 8 หน้า (home/stops/routes/stop/check/blog/about/credits) แปลง partials → React component ตรง mock
- ตรรกะพอร์ตเป็น src/lib/ui/*.ts (mount()) + runtime/PageRuntime
- CSS: base + pages/*.css import ต่อ route (คงลำดับ cascade ของ mock)
- asset/content: public/{image,resource/data,content,locales,vendor}
- แก้ path รูปไทล์พาร์ทเนอร์ (.image → /image) + fallback absolute
- ลบ UI เดิมที่ไม่ตรง mock (expanded/stops details/old components/globals.css)
- script/sync_data_to_postgres.mjs + sync_images_to_storage.mjs (dry-run/--apply, backup)
- docs/UI-PORT.md + DESIGN.md + README
This commit is contained in:
1 parent
24187fc3b7
commit
138a3d15d8
300 files changed
+20213
-1978
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import AboutView from "@/components/views/AboutView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
export const metadata = { title: "เกี่ยวกับเรา" };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<AboutView />
|
||||
<PageRuntime page="about" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import BlogView from "@/components/views/BlogView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
export const metadata = { title: "บ่นไปเรื่อย" };
|
||||
|
||||
export default async function Page({ params }: { params: Promise<{ postId: string }> }) {
|
||||
const { postId } = await params;
|
||||
return (
|
||||
<>
|
||||
<BlogView />
|
||||
<PageRuntime page="blog" params={{ postId: decodeURIComponent(postId) }} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import BlogView from "@/components/views/BlogView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
export const metadata = { title: "บ่นไปเรื่อย" };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<BlogView />
|
||||
<PageRuntime page="blog" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import CheckView from "@/components/views/CheckView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
export const metadata = { title: "เช็กเวลาเดินรถ" };
|
||||
|
||||
export default async function Page({ params }: { params: Promise<{ routeId: string }> }) {
|
||||
const { routeId } = await params;
|
||||
return (
|
||||
<>
|
||||
<CheckView />
|
||||
<PageRuntime page="check" params={{ routeId: decodeURIComponent(routeId) }} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import CheckView from "@/components/views/CheckView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
export const metadata = { title: "เช็กเวลาเดินรถ" };
|
||||
|
||||
export default async function Page({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
||||
}) {
|
||||
const sp = await searchParams;
|
||||
const query: Record<string, string> = {};
|
||||
if (typeof sp.route === "string") query.route = sp.route;
|
||||
return (
|
||||
<>
|
||||
<CheckView />
|
||||
<PageRuntime page="check" query={query} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import CreditsView from "@/components/views/CreditsView";
|
||||
|
||||
export const metadata = { title: "เครดิต" };
|
||||
|
||||
export default function Page() {
|
||||
return <CreditsView />;
|
||||
}
|
||||
@@ -1,887 +0,0 @@
|
||||
/* ============================================================
|
||||
AT Transit — bold-creative light theme
|
||||
Ported from flow_ui/ui/_shared.css + index.html inline styles
|
||||
============================================================ */
|
||||
|
||||
:root {
|
||||
--bg: #f7f9fd;
|
||||
--surface: #ffffff;
|
||||
--ink: #1f2a44;
|
||||
--ink-muted: #4a5876;
|
||||
--muted: #6f7b95;
|
||||
--line: #e9eef7;
|
||||
|
||||
--sky-50: #dbeafe; --sky-700: #1d4ed8;
|
||||
--purple-50: #ede9fe; --purple-700: #6d28d9;
|
||||
--pink-50: #fce7f3; --pink-700: #be185d;
|
||||
--mint-50: #d1fae5; --mint-700: #047857;
|
||||
--green-50: #dcfce7; --green-700: #15803d;
|
||||
--amber-50: #fef3c7; --amber-700: #b45309;
|
||||
|
||||
--grad-sky: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
|
||||
--grad-purple: linear-gradient(135deg, #8b5cf6 0%, #c084fc 100%);
|
||||
--grad-pink: linear-gradient(135deg, #ec4899 0%, #f472b6 100%);
|
||||
--grad-mint: linear-gradient(135deg, #10b981 0%, #34d399 100%);
|
||||
--grad-amber: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
|
||||
--grad-cta: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
|
||||
|
||||
--radius: 16px;
|
||||
--radius-lg: 22px;
|
||||
--shadow-sm: 0 4px 14px rgba(20, 40, 90, .06);
|
||||
--shadow-md: 0 10px 24px rgba(20, 40, 90, .10);
|
||||
--shadow-lg: 0 18px 36px rgba(15, 23, 42, .14);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
body {
|
||||
font-family: "Noto Sans Thai", "Prompt", "Sukhumvit Set", "Sarabun",
|
||||
system-ui, -apple-system, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--ink);
|
||||
min-height: 100vh;
|
||||
}
|
||||
a { color: inherit; text-decoration: none; }
|
||||
img { max-width: 100%; display: block; }
|
||||
|
||||
/* ---------- Layout helpers ---------- */
|
||||
.container { max-width: 1200px; margin: 0 auto; padding: 0 28px; }
|
||||
@media (max-width: 640px) { .container { padding: 0 18px; } }
|
||||
.main { padding: 40px 0 24px; }
|
||||
|
||||
/* ---------- Topbar ---------- */
|
||||
.topbar {
|
||||
position: sticky; top: 0; z-index: 50;
|
||||
background: #ffffff;
|
||||
border-bottom: 1px solid var(--line);
|
||||
box-shadow: 0 2px 8px rgba(20, 40, 90, .04);
|
||||
}
|
||||
.topbar__inner {
|
||||
display: flex; align-items: center; gap: 18px;
|
||||
padding: 14px 28px; max-width: 1200px; margin: 0 auto;
|
||||
}
|
||||
.brand { display: flex; align-items: center; gap: 12px; }
|
||||
.brand__logo {
|
||||
width: 44px; height: 44px; border-radius: 12px;
|
||||
background: var(--grad-cta);
|
||||
padding: 4px;
|
||||
}
|
||||
.brand__title { margin: 0; font-weight: 800; font-size: 1.05rem; color: var(--ink); }
|
||||
.brand__subtitle { margin: 0; font-size: .72rem; color: var(--muted); }
|
||||
|
||||
.nav { margin-left: auto; display: flex; gap: 28px; }
|
||||
.nav a {
|
||||
color: var(--ink-muted); font-size: .92rem; font-weight: 600;
|
||||
padding: 6px 4px; border-bottom: 2px solid transparent; transition: color .15s;
|
||||
}
|
||||
.nav a.active { color: var(--pink-700); border-bottom-color: #ec4899; }
|
||||
.nav a:hover { color: var(--ink); }
|
||||
|
||||
.cta-pill {
|
||||
background: var(--grad-cta); color: #fff; padding: 10px 22px;
|
||||
border-radius: 999px; font-weight: 700; font-size: .88rem;
|
||||
box-shadow: 0 6px 14px rgba(124, 58, 237, .3);
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.nav { display: none; }
|
||||
.brand__subtitle { display: none; }
|
||||
}
|
||||
|
||||
/* ---------- Hero ---------- */
|
||||
.hero {
|
||||
position: relative; overflow: hidden;
|
||||
padding: 56px 0 64px;
|
||||
background: linear-gradient(180deg, #f0ebff 0%, #ffe8ee 50%, #fff4d6 100%);
|
||||
text-align: center;
|
||||
}
|
||||
.hero__blob {
|
||||
position: absolute; border-radius: 50%;
|
||||
filter: blur(50px); opacity: .55; z-index: 0;
|
||||
}
|
||||
.hero__blob.one { width: 220px; height: 220px; background: #b794f4; top: -50px; left: 8%; }
|
||||
.hero__blob.two { width: 260px; height: 260px; background: #f9a8d4; top: 40%; right: 8%; }
|
||||
.hero__blob.three { width: 180px; height: 180px; background: #fde68a; bottom: -40px; left: 38%; }
|
||||
.hero__inner { position: relative; z-index: 1; }
|
||||
|
||||
.hero__badge {
|
||||
display: inline-block;
|
||||
background: rgba(255, 255, 255, .8);
|
||||
backdrop-filter: blur(6px);
|
||||
color: var(--purple-700);
|
||||
padding: 6px 16px; border-radius: 999px;
|
||||
font-size: .82rem; font-weight: 700;
|
||||
margin-bottom: 18px;
|
||||
box-shadow: 0 4px 10px rgba(124, 58, 237, .12);
|
||||
}
|
||||
.hero h1 {
|
||||
margin: 0 0 26px;
|
||||
font-size: clamp(1.6rem, 4vw, 2.4rem);
|
||||
font-weight: 800; line-height: 1.35; color: var(--ink);
|
||||
}
|
||||
.hero__lead {
|
||||
margin: -6px auto 0;
|
||||
max-width: 640px;
|
||||
color: var(--ink-muted);
|
||||
font-size: 1rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.hero__grad {
|
||||
background: linear-gradient(120deg, #d946ef 10%, #a855f7 60%, #6366f1 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
.hero__actions {
|
||||
margin: 28px auto 0;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
max-width: 860px;
|
||||
}
|
||||
.pill-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 58px;
|
||||
background: rgba(255, 255, 255, .88);
|
||||
color: var(--ink);
|
||||
padding: 12px 18px;
|
||||
border-radius: 18px;
|
||||
font-weight: 800;
|
||||
font-size: .98rem;
|
||||
border: 1px solid rgba(124, 58, 237, .18);
|
||||
box-shadow: 0 10px 22px rgba(40, 60, 120, .10);
|
||||
transition: transform .15s, box-shadow .15s, border-color .15s;
|
||||
}
|
||||
.pill-link:hover { transform: translateY(-2px); box-shadow: 0 14px 24px rgba(40, 60, 120, .16); }
|
||||
.pill-link--primary {
|
||||
background: var(--grad-cta);
|
||||
color: #fff;
|
||||
border-color: transparent;
|
||||
}
|
||||
.pill-link--secondary {
|
||||
background: rgba(255, 255, 255, .95);
|
||||
border-color: rgba(59, 130, 246, .22);
|
||||
}
|
||||
.pill-link--accent {
|
||||
background: rgba(255, 255, 255, .95);
|
||||
border-color: rgba(236, 72, 153, .22);
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.hero__actions { grid-template-columns: 1fr; }
|
||||
}
|
||||
|
||||
/* ---------- Zones / Cards ---------- */
|
||||
.zone { margin-bottom: 36px; }
|
||||
.zone__head {
|
||||
display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.zone__tag {
|
||||
padding: 5px 14px; border-radius: 999px;
|
||||
font-size: .82rem; font-weight: 700;
|
||||
}
|
||||
.zone__tag.sky { background: var(--sky-50); color: var(--sky-700); }
|
||||
.zone__tag.purple { background: var(--purple-50); color: var(--purple-700); }
|
||||
.zone__tag.pink { background: var(--pink-50); color: var(--pink-700); }
|
||||
.zone__tag.mint { background: var(--mint-50); color: var(--mint-700); }
|
||||
.zone__desc { color: var(--muted); font-size: .88rem; margin: 0; }
|
||||
|
||||
.grid {
|
||||
display: grid; gap: 18px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
}
|
||||
|
||||
.card {
|
||||
display: block; background: #fff; border-radius: var(--radius);
|
||||
overflow: hidden; box-shadow: var(--shadow-sm);
|
||||
transition: transform .18s ease, box-shadow .18s ease;
|
||||
color: inherit;
|
||||
}
|
||||
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
|
||||
|
||||
.card__head {
|
||||
height: 130px; display: flex; align-items: center; justify-content: center;
|
||||
position: relative;
|
||||
}
|
||||
.card__head.sky { background: var(--grad-sky); }
|
||||
.card__head.purple { background: var(--grad-purple); }
|
||||
.card__head.pink { background: var(--grad-pink); }
|
||||
.card__head.mint { background: var(--grad-mint); }
|
||||
.card__head.amber { background: var(--grad-amber); }
|
||||
|
||||
.card__num {
|
||||
color: #fff; font-size: 52px; font-weight: 900;
|
||||
text-shadow: 0 4px 12px rgba(0, 0, 0, .25);
|
||||
letter-spacing: .02em; margin: 0;
|
||||
}
|
||||
.card__body { padding: 14px 16px 16px; }
|
||||
.card__name {
|
||||
margin: 0 0 10px; font-size: .9rem; color: var(--ink); font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.card__chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.card__icon {
|
||||
font-size: 56px; line-height: 1;
|
||||
filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .25));
|
||||
}
|
||||
.chip {
|
||||
display: inline-block; padding: 4px 12px; border-radius: 999px;
|
||||
font-size: .78rem; font-weight: 700;
|
||||
}
|
||||
.chip.sky { background: var(--sky-50); color: var(--sky-700); }
|
||||
.chip.purple { background: var(--purple-50); color: var(--purple-700); }
|
||||
.chip.pink { background: var(--pink-50); color: var(--pink-700); }
|
||||
.chip.mint { background: var(--mint-50); color: var(--mint-700); }
|
||||
.chip.green { background: var(--green-50); color: var(--green-700); }
|
||||
.chip.amber { background: var(--amber-50); color: var(--amber-700); }
|
||||
|
||||
/* ---------- Stats summary ---------- */
|
||||
.summary { padding: 8px 0 40px; }
|
||||
.summary__grid {
|
||||
display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
|
||||
}
|
||||
.stat {
|
||||
padding: 28px 18px; text-align: center;
|
||||
border-radius: 18px; margin: 0;
|
||||
}
|
||||
.stat h3 { margin: 0 0 4px; font-size: 2rem; color: var(--ink); font-weight: 800; }
|
||||
.stat p { margin: 0; font-size: .82rem; color: var(--ink-muted); font-weight: 600; }
|
||||
.stat.pink { background: var(--pink-50); }
|
||||
.stat.sky { background: var(--sky-50); }
|
||||
.stat.purple { background: var(--purple-50); }
|
||||
.stat.mint { background: var(--mint-50); }
|
||||
@media (max-width: 720px) {
|
||||
.summary__grid { grid-template-columns: repeat(2, 1fr); }
|
||||
}
|
||||
|
||||
/* ---------- Generic content (routes/stops detail pages) ---------- */
|
||||
.page { max-width: 1200px; margin: 0 auto; padding: 28px 28px 60px; }
|
||||
.section-title { margin: 28px 0 14px; font-size: 1.25rem; color: var(--ink); font-weight: 800; }
|
||||
.muted { color: var(--muted); }
|
||||
|
||||
.panel {
|
||||
background: #fff; border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm); padding: 22px 24px;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.crumbs { color: var(--muted); font-size: .85rem; margin: 8px 0 12px; }
|
||||
.crumbs a { color: var(--purple-700); font-weight: 600; }
|
||||
.crumbs a:hover { text-decoration: underline; }
|
||||
|
||||
.pill {
|
||||
display: inline-block; padding: 5px 12px; border-radius: 999px;
|
||||
background: var(--purple-50); color: var(--purple-700);
|
||||
font-size: .78rem; font-weight: 700;
|
||||
}
|
||||
.pill--alt { background: var(--pink-50); color: var(--pink-700); }
|
||||
|
||||
.table {
|
||||
width: 100%; border-collapse: separate; border-spacing: 0;
|
||||
margin-top: 14px;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #fbfbff 100%);
|
||||
border-radius: var(--radius); overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
.table th, .table td { padding: 14px 18px; text-align: left; font-size: .92rem; }
|
||||
.table th {
|
||||
background: linear-gradient(180deg, #f3eefe 0%, #fde7f0 100%);
|
||||
color: var(--ink); font-weight: 800;
|
||||
font-size: .76rem; text-transform: uppercase; letter-spacing: .06em;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.table tr + tr td { border-top: 1px solid var(--line); }
|
||||
.table tbody tr:hover td { background: #faf8ff; }
|
||||
|
||||
.map-wrap {
|
||||
height: 360px; border-radius: var(--radius); overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
|
||||
/* ---------- Stop detail (map + gallery) ---------- */
|
||||
.stop-detail__split {
|
||||
display: grid;
|
||||
grid-template-columns: 1.1fr 1fr;
|
||||
gap: 18px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.stop-detail__split { grid-template-columns: 1fr; }
|
||||
}
|
||||
.stop-detail__gallery {
|
||||
display: flex; flex-direction: column; gap: 10px;
|
||||
background: #fff; border-radius: var(--radius);
|
||||
border: 1px solid var(--line); box-shadow: var(--shadow-sm);
|
||||
overflow: hidden;
|
||||
}
|
||||
.stop-detail__gallery--empty,
|
||||
.stop-detail__map--empty {
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
min-height: 320px; background: #f4f6fc; color: var(--muted);
|
||||
}
|
||||
.stop-detail__hero-img {
|
||||
width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block;
|
||||
}
|
||||
.stop-detail__thumbs {
|
||||
display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
|
||||
padding: 0 10px 10px;
|
||||
}
|
||||
.stop-detail__thumbs img {
|
||||
width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
|
||||
border-radius: 10px; border: 1px solid var(--line);
|
||||
}
|
||||
.stop-detail__map {
|
||||
height: 100%; min-height: 360px;
|
||||
border-radius: var(--radius); overflow: hidden;
|
||||
border: 1px solid var(--line); box-shadow: var(--shadow-sm);
|
||||
background: #e5edf7;
|
||||
}
|
||||
.stop-detail__placeholder {
|
||||
font-size: .95rem; font-weight: 600;
|
||||
}
|
||||
|
||||
/* ---------- Schedule card list (soft gradient, modern) ---------- */
|
||||
.schedule-list {
|
||||
display: grid; gap: 14px; margin-top: 14px;
|
||||
}
|
||||
.schedule-card {
|
||||
position: relative;
|
||||
display: grid; grid-template-columns: minmax(220px, 320px) 1fr;
|
||||
gap: 18px; align-items: center;
|
||||
padding: 18px 20px 18px 26px;
|
||||
background: linear-gradient(135deg, #ffffff 0%, #fbfaff 60%, #fff5fb 100%);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
overflow: hidden;
|
||||
transition: transform .15s ease, box-shadow .15s ease;
|
||||
}
|
||||
.schedule-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
|
||||
.schedule-card__rail {
|
||||
position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
|
||||
background: var(--grad-cta);
|
||||
}
|
||||
.schedule-card--sky .schedule-card__rail { background: var(--grad-sky); }
|
||||
.schedule-card--purple .schedule-card__rail { background: var(--grad-purple); }
|
||||
.schedule-card--pink .schedule-card__rail { background: var(--grad-pink); }
|
||||
.schedule-card--mint .schedule-card__rail { background: var(--grad-mint); }
|
||||
.schedule-card--amber .schedule-card__rail { background: var(--grad-amber); }
|
||||
.schedule-card--sky { background: linear-gradient(135deg, #ffffff 0%, #f0f6ff 100%); }
|
||||
.schedule-card--purple { background: linear-gradient(135deg, #ffffff 0%, #f6f1ff 100%); }
|
||||
.schedule-card--pink { background: linear-gradient(135deg, #ffffff 0%, #fff0f7 100%); }
|
||||
.schedule-card--mint { background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%); }
|
||||
.schedule-card--amber { background: linear-gradient(135deg, #ffffff 0%, #fff7e8 100%); }
|
||||
|
||||
.schedule-card__head {
|
||||
display: flex; flex-direction: column; gap: 10px;
|
||||
}
|
||||
.schedule-card__route {
|
||||
display: inline-flex; flex-direction: column; align-items: flex-start;
|
||||
padding: 10px 16px; border-radius: 14px;
|
||||
color: #fff; min-width: 140px;
|
||||
box-shadow: 0 8px 18px rgba(15, 23, 42, .15);
|
||||
background: var(--grad-cta);
|
||||
}
|
||||
.schedule-card__route.sky { background: var(--grad-sky); }
|
||||
.schedule-card__route.purple { background: var(--grad-purple); }
|
||||
.schedule-card__route.pink { background: var(--grad-pink); }
|
||||
.schedule-card__route.mint { background: var(--grad-mint); }
|
||||
.schedule-card__route.amber { background: var(--grad-amber); }
|
||||
.schedule-card__route-label {
|
||||
font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
|
||||
opacity: .85; font-weight: 700;
|
||||
}
|
||||
.schedule-card__route-id {
|
||||
font-size: 1.5rem; font-weight: 900; letter-spacing: .02em; line-height: 1.1;
|
||||
}
|
||||
.schedule-card__meta {
|
||||
display: flex; flex-direction: column; gap: 4px;
|
||||
}
|
||||
.schedule-card__direction {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
font-weight: 700; color: var(--ink); font-size: .92rem;
|
||||
}
|
||||
.schedule-card__note {
|
||||
font-size: .82rem; color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.schedule-card__times {
|
||||
display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
|
||||
}
|
||||
.schedule-card__time {
|
||||
display: inline-flex; align-items: center; gap: 5px;
|
||||
padding: 7px 12px; border-radius: 999px;
|
||||
font-size: .88rem; font-weight: 700; letter-spacing: .02em;
|
||||
color: var(--ink);
|
||||
background: linear-gradient(135deg, #ffffff 0%, #f3eefe 100%);
|
||||
border: 1px solid #e3d9fb;
|
||||
box-shadow: 0 2px 6px rgba(124, 58, 237, .08);
|
||||
}
|
||||
.schedule-card__time:hover {
|
||||
background: var(--grad-cta); color: #fff; border-color: transparent;
|
||||
}
|
||||
.schedule-card__empty {
|
||||
font-size: .85rem; color: var(--muted); font-style: italic;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.schedule-card { grid-template-columns: 1fr; gap: 12px; padding: 16px 16px 16px 22px; }
|
||||
.schedule-card__route { width: 100%; }
|
||||
}
|
||||
|
||||
/* Detail-page hero (inside .page wrapper) */
|
||||
.page > .hero {
|
||||
border-radius: var(--radius-lg);
|
||||
margin-bottom: 22px;
|
||||
padding: 30px 28px;
|
||||
text-align: left;
|
||||
background: linear-gradient(135deg, #ede9fe 0%, #fce7f3 100%);
|
||||
}
|
||||
.page > .hero h1 {
|
||||
font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 6px 0 10px;
|
||||
}
|
||||
|
||||
/* ---------- Footer (rich dark) ---------- */
|
||||
.footer {
|
||||
margin-top: 48px;
|
||||
background:
|
||||
radial-gradient(circle at 0% 0%, rgba(122, 76, 192, .35), transparent 35%),
|
||||
radial-gradient(circle at 100% 10%, rgba(48, 113, 184, .35), transparent 35%),
|
||||
linear-gradient(180deg, #1a1830 0%, #0f1126 100%);
|
||||
color: #cfd5ec;
|
||||
padding: 48px 0 0;
|
||||
}
|
||||
.footer .container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
|
||||
.footer__grid {
|
||||
display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.1fr; gap: 28px;
|
||||
}
|
||||
.footer__brand { display: flex; flex-direction: column; gap: 12px; }
|
||||
.footer__brand-row { display: flex; align-items: center; gap: 12px; }
|
||||
.footer__brand-row img {
|
||||
width: 48px; height: 48px; border-radius: 12px;
|
||||
background: #fff; padding: 4px; object-fit: contain;
|
||||
}
|
||||
.footer__brand-row strong {
|
||||
display: block; color: #fff; font-size: 1.05rem;
|
||||
font-weight: 800; letter-spacing: .01em;
|
||||
}
|
||||
.footer__brand-row span { display: block; color: #9aa3c3; font-size: .82rem; margin-top: 2px; }
|
||||
.footer__brand p { margin: 0; color: #b6bdda; font-size: .88rem; line-height: 1.6; }
|
||||
|
||||
.footer__col h4 {
|
||||
margin: 0 0 14px; color: #fff; font-size: .9rem;
|
||||
font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
|
||||
}
|
||||
.footer__col ul {
|
||||
list-style: none; padding: 0; margin: 0;
|
||||
display: flex; flex-direction: column; gap: 8px;
|
||||
}
|
||||
.footer__col ul a {
|
||||
color: #cfd5ec; font-size: .9rem; transition: color .15s;
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
}
|
||||
.footer__col ul a::before { content: "›"; color: #a855f7; font-weight: 800; }
|
||||
.footer__col ul a:hover { color: #fff; }
|
||||
.footer__contact .row { margin-bottom: 8px; }
|
||||
.footer__contact a, .footer__contact span {
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
color: #cfd5ec; font-size: .88rem;
|
||||
}
|
||||
|
||||
.footer__sponsors {
|
||||
margin-top: 36px; padding-top: 28px;
|
||||
border-top: 1px solid rgba(255, 255, 255, .08);
|
||||
}
|
||||
.footer__sponsors h4 { margin: 0 0 6px; color: #fff; font-size: .95rem; font-weight: 800; }
|
||||
.footer__sponsors .lead { margin: 0 0 18px; color: #9aa3c3; font-size: .85rem; }
|
||||
.sponsor-strip {
|
||||
display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px;
|
||||
}
|
||||
.sponsor-tile {
|
||||
background: #fff; border-radius: 12px; padding: 10px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
aspect-ratio: 5 / 3; overflow: hidden;
|
||||
transition: transform .15s, box-shadow .15s;
|
||||
}
|
||||
.sponsor-tile img {
|
||||
width: 100%; height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
.sponsor-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(0, 0, 0, .35); }
|
||||
|
||||
.footer__bottom {
|
||||
margin-top: 36px; padding: 18px 0 22px;
|
||||
border-top: 1px solid rgba(255, 255, 255, .08);
|
||||
text-align: center;
|
||||
}
|
||||
.footer__bottom p { margin: 0; color: #8d96b8; font-size: .82rem; letter-spacing: .02em; }
|
||||
.footer__bottom .pill {
|
||||
display: inline-block; margin-left: 10px; padding: 2px 10px;
|
||||
border-radius: 999px; background: rgba(122, 76, 192, .25);
|
||||
color: #d8c7ff; font-size: .72rem; font-weight: 700;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) { .footer__grid { grid-template-columns: 1fr 1fr; } }
|
||||
@media (max-width: 640px) {
|
||||
.footer__grid { grid-template-columns: 1fr; }
|
||||
.footer { padding: 36px 0 0; }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
Modern soft-gradient list pages (/stops, /routes)
|
||||
============================================================ */
|
||||
.page-hero {
|
||||
position: relative; overflow: hidden;
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 44px 36px 38px;
|
||||
margin-bottom: 22px;
|
||||
background:
|
||||
radial-gradient(120% 140% at 0% 0%, #ede9fe 0%, transparent 55%),
|
||||
radial-gradient(120% 140% at 100% 0%, #fce7f3 0%, transparent 55%),
|
||||
radial-gradient(120% 140% at 50% 120%, #fef3c7 0%, transparent 55%),
|
||||
linear-gradient(135deg, #ffffff 0%, #fbfaff 100%);
|
||||
border: 1px solid rgba(168, 85, 247, .12);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
.page-hero--alt {
|
||||
background:
|
||||
radial-gradient(120% 140% at 0% 0%, #dbeafe 0%, transparent 55%),
|
||||
radial-gradient(120% 140% at 100% 0%, #ede9fe 0%, transparent 55%),
|
||||
radial-gradient(120% 140% at 50% 120%, #d1fae5 0%, transparent 55%),
|
||||
linear-gradient(135deg, #ffffff 0%, #f7faff 100%);
|
||||
border-color: rgba(59, 130, 246, .14);
|
||||
}
|
||||
.page-hero__blob {
|
||||
position: absolute; border-radius: 50%; filter: blur(46px); opacity: .55;
|
||||
pointer-events: none;
|
||||
}
|
||||
.page-hero__blob--a { width: 220px; height: 220px; background: #c4b5fd; top: -50px; left: -40px; }
|
||||
.page-hero__blob--b { width: 260px; height: 260px; background: #f9a8d4; top: 30%; right: -60px; }
|
||||
.page-hero__blob--c { width: 180px; height: 180px; background: #fde68a; bottom: -50px; left: 40%; }
|
||||
.page-hero--alt .page-hero__blob--a { background: #93c5fd; }
|
||||
.page-hero--alt .page-hero__blob--b { background: #c4b5fd; }
|
||||
.page-hero--alt .page-hero__blob--c { background: #6ee7b7; }
|
||||
.page-hero__inner { position: relative; z-index: 1; }
|
||||
.page-hero__badge {
|
||||
display: inline-block; padding: 6px 14px; border-radius: 999px;
|
||||
background: rgba(255, 255, 255, .7); backdrop-filter: blur(6px);
|
||||
border: 1px solid rgba(168, 85, 247, .25);
|
||||
color: var(--purple-700); font-size: .72rem; font-weight: 800;
|
||||
letter-spacing: .08em;
|
||||
}
|
||||
.page-hero__title {
|
||||
margin: 14px 0 8px; font-size: 2.4rem; font-weight: 900;
|
||||
color: var(--ink); letter-spacing: -.01em; line-height: 1.15;
|
||||
}
|
||||
.page-hero__title-grad {
|
||||
background: var(--grad-cta); -webkit-background-clip: text;
|
||||
background-clip: text; color: transparent;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.page-hero--alt .page-hero__title-grad { background: var(--grad-sky); -webkit-background-clip: text; background-clip: text; }
|
||||
.page-hero__subtitle { margin: 0 0 16px; color: var(--ink-muted); font-size: 1rem; }
|
||||
.page-hero__stats { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
.page-hero__stat {
|
||||
display: inline-flex; align-items: baseline; gap: 6px;
|
||||
padding: 8px 16px; border-radius: 999px;
|
||||
background: rgba(255, 255, 255, .8); backdrop-filter: blur(8px);
|
||||
border: 1px solid rgba(15, 23, 42, .06);
|
||||
font-size: .85rem; color: var(--ink-muted); font-weight: 600;
|
||||
box-shadow: 0 4px 12px rgba(124, 58, 237, .08);
|
||||
}
|
||||
.page-hero__stat b {
|
||||
background: var(--grad-cta); -webkit-background-clip: text;
|
||||
background-clip: text; color: transparent;
|
||||
font-size: 1.05rem; font-weight: 900;
|
||||
}
|
||||
|
||||
.map-wrap--soft { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 18px; }
|
||||
|
||||
/* Toolbar (search + filter chips) */
|
||||
.toolbar {
|
||||
display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
|
||||
padding: 14px 16px; margin: 18px 0;
|
||||
background: linear-gradient(135deg, #ffffff 0%, #fbfaff 100%);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
.toolbar__search {
|
||||
flex: 1 1 280px;
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
padding: 8px 14px; border-radius: 12px;
|
||||
background: #f4f6fc; border: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
}
|
||||
.toolbar__search input {
|
||||
flex: 1; border: 0; outline: 0; background: transparent;
|
||||
font: inherit; color: var(--ink);
|
||||
}
|
||||
.toolbar__chips { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
|
||||
.chip-soft {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
padding: 6px 12px; border-radius: 999px;
|
||||
font-size: .78rem; font-weight: 700; letter-spacing: .01em;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.chip-soft--sky { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); color: var(--sky-700); border-color: #cfe0fb; }
|
||||
.chip-soft--purple { background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); color: var(--purple-700); border-color: #ddd3fb; }
|
||||
.chip-soft--pink { background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%); color: var(--pink-700); border-color: #f9cce3; }
|
||||
.chip-soft--mint { background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%); color: var(--mint-700); border-color: #b6ecd0; }
|
||||
.chip-soft--amber { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); color: var(--amber-700); border-color: #fde9a8; }
|
||||
|
||||
/* Tile grid + tile component */
|
||||
.tile-grid {
|
||||
display: grid; gap: 16px; margin-top: 4px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
}
|
||||
.tile {
|
||||
position: relative;
|
||||
display: grid; grid-template-columns: 76px 1fr auto;
|
||||
gap: 14px; align-items: center;
|
||||
padding: 16px 18px; border-radius: var(--radius-lg);
|
||||
border: 1px solid var(--line);
|
||||
background: linear-gradient(135deg, #ffffff 0%, #fbfaff 100%);
|
||||
box-shadow: var(--shadow-sm);
|
||||
color: inherit; overflow: hidden;
|
||||
transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
|
||||
}
|
||||
.tile::before {
|
||||
content: ""; position: absolute; inset: 0;
|
||||
background: var(--grad-cta); opacity: 0;
|
||||
transition: opacity .2s ease;
|
||||
border-radius: inherit; pointer-events: none;
|
||||
mix-blend-mode: multiply;
|
||||
}
|
||||
.tile:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: var(--shadow-md);
|
||||
border-color: rgba(168, 85, 247, .28);
|
||||
}
|
||||
.tile--sky { background: linear-gradient(135deg, #ffffff 0%, #f0f6ff 100%); }
|
||||
.tile--purple { background: linear-gradient(135deg, #ffffff 0%, #f6f1ff 100%); }
|
||||
.tile--pink { background: linear-gradient(135deg, #ffffff 0%, #fff0f7 100%); }
|
||||
.tile--mint { background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%); }
|
||||
.tile--amber { background: linear-gradient(135deg, #ffffff 0%, #fff7e8 100%); }
|
||||
|
||||
.tile__badge {
|
||||
width: 64px; height: 64px; border-radius: 18px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
color: #fff; font-size: 30px; font-weight: 900;
|
||||
box-shadow: 0 10px 22px rgba(15, 23, 42, .18);
|
||||
background: var(--grad-cta);
|
||||
}
|
||||
.tile__badge--num { font-size: 18px; letter-spacing: .02em; padding: 0 6px; text-align: center; }
|
||||
.tile__badge--sky { background: var(--grad-sky); }
|
||||
.tile__badge--purple { background: var(--grad-purple); }
|
||||
.tile__badge--pink { background: var(--grad-pink); }
|
||||
.tile__badge--mint { background: var(--grad-mint); }
|
||||
.tile__badge--amber { background: var(--grad-amber); }
|
||||
|
||||
.tile__body { min-width: 0; }
|
||||
.tile__title {
|
||||
margin: 0 0 4px; font-size: 1rem; font-weight: 800; color: var(--ink);
|
||||
line-height: 1.3;
|
||||
overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
|
||||
-webkit-line-clamp: 2; -webkit-box-orient: vertical;
|
||||
}
|
||||
.tile__meta {
|
||||
margin: 0 0 8px; font-size: .82rem; color: var(--ink-muted);
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.tile__chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.tile__arrow {
|
||||
font-size: 1.4rem; color: var(--muted); font-weight: 700;
|
||||
transition: transform .18s ease, color .18s ease;
|
||||
}
|
||||
.tile:hover .tile__arrow { color: var(--purple-700); transform: translateX(4px); }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.page-hero { padding: 32px 22px 28px; }
|
||||
.page-hero__title { font-size: 1.8rem; }
|
||||
.tile { grid-template-columns: 56px 1fr; padding: 14px; }
|
||||
.tile__badge { width: 52px; height: 52px; font-size: 24px; border-radius: 14px; }
|
||||
.tile__arrow { display: none; }
|
||||
}
|
||||
|
||||
/* ============ Route detail hero ============ */
|
||||
.route-hero { padding-top: 38px; }
|
||||
.route-hero__top {
|
||||
display: grid;
|
||||
grid-template-columns: 96px 1fr;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
position: relative; z-index: 1;
|
||||
}
|
||||
.route-hero__badge {
|
||||
width: 96px; height: 96px;
|
||||
border-radius: 26px;
|
||||
background: linear-gradient(135deg,#7c3aed,#ec4899 55%,#f59e0b);
|
||||
color: #fff;
|
||||
font-weight: 900; font-size: 1.9rem;
|
||||
letter-spacing: .5px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
box-shadow: 0 18px 38px rgba(124,58,237,.35), inset 0 1px 0 rgba(255,255,255,.4);
|
||||
border: 3px solid rgba(255,255,255,.7);
|
||||
}
|
||||
.route-hero__title-wrap { min-width: 0; }
|
||||
.route-hero__chips {
|
||||
display: flex; flex-wrap: wrap; gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.route-hero__actions {
|
||||
margin-top: 18px;
|
||||
display: flex; flex-wrap: wrap; gap: 12px;
|
||||
position: relative; z-index: 1;
|
||||
}
|
||||
.route-hero__cta {
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
padding: 12px 22px;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(135deg,#7c3aed,#ec4899);
|
||||
color: #fff !important; font-weight: 800; font-size: .95rem;
|
||||
text-decoration: none;
|
||||
box-shadow: 0 12px 28px rgba(124,58,237,.32);
|
||||
transition: transform .18s ease, box-shadow .18s ease;
|
||||
}
|
||||
.route-hero__cta:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(124,58,237,.42); }
|
||||
.route-hero__back {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
padding: 12px 18px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255,255,255,.72);
|
||||
border: 1px solid rgba(124,58,237,.18);
|
||||
color: var(--purple-700) !important; font-weight: 700; font-size: .9rem;
|
||||
text-decoration: none;
|
||||
backdrop-filter: blur(6px);
|
||||
transition: background .18s ease;
|
||||
}
|
||||
.route-hero__back:hover { background: #fff; }
|
||||
|
||||
/* ============ Route map section ============ */
|
||||
.route-map-section { margin-top: 28px; }
|
||||
.route-map-section__head {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
gap: 14px; flex-wrap: wrap;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.route-map-section__head .section-title { margin: 0; }
|
||||
.route-map-section__legend {
|
||||
display: inline-flex; flex-wrap: wrap; gap: 14px;
|
||||
font-size: .85rem; color: var(--ink-muted); font-weight: 600;
|
||||
}
|
||||
.route-map-section__legend span { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.dot {
|
||||
width: 12px; height: 12px; border-radius: 50%;
|
||||
display: inline-block;
|
||||
border: 2px solid #fff;
|
||||
box-shadow: 0 0 0 1px rgba(0,0,0,.08);
|
||||
}
|
||||
.dot--start { background: linear-gradient(135deg,#34d399,#10b981); }
|
||||
.dot--mid { background: linear-gradient(135deg,#a78bfa,#7c3aed); }
|
||||
.dot--end { background: linear-gradient(135deg,#fb7185,#e11d48); }
|
||||
.route-map {
|
||||
height: 460px;
|
||||
border: 1px solid rgba(124,58,237,.12);
|
||||
}
|
||||
.route-map-empty {
|
||||
padding: 28px;
|
||||
text-align: center;
|
||||
border-radius: 20px;
|
||||
background: linear-gradient(135deg,#fdf4ff,#eef2ff);
|
||||
border: 1px dashed rgba(124,58,237,.25);
|
||||
}
|
||||
|
||||
/* ============ Stops timeline ============ */
|
||||
.stop-timeline {
|
||||
list-style: none;
|
||||
padding: 0; margin: 14px 0 0;
|
||||
display: flex; flex-direction: column; gap: 10px;
|
||||
position: relative;
|
||||
}
|
||||
.stop-node {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: 56px 1fr auto;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 14px 16px;
|
||||
border-radius: 18px;
|
||||
background: linear-gradient(135deg,#ffffff 0%,#fbfaff 100%);
|
||||
border: 1px solid rgba(124,58,237,.10);
|
||||
box-shadow: 0 6px 16px rgba(31,28,68,.05);
|
||||
transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
|
||||
}
|
||||
.stop-node:hover {
|
||||
transform: translateY(-1px);
|
||||
border-color: rgba(124,58,237,.25);
|
||||
box-shadow: 0 10px 24px rgba(124,58,237,.12);
|
||||
}
|
||||
.stop-node__line {
|
||||
position: absolute;
|
||||
left: 43px; top: 100%;
|
||||
width: 2px; height: 10px;
|
||||
background: linear-gradient(180deg, rgba(124,58,237,.35), rgba(124,58,237,0));
|
||||
}
|
||||
.stop-node:last-child .stop-node__line { display: none; }
|
||||
.stop-node__bullet {
|
||||
width: 44px; height: 44px;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(135deg,#a78bfa,#7c3aed);
|
||||
color: #fff;
|
||||
font-weight: 800; font-size: 1.05rem;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
border: 3px solid #fff;
|
||||
box-shadow: 0 6px 14px rgba(124,58,237,.30);
|
||||
}
|
||||
.stop-node__bullet.is-start { background: linear-gradient(135deg,#34d399,#10b981); box-shadow: 0 6px 14px rgba(16,185,129,.30); }
|
||||
.stop-node__bullet.is-end { background: linear-gradient(135deg,#fb7185,#e11d48); box-shadow: 0 6px 14px rgba(225,29,72,.28); }
|
||||
.stop-node--sky .stop-node__bullet:not(.is-start):not(.is-end) { background: linear-gradient(135deg,#7dd3fc,#0284c7); }
|
||||
.stop-node--pink .stop-node__bullet:not(.is-start):not(.is-end) { background: linear-gradient(135deg,#fda4af,#db2777); }
|
||||
.stop-node--mint .stop-node__bullet:not(.is-start):not(.is-end) { background: linear-gradient(135deg,#6ee7b7,#059669); }
|
||||
.stop-node--amber .stop-node__bullet:not(.is-start):not(.is-end) { background: linear-gradient(135deg,#fcd34d,#d97706); }
|
||||
.stop-node__body { min-width: 0; }
|
||||
.stop-node__head {
|
||||
display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.stop-node__title {
|
||||
font-weight: 800; font-size: 1.02rem;
|
||||
color: var(--ink, #1f1c44);
|
||||
text-decoration: none;
|
||||
}
|
||||
.stop-node__title:hover { color: var(--purple-700); }
|
||||
.stop-node__meta {
|
||||
display: flex; flex-wrap: wrap; gap: 8px;
|
||||
align-items: center;
|
||||
font-size: .85rem; color: var(--ink-muted);
|
||||
}
|
||||
.stop-node__loc { font-size: .82rem; }
|
||||
.stop-node__warn {
|
||||
font-size: .75rem; font-weight: 700;
|
||||
padding: 2px 8px; border-radius: 999px;
|
||||
background: #fff7ed; color: #c2410c;
|
||||
border: 1px solid #fed7aa;
|
||||
}
|
||||
.stop-node__arrow {
|
||||
font-size: 1.4rem; color: var(--muted);
|
||||
font-weight: 700; text-decoration: none;
|
||||
transition: transform .18s ease, color .18s ease;
|
||||
}
|
||||
.stop-node:hover .stop-node__arrow { color: var(--purple-700); transform: translateX(4px); }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.route-hero__top { grid-template-columns: 76px 1fr; gap: 14px; }
|
||||
.route-hero__badge { width: 76px; height: 76px; font-size: 1.5rem; border-radius: 22px; }
|
||||
.route-map { height: 360px; }
|
||||
.stop-node { grid-template-columns: 48px 1fr; padding: 12px 14px; }
|
||||
.stop-node__bullet { width: 40px; height: 40px; font-size: .95rem; border-radius: 12px; }
|
||||
.stop-node__line { left: 37px; }
|
||||
.stop-node__arrow { display: none; }
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#8b5cf6"/>
|
||||
<stop offset="100%" stop-color="#ec4899"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="64" height="64" rx="16" fill="url(#bg)"/>
|
||||
<g fill="#fff" transform="translate(8 14)">
|
||||
<rect x="2" y="6" width="44" height="22" rx="6" fill="#fff"/>
|
||||
<rect x="6" y="10" width="14" height="10" rx="2" fill="#8b5cf6"/>
|
||||
<rect x="22" y="10" width="14" height="10" rx="2" fill="#8b5cf6"/>
|
||||
<circle cx="12" cy="32" r="5" fill="#1f2a44"/>
|
||||
<circle cx="36" cy="32" r="5" fill="#1f2a44"/>
|
||||
<circle cx="12" cy="32" r="2" fill="#fff"/>
|
||||
<circle cx="36" cy="32" r="2" fill="#fff"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 808 B |
+34
-10
@@ -1,27 +1,51 @@
|
||||
import "./globals.css";
|
||||
import type { Metadata } from "next";
|
||||
import { Header } from "@/components/Header";
|
||||
import { Footer } from "@/components/Footer";
|
||||
import IconSprite from "@/components/IconSprite";
|
||||
import SiteBoot from "@/components/SiteBoot";
|
||||
import SiteFooter from "@/components/SiteFooter";
|
||||
import SiteHeader from "@/components/SiteHeader";
|
||||
|
||||
// ลำดับ CSS ต้องตรงกับ mock: shared → map → shell → page → responsive
|
||||
import "@/styles/_shared.css";
|
||||
import "@/styles/map.css";
|
||||
import "@/styles/shell.css";
|
||||
import "@/styles/responsive.css";
|
||||
// CSS ของ partial ต้องมาหลัง responsive.css — ตรงกับลำดับใน mock
|
||||
// (router เดิม inject <style> ของ partial หลัง <link responsive.css>)
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "AT Transit — สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง",
|
||||
title: {
|
||||
default: "Atroute — สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง",
|
||||
template: "Atroute — %s",
|
||||
},
|
||||
description:
|
||||
"ค้นหาเส้นทาง ตารางเดินรถ และจุดจอดในจังหวัดอ่างทองและจังหวัดใกล้เคียง",
|
||||
"ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง",
|
||||
manifest: "/ui-manifest.json",
|
||||
icons: { icon: "/image/icons/minibus-512x512.png" },
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang="th">
|
||||
<head>
|
||||
{/* ฟอนต์ K2D ฝังในโปรเจกต์ + Leaflet CSS (ไฟล์ static ใน public) */}
|
||||
<link rel="stylesheet" href="/vendor/fonts/k2d.css" />
|
||||
<link rel="stylesheet" href="/vendor/leaflet/leaflet.css" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&family=Prompt:wght@400;500;600;700&display=swap"
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&family=Prompt:wght@400;500;600;700&display=swap"
|
||||
/>
|
||||
<meta name="theme-color" content="#7a4cc0" />
|
||||
<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" />
|
||||
<script src="/vendor/leaflet/leaflet.js" defer />
|
||||
</head>
|
||||
<body>
|
||||
<Header />
|
||||
{children}
|
||||
<Footer />
|
||||
<body className="main-theme-page">
|
||||
<IconSprite />
|
||||
<SiteHeader />
|
||||
<div id="view">{children}</div>
|
||||
<SiteFooter />
|
||||
<SiteBoot />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
+16
-119
@@ -1,127 +1,24 @@
|
||||
import Link from "next/link";
|
||||
import { api, type RouteListItem } from "@/lib/api";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import HomeView from "@/components/views/HomeView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
// Map route_group_code to visual tone
|
||||
const ZONE_TONES: Record<string, "sky" | "purple" | "pink" | "mint"> = {
|
||||
bangkok: "sky",
|
||||
interprovincial: "purple",
|
||||
in_province: "pink",
|
||||
municipal: "mint",
|
||||
};
|
||||
export const metadata = { title: "หน้าแรก" };
|
||||
|
||||
const ZONE_DESCS: Record<string, string> = {
|
||||
bangkok: "เส้นทางเชื่อมต่อกรุงเทพมหานคร",
|
||||
interprovincial: "เส้นทางเชื่อมต่อจังหวัดใกล้เคียง",
|
||||
in_province: "เส้นทางภายในจังหวัดอ่างทอง",
|
||||
municipal: "เส้นทางภายในเขตเทศบาล",
|
||||
};
|
||||
|
||||
// Display order: bangkok → interprovincial → in_province → municipal
|
||||
const ZONE_ORDER = ["bangkok", "interprovincial", "in_province", "municipal"];
|
||||
|
||||
// Cycle chip colors within a zone for visual rhythm
|
||||
const CHIP_CYCLE = ["purple", "sky", "pink", "mint"] as const;
|
||||
|
||||
export default async function HomePage() {
|
||||
const [groupsRes, routesRes] = await Promise.allSettled([
|
||||
api.routeGroups(),
|
||||
api.routes(),
|
||||
]);
|
||||
|
||||
const groups = groupsRes.status === "fulfilled" ? groupsRes.value.items : [];
|
||||
const routes = routesRes.status === "fulfilled" ? routesRes.value.items : [];
|
||||
|
||||
// Group routes by code
|
||||
const byCode = new Map<string, RouteListItem[]>();
|
||||
for (const r of routes) {
|
||||
const list = byCode.get(r.route_group_code) ?? [];
|
||||
list.push(r);
|
||||
byCode.set(r.route_group_code, list);
|
||||
export default async function Page({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
||||
}) {
|
||||
const sp = await searchParams;
|
||||
const query: Record<string, string> = {};
|
||||
// ลิงก์สั้นเดิม: #/?s=<รหัสสถานี> และ #/?p=<province_id>
|
||||
for (const key of ["s", "p"]) {
|
||||
const value = sp[key];
|
||||
if (typeof value === "string") query[key] = value;
|
||||
}
|
||||
|
||||
const orderedGroups = [...groups].sort((a, b) => {
|
||||
const ai = ZONE_ORDER.indexOf(a.code);
|
||||
const bi = ZONE_ORDER.indexOf(b.code);
|
||||
return (ai === -1 ? 99 : ai) - (bi === -1 ? 99 : bi);
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<VisitTracker path="/" />
|
||||
|
||||
<section className="hero">
|
||||
<div className="hero__blob one" aria-hidden />
|
||||
<div className="hero__blob two" aria-hidden />
|
||||
<div className="hero__blob three" aria-hidden />
|
||||
<div className="container hero__inner">
|
||||
<span className="hero__badge">✨ ยินดีต้อนรับ</span>
|
||||
<h1>
|
||||
สถานีขนส่งผู้โดยสารภายใน
|
||||
<br />
|
||||
<span className="hero__grad">จังหวัดอ่างทอง</span>
|
||||
</h1>
|
||||
<p className="hero__lead">
|
||||
ดูสายรถ, ค้นหาป้าย และเปิดตัวอย่างเส้นทางได้ทันทีจากหน้าแรก
|
||||
</p>
|
||||
<div className="hero__actions">
|
||||
<Link className="pill-link pill-link--primary" href="/routes">
|
||||
ดูรายละเอียดสายรถ
|
||||
</Link>
|
||||
<Link className="pill-link pill-link--secondary" href="/stops">
|
||||
ค้นหาป้ายหยุดรถ
|
||||
</Link>
|
||||
{routes[0] && (
|
||||
<Link
|
||||
className="pill-link pill-link--accent"
|
||||
href={`/routes/${encodeURIComponent(routes[0].route_id)}`}
|
||||
>
|
||||
ดูตัวอย่างสายรถ
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<main className="main">
|
||||
<div className="container">
|
||||
{orderedGroups.map((g) => {
|
||||
const items = byCode.get(g.code) ?? [];
|
||||
if (items.length === 0) return null;
|
||||
const tone = ZONE_TONES[g.code] ?? "purple";
|
||||
return (
|
||||
<section key={g.id} className="zone">
|
||||
<div className="zone__head">
|
||||
<span className={`zone__tag ${tone}`}>{g.label_th}</span>
|
||||
<p className="zone__desc">
|
||||
{ZONE_DESCS[g.code] ?? ""} · {items.length} เส้นทาง
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid">
|
||||
{items.map((r, i) => (
|
||||
<Link
|
||||
key={r.route_id}
|
||||
href={`/routes/${encodeURIComponent(r.route_id)}`}
|
||||
className="card"
|
||||
>
|
||||
<div className={`card__head ${tone}`}>
|
||||
<p className="card__num">{r.route_id}</p>
|
||||
</div>
|
||||
<div className="card__body">
|
||||
<p className="card__name">{r.name_th}</p>
|
||||
<span className={`chip ${CHIP_CYCLE[i % CHIP_CYCLE.length]}`}>
|
||||
✅ ดูตาราง
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<HomeView />
|
||||
<PageRuntime page="home" query={query} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
type ExpandedRoutePageProps = {
|
||||
params: Promise<{ routeId: string }>;
|
||||
};
|
||||
|
||||
export default async function ExpandedRoutePage({ params }: ExpandedRoutePageProps) {
|
||||
const { routeId } = await params;
|
||||
redirect(`/routes/${encodeURIComponent(routeId)}`);
|
||||
return null;
|
||||
}
|
||||
@@ -1,268 +1,14 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { api, isApiNotFoundError, resolveFileUrl, type RouteDetail, type RouteStop, type StopListItem, type Schedule } from "@/lib/api";
|
||||
import LazyMapView from "@/components/LazyMapView";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import RouteView from "@/components/views/RouteView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
export const metadata = { title: "รายละเอียดสายรถ" };
|
||||
|
||||
type RouteDetailPageProps = {
|
||||
params: Promise<{ routeId: string }>;
|
||||
};
|
||||
|
||||
export default async function RouteDetailPage({
|
||||
params,
|
||||
}: RouteDetailPageProps) {
|
||||
export default async function Page({ params }: { params: Promise<{ routeId: string }> }) {
|
||||
const { routeId } = await params;
|
||||
|
||||
let route: RouteDetail | null = null;
|
||||
let stops: RouteStop[] = [];
|
||||
let schedules: Schedule[] = [];
|
||||
let allStops: StopListItem[] = [];
|
||||
|
||||
try {
|
||||
[route, { items: stops }, { items: schedules }, { items: allStops }] = await Promise.all([
|
||||
api.route(routeId),
|
||||
api.routeStops(routeId),
|
||||
api.schedules({ route_id: routeId }),
|
||||
api.stops(),
|
||||
]);
|
||||
} catch (error) {
|
||||
if (isApiNotFoundError(error)) {
|
||||
notFound();
|
||||
}
|
||||
route = null;
|
||||
stops = [];
|
||||
schedules = [];
|
||||
allStops = [];
|
||||
}
|
||||
|
||||
if (!route) {
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/routes/${routeId}`} />
|
||||
<section className="hero">
|
||||
<h1>ไม่สามารถโหลดข้อมูลเส้นทางได้</h1>
|
||||
<p className="muted">ระบบยังเปิดอยู่ แต่ backend ตอบกลับไม่ได้ในตอนนี้</p>
|
||||
<Link href="/routes">กลับไปหน้าสายรถ</Link>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
// Build coord lookup by station_id from /stops dataset
|
||||
const coordById = new Map<number, { lat: number; lng: number }>();
|
||||
for (const s of allStops) {
|
||||
if (s.lat != null && s.lng != null) {
|
||||
coordById.set(s.id, { lat: s.lat, lng: s.lng });
|
||||
}
|
||||
}
|
||||
|
||||
const mapPoints = stops
|
||||
.map((s) => {
|
||||
const c = coordById.get(s.station_id);
|
||||
if (!c) return null;
|
||||
return {
|
||||
id: s.station_id,
|
||||
lat: c.lat,
|
||||
lng: c.lng,
|
||||
label: s.name_th,
|
||||
code: s.code,
|
||||
sequence: s.stop_sequence,
|
||||
};
|
||||
})
|
||||
.filter((x): x is NonNullable<typeof x> => x !== null);
|
||||
|
||||
const path: [number, number][] = mapPoints.map((p) => [p.lat, p.lng]);
|
||||
const provinceSet = new Set(
|
||||
stops.map((s) => s.province_th).filter((x): x is string => !!x),
|
||||
);
|
||||
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/routes/${routeId}`} />
|
||||
|
||||
<section className="page-hero page-hero--alt route-hero">
|
||||
<span className="page-hero__blob page-hero__blob--a" aria-hidden />
|
||||
<span className="page-hero__blob page-hero__blob--b" aria-hidden />
|
||||
<span className="page-hero__blob page-hero__blob--c" aria-hidden />
|
||||
<div className="route-hero__top">
|
||||
<div className="route-hero__badge">{route.route_id}</div>
|
||||
<div className="route-hero__title-wrap">
|
||||
<div className="route-hero__chips">
|
||||
<span className="chip-soft chip-soft--purple">{route.route_group_label_th || route.route_group_code}</span>
|
||||
<span className="chip-soft chip-soft--sky">{route.vehicle_type}</span>
|
||||
{provinceSet.size > 0 && (
|
||||
<span className="chip-soft chip-soft--mint">{provinceSet.size} จังหวัด</span>
|
||||
)}
|
||||
</div>
|
||||
<h1 className="page-hero__title">
|
||||
<span className="page-hero__title-grad">{route.name_th}</span>
|
||||
</h1>
|
||||
<p className="page-hero__subtitle">
|
||||
เส้นทางหมายเลข {route.route_id} · ผ่าน {stops.length} จุดจอด · {schedules.length} รอบเวลา
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="page-hero__stats">
|
||||
<span className="page-hero__stat"><b>{stops.length}</b> จุดจอด</span>
|
||||
<span className="page-hero__stat"><b>{schedules.length}</b> รอบเวลา</span>
|
||||
<span className="page-hero__stat"><b>{provinceSet.size}</b> จังหวัด</span>
|
||||
</div>
|
||||
|
||||
<div className="route-hero__actions">
|
||||
<Link href="/routes" className="route-hero__back">
|
||||
← กลับสายทั้งหมด
|
||||
</Link>
|
||||
</div>
|
||||
{/* ภาพประกอบ */}
|
||||
{route.images && route.images.length > 0 && (
|
||||
<section>
|
||||
<h2 className="section-title">ภาพประกอบ</h2>
|
||||
<div className="grid">
|
||||
{route.images.map((img) => (
|
||||
<figure key={img.id} className="card" style={{ padding: 8 }}>
|
||||
<img
|
||||
src={resolveFileUrl(img.url_path)}
|
||||
alt={String((img.meta as any)?.alt_th || route.name_th)}
|
||||
style={{ width: "100%", borderRadius: 12, display: "block" }}
|
||||
/>
|
||||
</figure>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* ติดต่อ */}
|
||||
<section>
|
||||
<h2 className="section-title">ติดต่อ</h2>
|
||||
{Array.isArray((route.contact as any)?.phones) && (route.contact as any).phones.length > 0 ? (
|
||||
<ul>
|
||||
{(route.contact as any).phones.map((p: any, i: number) => (
|
||||
<li key={i}>
|
||||
<strong>{p.label || "โทร"}:</strong> <a href={`tel:${p.number}`}>{p.number}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="muted">ไม่พบเบอร์ติดต่อ</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* เมตาดาตา */}
|
||||
<section>
|
||||
<h2 className="section-title">เมตาดาตา</h2>
|
||||
<pre className="card" style={{ overflow: "auto", padding: 16 }}>
|
||||
{JSON.stringify(route.metadata, null, 2)}
|
||||
</pre>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section className="route-map-section">
|
||||
<div className="route-map-section__head">
|
||||
<h2 className="section-title">เส้นทางวิ่ง</h2>
|
||||
<span className="route-map-section__legend">
|
||||
<span><i className="dot dot--start" /> ต้นทาง</span>
|
||||
<span><i className="dot dot--mid" /> จุดผ่าน</span>
|
||||
<span><i className="dot dot--end" /> ปลายทาง</span>
|
||||
</span>
|
||||
</div>
|
||||
{mapPoints.length >= 1 ? (
|
||||
<div className="map-wrap map-wrap--soft route-map">
|
||||
<LazyMapView points={mapPoints} path={path} />
|
||||
</div>
|
||||
) : (
|
||||
<p className="muted route-map-empty">— ยังไม่มีพิกัดสำหรับจุดจอดของสายนี้ —</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2 className="section-title">จุดจอดตามลำดับ ({stops.length})</h2>
|
||||
<ol className="stop-timeline">
|
||||
{stops.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
const isStart = i === 0;
|
||||
const isEnd = i === stops.length - 1;
|
||||
const hasCoord = coordById.has(s.station_id);
|
||||
const stopHref = s.code ? `/stops/${encodeURIComponent(s.code)}` : null;
|
||||
return (
|
||||
<li key={s.station_id} className={`stop-node stop-node--${tone}`}>
|
||||
<span className="stop-node__line" aria-hidden />
|
||||
<span className={`stop-node__bullet ${isStart ? "is-start" : isEnd ? "is-end" : ""}`}>
|
||||
{s.stop_sequence}
|
||||
</span>
|
||||
<div className="stop-node__body">
|
||||
<div className="stop-node__head">
|
||||
{stopHref ? (
|
||||
<Link href={stopHref} className="stop-node__title">
|
||||
{s.name_th}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="stop-node__title">{s.name_th}</span>
|
||||
)}
|
||||
{isStart && <span className="chip-soft chip-soft--mint">ต้นทาง</span>}
|
||||
{isEnd && <span className="chip-soft chip-soft--pink">ปลายทาง</span>}
|
||||
</div>
|
||||
<div className="stop-node__meta">
|
||||
<span className="chip-soft chip-soft--sky">{s.station_type}</span>
|
||||
{(s.city_th || s.province_th) && (
|
||||
<span className="stop-node__loc">
|
||||
📍 {[s.city_th, s.province_th].filter(Boolean).join(" · ")}
|
||||
</span>
|
||||
)}
|
||||
{!hasCoord && (
|
||||
<span className="stop-node__warn">ไม่มีพิกัดบนแผนที่</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{stopHref ? (
|
||||
<Link href={stopHref} className="stop-node__arrow" aria-label="ดูจุดจอด">→</Link>
|
||||
) : (
|
||||
<span className="stop-node__arrow" aria-hidden>→</span>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2 className="section-title">ตารางเวลา ({schedules.length})</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูลตารางเวลา</p>
|
||||
) : (
|
||||
<div className="schedule-list">
|
||||
{schedules.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
return (
|
||||
<article key={s.id} className={`schedule-card schedule-card--${tone}`}>
|
||||
<span className="schedule-card__rail" aria-hidden />
|
||||
<div className="schedule-card__head">
|
||||
<div className={`schedule-card__route ${tone}`}>
|
||||
<span>{s.station_name_th}</span>
|
||||
<small>จุดต้นทาง</small>
|
||||
</div>
|
||||
<div className="schedule-card__meta">
|
||||
<strong>{s.direction_note || "ทุกทิศทาง"}</strong>
|
||||
{s.schedule_note && <span>{s.schedule_note}</span>}
|
||||
</div>
|
||||
</div>
|
||||
{s.departure_times.length === 0 ? (
|
||||
<span className="schedule-card__empty">— ยังไม่มีรอบ —</span>
|
||||
) : (
|
||||
<div className="schedule-card__times">
|
||||
{s.departure_times.map((t, j) => (
|
||||
<span key={`${s.id}-${j}`} className="schedule-card__time">🕒 {t}</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
<>
|
||||
<RouteView />
|
||||
<PageRuntime page="route" params={{ routeId: decodeURIComponent(routeId) }} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,95 +1,13 @@
|
||||
import Link from "next/link";
|
||||
import { api } from "@/lib/api";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import RouteView from "@/components/views/RouteView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
type SP = { group?: string; province?: string };
|
||||
export const metadata = { title: "รายละเอียดสายรถ" };
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
const GROUP_TONE: Record<string, (typeof TONES)[number]> = {
|
||||
REGIONAL: "sky",
|
||||
INTRA: "purple",
|
||||
INTERPROV: "pink",
|
||||
LOCAL: "mint",
|
||||
AIRPORT: "amber",
|
||||
};
|
||||
|
||||
export default async function RoutesPage({ searchParams }: { searchParams: SP }) {
|
||||
const group = searchParams.group;
|
||||
const province = searchParams.province ? Number(searchParams.province) : undefined;
|
||||
const res = await api.routes({ group, province }).catch(() => ({ items: [] }));
|
||||
const { items } = res;
|
||||
const groupCounts = items.reduce<Record<string, { label: string; n: number }>>((acc, r) => {
|
||||
const key = r.route_group_code;
|
||||
if (!acc[key]) acc[key] = { label: r.route_group_label_th || key, n: 0 };
|
||||
acc[key].n += 1;
|
||||
return acc;
|
||||
}, {});
|
||||
export default function Page() {
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path="/routes" />
|
||||
|
||||
<section className="page-hero page-hero--alt">
|
||||
<div className="page-hero__blob page-hero__blob--a" />
|
||||
<div className="page-hero__blob page-hero__blob--b" />
|
||||
<div className="page-hero__blob page-hero__blob--c" />
|
||||
<div className="page-hero__inner">
|
||||
<span className="page-hero__badge">🛣️ ROUTE NETWORK</span>
|
||||
<h1 className="page-hero__title">
|
||||
เส้นทางเดินรถ<span className="page-hero__title-grad">ทั้งหมด</span>
|
||||
</h1>
|
||||
<p className="page-hero__subtitle">
|
||||
{group ? `กรองหมวด: ${group}` : "ครอบคลุมทุกหมวด"}
|
||||
{province ? ` · จังหวัด #${province}` : ""}
|
||||
</p>
|
||||
<div className="page-hero__stats">
|
||||
<span className="page-hero__stat"><b>{items.length}</b> เส้นทาง</span>
|
||||
<span className="page-hero__stat"><b>{Object.keys(groupCounts).length}</b> หมวด</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="toolbar">
|
||||
<div className="toolbar__search">
|
||||
<span aria-hidden>🔍</span>
|
||||
<input placeholder="ค้นหาเลขสาย หรือชื่อเส้นทาง…" disabled />
|
||||
</div>
|
||||
<div className="toolbar__chips">
|
||||
{Object.entries(groupCounts).map(([code, { label, n }]) => (
|
||||
<span key={code} className={`chip-soft chip-soft--${GROUP_TONE[code] ?? "sky"}`}>
|
||||
{label} · {n}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="tile-grid">
|
||||
{items.map((r, i) => {
|
||||
const tone = GROUP_TONE[r.route_group_code] ?? TONES[i % TONES.length];
|
||||
return (
|
||||
<Link
|
||||
key={r.route_id}
|
||||
href={`/routes/${encodeURIComponent(r.route_id)}`}
|
||||
className={`tile tile--${tone}`}
|
||||
>
|
||||
<div className={`tile__badge tile__badge--${tone} tile__badge--num`}>
|
||||
<span>{r.route_id}</span>
|
||||
</div>
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{r.name_th}</p>
|
||||
<p className="tile__meta">{r.route_group_label_th || r.route_group_code}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{r.route_group_label_th || r.route_group_code}
|
||||
</span>
|
||||
<span className="chip-soft chip-soft--mint">🚌 {r.vehicle_type}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</main>
|
||||
<>
|
||||
<RouteView />
|
||||
<PageRuntime page="route" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import StopView from "@/components/views/StopView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
export const metadata = { title: "รายละเอียดป้าย" };
|
||||
|
||||
export default async function Page({ params }: { params: Promise<{ code: string }> }) {
|
||||
const { code } = await params;
|
||||
return (
|
||||
<>
|
||||
<StopView />
|
||||
<PageRuntime page="stop" params={{ code: decodeURIComponent(code) }} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
|
||||
interface StopDetailPageProps {
|
||||
params: Promise<{ stopId: string }>;
|
||||
}
|
||||
|
||||
export default async function StopDetailPage({ params }: StopDetailPageProps) {
|
||||
const { stopId } = await params;
|
||||
if (!stopId || stopId === "undefined") {
|
||||
notFound();
|
||||
}
|
||||
redirect(`/stops/details?code=${encodeURIComponent(stopId)}`);
|
||||
return null;
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { api, isApiNotFoundError, resolveFileUrl, type Schedule, type StopDetail } from "@/lib/api";
|
||||
import LazyMapView from "@/components/LazyMapView";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
|
||||
type StopDetailsPageProps = {
|
||||
searchParams: Promise<{ code?: string }>;
|
||||
};
|
||||
|
||||
export default async function StopDetailsPage({ searchParams }: StopDetailsPageProps) {
|
||||
const { code } = await searchParams;
|
||||
if (!code) notFound();
|
||||
|
||||
let stop: StopDetail | null = null;
|
||||
let schedules: Schedule[] = [];
|
||||
|
||||
try {
|
||||
stop = await api.stop(code);
|
||||
({ items: schedules } = await api.schedules({ stop_code: stop.code }));
|
||||
} catch (error) {
|
||||
if (isApiNotFoundError(error)) {
|
||||
notFound();
|
||||
}
|
||||
stop = null;
|
||||
schedules = [];
|
||||
}
|
||||
|
||||
if (!stop) {
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/stops/details?code=${code}`} />
|
||||
<section className="hero">
|
||||
<h1>ไม่สามารถโหลดข้อมูลป้ายนี้ได้</h1>
|
||||
<p className="muted">ระบบยังเปิดอยู่ แต่ backend ตอบกลับไม่ได้ในตอนนี้</p>
|
||||
<Link href="/stops">กลับไปหน้าป้ายหยุดรถ</Link>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
const place = [stop.city_th, stop.province_th].filter(Boolean).join(" / ") || "—";
|
||||
const hasMap = stop.lat != null && stop.lng != null;
|
||||
const mapPoints = hasMap
|
||||
? [{ id: stop.id, lat: stop.lat as number, lng: stop.lng as number, label: stop.name_th, code: stop.code }]
|
||||
: [];
|
||||
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/stops/details?code=${stop.code}`} />
|
||||
<section className="hero">
|
||||
<span className="pill">{stop.station_type}</span>
|
||||
<h1 style={{ marginTop: 10 }}>{stop.name_th}</h1>
|
||||
<p className="muted">📍 {place}{hasMap ? ` · ${stop.lat?.toFixed(4)}, ${stop.lng?.toFixed(4)}` : ""}</p>
|
||||
</section>
|
||||
<div className="stop-detail__split">
|
||||
{stop.images.length > 0 ? (
|
||||
<div className="stop-detail__gallery">
|
||||
<img
|
||||
className="stop-detail__hero-img"
|
||||
src={resolveFileUrl(stop.images[0].url_path)}
|
||||
alt={(stop.images[0].meta as { alt_th?: string } | undefined)?.alt_th ?? stop.name_th}
|
||||
/>
|
||||
{stop.images.length > 1 && (
|
||||
<div className="stop-detail__thumbs">
|
||||
{stop.images.slice(1, 5).map((img) => (
|
||||
<img key={img.id} src={resolveFileUrl(img.url_path)} alt={stop.name_th} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="stop-detail__gallery stop-detail__gallery--empty">
|
||||
<div className="stop-detail__placeholder">📷 ยังไม่มีรูปป้ายนี้</div>
|
||||
</div>
|
||||
)}
|
||||
{hasMap ? (
|
||||
<div className="stop-detail__map">
|
||||
<LazyMapView points={mapPoints} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="stop-detail__map stop-detail__map--empty">
|
||||
<div className="stop-detail__placeholder">🗺️ ยังไม่มีพิกัดของป้ายนี้</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<h2 className="section-title">ตารางเวลาที่จุดนี้</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูล</p>
|
||||
) : (
|
||||
<div className="schedule-list">
|
||||
{schedules.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
return (
|
||||
<article key={s.id} className={`schedule-card schedule-card--${tone}`}>
|
||||
<div className="schedule-card__rail" />
|
||||
<div className="schedule-card__head">
|
||||
<Link
|
||||
href={`/routes/${encodeURIComponent(s.route_id)}`}
|
||||
className={`schedule-card__route ${tone}`}
|
||||
>
|
||||
<span className="schedule-card__route-label">เส้นทาง</span>
|
||||
<span className="schedule-card__route-id">{s.route_id}</span>
|
||||
</Link>
|
||||
<div className="schedule-card__meta">
|
||||
<span className="schedule-card__direction">
|
||||
<span aria-hidden>🧭</span>
|
||||
{s.direction_note || "ไม่ระบุทิศทาง"}
|
||||
</span>
|
||||
{s.schedule_note && (
|
||||
<span className="schedule-card__note">📝 {s.schedule_note}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="schedule-card__times">
|
||||
{s.departure_times.length === 0 ? (
|
||||
<span className="schedule-card__empty">— ยังไม่มีรอบ —</span>
|
||||
) : (
|
||||
s.departure_times.map((t, j) => (
|
||||
<span key={j} className="schedule-card__time">🕒 {t}</span>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -1,138 +1,13 @@
|
||||
import Link from "next/link";
|
||||
import { api } from "@/lib/api";
|
||||
import LazyMapView from "@/components/LazyMapView";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import StopsView from "@/components/views/StopsView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
const TYPE_TONE: Record<string, (typeof TONES)[number]> = {
|
||||
terminal: "purple",
|
||||
station: "sky",
|
||||
pickup: "amber",
|
||||
market: "pink",
|
||||
landmark: "mint",
|
||||
};
|
||||
const TYPE_ICON: Record<string, string> = {
|
||||
terminal: "🚍",
|
||||
station: "🚏",
|
||||
pickup: "🛣️",
|
||||
market: "🏪",
|
||||
landmark: "📍",
|
||||
};
|
||||
const TYPE_LABEL: Record<string, string> = {
|
||||
terminal: "สถานีขนส่ง",
|
||||
station: "ป้ายหลัก",
|
||||
pickup: "จุดรับส่ง",
|
||||
market: "ตลาด/ชุมชน",
|
||||
landmark: "จุดสังเกต",
|
||||
};
|
||||
export const metadata = { title: "ป้ายหยุดรถ" };
|
||||
|
||||
export default async function StopsPage() {
|
||||
const { items } = await api.stops().catch(() => ({ items: [] }));
|
||||
const points = items
|
||||
.filter((s) => s.lat != null && s.lng != null)
|
||||
.map((s) => ({ id: s.id, lat: s.lat as number, lng: s.lng as number, label: s.name_th, code: s.code }));
|
||||
const typeCounts = items.reduce<Record<string, number>>((acc, s) => {
|
||||
acc[s.station_type] = (acc[s.station_type] ?? 0) + 1;
|
||||
return acc;
|
||||
}, {});
|
||||
export default function Page() {
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path="/stops" />
|
||||
|
||||
<section className="page-hero">
|
||||
<div className="page-hero__blob page-hero__blob--a" />
|
||||
<div className="page-hero__blob page-hero__blob--b" />
|
||||
<div className="page-hero__blob page-hero__blob--c" />
|
||||
<div className="page-hero__inner">
|
||||
<span className="page-hero__badge">🚏 STOP DIRECTORY</span>
|
||||
<h1 className="page-hero__title">
|
||||
จุดจอด<span className="page-hero__title-grad">ทั่วประเทศ</span>
|
||||
</h1>
|
||||
<p className="page-hero__subtitle">
|
||||
ค้นหาป้าย / สถานีขนส่ง พร้อมแผนที่และเส้นทางที่ผ่าน
|
||||
</p>
|
||||
<div className="page-hero__stats">
|
||||
<span className="page-hero__stat"><b>{items.length}</b> จุดจอด</span>
|
||||
<span className="page-hero__stat"><b>{points.length}</b> มีพิกัด</span>
|
||||
<span className="page-hero__stat"><b>{Object.keys(typeCounts).length}</b> ประเภท</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{points.length > 0 && (
|
||||
<div className="map-wrap map-wrap--soft">
|
||||
<LazyMapView points={points} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="toolbar">
|
||||
<div className="toolbar__search">
|
||||
<span aria-hidden>🔍</span>
|
||||
<input placeholder="ค้นหาชื่อป้าย หรือจังหวัด…" disabled />
|
||||
</div>
|
||||
<div className="toolbar__chips">
|
||||
{Object.entries(typeCounts).map(([t, n]) => (
|
||||
<span key={t} className={`chip-soft chip-soft--${TYPE_TONE[t] ?? "sky"}`}>
|
||||
{TYPE_ICON[t] ?? "📍"} {TYPE_LABEL[t] ?? t} · {n}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="tile-grid">
|
||||
{items.map((s, i) => {
|
||||
const tone = TYPE_TONE[s.station_type] ?? TONES[i % TONES.length];
|
||||
const icon = TYPE_ICON[s.station_type] ?? "📍";
|
||||
const place = [s.city_th, s.province_th].filter(Boolean).join(" · ");
|
||||
const stopHref = s.code ? `/stops/${encodeURIComponent(s.code)}` : null;
|
||||
return (
|
||||
stopHref ? (
|
||||
<Link
|
||||
key={s.id}
|
||||
href={stopHref}
|
||||
className={`tile tile--${tone}`}
|
||||
>
|
||||
<div className={`tile__badge tile__badge--${tone}`}>
|
||||
<span>{icon}</span>
|
||||
</div>
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{s.name_th}</p>
|
||||
<p className="tile__meta">{place || "—"}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{TYPE_LABEL[s.station_type] ?? s.station_type}
|
||||
</span>
|
||||
{s.lat != null && s.lng != null && (
|
||||
<span className="chip-soft chip-soft--mint">📍 บนแผนที่</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</Link>
|
||||
) : (
|
||||
<div key={s.id} className={`tile tile--${tone} tile--disabled`}>
|
||||
<div className={`tile__badge tile__badge--${tone}`}>
|
||||
<span>{icon}</span>
|
||||
</div>
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{s.name_th}</p>
|
||||
<p className="tile__meta">{place || "—"}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{TYPE_LABEL[s.station_type] ?? s.station_type}
|
||||
</span>
|
||||
{s.lat != null && s.lng != null && (
|
||||
<span className="chip-soft chip-soft--mint">📍 บนแผนที่</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</main>
|
||||
<>
|
||||
<StopsView />
|
||||
<PageRuntime page="stops" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import { api, resolveFileUrl } from "@/lib/api";
|
||||
|
||||
const popularRoutes = [
|
||||
{ id: "101", label: "สาย 101 · อ่างทอง-อยุธยา" },
|
||||
{ id: "902", label: "สาย 902 · กรุงเทพ-อ่างทอง" },
|
||||
{ id: "15", label: "สาย 15 · สายใน" },
|
||||
{ id: "464", label: "สาย 464 · สุพรรณ-สระบุรี" },
|
||||
];
|
||||
|
||||
const SPONSOR_LABELS: Record<string, string> = {
|
||||
"7-11": "7-Eleven",
|
||||
"shopee": "Shopee",
|
||||
"lazada": "Lazada",
|
||||
"airasia-move": "airasia MOVE",
|
||||
"busonlineticket": "busonlineticket",
|
||||
"trip": "Trip.com",
|
||||
"truck2hand": "truck2hand",
|
||||
"tcl999-angthong": "ทีซีแอล 999 อ่างทอง",
|
||||
"bus-pingraow": "รถบัสปิ่นเกล้า",
|
||||
};
|
||||
|
||||
function labelFor(entityId: string): string {
|
||||
return SPONSOR_LABELS[entityId] ?? entityId;
|
||||
}
|
||||
|
||||
export async function Footer() {
|
||||
let sponsors: { entity_id: string; url_path: string }[] = [];
|
||||
try {
|
||||
const res = await api.images({ entity_type: "sponsor" });
|
||||
sponsors = res.items.map((item) => ({
|
||||
entity_id: item.entity_id,
|
||||
url_path: item.url_path,
|
||||
}));
|
||||
} catch {
|
||||
sponsors = [];
|
||||
}
|
||||
|
||||
return (
|
||||
<footer className="footer">
|
||||
<div className="container">
|
||||
<div className="footer__grid">
|
||||
<div className="footer__brand">
|
||||
<div className="footer__brand-row">
|
||||
<Image src="/logo.svg" alt="AT Transit" width={48} height={48} />
|
||||
<div>
|
||||
<strong>AT Transit</strong>
|
||||
<span>สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง
|
||||
อัปเดตข้อมูลล่าสุดจากผู้ประกอบการแต่ละสายโดยตรง
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="footer__col">
|
||||
<h4>เมนู</h4>
|
||||
<ul>
|
||||
<li><Link href="/">หน้าแรก</Link></li>
|
||||
<li><Link href="/stops">ค้นหาป้ายหยุดรถ</Link></li>
|
||||
<li><Link href="/routes">รายละเอียดสายรถ</Link></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="footer__col">
|
||||
<h4>สายยอดนิยม</h4>
|
||||
<ul>
|
||||
{popularRoutes.map((r) => (
|
||||
<li key={r.id}>
|
||||
<Link href={`/routes/${r.id}`}>{r.label}</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="footer__col footer__contact">
|
||||
<h4>ติดต่อ</h4>
|
||||
<div className="row"><a href="tel:+66649639025">📞 +66 64 963 9025</a></div>
|
||||
<div className="row"><span>📍 ถนนเทศบาล 1 อ.เมือง อ่างทอง</span></div>
|
||||
<div className="row"><span>🕒 บริการ 04:30 - 21:00 น.</span></div>
|
||||
<div className="row"><a href="#">💬 LINE Official: @attransit</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="footer__sponsors" aria-label="ผู้สนับสนุน">
|
||||
<h4>ผู้สนับสนุน & พาร์ทเนอร์</h4>
|
||||
<p className="lead">จองตั๋ว · สั่งของ · เช็กของฝาก ที่ร้านค้าและบริการพันธมิตรของเรา</p>
|
||||
<div className="sponsor-strip">
|
||||
{sponsors.length > 0 ? (
|
||||
sponsors.map((s) => (
|
||||
<a
|
||||
key={s.entity_id}
|
||||
className="sponsor-tile"
|
||||
href="#"
|
||||
aria-label={labelFor(s.entity_id)}
|
||||
title={labelFor(s.entity_id)}
|
||||
>
|
||||
<img src={resolveFileUrl(s.url_path)} alt={labelFor(s.entity_id)} loading="lazy" />
|
||||
</a>
|
||||
))
|
||||
) : (
|
||||
<span className="sponsor-tile sponsor-tile--empty">ยังไม่มีข้อมูลผู้สนับสนุน</span>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="footer__bottom">
|
||||
<p>© {new Date().getFullYear()} AT Transit <span className="pill">mockup template</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
"use client";
|
||||
import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
const links = [
|
||||
{ href: "/", label: "หน้าแรก" },
|
||||
{ href: "/stops", label: "ป้ายหยุดรถ" },
|
||||
{ href: "/routes", label: "รายละเอียดสายรถ" },
|
||||
];
|
||||
|
||||
export function Header() {
|
||||
const pathname = usePathname();
|
||||
const isActive = (href: string) =>
|
||||
href === "/" ? pathname === "/" : pathname.startsWith(href);
|
||||
|
||||
return (
|
||||
<header className="topbar">
|
||||
<div className="topbar__inner">
|
||||
<Link href="/" className="brand">
|
||||
<Image
|
||||
src="/logo.svg"
|
||||
alt="AT Transit"
|
||||
width={44}
|
||||
height={44}
|
||||
className="brand__logo"
|
||||
priority
|
||||
/>
|
||||
<div>
|
||||
<p className="brand__title">AT Transit</p>
|
||||
<p className="brand__subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</p>
|
||||
</div>
|
||||
</Link>
|
||||
<nav className="nav" aria-label="เมนูหลัก">
|
||||
{links.map((l) => (
|
||||
<Link key={l.href} href={l.href} className={isActive(l.href) ? "active" : ""}>
|
||||
{l.label}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
<Link href="/routes" className="cta-pill">เช็กเวลาเดินรถ</Link>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/* Ported from web-at-transit-mock/ui/partials/sprite.html — markup 1:1 with the mock. */
|
||||
export default function IconSprite() {
|
||||
return (
|
||||
<>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" style={{display: 'none'}} aria-hidden="true">
|
||||
<symbol id="ic-alarm-clock" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<circle cx={12} cy={13} r={8} />
|
||||
<path d="M12 9v4l2 2" />
|
||||
<path d="M5 3 2 6" />
|
||||
<path d="m22 6-3-3" />
|
||||
<path d="M6.38 18.7 4 21" />
|
||||
<path d="M17.64 18.67 20 21" />
|
||||
</symbol>
|
||||
<symbol id="ic-x" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round"><path d="M18 6 6 18" /><path d="m6 6 12 12" /></symbol>
|
||||
<symbol id="ic-arrow-right" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M5 12h14" />
|
||||
<path d="m12 5 7 7-7 7" />
|
||||
</symbol>
|
||||
<symbol id="ic-bus" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M8 6v6" />
|
||||
<path d="M15 6v6" />
|
||||
<path d="M2 12h19.6" />
|
||||
<path d="M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3" />
|
||||
<circle cx={7} cy={18} r={2} />
|
||||
<path d="M9 18h5" />
|
||||
<circle cx={16} cy={18} r={2} />
|
||||
</symbol>
|
||||
<symbol id="ic-bus-front" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M4 6 2 7" />
|
||||
<path d="M10 6h4" />
|
||||
<path d="m22 7-2-1" />
|
||||
<rect width={16} height={16} x={4} y={3} rx={2} />
|
||||
<path d="M4 11h16" />
|
||||
<path d="M8 15h.01" />
|
||||
<path d="M16 15h.01" />
|
||||
<path d="M6 19v2" />
|
||||
<path d="M18 21v-2" />
|
||||
</symbol>
|
||||
<symbol id="ic-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M20 6 9 17l-5-5" />
|
||||
</symbol>
|
||||
<symbol id="ic-clock" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<circle cx={12} cy={12} r={10} />
|
||||
<path d="M12 6v6l4 2" />
|
||||
</symbol>
|
||||
<symbol id="ic-globe" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<circle cx={12} cy={12} r={10} />
|
||||
<path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" />
|
||||
<path d="M2 12h20" />
|
||||
</symbol>
|
||||
<symbol id="ic-hourglass" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M5 22h14" />
|
||||
<path d="M5 2h14" />
|
||||
<path d="M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22" />
|
||||
<path d="M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2" />
|
||||
</symbol>
|
||||
<symbol id="ic-map" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z" />
|
||||
<path d="M15 5.764v15" />
|
||||
<path d="M9 3.236v15" />
|
||||
</symbol>
|
||||
<symbol id="ic-map-pin" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" />
|
||||
<circle cx={12} cy={10} r={3} />
|
||||
</symbol>
|
||||
<symbol id="ic-message-circle" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719" />
|
||||
</symbol>
|
||||
<symbol id="ic-phone" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384" />
|
||||
</symbol>
|
||||
<symbol id="ic-refresh-cw" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" />
|
||||
<path d="M21 3v5h-5" />
|
||||
<path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" />
|
||||
<path d="M8 16H3v5" />
|
||||
</symbol>
|
||||
<symbol id="ic-search" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="m21 21-4.34-4.34" />
|
||||
<circle cx={11} cy={11} r={8} />
|
||||
</symbol>
|
||||
<symbol id="ic-triangle-alert" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" />
|
||||
<path d="M12 9v4" />
|
||||
<path d="M12 17h.01" />
|
||||
</symbol>
|
||||
<symbol id="ic-share-2" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round"><circle cx={18} cy={5} r={3} /><circle cx={6} cy={12} r={3} /><circle cx={18} cy={19} r={3} /><line x1="8.59" y1="13.51" x2="15.42" y2="17.49" /><line x1="15.41" y1="6.51" x2="8.59" y2="10.49" /></symbol>
|
||||
<symbol id="ic-link" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" /></symbol>
|
||||
<symbol id="ic-facebook" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round"><path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z" /></symbol>
|
||||
<symbol id="ic-copy" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round"><rect width={14} height={14} x={8} y={8} rx={2} ry={2} /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" /></symbol>
|
||||
</svg>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import dynamic from "next/dynamic";
|
||||
import type { MapViewProps } from "@/components/MapView";
|
||||
|
||||
const ClientMapView = dynamic(() => import("@/components/MapView"), { ssr: false });
|
||||
|
||||
export default function LazyMapView(props: MapViewProps) {
|
||||
return <ClientMapView {...props} />;
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
"use client";
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import { MapContainer, TileLayer, Marker, Popup, Polyline, useMap } from "react-leaflet";
|
||||
import L from "leaflet";
|
||||
import { useEffect } from "react";
|
||||
|
||||
type LatLng = [number, number];
|
||||
type Point = { id: number; lat: number; lng: number; label: string; code: string; sequence?: number };
|
||||
|
||||
// Fix default marker icon paths for webpack/Next
|
||||
const icon = new L.Icon({
|
||||
iconUrl: "https://unpkg.com/[email protected]/dist/images/marker-icon.png",
|
||||
iconRetinaUrl: "https://unpkg.com/[email protected]/dist/images/marker-icon-2x.png",
|
||||
shadowUrl: "https://unpkg.com/[email protected]/dist/images/marker-shadow.png",
|
||||
iconSize: [25, 41],
|
||||
iconAnchor: [12, 41],
|
||||
});
|
||||
|
||||
function numberedIcon(n: number, tone: "start" | "mid" | "end") {
|
||||
const colors: Record<string, string> = {
|
||||
start: "linear-gradient(135deg,#34d399,#10b981)",
|
||||
end: "linear-gradient(135deg,#fb7185,#e11d48)",
|
||||
mid: "linear-gradient(135deg,#a78bfa,#7c3aed)",
|
||||
};
|
||||
const html =
|
||||
'<div style="' +
|
||||
'width:32px;height:32px;border-radius:50%;' +
|
||||
'background:' + colors[tone] + ';' +
|
||||
'color:#fff;font-weight:800;font-size:13px;font-family:system-ui;' +
|
||||
'display:flex;align-items:center;justify-content:center;' +
|
||||
'border:3px solid #fff;' +
|
||||
'box-shadow:0 4px 10px rgba(31,28,68,.28), 0 0 0 1px rgba(124,58,237,.18);' +
|
||||
'">' + String(n) + '</div>';
|
||||
return L.divIcon({
|
||||
html,
|
||||
className: "route-marker",
|
||||
iconSize: [32, 32],
|
||||
iconAnchor: [16, 16],
|
||||
popupAnchor: [0, -14],
|
||||
});
|
||||
}
|
||||
|
||||
function FitBounds({ positions }: { positions: LatLng[] }) {
|
||||
const map = useMap();
|
||||
useEffect(() => {
|
||||
if (positions.length === 0) return;
|
||||
if (positions.length === 1) {
|
||||
map.setView(positions[0], 12);
|
||||
return;
|
||||
}
|
||||
const bounds = L.latLngBounds(positions.map((p) => L.latLng(p[0], p[1])));
|
||||
map.fitBounds(bounds, { padding: [36, 36] });
|
||||
}, [map, positions]);
|
||||
return null;
|
||||
}
|
||||
|
||||
type Props = {
|
||||
points: Point[];
|
||||
path?: LatLng[];
|
||||
};
|
||||
|
||||
export type MapViewProps = Props;
|
||||
|
||||
export default function MapView({ points, path }: Props) {
|
||||
const fallback: LatLng[] = points.map((p) => [p.lat, p.lng]);
|
||||
const positions: LatLng[] = path && path.length > 0 ? path : fallback;
|
||||
const center: LatLng = positions.length > 0 ? positions[0] : [9.1, 99.3];
|
||||
const isRoute = !!path && path.length > 0;
|
||||
return (
|
||||
<MapContainer center={center} zoom={9} style={{ height: "100%", width: "100%" }}>
|
||||
<TileLayer
|
||||
attribution='© OpenStreetMap'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
/>
|
||||
{isRoute && path ? (
|
||||
<Polyline
|
||||
positions={path}
|
||||
pathOptions={{ color: "#7c3aed", weight: 5, opacity: 0.85, lineCap: "round" }}
|
||||
/>
|
||||
) : null}
|
||||
{points.map((p, idx) => {
|
||||
let tone: "start" | "mid" | "end" = "mid";
|
||||
if (isRoute) {
|
||||
if (idx === 0) tone = "start";
|
||||
else if (idx === points.length - 1) tone = "end";
|
||||
}
|
||||
const markerIcon = isRoute ? numberedIcon(p.sequence ?? idx + 1, tone) : icon;
|
||||
const stopHref = p.code ? `/stops/${encodeURIComponent(p.code)}` : null;
|
||||
return (
|
||||
<Marker key={String(p.id) + "-" + String(idx)} position={[p.lat, p.lng]} icon={markerIcon}>
|
||||
<Popup>
|
||||
<strong>{p.label}</strong>
|
||||
<br />
|
||||
{stopHref ? <a href={stopHref}>รายละเอียด →</a> : <span>ไม่มีรหัสป้าย</span>}
|
||||
</Popup>
|
||||
</Marker>
|
||||
);
|
||||
})}
|
||||
<FitBounds positions={positions} />
|
||||
</MapContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { mountPage } from "@/lib/runtime";
|
||||
|
||||
export type PageKey = "home" | "stops" | "route" | "stop" | "check" | "blog" | "about";
|
||||
|
||||
/**
|
||||
* Static import map — keeps every ported module in the client bundle graph
|
||||
* while letting server components pass only plain strings.
|
||||
*/
|
||||
const LOADERS: Record<PageKey, () => Promise<{ default: () => void }>> = {
|
||||
home: () => import("@/lib/ui/home.init"),
|
||||
stops: async () => {
|
||||
await import("@/lib/ui/stops.nearme");
|
||||
await import("@/lib/ui/stops.search");
|
||||
return import("@/lib/ui/stops.init");
|
||||
},
|
||||
route: () => import("@/lib/ui/route.init"),
|
||||
stop: () => import("@/lib/ui/stop.init"),
|
||||
check: () => import("@/lib/ui/check.init"),
|
||||
blog: () => import("@/lib/ui/blog.init"),
|
||||
about: () => import("@/lib/ui/about.init"),
|
||||
};
|
||||
|
||||
type Props = {
|
||||
page: PageKey;
|
||||
params?: Record<string, string>;
|
||||
query?: Record<string, string>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Mounts a ported mock page module after the shared runtime is ready.
|
||||
* Rendered next to the view markup; the module hydrates it by id, exactly
|
||||
* like the mock partials did.
|
||||
*/
|
||||
export default function PageRuntime({ page, params = {}, query = {} }: Props) {
|
||||
const key = `${page}|${JSON.stringify(params)}|${JSON.stringify(query)}`;
|
||||
|
||||
useEffect(() => {
|
||||
mountPage({ params, query }, LOADERS[page]).catch((error) => {
|
||||
console.error("[mock-page] mount failed", page, error);
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [key]);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { ensureRuntime } from "@/lib/runtime";
|
||||
|
||||
/**
|
||||
* App-wide mock runtime glue:
|
||||
* - loads the shared window.* libraries once (i18n, map, schedules, ...)
|
||||
* - re-applies translations after client navigation
|
||||
* - a language switch reloads, mirroring the mock router's full re-render
|
||||
*/
|
||||
export default function SiteBoot() {
|
||||
const pathname = usePathname();
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
await ensureRuntime();
|
||||
if (cancelled) return;
|
||||
const w = window as unknown as { I18N?: { apply?: () => void } };
|
||||
w.I18N?.apply?.();
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [pathname]);
|
||||
|
||||
useEffect(() => {
|
||||
function onLangChange() {
|
||||
// mock router re-rendered every partial on langchange; a reload gives the
|
||||
// ported JS-built views the same clean slate.
|
||||
window.location.reload();
|
||||
}
|
||||
window.addEventListener("langchange", onLangChange);
|
||||
return () => window.removeEventListener("langchange", onLangChange);
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { ensureRuntime } from "@/lib/runtime";
|
||||
|
||||
const FALLBACK_POPULAR = [
|
||||
{ id: "101", label: "สาย 101 · อ่างทอง-อยุธยา" },
|
||||
{ id: "902", label: "สาย 902 · กรุงเทพ-อ่างทอง" },
|
||||
{ id: "15", label: "สาย 15 · สายใน" },
|
||||
{ id: "464", label: "สาย 464 · สุพรรณ-สระบุรี" },
|
||||
];
|
||||
|
||||
export default function SiteFooter() {
|
||||
// เดิม router.js เรียก mountPopular() ทุกครั้งที่ render — ที่นี่เรียกครั้งเดียวหลัง runtime พร้อม
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
await ensureRuntime();
|
||||
const w = window as unknown as {
|
||||
Popular?: { mount: (id: string, routes: unknown[]) => void };
|
||||
};
|
||||
if (cancelled || !w.Popular) return;
|
||||
try {
|
||||
const res = await fetch("/resource/data/routes.json", { cache: "no-store" });
|
||||
const data = res.ok ? await res.json() : null;
|
||||
const routes = (data && data.routes) || [];
|
||||
if (routes.length && !cancelled) w.Popular.mount("footer-popular-list", routes);
|
||||
} catch {
|
||||
/* ไม่มีข้อมูล → คง li fallback ใน HTML */
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<footer className="mu-site-footer">
|
||||
<div className="mu-container">
|
||||
<div className="mu-footer-grid">
|
||||
<div className="mu-footer-brand">
|
||||
<div className="mu-footer-brand-row">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src="/image/icons/minibus-512x512.png" alt="Atroute" />
|
||||
<div>
|
||||
<strong>Atroute</strong>
|
||||
<span data-i18n="brand.subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="about" data-i18n="footer.about">
|
||||
ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง
|
||||
อัปเดตข้อมูลล่าสุดจากผู้ประกอบการแต่ละสายโดยตรง
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mu-footer-col">
|
||||
<h4 data-i18n="footer.menu">เมนู</h4>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/" data-i18n="nav.home">
|
||||
หน้าแรก
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/stops" data-i18n="nav.stops">
|
||||
ค้นหาป้ายหยุดรถ
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/routes" data-i18n="nav.routes">
|
||||
รายละเอียดสายรถ
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/about" data-i18n="nav.about">
|
||||
เกี่ยวกับเรา
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/blog" data-i18n="nav.blog">
|
||||
บ่นไปเรื่อย
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/credits" data-i18n="nav.credits">
|
||||
เครดิต
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="mu-footer-col">
|
||||
<h4 data-i18n="footer.popular">สายที่เปิดดูบ่อย</h4>
|
||||
{/* เติมด้วย Popular.mount() — li ข้างในเป็น fallback เมื่อ JS ปิด */}
|
||||
<ul id="footer-popular-list" data-i18n-skip>
|
||||
{FALLBACK_POPULAR.map((item) => (
|
||||
<li key={item.id}>
|
||||
<a href={`/routes/${item.id}`}>{item.label}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="mu-footer-col mu-footer-contact">
|
||||
<h4 data-i18n="footer.contact">ติดต่อ</h4>
|
||||
<div className="row">
|
||||
<a href="mailto:[email protected]">
|
||||
<svg className="ic" aria-hidden="true">
|
||||
<use href="#ic-mail" />
|
||||
</svg>{" "}
|
||||
atroute@hobbygirds.com
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mu-footer-bottom">
|
||||
<p>© 2026 Atroute</p>
|
||||
<span className="mu-visitor" title="จำนวนผู้เข้าชมเว็บไซต์">
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth={2}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="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>ผู้เข้าชม</span>
|
||||
<strong id="visitor-count">12,834</strong>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
const NAV = [
|
||||
{ href: "/", key: "nav.home", label: "หน้าแรก" },
|
||||
{ href: "/stops", key: "nav.stops", label: "ป้ายหยุดรถ" },
|
||||
{ href: "/routes", key: "nav.routes", label: "รายละเอียดสายรถ" },
|
||||
{ href: "/about", key: "nav.about", label: "เกี่ยวกับเรา" },
|
||||
{ href: "/blog", key: "nav.blog", label: "บ่นไปเรื่อย" },
|
||||
{ href: "/credits", key: "nav.credits", label: "เครดิต" },
|
||||
];
|
||||
|
||||
function isActive(pathname: string, href: string): boolean {
|
||||
if (href === "/") return pathname === "/";
|
||||
return pathname === href || pathname.startsWith(`${href}/`);
|
||||
}
|
||||
|
||||
export default function SiteHeader() {
|
||||
const pathname = usePathname() || "/";
|
||||
const menuRef = useRef<HTMLDetailsElement>(null);
|
||||
|
||||
// ปิดเมนู hamburger เมื่อเปลี่ยนหน้า หรือคลิกนอกเมนู (เดิมอยู่ใน index.html)
|
||||
useEffect(() => {
|
||||
if (menuRef.current) menuRef.current.removeAttribute("open");
|
||||
function onDocClick(event: MouseEvent) {
|
||||
const menu = menuRef.current;
|
||||
if (!menu) return;
|
||||
const target = event.target as HTMLElement;
|
||||
if (target.closest(".mu-menu-panel a")) {
|
||||
menu.removeAttribute("open");
|
||||
return;
|
||||
}
|
||||
if (!target.closest(".mu-menu")) menu.removeAttribute("open");
|
||||
}
|
||||
document.addEventListener("click", onDocClick);
|
||||
return () => document.removeEventListener("click", onDocClick);
|
||||
}, [pathname]);
|
||||
|
||||
return (
|
||||
<header className="mu-topbar">
|
||||
<div className="mu-container mu-topbar-inner">
|
||||
<a className="mu-brand" href="/" aria-label="Atroute — หน้าแรก">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
className="mu-logo-img"
|
||||
src="/image/icons/minibus-512x512.png"
|
||||
alt="Atroute logo"
|
||||
width={44}
|
||||
height={44}
|
||||
decoding="async"
|
||||
/>
|
||||
<span>
|
||||
<span className="mu-brand-title">Atroute</span>
|
||||
<span className="mu-brand-subtitle" data-i18n="brand.subtitle">
|
||||
สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<nav className="mu-nav" aria-label="เมนูหลัก">
|
||||
{NAV.map((item) => (
|
||||
<a
|
||||
key={item.href}
|
||||
className={isActive(pathname, item.href) ? "active" : undefined}
|
||||
href={item.href}
|
||||
data-i18n={item.key}
|
||||
>
|
||||
{item.label}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
<details className="mu-menu" id="topnav" ref={menuRef}>
|
||||
<summary className="mu-menu-btn" aria-label="เมนูหลัก" aria-haspopup="true">
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth={2}
|
||||
strokeLinecap="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<line x1="4" x2="20" y1="6" y2="6" />
|
||||
<line x1="4" x2="20" y1="12" y2="12" />
|
||||
<line x1="4" x2="20" y1="18" y2="18" />
|
||||
</svg>
|
||||
</summary>
|
||||
<div className="mu-menu-panel" role="menu">
|
||||
{NAV.slice(0, 3).map((item) => (
|
||||
<a key={item.href} href={item.href} data-i18n={item.key} role="menuitem">
|
||||
{item.label}
|
||||
</a>
|
||||
))}
|
||||
<a href="/check" data-i18n="cta.check" role="menuitem">
|
||||
เช็กเวลาเดินรถ
|
||||
</a>
|
||||
{NAV.slice(3).map((item) => (
|
||||
<a key={item.href} href={item.href} data-i18n={item.key} role="menuitem">
|
||||
{item.label}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<div className="mu-lang-switch" role="group" aria-label="ภาษา / Language">
|
||||
<button type="button" className="mu-lang-btn" data-i18n-switch="th">
|
||||
ไทย
|
||||
</button>
|
||||
<button type="button" className="mu-lang-btn" data-i18n-switch="en">
|
||||
EN
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<a className="mu-action-btn" href="/check" data-i18n="cta.check">
|
||||
เช็กเวลาเดินรถ
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/* Ported from web-at-transit-mock/ui/partials/about.html — markup 1:1 with the mock. */
|
||||
import "@/styles/pages/about.css";
|
||||
export default function AboutView() {
|
||||
return (
|
||||
<>
|
||||
|
||||
{/* ============ HERO (ภาษาเดียวกับหน้าแรก) ============ */}
|
||||
<section className="mu-hero">
|
||||
<img className="mu-hero-map" src="/image/network/overview-map.png" alt="" aria-hidden="true" decoding="async" />
|
||||
<div className="mu-blob one" />
|
||||
<div className="mu-blob two" />
|
||||
<div className="mu-blob three" />
|
||||
<div className="mu-container mu-hero-content">
|
||||
<span className="mu-badge"><svg className="ic" aria-hidden="true"><use href="#ic-map-pin" /></svg> <span data-i18n="nav.about">เกี่ยวกับเรา</span></span>
|
||||
<h1><span data-i18n="about.title">เกี่ยวกับเรา</span><br /><span className="mu-gradient-text" data-i18n="about.brand">เมื่อไหร่รถจะมา</span></h1>
|
||||
<p className="mu-hero-lead" data-i18n="about.lead">เรื่องราวและที่มาของเว็บนี้ — อ่านเรียงตามบล็อกด้านล่างได้เลย</p>
|
||||
</div>
|
||||
</section>
|
||||
{/* ============ เนื้อหา (โหลดจาก about-data: text1.json + pic1, text2.json + pic2 ...) ============ */}
|
||||
<section className="mu-about-wrap">
|
||||
<div className="mu-container">
|
||||
<div id="about-blocks" aria-live="polite">
|
||||
<div className="mu-about-skeleton"><div className="mu-about-skel-card" /></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/* Ported from web-at-transit-mock/ui/partials/blog.html — markup 1:1 with the mock. */
|
||||
import "@/styles/pages/blog.css";
|
||||
export default function BlogView() {
|
||||
return (
|
||||
<>
|
||||
|
||||
{/* ============ HERO ============ */}
|
||||
<section className="mu-hero">
|
||||
<img className="mu-hero-map" src="/image/network/overview-map.png" alt="" aria-hidden="true" decoding="async" />
|
||||
<div className="mu-blob one" />
|
||||
<div className="mu-blob two" />
|
||||
<div className="mu-blob three" />
|
||||
<div className="mu-container mu-hero-content">
|
||||
<span className="mu-badge"><svg className="ic" aria-hidden="true"><use href="#ic-message-circle" /></svg> <span data-i18n="nav.blog">บ่นไปเรื่อย</span></span>
|
||||
<h1><span data-i18n="blog.title">บ่นไปเรื่อย</span><br /><span className="mu-gradient-text" data-i18n="blog.subtitle">หน้านี้ก็เหมือนไดอารี่ของเรา อยากบ่นอะไรก็บ่น</span></h1>
|
||||
<p className="mu-hero-lead" data-i18n="blog.lead">ขอบคุณที่เข้ามาอ่านบางบทความก็มีสาระบางบทความก็ไม่มีสาระ </p>
|
||||
</div>
|
||||
</section>
|
||||
{/* ============ รายการบทความ (โหลดจาก blog-data: text1.json + pic1, ...) ============ */}
|
||||
<section className="mu-blog-wrap">
|
||||
<div className="mu-container">
|
||||
<div className="mu-blog-bar" id="blog-bar" hidden>
|
||||
<p className="mu-blog-count" id="blog-count" />
|
||||
<div className="mu-view-switch" role="group" aria-label="มุมมอง">
|
||||
<button type="button" className="mu-view-btn" data-view="grid">
|
||||
<svg className="ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><rect width={7} height={7} x={3} y={3} rx={1} /><rect width={7} height={7} x={14} y={3} rx={1} /><rect width={7} height={7} x={14} y={14} rx={1} /><rect width={7} height={7} x={3} y={14} rx={1} /></svg>
|
||||
<span data-i18n="blog.viewGrid">ตาราง</span>
|
||||
</button>
|
||||
<button type="button" className="mu-view-btn" data-view="list">
|
||||
<svg className="ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><line x1={8} x2={21} y1={6} y2={6} /><line x1={8} x2={21} y1={12} y2={12} /><line x1={8} x2={21} y1={18} y2={18} /><line x1={3} x2="3.01" y1={6} y2={6} /><line x1={3} x2="3.01" y1={12} y2={12} /><line x1={3} x2="3.01" y1={18} y2={18} /></svg>
|
||||
<span data-i18n="blog.viewList">รายการ</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="blog-list" aria-live="polite">
|
||||
<div className="mu-blog-skel" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/* Ported from web-at-transit-mock/ui/partials/checkSchedule.html — markup 1:1 with the mock. */
|
||||
import "@/styles/pages/check.css";
|
||||
export default function CheckView() {
|
||||
return (
|
||||
<>
|
||||
|
||||
{/* ============ HERO (ภาษาเดียวกับหน้าแรก) ============ */}
|
||||
<section className="mu-hero">
|
||||
<img className="mu-hero-map" src="/image/network/overview-map.png" alt="" aria-hidden="true" fetchPriority="high" decoding="async" />
|
||||
<div className="mu-blob one" />
|
||||
<div className="mu-blob two" />
|
||||
<div className="mu-blob three" />
|
||||
<div className="mu-container mu-hero-content">
|
||||
<span className="mu-badge"><svg className="ic" aria-hidden="true"><use href="#ic-clock" /></svg> <span data-i18n="cta.check">เช็กเวลาเดินรถ</span></span>
|
||||
<h1><span data-i18n="check.title">ตารางเวลาเดินรถ</span><br /><span className="mu-gradient-text" id="check-hero-route" /></h1>
|
||||
<p className="mu-hero-lead" data-i18n="check.lead">เลือกสายรถ แล้วดูรอบรถทุกจุดจอดในหน้าเดียว</p>
|
||||
<div className="mu-route-selector single">
|
||||
<div className="mu-select-field">
|
||||
<label htmlFor="check-route-select">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M8 6v6" /><path d="M15 6v6" /><path d="M2 12h19.6" /><path d="M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3" /><circle cx={7} cy={18} r={2} /><path d="M9 18h5" /><circle cx={16} cy={18} r={2} /></svg>
|
||||
<span data-i18n="route.selectRoute">เลือกสายรถ</span>
|
||||
</label>
|
||||
<div className="mu-select-box">
|
||||
<svg className="mu-select-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M8 6v6" /><path d="M15 6v6" /><path d="M2 12h19.6" /><path d="M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3" /><circle cx={7} cy={18} r={2} /><path d="M9 18h5" /><circle cx={16} cy={18} r={2} /></svg>
|
||||
<select id="check-route-select" data-i18n-attr="aria-label:route.selectRoute" />
|
||||
<svg className="mu-select-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6" /></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{/* ============ สรุปเส้นทาง (สถิติแบบ index) ============ */}
|
||||
<section className="mu-summary" aria-label="สรุปเส้นทาง">
|
||||
<div className="mu-container">
|
||||
<div className="mu-summary-grid">
|
||||
<div className="mu-stat tag-purple"><h3 id="check-stat-stops">–</h3><p data-i18n="check.kpiStops">จุดจอดหลัก</p></div>
|
||||
<div className="mu-stat tag-sky"><h3 id="check-stat-provinces">–</h3><p data-i18n="check.kpiProvince">จังหวัดที่ผ่าน</p></div>
|
||||
<div className="mu-stat tag-mint"><h3 id="check-stat-trips">–</h3><p data-i18n="check.kpiTrips">รอบต่อวัน</p></div>
|
||||
<div className="mu-stat tag-pink"><h3 id="check-stat-next">–</h3><p data-i18n="check.kpiNext">รอบถัดไป</p></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{/* ============ ตารางเวลาเดินรถ ============ */}
|
||||
<section className="mu-schedule" aria-label="ตารางเวลาเดินรถ">
|
||||
<div className="mu-container">
|
||||
<div className="mu-zone">
|
||||
<div className="mu-zone-head">
|
||||
<span className="mu-zone-tag tag-purple" data-i18n="check.scheduleAll">ตารางเวลาเดินรถทุกจุดจอด</span>
|
||||
<p className="mu-zone-desc mu-zone-meta" id="check-zone-desc" />
|
||||
<p className="mu-zone-desc mu-zone-meta mu-zone-now" id="check-now-line" />
|
||||
<p className="mu-zone-desc mu-zone-updated" id="check-updated-line" />
|
||||
</div>
|
||||
{/* การ์ดจุดจอด + ชิปเวลา: สร้างจาก resource/data/schedules.json (checkSchedule.init.js) */}
|
||||
<ul className="mu-schedule-list" id="check-schedule-list" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/* Ported from web-at-transit-mock/ui/partials/credits.html — markup 1:1 with the mock. */
|
||||
import "@/styles/pages/credits.css";
|
||||
export default function CreditsView() {
|
||||
return (
|
||||
<>
|
||||
<main className="mu-page">
|
||||
<div className="mu-credit-wrap">
|
||||
<div className="mu-credit-hero">
|
||||
<p className="mu-breadcrumb"><a href="/">หน้าแรก</a>/ เครดิต</p>
|
||||
<h1><span data-i18n="credits.title">เครดิตและแหล่งที่มา</span></h1>
|
||||
<p>รายการทรัพยากรทั้งหมดที่ใช้ในเว็บนี้ พร้อมใบอนุญาต (license) ตามข้อกำหนดของเจ้าของแต่ละราย</p>
|
||||
</div>
|
||||
<section className="mu-credit-section">
|
||||
<h2><span data-i18n="credits.icons">ไอคอน — Lucide</span></h2>
|
||||
<p className="src">แหล่งที่มา: <a href="https://lucide.dev" rel="noopener">lucide.dev</a> · ใบอนุญาต: <a href="https://github.com/lucide-icons/lucide/blob/main/LICENSE" rel="noopener">MIT License</a> — ใช้ได้ฟรีทั้งส่วนบุคคลและเชิงพาณิชย์ โดยไม่ต้องระบุเครดิต แต่เราระบุไว้เพื่อความโปร่งใส</p>
|
||||
<ul>
|
||||
<li>ไอคอนที่ใช้ทั้งหมด 15 รายการ เก็บที่ <code>/image/icons/lucide/</code></li>
|
||||
<li>alarm-clock, arrow-right, bus, bus-front, check, clock, globe, hourglass, map, map-pin, message-circle, phone, refresh-cw, search, triangle-alert</li>
|
||||
<li>วิธีใช้งาน: sprite <code>src/components/IconSprite.tsx</code> + <code><svg class="ic"><use href="#ic-ชื่อ"></code></li>
|
||||
</ul>
|
||||
<div className="mu-license">
|
||||
<strong>MIT License (สรุป):</strong> อนุญาตให้ใช้ คัดลอก แก้ไข ผสาน เผยแพร่ แจกจ่าย ขาย และ/หรือให้สิทธิ์ใช้งานซอฟต์แวร์นี้ โดยมีเงื่อนไขให้ข้อความแสดงลิขสิทธิ์และข้อความอนุญาตข้างต้นปรากฏอยู่ในสำเนาทั้งหมดหรือส่วนสำคัญของซอฟต์แวร์ ซอฟต์แวร์นี้ให้บริการ "ตามสภาพ" โดยไม่มีการรับประกันใด ๆ
|
||||
</div>
|
||||
</section>
|
||||
<section className="mu-credit-section">
|
||||
<h2><span data-i18n="credits.fonts">ฟอนต์ — Google Fonts</span></h2>
|
||||
<p className="src">แหล่งที่มา: <a href="https://fonts.google.com" rel="noopener">fonts.google.com</a> · ใบอนุญาต: <a href="https://openfontlicense.org" rel="noopener">SIL Open Font License 1.1</a></p>
|
||||
<ul>
|
||||
<li><strong>K2D</strong> — ฟอนต์หลักของเว็บ (เนื้อหา + หัวเรื่อง) · มีหัวแบบไทย น้ำหนัก 300–800</li>
|
||||
<li><strong>Noto Sans Thai</strong> — ตัวสำรองเนื้อหา (โหลดผ่าน Google Fonts CDN)</li>
|
||||
<li><strong>Prompt</strong> — ตัวสำรองหัวเรื่อง/ตัวหนา</li>
|
||||
<li><strong>IBM Plex Mono</strong> — เวลา · เลขสาย · ตัวเลข (เรียงตรงกัน)</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section className="mu-credit-section">
|
||||
<h2><span data-i18n="credits.map">แผนที่</span></h2>
|
||||
<p className="src">ใบอนุญาต: Leaflet <a href="https://github.com/Leaflet/Leaflet/blob/main/LICENSE" rel="noopener">BSD-2-Clause</a> · ชุดแผนที่ (tiles): <a href="https://www.openstreetmap.org/copyright" rel="noopener">OpenStreetMap © ผู้มีส่วนร่วม (ODbL)</a></p>
|
||||
<ul>
|
||||
<li>Leaflet — ไลบรารีแผนที่แบบ open-source</li>
|
||||
<li>OpenStreetMap — ภาพ tiles และข้อมูลแผนที่ที่ใช้แสดงผล</li>
|
||||
<li>เส้นทางเดินรถ จุดจอด และหมุดสถานี วาดจากข้อมูล GIS ของทีม (<code>GeoJSON</code>) ทับบนแผนที่</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section className="mu-credit-section">
|
||||
<h2><span data-i18n="credits.photos">ขอขอบคุณภาพรถประจำทาง</span></h2>
|
||||
<p className="src">ภาพรถโดยสารประจำทางที่แสดงในหน้ารายละเอียดสาย มาจากแหล่งข้อมูลสาธารณะด้านล่างนี้ — ขอบคุณเจ้าของภาพและผู้รวบรวมทุกท่าน</p>
|
||||
<ul>
|
||||
<li><strong>สาย 2194</strong> หัวเวียง-อยุธยา — จาก <a href="http://www.bangkokbusclub.com/cms/showthread.php?t=4968" rel="noopener">bangkokbusclub.com</a></li>
|
||||
<li><strong>สาย 8</strong> กรุงเทพ-สรรคบุรี-ชัยนาท — จาก <a href="https://web.facebook.com/groups/431811197419587/posts/2006978336569524/" rel="noopener">กลุ่ม Facebook (web.facebook.com)</a></li>
|
||||
<li><strong>สาย 954</strong> กรุงเทพ-ท่าช้าง — จาก <a href="https://gogo.town/route/bangkok-rangsit-angthong-thachang/" rel="noopener">gogo.town</a></li>
|
||||
<li><strong>รถไฟฟ้าสายสีแดง </strong> กรุงเทพ-ชุมทางบ้านภาชี — จาก <a href="https://thelist.group/realist/blog/%E0%B8%A3%E0%B8%96%E0%B9%84%E0%B8%9F%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%AA%E0%B8%B2%E0%B8%A2%E0%B8%AA%E0%B8%B5%E0%B9%81%E0%B8%94%E0%B8%87/" rel="noopener">thelist.group</a></li>
|
||||
</ul>
|
||||
<p className="mu-license">
|
||||
<span data-i18n="credits.photosNote">และสายอื่น ๆ ที่ไม่ได้ระบุ ขอขอบคุณมา ณ ที่นี้</span>
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/* Ported from web-at-transit-mock/ui/partials/home.html — markup 1:1 with the mock. */
|
||||
import "@/styles/pages/home.css";
|
||||
export default function HomeView() {
|
||||
return (
|
||||
<>
|
||||
|
||||
<section className="mu-hero">
|
||||
<img className="mu-hero-map" src="/image/network/overview-map.png" alt="" aria-hidden="true" fetchPriority="high" decoding="async" />
|
||||
<div className="mu-blob one" />
|
||||
<div className="mu-blob two" />
|
||||
<div className="mu-blob three" />
|
||||
<div className="mu-container mu-hero-content">
|
||||
<span className="mu-badge" data-i18n="home.welcome">ยินดีต้อนรับ</span>
|
||||
<h1><span data-i18n="home.title1">สถานีขนส่งผู้โดยสารภายใน</span><br /><span className="mu-gradient-text" id="hero-province">จังหวัดอ่างทอง</span></h1>
|
||||
<div className="mu-route-selector">
|
||||
<div className="mu-select-field">
|
||||
<label htmlFor="province-select">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" /><circle cx={12} cy={10} r={3} /></svg>
|
||||
<span data-i18n="home.chooseProvince">เลือกจังหวัด</span>
|
||||
</label>
|
||||
<div className="mu-select-box">
|
||||
<svg className="mu-select-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" /><circle cx={12} cy={10} r={3} /></svg>
|
||||
<select id="province-select" data-i18n-attr="aria-label:home.chooseProvince" />
|
||||
<svg className="mu-select-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6" /></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span className="mu-select-arrow" aria-hidden="true"><svg className="ic"><use href="#ic-arrow-right" /></svg></span>
|
||||
<div className="mu-select-field">
|
||||
<label htmlFor="station-select">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M8 6v6" /><path d="M15 6v6" /><path d="M2 12h19.6" /><path d="M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3" /><circle cx={7} cy={18} r={2} /><path d="M9 18h5" /><circle cx={16} cy={18} r={2} /></svg>
|
||||
<span data-i18n="home.chooseStation">สถานีขนส่งผู้โดยสาร</span>
|
||||
</label>
|
||||
<div className="mu-select-box">
|
||||
<svg className="mu-select-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M8 6v6" /><path d="M15 6v6" /><path d="M2 12h19.6" /><path d="M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3" /><circle cx={7} cy={18} r={2} /><path d="M9 18h5" /><circle cx={16} cy={18} r={2} /></svg>
|
||||
<select id="station-select" data-i18n-attr="aria-label:home.chooseStation" />
|
||||
<svg className="mu-select-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6" /></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p className="mu-select-hint" id="station-hint" aria-live="polite" />
|
||||
</div>
|
||||
</section>
|
||||
<section className="mu-sponsor-marquee" aria-label="ผู้สนับสนุนและพาร์ทเนอร์">
|
||||
<div className="mu-sponsor-head">
|
||||
<h4 data-i18n="footer.sponsors">ผู้สนับสนุน & พาร์ทเนอร์</h4>
|
||||
<p className="lead" data-i18n="footer.sponsorsLead">ร่วมเป็นผู้สนับสนุนเราได้ เมื่อซื้อของออนไลน์ หรือซื้อตั๋วรถทัวร์ เครื่องบิน ออนไลน์กดเลือกสินค้า หรือบริการผ่านลิงค์นายหน้าของเราไม่มีค่าใช้จ่ายเพิ่ม</p>
|
||||
</div>
|
||||
<div className="mu-marquee">
|
||||
<div className="mu-marquee-track">
|
||||
<a className="mu-marquee-tile" href="#" aria-label="7-Eleven"><img src="/image/partners/7-11.png" alt="7-Eleven" decoding="async" /></a>
|
||||
<a className="mu-marquee-tile" href="#" aria-label="Shopee"><img src="/image/partners/shopee.png" alt="Shopee" decoding="async" /></a>
|
||||
<a className="mu-marquee-tile" href="#" aria-label="Lazada"><img src="/image/partners/lazada.png" alt="Lazada" decoding="async" /></a>
|
||||
<a className="mu-marquee-tile" href="#" aria-label="airasia MOVE"><img src="/image/partners/airasia-move.png" alt="airasia MOVE" decoding="async" /></a>
|
||||
<a className="mu-marquee-tile" href="#" aria-label="busonlineticket"><img src="/image/partners/busonlineticket.png" alt="busonlineticket" decoding="async" /></a>
|
||||
<a className="mu-marquee-tile" href="#" aria-label="Trip.com"><img src="/image/partners/trip.jpg" alt="Trip.com" decoding="async" /></a>
|
||||
<a className="mu-marquee-tile" href="#" aria-label="truck2hand"><img src="/image/partners/truck2hand.png" alt="truck2hand" decoding="async" /></a>
|
||||
<a className="mu-marquee-tile" href="#" aria-label="ทีซีแอล 999 อ่างทอง"><img src="/image/partners/tcl999-angthong.jpg" alt="ทีซีแอล 999 อ่างทอง" decoding="async" /></a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<main className="mu-main">
|
||||
<div className="mu-container">
|
||||
{/* คำอธิบายสีการ์ดตามหมวดเส้นทาง */}
|
||||
<section className="mu-legend" aria-label="คำอธิบายสีการ์ดตามหมวดเส้นทาง">
|
||||
<h2 className="mu-legend-title" data-i18n="legend.title">คำอธิบายสีการ์ดตามหมวดเส้นทาง</h2>
|
||||
<ul className="mu-legend-list">
|
||||
<li><span className="sw sw-bangkok" aria-hidden="true" /><span data-i18n="legend.bangkok">หมวดเส้นทางเข้ากรุงเทพฯ — การ์ดสีน้ำเงิน</span></li>
|
||||
<li><span className="sw sw-interprov" aria-hidden="true" /><span data-i18n="legend.interprov">หมวดเส้นทางระหว่างจังหวัด — การ์ดสีม่วง</span></li>
|
||||
<li><span className="sw sw-inprov" aria-hidden="true" /><span data-i18n="legend.inprov">หมวดเส้นทางภายในจังหวัด — การ์ดสีชมพู</span></li>
|
||||
<li><span className="sw sw-municipal" aria-hidden="true" /><span data-i18n="legend.municipal">หมวดเส้นทางภายในเทศบาล — การ์ดสีเหลืองอ่อน</span></li>
|
||||
<li><span className="sw sw-empty" aria-hidden="true" /><span data-i18n="legend.empty">ยังไม่มีข้อมูล — การ์ดสีเทา แสดง N/A แทนเลขสาย</span></li>
|
||||
</ul>
|
||||
<p className="mu-legend-note" data-i18n="legend.note">อ่างทองยังไม่มีรถหมวด 1 (เส้นทางภายในเทศบาล) จึงแสดงการ์ดสีเทาและใช้ N/A แทนตัวเลขสายเส้นทาง</p>
|
||||
</section>
|
||||
{/* หมวดเส้นทางทั้งหมด: สร้างจาก resource/data/route_groups.json + routes.json (+ routes_municipal.json)
|
||||
ที่มา: ui/partials/home.init.js → initRouteZones() — ห้าม hardcode การ์ดในไฟล์นี้ */}
|
||||
<div id="route-zones" />
|
||||
{/* ปุ่มแชร์ลิงก์สั้น (มุมล่างขวา ต่อจากการ์ดหมวดเส้นทางภายในจังหวัด) */}
|
||||
<div className="mu-share-row">
|
||||
<button type="button" className="mu-share-btn" id="share-btn">
|
||||
<svg className="ic" aria-hidden="true"><use href="#ic-share-2" /></svg>
|
||||
<span data-i18n="share.label">แชร์ลิงก์สั้น</span>
|
||||
</button>
|
||||
<p className="mu-share-status" id="share-status" aria-live="polite" />
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/* Ported from web-at-transit-mock/ui/partials/busDetail.html — markup 1:1 with the mock. */
|
||||
import "@/styles/pages/route.css";
|
||||
export default function RouteView() {
|
||||
return (
|
||||
<>
|
||||
<main className="mu-page">
|
||||
<div className="mu-container">
|
||||
<p className="mu-breadcrumb"><a href="/">หน้าแรก</a>/ <span data-i18n="nav.routes">รายละเอียดสายรถ</span></p>
|
||||
<h1 className="mu-page-title"><span className="mu-route-chip" id="route-chip" /> <span id="route-title" /></h1>
|
||||
{/* ตัวเลือกสายรถ: เติมจาก resource/data/routes.json (busDetail.init.js) */}
|
||||
<form className="mu-toolbar" data-prevent-submit="1">
|
||||
<select aria-label="เลือกสายรถ" id="route-select" />
|
||||
</form>
|
||||
{/* ============ รถประจำสาย + ติดต่อผู้ประกอบการ (การ์ดเดียว) ============ */}
|
||||
{/* รูปรถ/คำอธิบาย/QR/เบอร์โทร: เติมจาก resource/data/captions/caption<รหัสสาย>.json + routes.json */}
|
||||
<section className="mu-vehicle-card" aria-label="รถประจำสายและติดต่อผู้ประกอบการ" id="route-vehicle-card">
|
||||
<img id="route-vehicle-img" alt="" loading="lazy" decoding="async" hidden />
|
||||
<div className="meta">
|
||||
<p className="label" data-i18n="route.vehicle">รถประจำสาย</p>
|
||||
<h2 id="route-vehicle-title" hidden />
|
||||
<p id="route-vehicle-desc" hidden />
|
||||
</div>
|
||||
<div className="mu-vehicle-contact" id="route-contact" />
|
||||
</section>
|
||||
{/* ============ สรุปเส้นทาง ============ */}
|
||||
<section className="mu-summary" aria-label="สรุปเส้นทาง">
|
||||
<div className="mu-container">
|
||||
<div className="mu-summary-grid">
|
||||
<div className="mu-stat tag-purple"><h3 id="stat-stops">–</h3><p>จุดจอดหลัก</p></div>
|
||||
<div className="mu-stat tag-sky"><h3 id="stat-provinces">–</h3><p>จังหวัดที่ผ่าน</p></div>
|
||||
<div className="mu-stat tag-mint"><h3 id="stat-trips">–</h3><p>รอบต่อวัน</p></div>
|
||||
<div className="mu-stat tag-pink"><h3 id="stat-next">–</h3><p>รอบถัดไป</p></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{/* ============ แผนที่เส้นทาง (Leaflet + GeoJSON จาก QGIS) ============ */}
|
||||
<section className="mu-zone" aria-label="แผนที่เส้นทาง">
|
||||
<div className="mu-zone-head">
|
||||
<span className="mu-zone-tag tag-sky" data-i18n="route.mapTitle">เส้นทางเดินรถ</span>
|
||||
<p className="mu-zone-desc" data-i18n="route.mapDesc">เส้นทางจริงจากข้อมูล GIS · ป้ายหยุดรถตามเส้นทาง</p>
|
||||
</div>
|
||||
<div className="mu-map-card">
|
||||
<div className="at-map" id="route-map" role="region" aria-label="แผนที่เส้นทางเดินรถ" />
|
||||
<p className="at-map-caption" id="route-map-caption" />
|
||||
<div className="at-km-wrap" hidden>
|
||||
<h3><span data-i18n="map.alongRoute">จุดจอดตามเส้นทาง (กม. จากต้นทาง)</span></h3>
|
||||
<ul id="route-map-list" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/* Ported from web-at-transit-mock/ui/partials/stopDetail.html — markup 1:1 with the mock. */
|
||||
import "@/styles/pages/stop.css";
|
||||
export default function StopView() {
|
||||
return (
|
||||
<>
|
||||
<main className="mu-page">
|
||||
<div className="mu-container">
|
||||
<p className="mu-breadcrumb" id="stop-breadcrumb" />
|
||||
<section className="mu-stop-hero">
|
||||
<div>
|
||||
<h1 className="mu-stop-hero-title"><svg className="ic" aria-hidden="true"><use href="#ic-map-pin" /></svg> <span id="stop-title" /></h1>
|
||||
<p className="mu-stop-hero-sub" id="stop-sub" />
|
||||
<div className="mu-meta-row" id="stop-meta" />
|
||||
<div className="mu-hero-metric-grid" id="stop-metrics" />
|
||||
</div>
|
||||
<div>
|
||||
<img className="mu-stop-hero-photo" id="stop-photo" alt="" fetchPriority="high" decoding="async" hidden />
|
||||
<div className="mu-live-clock-card" id="mu-live-clock-card">
|
||||
<div>
|
||||
<p className="mu-live-clock-title" data-i18n="stop.nowAtStop">เวลาปัจจุบัน ณ ป้ายนี้</p>
|
||||
<p className="mu-live-clock-time" id="mu-current-time">--:--</p>
|
||||
</div>
|
||||
<p className="mu-live-clock-note"><span className="mu-live-dot" /><span data-i18n="stop.autoNext">กำลังคำนวณเที่ยวถัดไปอัตโนมัติ</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section className="mu-nearby" id="stop-nearby" aria-label="สถานที่ใกล้เคียง" hidden>
|
||||
<h2><span data-i18n="stop.nearby">ใกล้เคียงป้าย</span></h2>
|
||||
<p className="sub" id="stop-nearby-sub" />
|
||||
<div className="mu-nearby-grid" id="stop-nearby-grid" />
|
||||
</section>
|
||||
<div className="mu-toolbar" id="stop-toolbar" />
|
||||
<section className="mu-info-grid" id="stop-info" aria-label="stop highlights" />
|
||||
<section className="mu-layout-grid">
|
||||
<div className="mu-card-panel">
|
||||
<h2><span data-i18n="stop.routes">สายรถที่ผ่านจุดนี้</span></h2>
|
||||
<div className="mu-route-tools">
|
||||
<input id="mu-route-filter" className="mu-route-filter" type="text" placeholder="ค้นหาสายรถหรือปลายทาง" data-i18n-attr="placeholder:stop.searchRoute,aria-label:stop.searchRoute" />
|
||||
<span className="mu-route-count" id="mu-route-count" />
|
||||
</div>
|
||||
<ul className="mu-list mu-stop-list" id="stop-routes" />
|
||||
</div>
|
||||
<aside className="mu-card-panel">
|
||||
<h2><span data-i18n="stop.mapInfo">แผนที่และข้อมูลป้าย</span></h2>
|
||||
<div className="at-map" id="stop-map" role="region" aria-label="แผนที่เส้นทางที่ผ่านป้ายนี้" />
|
||||
<p className="at-map-caption" id="stop-map-caption" />
|
||||
<div id="stop-chips" style={{display: 'flex', flexWrap: 'wrap', gap: 8, marginTop: 14}} />
|
||||
</aside>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/* Ported from web-at-transit-mock/ui/partials/busStop.html — markup 1:1 with the mock. */
|
||||
import "@/styles/pages/stops.css";
|
||||
export default function StopsView() {
|
||||
return (
|
||||
<>
|
||||
<main className="mu-page">
|
||||
<div className="mu-container">
|
||||
<p className="mu-breadcrumb"><a href="/" data-i18n="nav.home">หน้าแรก</a>/ <span data-i18n="nav.stops">ป้ายหยุดรถ</span></p>
|
||||
<section className="mu-hero-panel">
|
||||
<div>
|
||||
<h1 className="mu-hero-title"><span data-i18n="stops.title">ค้นหาป้ายหยุดรถแบบรวดเร็ว</span></h1>
|
||||
<p className="mu-hero-subtitle"><span data-i18n="stops.subtitle">ค้นหาด้วยรหัสหลักกิโลเมตรของป้าย หรือค้นหาด้วยชื่อสถานที่สำคัญ</span></p>
|
||||
<div className="mu-kpi-grid" id="stops-kpi" aria-label="summary metrics" />
|
||||
</div>
|
||||
<div className="mu-hero-map">
|
||||
<p className="mu-hero-map-title"><span data-i18n="stops.mapTitle">แผนที่ย่อของเครือข่ายป้าย</span></p>
|
||||
<div className="mu-hero-map-box">
|
||||
<img className="mu-hero-map-photo" src="/image/network/overview-map.png" alt="แผนที่เครือข่ายป้าย Atroute" loading="lazy" decoding="async" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<form className="mu-toolbar" id="stops-form" data-prevent-submit="1">
|
||||
{/* โหมดค้นหา: เลือกอย่างใดอย่างหนึ่ง (ห้ามชนกัน) */}
|
||||
<div className="mu-search-tabs" role="tablist" aria-label="รูปแบบการค้นหา">
|
||||
<button type="button" className="mu-search-tab" data-mode="code" role="tab" aria-selected="true">
|
||||
<svg className="ic" aria-hidden="true"><use href="#ic-map-pin" /></svg>
|
||||
<span data-i18n="stops.modeCode">ค้นหาด้วยรหัสป้าย</span>
|
||||
</button>
|
||||
<button type="button" className="mu-search-tab" data-mode="place" role="tab" aria-selected="false">
|
||||
<svg className="ic" aria-hidden="true"><use href="#ic-landmark" /></svg>
|
||||
<span data-i18n="stops.modePlace">ค้นหาด้วยชื่อสถานที่</span>
|
||||
</button>
|
||||
</div>
|
||||
{/* โหมด 1: รหัสป้าย (5 ช่อง: 2 หน้า + 3 หลัง) */}
|
||||
<div className="mu-search-mode" id="stops-code-wrap">
|
||||
<div className="mu-code-boxes" id="stops-code-boxes" role="group" data-i18n-attr="aria-label:stops.codePh" aria-label="รหัสป้าย">
|
||||
<input className="mu-code-cell" type="text" inputMode="numeric" maxLength={1} autoComplete="off" aria-label="หลักที่ 1" placeholder="0" />
|
||||
<input className="mu-code-cell" type="text" inputMode="numeric" maxLength={1} autoComplete="off" aria-label="หลักที่ 2" placeholder="0" />
|
||||
<span className="mu-code-plus" aria-hidden="true">+</span>
|
||||
<input className="mu-code-cell" type="text" inputMode="numeric" maxLength={1} autoComplete="off" aria-label="หลักที่ 3" placeholder="0" />
|
||||
<input className="mu-code-cell" type="text" inputMode="numeric" maxLength={1} autoComplete="off" aria-label="หลักที่ 4" placeholder="0" />
|
||||
<input className="mu-code-cell" type="text" inputMode="numeric" maxLength={1} autoComplete="off" aria-label="หลักที่ 5" placeholder="0" />
|
||||
</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>
|
||||
<div className="mu-search-field">
|
||||
<svg className="ic" aria-hidden="true"><use href="#ic-search" /></svg>
|
||||
<input type="search" id="stops-place-input" autoComplete="off" placeholder="โรงพยาบาลอ่างทอง" data-i18n-attr="placeholder:stops.placePh,aria-label:stops.placePh" />
|
||||
</div>
|
||||
<div className="mu-suggest" id="stops-suggest" hidden />
|
||||
<p className="mu-search-hint" data-i18n="stops.placeHint">พิมพ์ชื่อสถานที่สำคัญ เช่น โรงพยาบาล สำนักงานที่ดิน แล้วเลือกรายการที่ตรงกัน</p>
|
||||
</div>
|
||||
<div className="mu-toolbar-actions">
|
||||
<button type="button" className="mu-btn primary" id="stops-search-btn"><span data-i18n="common.search">ค้นหา</span></button>
|
||||
<button type="button" className="mu-btn ghost" id="stops-reset-btn"><span data-i18n="stops.reset">ล้างค่า</span></button>
|
||||
<button type="button" className="mu-btn ghost" id="near-me-btn">
|
||||
<svg className="ic" aria-hidden="true"><use href="#ic-map-pin" /></svg>
|
||||
<span data-i18n="map.useMyLocation">ป้ายใกล้ฉัน</span>
|
||||
</button>
|
||||
<a className="mu-btn ghost" href="/"><span data-i18n="common.back">ย้อนกลับ</span></a>
|
||||
</div>
|
||||
<p className="mu-toolbar-count" id="stops-count" hidden />
|
||||
</form>
|
||||
<div id="near-me-result" className="mu-near-wrap" hidden />
|
||||
<ul className="mu-stop-grid" id="stops-list" />
|
||||
<div className="mu-show-more">
|
||||
<button type="button" className="mu-btn outline" id="stops-show-all" data-i18n="stops.showAll" hidden>แสดงป้ายทั้งหมด</button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Runtime bootstrap for the ported mock UI.
|
||||
*
|
||||
* The mock (web-at-transit-mock) used classic <script> tags plus a hash router.
|
||||
* In Next.js the shared libraries are ES modules that attach the same
|
||||
* `window.*` globals, and each page exposes a `mount()` function instead of a
|
||||
* DOMContentLoaded bootstrap. Import order matters: page modules rely on
|
||||
* I18N, ATMap, Schedules and OtherStop being present.
|
||||
*/
|
||||
|
||||
export type MockRoute = {
|
||||
params: Record<string, string>;
|
||||
query: Record<string, string>;
|
||||
};
|
||||
|
||||
type PageModule = { default: () => void };
|
||||
|
||||
let bootPromise: Promise<void> | null = null;
|
||||
|
||||
export function ensureRuntime(): Promise<void> {
|
||||
if (typeof window === "undefined") return Promise.resolve();
|
||||
if (!bootPromise) {
|
||||
bootPromise = (async () => {
|
||||
await import("./ui/imageurl");
|
||||
await import("./ui/i18n");
|
||||
await import("./ui/popular");
|
||||
await import("./ui/visitors");
|
||||
await import("./ui/map");
|
||||
await import("./ui/schedules");
|
||||
await import("./ui/otherStop");
|
||||
|
||||
const w = window as unknown as {
|
||||
I18N?: { ready?: Promise<unknown>; apply?: () => void };
|
||||
};
|
||||
if (w.I18N?.ready) await w.I18N.ready;
|
||||
w.I18N?.apply?.();
|
||||
})();
|
||||
}
|
||||
return bootPromise;
|
||||
}
|
||||
|
||||
/** The mock partials contained `onsubmit="return false"`; keep that behaviour. */
|
||||
function preventFormSubmit() {
|
||||
if (typeof document === "undefined") return;
|
||||
if ((document as unknown as { __mockSubmitGuard?: boolean }).__mockSubmitGuard) return;
|
||||
(document as unknown as { __mockSubmitGuard?: boolean }).__mockSubmitGuard = true;
|
||||
document.addEventListener(
|
||||
"submit",
|
||||
(event) => {
|
||||
const form = event.target as HTMLElement | null;
|
||||
if (form?.closest?.("[data-prevent-submit]")) event.preventDefault();
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
/** Mount one ported page module with the route context the mock expected. */
|
||||
export async function mountPage(
|
||||
route: MockRoute,
|
||||
load: () => Promise<PageModule>,
|
||||
): Promise<void> {
|
||||
await ensureRuntime();
|
||||
const w = window as unknown as {
|
||||
__route?: MockRoute;
|
||||
I18N?: { apply?: () => void };
|
||||
};
|
||||
w.__route = route;
|
||||
preventFormSubmit();
|
||||
const mod = await load();
|
||||
mod.default();
|
||||
w.I18N?.apply?.();
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/about.init.js — logic unchanged; bootstrap converted to mount(). */
|
||||
/* ============================================================
|
||||
หน้าเกี่ยวกับเรา — loader
|
||||
------------------------------------------------------------
|
||||
อ่านเนื้อหาจาก partials/about-data/ เรียงสลับกันไปเรื่อย ๆ:
|
||||
text1.json + pic1.<ext> , text2.json + pic2.<ext> , ...
|
||||
- textN.json: { "th": { "title": "...", "body": ["...", "..."] },
|
||||
"en": { "title": "...", "body": [...] } }
|
||||
(ไม่เขียน en → โหมด EN ใช้ th แทน)
|
||||
- picN รองรับ .jpg .jpeg .png .webp
|
||||
- หยุดเองเมื่อหา textN.json ถัดไปไม่เจอ
|
||||
============================================================ */
|
||||
/* ---- ported module body ---- */
|
||||
'use strict';
|
||||
|
||||
var DATA_DIR = '/content/about-data/';
|
||||
var IMG_EXTS = ['jpg', 'jpeg', 'png', 'webp'];
|
||||
var MAX_BLOCKS = 30;
|
||||
|
||||
function lang() {
|
||||
return (window.I18N && I18N.getLang()) || 'th';
|
||||
}
|
||||
|
||||
function pick(data, l) {
|
||||
if (!data) return null;
|
||||
if (l !== 'th' && data[l]) return data[l];
|
||||
return data.th || data[l] || data[Object.keys(data)[0]] || data;
|
||||
}
|
||||
|
||||
function fetchJSON(n) {
|
||||
return fetch(DATA_DIR + 'text' + n + '.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.catch(function () { return null; });
|
||||
}
|
||||
|
||||
function findImage(n) {
|
||||
var i = 0;
|
||||
function tryNext() {
|
||||
if (i >= IMG_EXTS.length) return Promise.resolve(null);
|
||||
var url = DATA_DIR + 'pic' + n + '.' + IMG_EXTS[i++];
|
||||
return fetch(url, { method: 'HEAD', cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? url : tryNext(); })
|
||||
.catch(tryNext);
|
||||
}
|
||||
return tryNext();
|
||||
}
|
||||
|
||||
function renderBlock(host, data, imgUrl) {
|
||||
var c = pick(data, lang());
|
||||
if (!c) return;
|
||||
var art = document.createElement('article');
|
||||
art.className = 'mu-about-block';
|
||||
|
||||
var text = document.createElement('div');
|
||||
text.className = 'mu-about-text';
|
||||
var h2 = document.createElement('h2');
|
||||
h2.textContent = c.title || '';
|
||||
text.appendChild(h2);
|
||||
(c.body || c.paragraphs || []).forEach(function (p) {
|
||||
var el = document.createElement('p');
|
||||
el.textContent = p;
|
||||
text.appendChild(el);
|
||||
});
|
||||
art.appendChild(text);
|
||||
|
||||
if (imgUrl) {
|
||||
var media = document.createElement('div');
|
||||
media.className = 'mu-about-media';
|
||||
var img = document.createElement('img');
|
||||
img.src = imgUrl;
|
||||
img.alt = c.imgAlt || c.title || '';
|
||||
img.loading = 'lazy';
|
||||
img.decoding = 'async';
|
||||
media.appendChild(img);
|
||||
art.appendChild(media);
|
||||
}
|
||||
host.appendChild(art);
|
||||
}
|
||||
|
||||
function init() {
|
||||
var host = document.getElementById('about-blocks');
|
||||
if (!host) return;
|
||||
var cleared = false;
|
||||
|
||||
var n = 1;
|
||||
function next() {
|
||||
if (n > MAX_BLOCKS) return;
|
||||
var current = n++;
|
||||
fetchJSON(current).then(function (data) {
|
||||
if (!data) return; // ไม่มี textN ถัดไป → จบ
|
||||
if (!cleared) { host.innerHTML = ''; cleared = true; }
|
||||
findImage(current).then(function (imgUrl) {
|
||||
renderBlock(host, data, imgUrl);
|
||||
next();
|
||||
});
|
||||
});
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
export default function mount(): void {
|
||||
init();
|
||||
}
|
||||
@@ -0,0 +1,612 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/blog.init.js — logic unchanged; bootstrap converted to mount(). */
|
||||
/* ============================================================
|
||||
หน้าบทความ — loader + สลับมุมมอง ตาราง/รายการ + หน้าอ่านบทความ
|
||||
------------------------------------------------------------
|
||||
ข้อมูล: partials/blog-data/ (ระบบเดียวกับ about us)
|
||||
text1.json + pic1.<ext> , text2.json + pic2.<ext> , ...
|
||||
{ "th": { "title","body":["..."],"tag" }, "en": {...}, "date": "2026-09-01" }
|
||||
|
||||
route:
|
||||
#/blog → รายการบทความ (มุมมอง grid/list — จำค่าใน localStorage)
|
||||
#/blog/:n → อ่านบทความที่ n
|
||||
============================================================ */
|
||||
/* ---- ported module body ---- */
|
||||
'use strict';
|
||||
|
||||
var DATA_DIR = '/content/blog-data/';
|
||||
var IMG_EXTS = ['jpg', 'jpeg', 'png', 'webp'];
|
||||
var MAX_POSTS = 50;
|
||||
var LS_VIEW = 'at_blog_view';
|
||||
var EXCERPT_LEN = 150;
|
||||
|
||||
function lang() { return (window.I18N && I18N.getLang()) || 'th'; }
|
||||
function t(key) { return window.I18N ? I18N.t(key) : key; }
|
||||
|
||||
function pick(data, l) {
|
||||
if (!data) return null;
|
||||
if (l !== 'th' && data[l]) return data[l];
|
||||
return data.th || data[l] || data[Object.keys(data)[0]] || data;
|
||||
}
|
||||
|
||||
function fetchJSON(n) {
|
||||
return fetch(DATA_DIR + 'text' + n + '.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.catch(function () { return null; });
|
||||
}
|
||||
|
||||
function findImage(n) {
|
||||
var i = 0;
|
||||
function tryNext() {
|
||||
if (i >= IMG_EXTS.length) return Promise.resolve(null);
|
||||
var url = DATA_DIR + 'pic' + n + '.' + IMG_EXTS[i++];
|
||||
return fetch(url, { method: 'HEAD', cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? url : tryNext(); })
|
||||
.catch(tryNext);
|
||||
}
|
||||
return tryNext();
|
||||
}
|
||||
|
||||
function loadPosts() {
|
||||
var posts = [];
|
||||
var n = 1;
|
||||
function next() {
|
||||
if (n > MAX_POSTS) return Promise.resolve(posts);
|
||||
var current = n++;
|
||||
return fetchJSON(current).then(function (data) {
|
||||
if (!data) return posts;
|
||||
return findImage(current).then(function (imgUrl) {
|
||||
posts.push({ n: current, data: data, img: imgUrl });
|
||||
return next();
|
||||
});
|
||||
});
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
function getView() {
|
||||
try {
|
||||
var v = localStorage.getItem(LS_VIEW);
|
||||
return v === 'list' ? 'list' : 'grid';
|
||||
} catch (e) { return 'grid'; }
|
||||
}
|
||||
|
||||
function setView(v) {
|
||||
try { localStorage.setItem(LS_VIEW, v); } catch (e) {}
|
||||
}
|
||||
|
||||
function readTime(body) {
|
||||
var words = (body || []).join(' ').length;
|
||||
return Math.max(1, Math.round(words / 350)); // ~350 ตัวอักษร/นาที
|
||||
}
|
||||
|
||||
function renderGrid(posts, host) {
|
||||
posts.forEach(function (p) {
|
||||
var c = pick(p.data, lang());
|
||||
var a = document.createElement('a');
|
||||
a.className = 'mu-blog-card';
|
||||
a.href = '/blog/' + p.n;
|
||||
|
||||
var cover = document.createElement('div');
|
||||
cover.className = 'mu-cover' + (p.img ? '' : ' no-img');
|
||||
if (p.img) {
|
||||
var im = document.createElement('img');
|
||||
im.src = imgUrl(p.img); im.alt = ''; im.loading = 'lazy'; im.decoding = 'async';
|
||||
cover.appendChild(im);
|
||||
}
|
||||
if (c.tag) {
|
||||
var tag = document.createElement('span');
|
||||
tag.className = 'mu-cover-tag';
|
||||
tag.textContent = c.tag;
|
||||
cover.appendChild(tag);
|
||||
}
|
||||
var ct = document.createElement('p');
|
||||
ct.className = 'mu-cover-title';
|
||||
ct.textContent = c.title || '';
|
||||
cover.appendChild(ct);
|
||||
a.appendChild(cover);
|
||||
|
||||
var body = document.createElement('div');
|
||||
body.className = 'mu-blog-body';
|
||||
body.innerHTML = '<div class="mu-blog-meta"></div><h2></h2><p class="mu-blog-excerpt"></p><span class="mu-blog-more"></span>';
|
||||
body.querySelector('h2').textContent = c.title || '';
|
||||
body.querySelector('.mu-blog-excerpt').textContent = (c.body || []).join(' ').slice(0, EXCERPT_LEN) + '…';
|
||||
body.querySelector('.mu-blog-more').textContent = t('blog.readMore') + ' →';
|
||||
var meta = body.querySelector('.mu-blog-meta');
|
||||
if (p.data.date) {
|
||||
var tm = document.createElement('time');
|
||||
tm.dateTime = p.data.date;
|
||||
tm.textContent = p.data.date;
|
||||
meta.appendChild(tm);
|
||||
var dot = document.createElement('span'); dot.textContent = '·'; meta.appendChild(dot);
|
||||
}
|
||||
var rt = document.createElement('span');
|
||||
rt.textContent = readTime(c.body) + ' ' + t('blog.minRead');
|
||||
meta.appendChild(rt);
|
||||
a.appendChild(body);
|
||||
host.appendChild(a);
|
||||
});
|
||||
}
|
||||
|
||||
function renderList(posts, host) {
|
||||
posts.forEach(function (p) {
|
||||
var c = pick(p.data, lang());
|
||||
var a = document.createElement('a');
|
||||
a.className = 'mu-blog-row';
|
||||
a.href = '/blog/' + p.n;
|
||||
if (p.img) {
|
||||
var im = document.createElement('img');
|
||||
im.className = 'thumb'; im.src = p.img; im.alt = ''; im.loading = 'lazy'; im.decoding = 'async';
|
||||
a.appendChild(im);
|
||||
}
|
||||
var box = document.createElement('div');
|
||||
box.innerHTML = '<div class="mu-blog-meta"></div><h2></h2><p class="mu-blog-excerpt"></p>';
|
||||
box.querySelector('h2').textContent = c.title || '';
|
||||
box.querySelector('.mu-blog-excerpt').textContent = (c.body || []).join(' ').slice(0, 110) + '…';
|
||||
var meta = box.querySelector('.mu-blog-meta');
|
||||
var bits = [];
|
||||
if (p.data.date) bits.push(p.data.date);
|
||||
if (c.tag) bits.push(c.tag);
|
||||
bits.push(readTime(c.body) + ' ' + t('blog.minRead'));
|
||||
meta.textContent = bits.join(' · ');
|
||||
a.appendChild(box);
|
||||
host.appendChild(a);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* ---------- มินิมาร์กดาวน์สำหรับเนื้อหาบทความ ----------
|
||||
ปลอดภัย: escape HTML "ก่อน" แล้วจึงแปลงมาร์กดาวน์ (ไม่รับ HTML ดิบจากไฟล์)
|
||||
รองรับ:
|
||||
**หนา** / __หนา__ → <strong>
|
||||
*เอียง* / _เอียง_ → <em>
|
||||
[ข้อความ](url) → <a target=_blank rel=noopener>
|
||||
 → <img> (ย่อหน้าที่เป็นรูปเดี่ยว ๆ)
|
||||
- ข้อ / * ข้อ → <ul><li> (ติดกันหลายบรรทัด)
|
||||
`โค้ด` → <code>
|
||||
หมายเหตุ: URL ที่ไม่ใช่ http/https/./../ จะถูกทิ้ง (กัน javascript:) */
|
||||
function escHtml(s) {
|
||||
return String(s == null ? '' : s)
|
||||
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
||||
.replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
function safeUrl(u) {
|
||||
var s = String(u == null ? '' : u).trim();
|
||||
if (/^https?:\/\//i.test(s)) return s; /* เว็บภายนอก */
|
||||
if (/^(\.{0,2}\/)?[\w.\-]+\/[\w.\-/]*[\w.\-]$/.test(s)) return s; /* เส้นทางไฟล์: pic1.jpg · ./a/b.png · ../x/y.jpg */
|
||||
if (/^[\w.\-]+\.(jpg|jpeg|png|webp|gif|svg)$/i.test(s)) return s; /* ชื่อไฟล์เดี่ยว ๆ */
|
||||
return ''; /* javascript: / data: / อื่น ๆ → ทิ้ง */
|
||||
}
|
||||
/* แปลง inline (ตัวหนา/เอียง/ลิงก์/โค้ด) บนข้อความที่ escape แล้ว */
|
||||
function inlineMd(txt) {
|
||||
var s = escHtml(txt);
|
||||
s = s.replace(/!\[([^\]]*)\]\(([^()\s]*(?:\([^()]*\)[^()\s]*)*)\)/g, function (_, alt, url) {
|
||||
var u = safeUrl(url);
|
||||
return u ? '<img src="' + u + '" alt="' + alt + '" loading="lazy" decoding="async">' : alt;
|
||||
});
|
||||
s = s.replace(/\[([^\]]+)\]\(([^()\s]*(?:\([^()]*\)[^()\s]*)*)\)/g, function (_, label, url) {
|
||||
var u = safeUrl(url);
|
||||
return u ? '<a href="' + u + '" target="_blank" rel="noopener noreferrer">' + label + '</a>' : label;
|
||||
});
|
||||
s = s.replace(/`([^`]+)`/g, '<code>$1</code>');
|
||||
s = s.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
|
||||
s = s.replace(/__([^_]+)__/g, '<strong>$1</strong>');
|
||||
s = s.replace(/(^|[^*])\*([^*\s][^*]*?)\*/g, '$1<em>$2</em>');
|
||||
s = s.replace(/(^|[^_])_([^_\s][^_]*?)_/g, '$1<em>$2</em>');
|
||||
return s;
|
||||
}
|
||||
/* เรนเดอร์ body[] ลง host — จัดกลุ่มรายการ "- " ต่อกันเป็น <ul> */
|
||||
function renderBody(host, body) {
|
||||
var i = 0, list = null;
|
||||
function closeList() { if (list) { host.appendChild(list); list = null; } }
|
||||
body.forEach(function (raw) {
|
||||
var line = String(raw == null ? '' : raw);
|
||||
var bullet = line.match(/^\s*[-*]\s+(.+)$/);
|
||||
if (bullet) {
|
||||
if (!list) list = document.createElement('ul');
|
||||
var li = document.createElement('li');
|
||||
li.innerHTML = inlineMd(bullet[1]);
|
||||
list.appendChild(li);
|
||||
return;
|
||||
}
|
||||
closeList();
|
||||
/* ย่อหน้าที่เป็นรูปเดี่ยว  → ใช้ <figure> */
|
||||
var onlyImg = line.trim().match(/^!\[([^\]]*)\]\(([^)\s]+)\)$/);
|
||||
if (onlyImg) {
|
||||
var u = safeUrl(onlyImg[2]);
|
||||
if (u) {
|
||||
var fig = document.createElement('figure');
|
||||
fig.className = 'mu-post-figure';
|
||||
fig.innerHTML = '<img src="' + u + '" alt="' + escHtml(onlyImg[1]) + '" loading="lazy" decoding="async">' +
|
||||
(onlyImg[1] ? '<figcaption>' + escHtml(onlyImg[1]) + '</figcaption>' : '');
|
||||
host.appendChild(fig);
|
||||
return;
|
||||
}
|
||||
}
|
||||
var p = document.createElement('p');
|
||||
p.innerHTML = inlineMd(line);
|
||||
host.appendChild(p);
|
||||
});
|
||||
closeList();
|
||||
}
|
||||
|
||||
/* รูปปก — เติม ?v= เวอร์ชันแอป (กัน cache-first ของ SW ค้างรูปเก่า) ให้ตรงกับหน้าอื่น */
|
||||
function imgUrl(u) {
|
||||
return (window.ImgURL && ImgURL.of) ? ImgURL.of(u) : u;
|
||||
}
|
||||
|
||||
/* ---------- แผนที่เส้นทางแทนรูปปก (กำหนดใน textN.json) ----------
|
||||
"map": { "route_id": "101", "height": 320, "interactive": false, "caption": "…" }
|
||||
เงื่อนไข: ถ้าไม่มีไฟล์ geojson ของสายนั้น → คงรูป picN ไว้ + ป้ายบอก (ไม่พัง ไม่ขึ้นแผนที่เปล่า)
|
||||
ใช้ ATMap.route() ตัวเดียวกับหน้า #/routes/:id (ไม่ต้องโหลดไลบรารีเพิ่ม) */
|
||||
var GEO_DIR = '/resource/data/geojson-web/';
|
||||
|
||||
function hasGeo(id) {
|
||||
return fetch(GEO_DIR + id + '.geojson', { method: 'HEAD', cache: 'no-store' })
|
||||
.then(function (r) { return r.ok; })
|
||||
.catch(function () { return false; });
|
||||
}
|
||||
|
||||
function mountBlogMap(cover, spec) {
|
||||
var rid = String((spec && spec.route_id) || '').trim();
|
||||
if (!cover || !rid) return;
|
||||
hasGeo(rid).then(function (ok) {
|
||||
if (!ok) { /* ไม่มีเส้นทาง → ใช้รูปเดิม + ป้าย */
|
||||
var note = document.createElement('span');
|
||||
note.className = 'mu-cover-note';
|
||||
note.textContent = t('blog.noGeo');
|
||||
cover.appendChild(note);
|
||||
return;
|
||||
}
|
||||
cover.innerHTML = ''; /* แผนที่แทนรูป */
|
||||
cover.classList.remove('no-img');
|
||||
cover.classList.add('is-map');
|
||||
var box = document.createElement('div');
|
||||
box.className = 'at-map' + (spec.interactive === false ? ' is-static' : '');
|
||||
if (spec.height) box.style.height = spec.height + 'px';
|
||||
cover.appendChild(box);
|
||||
if (spec.caption) {
|
||||
var cap = document.createElement('span');
|
||||
cap.className = 'mu-cover-cap';
|
||||
cap.textContent = spec.caption;
|
||||
cover.appendChild(cap);
|
||||
}
|
||||
if (window.ATMap) {
|
||||
ATMap.route(box, rid);
|
||||
/* container เพิ่งมีขนาด → สั่งวัดใหม่ (กันบั๊กแผนที่ 0×0) */
|
||||
var hit = (ATMap.maps || []).filter(function (m) { return m.el === box; })[0];
|
||||
if (hit && hit.map) setTimeout(function () { hit.map.invalidateSize(); }, 60);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderPost(post, host) {
|
||||
var c = pick(post.data, lang());
|
||||
var art = document.createElement('article');
|
||||
art.className = 'mu-post';
|
||||
|
||||
/* ---------- แผนที่ "เส้นทางที่เสนอ" (ความฝัน) — กำหนดใน textN.json → "map"."routes"[]
|
||||
"map": { "origin": {"station_code":"at_main_terminal","label":"บขส.อ่างทอง"},
|
||||
"routes": [ { "id":"…", "line_color":"#c8102e", "line_name":"สายสีแดง",
|
||||
"dest":{"name":"…","lat":13.9,"lng":100.6},
|
||||
"via":[{"name":"…","lat":…,"lng":…}],
|
||||
"distance_km":null, "duration_min":null, "fare_thb":null, "note":"" } ] }
|
||||
เงื่อนไข: เส้นทางที่ยังไม่ใส่พิกัดปลายทาง → ไม่วาดบนแผนที่ แต่ขึ้นในรายการพร้อมป้ายบอก
|
||||
ค่าที่เว้น null → ซ่อนในแผงรายละเอียด (ไม่โชว์ 0 หรือค่าว่าง) */
|
||||
var STATIONS_URL = '/resource/data/stations.json';
|
||||
var stationsP = null;
|
||||
|
||||
function numOrNull(v) {
|
||||
var n = parseFloat(v);
|
||||
return isFinite(n) ? n : null;
|
||||
}
|
||||
|
||||
/* พิกัดจากได้ทั้ง coords=[lat,lng] (แบบใหม่) หรือ lat/lng (แบบเดิม) — คืน [lat,lng] หรือ null */
|
||||
function coordsOf(o) {
|
||||
o = o || {};
|
||||
if (Array.isArray(o.coords) && o.coords.length >= 2) {
|
||||
var a = numOrNull(o.coords[0]), c = numOrNull(o.coords[1]);
|
||||
return (a == null || c == null) ? null : [a, c];
|
||||
}
|
||||
var la = numOrNull(o.lat), ln = numOrNull(o.lng);
|
||||
return (la == null || ln == null) ? null : [la, ln];
|
||||
}
|
||||
|
||||
function stationByCode(code) {
|
||||
if (!stationsP) {
|
||||
stationsP = fetch(STATIONS_URL, { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : {}; })
|
||||
.then(function (d) { return (d && d.stations) || []; })
|
||||
.catch(function () { return []; });
|
||||
}
|
||||
return stationsP.then(function (list) {
|
||||
return list.filter(function (s) { return String(s.station_code) === String(code); })[0] || null;
|
||||
});
|
||||
}
|
||||
|
||||
/* พิกัดต้นทาง: ใช้ lat/lng ที่ระบุมาตรง ๆ ก่อน ถ้าไม่มีจึงค้นจาก stations.json ด้วย station_code */
|
||||
function resolveOrigin(o) {
|
||||
o = o || {};
|
||||
var c = coordsOf(o);
|
||||
if (c) return Promise.resolve({ coords: c, label: o.label || '' });
|
||||
if (!o.station_code) return Promise.resolve(null);
|
||||
return stationByCode(o.station_code).then(function (s) {
|
||||
if (!s || numOrNull(s.latitude) == null) return null;
|
||||
return { coords: [numOrNull(s.latitude), numOrNull(s.longitude)], label: o.label || s.station_name_th || '' };
|
||||
});
|
||||
}
|
||||
|
||||
function buildProposal(spec) {
|
||||
var wrap = document.createElement('div');
|
||||
wrap.className = 'blog-mapx';
|
||||
var host = document.createElement('div');
|
||||
host.className = 'at-map blog-mapx-map';
|
||||
var legend = document.createElement('ul');
|
||||
legend.className = 'blog-mapx-legend';
|
||||
var panel = document.createElement('div');
|
||||
panel.className = 'blog-mapx-panel';
|
||||
panel.hidden = true;
|
||||
wrap.appendChild(host);
|
||||
wrap.appendChild(legend);
|
||||
wrap.appendChild(panel);
|
||||
|
||||
/* โครงได้ 2 แบบ:
|
||||
- ใหม่ "groups": [ {id, label, routes[]} ] → แสดงหัวกลุ่มคั่นในรายการ
|
||||
- เดิม "routes": [ ... ] → ไม่มีกลุ่ม (backward-compat) */
|
||||
var groups = Array.isArray(spec.groups) && spec.groups.length
|
||||
? spec.groups
|
||||
: [{ id: '', label: '', routes: spec.routes || [] }];
|
||||
var routes = [];
|
||||
groups.forEach(function (g) {
|
||||
(g.routes || []).forEach(function (r) {
|
||||
if (r && (r.line_name || r.dest)) { r.__group = g; routes.push(r); }
|
||||
});
|
||||
});
|
||||
var rows = [];
|
||||
|
||||
routes.forEach(function (r) {
|
||||
var li = document.createElement('li');
|
||||
li.className = 'blog-mapx-row';
|
||||
li.tabIndex = 0;
|
||||
var sw = document.createElement('span');
|
||||
sw.className = 'blog-mapx-sw';
|
||||
sw.style.background = r.line_color || '#7a4cc0';
|
||||
var nm = document.createElement('span');
|
||||
nm.className = 'blog-mapx-nm';
|
||||
nm.textContent = r.line_name || (r.dest && r.dest.name) || '';
|
||||
var ds = document.createElement('span');
|
||||
ds.className = 'blog-mapx-ds';
|
||||
ds.textContent = (r.dest && r.dest.name) || '';
|
||||
li.appendChild(sw);
|
||||
li.appendChild(nm);
|
||||
li.appendChild(ds);
|
||||
if (!coordsOf(r.dest)) { /* ยังไม่ใส่พิกัด → บอกให้รู้ */
|
||||
var badge = document.createElement('span');
|
||||
badge.className = 'blog-mapx-badge';
|
||||
badge.textContent = t('blog.mapNoCoord');
|
||||
li.appendChild(badge);
|
||||
}
|
||||
li.addEventListener('click', function () { pick(r); });
|
||||
li.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); pick(r); }
|
||||
});
|
||||
var badge = li.querySelector('.blog-mapx-badge');
|
||||
rows.push({ r: r, el: li, badge: badge });
|
||||
/* หัวกลุ่ม: แทรกเมื่อขึ้นกลุ่มใหม่ (มี label เท่านั้น) */
|
||||
if (r.__group && r.__group.label && !r.__group.__head) {
|
||||
r.__group.__head = document.createElement('li');
|
||||
r.__group.__head.className = 'blog-mapx-group';
|
||||
r.__group.__head.textContent = r.__group.label;
|
||||
legend.appendChild(r.__group.__head);
|
||||
}
|
||||
legend.appendChild(li);
|
||||
});
|
||||
|
||||
function pick(r) {
|
||||
highlight(r);
|
||||
show(r);
|
||||
}
|
||||
|
||||
/* ไฮไลต์เส้นที่เลือก — เส้นอื่นจางลง */
|
||||
function highlight(sel) {
|
||||
rows.forEach(function (x) { x.el.classList.toggle('is-on', x.r === sel); });
|
||||
routes.forEach(function (x) {
|
||||
if (!x.__layer) return;
|
||||
var on = x === sel;
|
||||
x.__layer.line.setStyle({ weight: on ? 7 : 4, opacity: on ? 1 : .3 });
|
||||
x.__layer.dot.setStyle({ opacity: on ? 1 : .35, fillOpacity: on ? 1 : .35 });
|
||||
});
|
||||
}
|
||||
|
||||
function show(r) {
|
||||
var d = r.dest || {};
|
||||
function line(k, v) {
|
||||
if (v == null || v === '') return;
|
||||
var p = document.createElement('p');
|
||||
p.className = 'blog-mapx-line';
|
||||
var s = document.createElement('span');
|
||||
s.textContent = k;
|
||||
var b = document.createElement('b');
|
||||
b.textContent = v;
|
||||
p.appendChild(s);
|
||||
p.appendChild(b);
|
||||
panel.appendChild(p);
|
||||
}
|
||||
panel.innerHTML = '';
|
||||
panel.hidden = false;
|
||||
var head = document.createElement('div');
|
||||
head.className = 'blog-mapx-head';
|
||||
var sw = document.createElement('span');
|
||||
sw.className = 'blog-mapx-sw';
|
||||
sw.style.background = r.line_color || '#7a4cc0';
|
||||
var title = document.createElement('strong');
|
||||
title.textContent = r.line_name || d.name || '';
|
||||
head.appendChild(sw);
|
||||
head.appendChild(title);
|
||||
panel.appendChild(head);
|
||||
line(t('blog.mapDest'), d.name);
|
||||
var via = (r.via || []).map(function (v) { return v && v.name; }).filter(Boolean).join(' · ');
|
||||
line(t('blog.mapVia'), via);
|
||||
var facts = [];
|
||||
if (numOrNull(r.distance_km) != null) facts.push(r.distance_km + ' ' + t('blog.km'));
|
||||
if (numOrNull(r.duration_min) != null) facts.push(r.duration_min + ' ' + t('blog.min'));
|
||||
if (numOrNull(r.fare_thb) != null) facts.push(r.fare_thb + ' ' + t('blog.thb'));
|
||||
if (facts.length) {
|
||||
var f = document.createElement('p');
|
||||
f.className = 'blog-mapx-facts';
|
||||
f.textContent = facts.join(' · ');
|
||||
panel.appendChild(f);
|
||||
}
|
||||
line(t('blog.mapNote'), r.note);
|
||||
}
|
||||
|
||||
if (!routes.length) {
|
||||
panel.hidden = false;
|
||||
panel.textContent = t('blog.mapNoRoutes');
|
||||
} else {
|
||||
var hint = document.createElement('p');
|
||||
hint.className = 'blog-mapx-hint';
|
||||
hint.textContent = t('blog.mapPick');
|
||||
wrap.appendChild(hint);
|
||||
}
|
||||
|
||||
resolveOrigin(spec.origin).then(function (org) {
|
||||
if (!org) {
|
||||
panel.hidden = false;
|
||||
panel.textContent = t('blog.mapNoOrigin');
|
||||
host.remove();
|
||||
return;
|
||||
}
|
||||
if (window.ATMap && ATMap.proposal) {
|
||||
ATMap.proposal(host, { origin: org, routes: routes }, function (r) { pick(r); }); /* groups ถูก flatten เป็น routes แล้ว */
|
||||
/* พิกัดปลายทางที่อ่านจาก geojson สำเร็จ → ลบป้าย "ยังไม่ใส่พิกัด" ออก */
|
||||
setTimeout(function () {
|
||||
rows.forEach(function (x) { if (x.r.__geoOk && x.badge) { x.badge.remove(); x.badge = null; } });
|
||||
}, 250);
|
||||
} else {
|
||||
host.remove();
|
||||
}
|
||||
});
|
||||
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/* ปก: รูป picN หรือแผนที่ (ถ้า textN.json ระบุ "map") — แผนที่ใช้เมื่อมีไฟล์เส้นทางจริงเท่านั้น */
|
||||
var spec = post.data.map;
|
||||
if (spec && (Array.isArray(spec.routes) || Array.isArray(spec.groups))) {
|
||||
/* ความฝัน: แผนที่เส้นทางที่เสนอ (ยังไม่มีจริง) — วาดจากโครงใน textN.json */
|
||||
var mapWrap = buildProposal(spec);
|
||||
if (c.tag) { /* ป้ายหมวด: แสดงมุมขวาบนของแผนที่ด้วย (แผนที่แทนที่ปก จึงไม่มีป้ายจาก .mu-cover) */
|
||||
var mapTag = document.createElement('span');
|
||||
mapTag.className = 'blog-mapx-tag';
|
||||
mapTag.textContent = c.tag;
|
||||
mapWrap.appendChild(mapTag);
|
||||
}
|
||||
art.appendChild(mapWrap);
|
||||
if (spec.note) {
|
||||
var src = document.createElement('p');
|
||||
src.className = 'blog-mapx-src';
|
||||
src.textContent = t('blog.mapNote') + ': ' + spec.note;
|
||||
art.appendChild(src);
|
||||
}
|
||||
} else if (post.img || spec) {
|
||||
var cover = document.createElement('div');
|
||||
cover.className = 'mu-cover' + (post.img ? '' : ' no-img');
|
||||
if (post.img) {
|
||||
var im = document.createElement('img');
|
||||
im.src = imgUrl(post.img); im.alt = c.title || ''; im.decoding = 'async';
|
||||
cover.appendChild(im);
|
||||
}
|
||||
if (c.tag) {
|
||||
var tag = document.createElement('span');
|
||||
tag.className = 'mu-cover-tag';
|
||||
tag.textContent = c.tag;
|
||||
cover.appendChild(tag);
|
||||
}
|
||||
art.appendChild(cover);
|
||||
if (spec) mountBlogMap(cover, spec);
|
||||
}
|
||||
|
||||
var body = document.createElement('div');
|
||||
body.className = 'mu-post-body';
|
||||
var back = document.createElement('a');
|
||||
back.className = 'mu-post-back';
|
||||
back.href = '/blog';
|
||||
back.textContent = '← ' + t('blog.backList');
|
||||
body.appendChild(back);
|
||||
|
||||
var meta = document.createElement('div');
|
||||
meta.className = 'mu-blog-meta';
|
||||
var bits = [];
|
||||
if (post.data.date) bits.push(post.data.date);
|
||||
bits.push(readTime(c.body) + ' ' + t('blog.minRead'));
|
||||
meta.textContent = bits.join(' · ');
|
||||
body.appendChild(meta);
|
||||
|
||||
var h1 = document.createElement('h1');
|
||||
h1.textContent = c.title || '';
|
||||
body.appendChild(h1);
|
||||
|
||||
renderBody(body, c.body || []); /* รองรับมาร์กดาวน์เบา ๆ (หนา/เอียง/ลิงก์/รูป/รายการ) */
|
||||
|
||||
art.appendChild(body);
|
||||
host.appendChild(art);
|
||||
}
|
||||
|
||||
function init() {
|
||||
var host = document.getElementById('blog-list');
|
||||
if (!host) return;
|
||||
|
||||
var route = window.__route || { params: {} };
|
||||
var postId = route.params && route.params.postId;
|
||||
|
||||
loadPosts().then(function (posts) {
|
||||
host.innerHTML = '';
|
||||
|
||||
if (postId) {
|
||||
var post = posts.filter(function (p) { return String(p.n) === String(postId); })[0];
|
||||
var bar = document.getElementById('blog-bar');
|
||||
if (bar) bar.hidden = true;
|
||||
if (post) {
|
||||
renderPost(post, host);
|
||||
} else {
|
||||
host.innerHTML = '<p class="mu-blog-empty">' + t('blog.notFound') + '</p>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!posts.length) {
|
||||
host.innerHTML = '<p class="mu-blog-empty">' + t('blog.empty') + '</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
var bar = document.getElementById('blog-bar');
|
||||
var count = document.getElementById('blog-count');
|
||||
if (count) count.textContent = t('blog.count') + ' ' + posts.length + ' ' + t('blog.items');
|
||||
if (bar) bar.hidden = false;
|
||||
|
||||
var mode = getView();
|
||||
function paint() {
|
||||
host.className = mode === 'list' ? 'mode-list' : 'mode-grid';
|
||||
host.innerHTML = '';
|
||||
(mode === 'list' ? renderList : renderGrid)(posts, host);
|
||||
document.querySelectorAll('.mu-view-btn').forEach(function (b) {
|
||||
b.classList.toggle('active', b.getAttribute('data-view') === mode);
|
||||
b.setAttribute('aria-pressed', String(b.getAttribute('data-view') === mode));
|
||||
});
|
||||
}
|
||||
paint();
|
||||
|
||||
document.querySelectorAll('.mu-view-btn').forEach(function (b) {
|
||||
b.addEventListener('click', function () {
|
||||
mode = b.getAttribute('data-view');
|
||||
setView(mode);
|
||||
paint();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default function mount(): void {
|
||||
init();
|
||||
}
|
||||
@@ -0,0 +1,543 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/checkSchedule.init.js — logic unchanged; bootstrap converted to mount(). */
|
||||
/* ============================================================
|
||||
checkSchedule.init.js — หน้า #/check/<รหัสสาย>
|
||||
------------------------------------------------------------
|
||||
ดึงข้อมูลจริง:
|
||||
resource/data/routes.json ชื่อสาย / ตัวเลือก / station_ids / province_ids
|
||||
resource/data/stations.json ชื่อจุดจอด + จังหวัด + รหัสป้าย
|
||||
resource/data/schedules.json เวลาออกรถ (แยกตามจุดจอด/ทิศทาง) + หมายเหตุ
|
||||
|
||||
การไฮไลต์ (ตามเวลาบนเครื่องผู้ใช้):
|
||||
- ไฮไลต์ "เที่ยวถัดไป" = เที่ยวแรกที่เวลายังไม่ผ่าน (>= เวลาปัจจุบัน)
|
||||
- เลยเที่ยวสุดท้ายของวันแล้ว → ไม่ไฮไลต์เลย
|
||||
- หลังเที่ยงคืน เวลาปัจจุบันน้อยกว่าเที่ยวแรก → เที่ยวแรกของวันถูกไฮไลต์เอง
|
||||
- ตรวจซ้ำทุก 30 วินาที (และตอนสลับสาย/กลับเข้าแท็บ)
|
||||
============================================================ */
|
||||
/* ---- ported module body ---- */
|
||||
'use strict';
|
||||
|
||||
var DATA = '/resource/data/';
|
||||
var FALLBACK_ID = '101';
|
||||
var REFRESH_MS = 30000;
|
||||
var TONES = { origin: 'tone-purple', transfer: 'tone-sky', pass: 'tone-mint', destination: 'tone-pink' };
|
||||
|
||||
/* นโยบายการแสดงจุดจอดบนหน้าเช็กเวลา
|
||||
false = แสดงทุกจุดใน routes.json → station_ids (จุดที่ยังไม่มีตารางจะขึ้นการ์ด "ยังไม่มีข้อมูลตารางเวลา")
|
||||
← ค่าเริ่มต้น: ตรงกับดีไซน์เดิม (หน้าเดิมโชว์จุดที่ยังไม่มีตารางพร้อมข้อความนี้)
|
||||
true = แสดงเฉพาะจุดที่มี record ใน schedules.json (กระดานเวลาล้วน ๆ) */
|
||||
var ONLY_STOPS_WITH_SCHEDULE = false;
|
||||
|
||||
var sections = []; /* [{ chips:[], times:[], station }] */
|
||||
var netRoute = null;
|
||||
var OTHER_ENTRIES = [];
|
||||
var ROUTE_IDS = []; /* routes.json ของสายที่แสดงอยู่ */
|
||||
var timer = null;
|
||||
|
||||
function $(id) { return document.getElementById(id); }
|
||||
function t(k, v) { return window.I18N ? I18N.t(k, v) : k; }
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
function fetchJSON(u) {
|
||||
return fetch(u, { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; });
|
||||
}
|
||||
function toMin(hhmm) {
|
||||
var a = String(hhmm).split(':');
|
||||
return (parseInt(a[0], 10) || 0) * 60 + (parseInt(a[1], 10) || 0);
|
||||
}
|
||||
function nowMin() { var d = new Date(); return d.getHours() * 60 + d.getMinutes(); }
|
||||
function hhmm(min) {
|
||||
var h = Math.floor(min / 60), m = min % 60;
|
||||
return (h < 10 ? '0' : '') + h + ':' + (m < 10 ? '0' : '') + m;
|
||||
}
|
||||
function setStat(id, s) {
|
||||
var el = $(id);
|
||||
if (!el) return;
|
||||
var v = (s == null ? '' : String(s)).trim();
|
||||
el.textContent = v || '–';
|
||||
}
|
||||
|
||||
/* ---------- จำแนกประเภทจุดจอดจากข้อมูล + ลำดับในเส้นทาง ---------- */
|
||||
/* บทบาทของจุดในการ์ด:
|
||||
index 0 = ต้นทาง · index สุดท้าย = ปลายทาง
|
||||
ระหว่างนั้น: จุดที่เป็น "สถานีขนส่งหลัก" = กลางทาง (จุดพักรถที่คนขึ้น/ลงได้)
|
||||
จุดป้ายริมทางทั่วไป = ผ่านทาง
|
||||
⚠️ ใช้กับ "ลำดับที่แสดงในหน้านี้" เท่านั้น — ลำดับมาอยู่ที่ station_order ไม่ใช่บทบาทถาวร */
|
||||
function kindOf(st, i, n) {
|
||||
if (i === 0) return { key: 'route.origin', icon: 'ic-map-pin', tone: TONES.origin };
|
||||
if (i === n - 1) return { key: 'route.destination', icon: 'ic-map-pin', tone: TONES.destination };
|
||||
if (st && st.station_type === 'main_terminal') return { key: 'route.transfer', icon: 'ic-map-pin', tone: TONES.transfer };
|
||||
return { key: 'route.pass', icon: 'ic-map-pin', tone: TONES.pass };
|
||||
}
|
||||
|
||||
/* ---------- สร้างการ์ดจุดจอด ---------- */
|
||||
function renderList(listEl, route, groups) {
|
||||
listEl.innerHTML = '';
|
||||
sections = [];
|
||||
|
||||
groups.forEach(function (g, i) {
|
||||
var kind = kindOf(g.st, i, groups.length);
|
||||
var li = document.createElement('li');
|
||||
var det = document.createElement('details');
|
||||
det.className = 'mu-stop-card';
|
||||
det.open = true;
|
||||
|
||||
var sum = document.createElement('summary');
|
||||
sum.innerHTML =
|
||||
'<span class="mu-stop-head ' + kind.tone + '">' +
|
||||
'<span class="mu-stop-kind"><svg class="ic" aria-hidden="true"><use href="#' + kind.icon + '"/></svg> <span>' + esc(t(kind.key)) + '</span></span>' +
|
||||
'<span class="mu-stop-title"><strong>' + esc(g.name) + '</strong><small>' + esc(g.city) + '</small></span>' +
|
||||
'<span class="mu-stop-chevron">\u2304</span>' +
|
||||
'</span>';
|
||||
det.appendChild(sum);
|
||||
|
||||
var body = document.createElement('div');
|
||||
body.className = 'mu-stop-body';
|
||||
|
||||
if (!g.recs.length) {
|
||||
var none = document.createElement('p');
|
||||
none.className = 'mu-stop-sub';
|
||||
none.textContent = t('route.empty');
|
||||
body.appendChild(none);
|
||||
}
|
||||
|
||||
/* มีอย่างน้อย 1 ทิศที่มีตารางจริงไหม — ถ้ามี ห้ามขึ้น "ยังไม่มีข้อมูล" ของทิศที่ว่าง
|
||||
(จุดเดียวมีได้หลายทิศ · ทิศว่างไม่ควรทำให้การ์ดที่ตารางขึ้นแล้วดูเหมือนไม่มีข้อมูล) */
|
||||
var hasAny = g.recs.some(function (x) { return (x.departure_times || []).length > 0; });
|
||||
|
||||
g.recs.forEach(function (r) {
|
||||
var times = (r.departure_times || []).slice();
|
||||
|
||||
/* ทิศนี้ยังไม่มีเวลา → ข้ามไปเลยถ้าทิศอื่นมีการ์ดข้อมูลอยู่แล้ว */
|
||||
if (!times.length) {
|
||||
if (hasAny) return;
|
||||
var empty = document.createElement('p');
|
||||
empty.className = 'mu-stop-sub';
|
||||
empty.textContent = t('route.empty');
|
||||
body.appendChild(empty);
|
||||
return;
|
||||
}
|
||||
|
||||
/* หัวแถว = ชื่อทิศ (direction_label) → ไม่มีค่อยใช้ direction_note → ไม่มีอีกค่อยบอกว่าอยู่ที่จุดนี้
|
||||
ทิศที่ไปคนละทางจากจุดเดียวกัน (ป่าโมกไปอ่างทอง / ป่าโมกไปอยุธยา) จึงแยกให้เห็นชัด */
|
||||
var sub = document.createElement('p');
|
||||
sub.className = 'mu-stop-sub';
|
||||
if ((r.direction_label || r.dir_label)) {
|
||||
sub.innerHTML = esc((r.direction_label || r.dir_label)) +
|
||||
(r.direction_note ? ' <span class="mu-direction-tag">' + esc(r.direction_note) + '</span>' : '');
|
||||
} else if (r.direction_note) {
|
||||
sub.innerHTML = esc(r.direction_note) + ' <span class="mu-direction-tag">' + esc(t('check.direction')) + '</span>';
|
||||
} else {
|
||||
sub.textContent = t('check.atStop') + ' ' + g.name;
|
||||
}
|
||||
body.appendChild(sub);
|
||||
|
||||
var grid = document.createElement('div');
|
||||
grid.className = 'mu-time-grid' + (r.estimated ? ' is-est' : ''); /* เวลาที่คำนวณจากต้นทาง */
|
||||
var chips = [];
|
||||
times.forEach(function (tm) {
|
||||
var c = document.createElement('div');
|
||||
c.className = 'mu-time-chip';
|
||||
c.textContent = tm;
|
||||
grid.appendChild(c);
|
||||
chips.push(c);
|
||||
});
|
||||
body.appendChild(grid);
|
||||
if (r.estimated) {
|
||||
var est = document.createElement('p');
|
||||
est.className = 'mu-est-note';
|
||||
/* มาจากกฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" → บอกจุดอ้างอิง + เตือนเรื่องการจราจร */
|
||||
est.textContent = r.estimateFrom && window.Schedules.offsetLabel
|
||||
? t('time.derived', {
|
||||
base: r.estimateFrom.name || ('#' + r.estimateFrom.station_id),
|
||||
n: Schedules.offsetLabel(r.estimateFrom.offsetMin)
|
||||
})
|
||||
: t('time.estimated');
|
||||
body.appendChild(est);
|
||||
}
|
||||
sections.push({ chips: chips, times: times, station: g.name });
|
||||
|
||||
if (r.schedule_note) {
|
||||
var note = document.createElement('p');
|
||||
note.className = 'mu-schedule-note';
|
||||
note.innerHTML = '<svg class="ic" aria-hidden="true"><use href="#ic-triangle-alert"/></svg> ' + esc(r.schedule_note);
|
||||
body.appendChild(note);
|
||||
}
|
||||
});
|
||||
|
||||
if (g.code) {
|
||||
var act = document.createElement('div');
|
||||
act.className = 'mu-inline-actions';
|
||||
var a = document.createElement('a');
|
||||
a.className = 'mu-btn ghost';
|
||||
a.href = '/stops/' + encodeURIComponent(g.code) + '?route=' + encodeURIComponent(route.route_id);
|
||||
a.textContent = t('check.toStopDetail');
|
||||
act.appendChild(a);
|
||||
body.appendChild(act);
|
||||
}
|
||||
|
||||
det.appendChild(body);
|
||||
li.appendChild(det);
|
||||
listEl.appendChild(li);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- แถวข้อมูลแบบ "ชิ้น" (segment) ----------
|
||||
แต่ละชิ้นเป็น flex item → ตัดบรรทัดเป็นหน่วย ไม่ตัดกลางคำ
|
||||
(สำคัญกับข้อความไทยที่ไม่มีเว้นวรรค เช่น "บขส.อ่างทอง → สถานีเดินรถโดยสารขนาดเล็ก (จตุจักร)"
|
||||
จะไม่ถูกตัดกลางชื่อสถานี) · ตัวคั่น "·" วาดด้วย CSS (.mu-zone-seg + .mu-zone-seg::before) */
|
||||
function icSvg(name) {
|
||||
return '<svg class="ic" aria-hidden="true"><use href="#' + name + '"/></svg>';
|
||||
}
|
||||
/* seg = "ข้อความล้วน" หรือ { html: "...", icon: "ic-xxx" } (html ต้อง esc() มาก่อน) */
|
||||
function setSegments(host, segs) {
|
||||
if (!host) return;
|
||||
host.innerHTML = '';
|
||||
segs.forEach(function (s) {
|
||||
var seg = document.createElement('span');
|
||||
seg.className = 'mu-zone-seg';
|
||||
if (s && typeof s === 'object') {
|
||||
seg.innerHTML = (s.icon ? icSvg(s.icon) : '') + (s.html || '');
|
||||
} else {
|
||||
seg.textContent = String(s == null ? '' : s); /* ข้อความล้วน — ปลอดภัยจาก HTML */
|
||||
}
|
||||
host.appendChild(seg);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- "อัปเดตล่าสุด N วันที่แล้ว" จากฟิลด์ updated (ISO) ----------
|
||||
เทียบ "วันนี้" กับวันที่ในฟิลด์ updated (ไม่ใช้เวลา → ไม่มีปัญหา timezone)
|
||||
วันเดียวกัน → "วันนี้" · เมื่อวาน → "เมื่อวาน"
|
||||
< 7 วัน → N วันที่แล้ว · < 30 วัน → N สัปดาห์ที่แล้ว
|
||||
< 365 วัน → N เดือนที่แล้ว · มากกว่า → N ปี M เดือนที่แล้ว
|
||||
หมายเหตุ: ใช้ mtime/Last-Modified จากเบราว์เซอร์ไม่ได้ (fetch ข้ามโดเมนไม่ให้อ่าน)
|
||||
→ ค่ามาจาก resource/tools/stamp-schedules.py ที่เติมจาก mtime จริง */
|
||||
function daysAgo(iso) {
|
||||
var m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '').trim());
|
||||
if (!m) return null;
|
||||
var then = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3]));
|
||||
if (isNaN(then.getTime())) return null;
|
||||
var now = new Date();
|
||||
var today = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()));
|
||||
return Math.round((today - then) / 86400000);
|
||||
}
|
||||
function agoLabel(days) {
|
||||
if (days == null) return '';
|
||||
if (days <= 0) return t('check.agoToday');
|
||||
if (days === 1) return t('check.agoYesterday');
|
||||
if (days < 7) return t('check.agoDays', { n: days });
|
||||
if (days < 30) return t('check.agoWeeks', { n: Math.floor(days / 7) });
|
||||
if (days < 365) return t('check.agoMonths', { n: Math.floor(days / 30) });
|
||||
var y = Math.floor(days / 365), mo = Math.floor((days % 365) / 30);
|
||||
return mo ? t('check.agoYearsMonths', { y: y, m: mo }) : t('check.agoYears', { y: y });
|
||||
}
|
||||
|
||||
function appendSubStopCards(listEl, rid, groups, schedDoc, recs) {
|
||||
if (!window.OtherStop || !OtherStop.allStops || !window.Schedules) return;
|
||||
/* allStops() คืน "รายการแบน": [{ index, name, city_th, province_th, lat, lng, offsetMin, hasCoord, entry }] */
|
||||
var sub = OtherStop.allStops(OTHER_ENTRIES, rid, ROUTE_IDS);
|
||||
if (!sub || sub.length < 2) return; /* มีจุดเดียว = การ์ดหลักแสดงอยู่แล้ว */
|
||||
|
||||
var first = sub[0].name;
|
||||
|
||||
/* จุดอ้างอิง = จุดแรกของจุดย่อย (index 0 · offset = 0) ซึ่งตรงกับการ์ดหลัก (station 8)
|
||||
แต่ละทิศมี "จุดอ้างอิงของตัวเอง" — ทิศที่มีข้อมูล (station_id = จุดอ้างอิง) ให้ offset คงที่ (+0)
|
||||
สายที่วิ่ง 2 ทาง (ไป-กลับ) จึงแสดงครบทั้ง 2 ทิศในทุกจุดย่อย
|
||||
ทิศที่ยังไม่มีตาราง (แค่ชื่อทิศ) → ไม่แสดง (ห้ามเดาเวลาที่ไม่มีต้นทาง) */
|
||||
/* จุดอ้างอิง = "จุดขึ้นรถประจำทางอื่นๆ" (station 8) — จุดแรกของ other_stop คือจุดที่มีตารางจริง
|
||||
ไม่ใช้ "record แรก" เพราะ recs เรียงตาม station_order (บขส.อ่างทองมาก่อน) จะได้จุดอ้างอิงผิด */
|
||||
var hubSid = null, hubDir = null; /* hubDir = ชื่อทิศ "ของจุดอ้างอิง" (ตัวตั้งเวลา) */
|
||||
groups.forEach(function (g) {
|
||||
if (String(g.sid) === '8') hubSid = '8';
|
||||
});
|
||||
if (hubSid === null) { /* ไม่มี station 8 → ใช้จุดแรกที่มีเวลาตามเดิม */
|
||||
groups.forEach(function (g) {
|
||||
g.recs.forEach(function (r) {
|
||||
if ((r.departure_times || []).length && hubSid === null) hubSid = String(r.station_id);
|
||||
});
|
||||
});
|
||||
}
|
||||
/* ทิศตั้งต้น = ทิศที่ "เริ่มจากจุดอ้างอิง" (จุดแรกของ other_stop = วัดสีบัวทอง)
|
||||
ตัวชี้ที่ใช้ได้: ชื่อทิศตรงกับ "จาก<ชื่อจุดแรก>" หรือ note ของจุดย่อย */
|
||||
var hubName = sub[0].name;
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) !== rid) return;
|
||||
if (hubDir !== null || !(r.departure_times || []).length) return;
|
||||
var lbl = String((r.direction_label || r.dir_label) || '');
|
||||
var note = String((r.direction_note || r.dir_note) || '');
|
||||
if (lbl.indexOf(hubName) !== -1 || note.indexOf(hubName) === 0) hubDir = (r.direction_label || r.dir_label);
|
||||
});
|
||||
if (hubSid === null) return; /* ไม่มีตารางจริงเลย → คำนวณไม่ได้ */
|
||||
|
||||
/* ทุกทิศของสายนี้: ทิศของจุดอ้างอิง = เวลาต้นทาง · ทิศอื่น = จุดอ้างอิง + offset ของจุดนี้ */
|
||||
var legs = [];
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) !== rid) return; /* เฉพาะสายนี้ — recs มีทุกสาย */
|
||||
if (!(r.departure_times || []).length) return; /* ทิศนี้ยังไม่มีตาราง → ข้าม */
|
||||
legs.push({ rec: r, fixed: ((r.direction_label || r.dir_label) === hubDir) ? 0 : null });
|
||||
});
|
||||
if (!legs.length) return; /* ไม่มีทิศที่คำนวณได้ → ไม่แสดงการ์ดย่อย */
|
||||
|
||||
/* จุดแรกของจุดย่อย = จุดอ้างอิงเอง (แสดงเป็นการ์ดหลักอยู่แล้ว) → เริ่มที่จุดที่ 2
|
||||
และข้ามจุดที่พิกัด/ชื่อซ้ำกับจุดอ้างอิง */
|
||||
sub.slice(1).forEach(function (x) {
|
||||
if (x.name === hubName) return; /* ชื่อซ้ำกับการ์ดต้นทาง → ไม่แสดงซ้ำ */
|
||||
var off = (x.offsetMin == null ? null : Number(x.offsetMin));
|
||||
var li = document.createElement('li');
|
||||
var det = document.createElement('details');
|
||||
det.className = 'mu-stop-card';
|
||||
det.open = true;
|
||||
var where = [x.city_th, x.province_th].filter(Boolean).join(' · ');
|
||||
var sum = document.createElement('summary');
|
||||
sum.innerHTML =
|
||||
'<span class="mu-stop-head ' + TONES.transfer + '">' +
|
||||
'<span class="mu-stop-kind"><svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg> <span>' +
|
||||
esc(t('stops.subStop')) + '</span></span>' +
|
||||
'<span class="mu-stop-title"><strong>' + esc(x.name) + '</strong><small>' + esc(where) + '</small></span>' +
|
||||
'<span class="mu-stop-chevron">\u2304</span>' +
|
||||
'</span>';
|
||||
det.appendChild(sum);
|
||||
|
||||
var body = document.createElement('div');
|
||||
body.className = 'mu-stop-body';
|
||||
|
||||
if (off == null) { /* ยังไม่ระบุเวลาเดินทาง → คำนวณไม่ได้ */
|
||||
var na = document.createElement('p');
|
||||
na.className = 'mu-stop-sub';
|
||||
na.textContent = t('stops.noOffset');
|
||||
body.appendChild(na);
|
||||
} else {
|
||||
legs.forEach(function (leg) {
|
||||
var r = leg.rec;
|
||||
var raw = (r.departure_times || []).length ? r.departure_times : [];
|
||||
if (!raw.length) return; /* ทิศนี้ยังไม่มีตารางจริง → ข้าม */
|
||||
|
||||
/* ทิศของจุดอ้างอิงเอง (fixed = 0) → เวลาเท่าต้นทาง · ทิศอื่น → บวก offset ของจุดนี้ */
|
||||
var o = (leg.fixed === 0) ? 0 : off;
|
||||
var times = (o === 0) ? raw.slice() : Schedules.shiftTimes(raw, o);
|
||||
|
||||
var head = document.createElement('p');
|
||||
head.className = 'mu-stop-sub';
|
||||
head.textContent = (r.direction_label || r.dir_label) || r.direction_note || ('จาก ' + first);
|
||||
body.appendChild(head);
|
||||
|
||||
var grid = document.createElement('div');
|
||||
grid.className = 'mu-time-grid' + (o === 0 ? '' : ' is-est');
|
||||
var chips = [];
|
||||
times.forEach(function (tm) {
|
||||
var chip = document.createElement('div');
|
||||
chip.className = 'mu-time-chip';
|
||||
chip.textContent = tm;
|
||||
grid.appendChild(chip);
|
||||
chips.push(chip);
|
||||
});
|
||||
body.appendChild(grid);
|
||||
/* ให้จุดย่อยอยู่ในระบบ "รอบถัดไป" ด้วย (refreshHighlights วน sections[])
|
||||
ไม่งั้นชิปของจุดย่อยไม่ถูกไฮไลต์ และรอบถัดไปมองไม่เห็นเวลาของจุดนี้ */
|
||||
sections.push({ chips: chips, times: times, station: x.name });
|
||||
|
||||
if (o !== 0) {
|
||||
var note = document.createElement('p');
|
||||
note.className = 'mu-est-note';
|
||||
note.textContent = t('time.derived', { base: first, n: Schedules.offsetLabel(o) });
|
||||
body.appendChild(note);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
det.appendChild(body);
|
||||
li.appendChild(det);
|
||||
listEl.appendChild(li);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- ไฮไลต์เที่ยวถัดไป + บรรทัดเวลาปัจจุบัน ---------- */
|
||||
function refreshHighlights() {
|
||||
var nowm = nowMin();
|
||||
var next = null; /* เที่ยวถัดไปที่เร็วที่สุดในทุกจุดจอด */
|
||||
|
||||
/* เลือกเที่ยวถัดไปของจุดหนึ่ง ๆ
|
||||
- ถ้ามีเที่ยวที่ยังไม่ผ่านวันนี้ → ใช้ตัวแรกนั้น
|
||||
- ถ้าหมดทุกเที่ยวของวันแล้ว → วนไปเที่ยวแรกของ "วันถัดไป" (+1440 เพื่อเทียบลำดับข้ามวันได้)
|
||||
หน้าจอแสดงแค่ HH:MM (ไม่ติดป้าย "พรุ่งนี้" — เจ้าของข้อมูลกำหนด) แต่ไฮไลต์ชิปแบบเดียวกัน */
|
||||
function pick(sec, idx, m) {
|
||||
if (idx < 0 || !sec.chips[idx]) return;
|
||||
sec.chips[idx].classList.add('next');
|
||||
if (next === null || m < next.m) next = { m: m, time: sec.times[idx], station: sec.station };
|
||||
}
|
||||
|
||||
sections.forEach(function (sec) {
|
||||
sec.chips.forEach(function (c) { c.classList.remove('next'); });
|
||||
if (!sec.times.length) return;
|
||||
for (var i = 0; i < sec.times.length; i++) {
|
||||
var m = toMin(sec.times[i]);
|
||||
if (m >= nowm) { pick(sec, i, m); return; }
|
||||
}
|
||||
pick(sec, 0, toMin(sec.times[0]) + 1440); /* หมดวัน → เที่ยวแรกพรุ่งนี้ */
|
||||
});
|
||||
|
||||
setStat('check-stat-next', next ? next.time : '');
|
||||
|
||||
var line = $('check-now-line');
|
||||
if (!line) return;
|
||||
var nowSegs = [{ icon: 'ic-clock', html: esc(t('check.now')) + ' <b>' + hhmm(nowm) + '</b>' }];
|
||||
if (next) {
|
||||
nowSegs.push({ html: esc(t('check.nextAt')) + ' <b>' + esc(next.time) + '</b> ' +
|
||||
'<span class="mu-zone-at">(' + esc(next.station) + ')</span>' });
|
||||
} else if (sections.length) {
|
||||
nowSegs.push({ html: '<b>' + esc(t('check.noMoreToday')) + '</b>' });
|
||||
}
|
||||
setSegments(line, nowSegs);
|
||||
}
|
||||
|
||||
/* ---------- โหลด + แสดงผล ---------- */
|
||||
function init() {
|
||||
var params = (window.__route && window.__route.params) || {};
|
||||
var query = (window.__route && window.__route.query) || {};
|
||||
var want = String(params.routeId || query.route || '');
|
||||
|
||||
Promise.all([
|
||||
fetchJSON(DATA + 'routes.json'),
|
||||
fetchJSON(DATA + 'stations.json'),
|
||||
Schedules.load().then(function (sd) { return Schedules.normSub(sd); }),
|
||||
fetchJSON(DATA + '8 other_stop.json').catch(function () { return null; }) /* จุดย่อยของ "จุดขึ้นรถอื่นๆ" */
|
||||
]).then(function (res) {
|
||||
var routes = (res[0] || {}).routes || [];
|
||||
OTHER_ENTRIES = (res[3] || {}).other_stop || [];
|
||||
ROUTE_IDS = routes.map(function (r) { return String(r.route_id); });
|
||||
var sts = (res[1] || {}).stations || [];
|
||||
if (window.Schedules && Schedules.setStationNames) Schedules.setStationNames(sts); /* ให้ข้อความ "คำนวณจาก ..." มีชื่อจุด */
|
||||
var recs = window.Schedules ? Schedules.records(res[2]) : ((res[2] || {}).schedules || res[2] || []);
|
||||
if (!routes.length) return;
|
||||
|
||||
var route = routes.filter(function (r) { return String(r.route_id) === want; })[0] ||
|
||||
routes.filter(function (r) { return String(r.route_id) === FALLBACK_ID; })[0] || routes[0];
|
||||
var rid = String(route.route_id);
|
||||
netRoute = route;
|
||||
|
||||
var byId = {};
|
||||
sts.forEach(function (s) { byId[s.station_id] = s; });
|
||||
|
||||
/* ตัวเลือกสายรถ (จาก routes.json) */
|
||||
var sel = $('check-route-select');
|
||||
if (sel) {
|
||||
sel.innerHTML = '';
|
||||
routes.forEach(function (r) {
|
||||
var o = document.createElement('option');
|
||||
o.value = r.route_id;
|
||||
o.textContent = 'สาย ' + r.route_id + (r.route_name_th ? ' - ' + r.route_name_th : '');
|
||||
sel.appendChild(o);
|
||||
});
|
||||
sel.value = rid;
|
||||
sel.addEventListener('change', function () {
|
||||
window.location.href = '/check/' + encodeURIComponent(sel.value);
|
||||
});
|
||||
}
|
||||
|
||||
/* Hero + คำอธิบายโซน */
|
||||
var hero = $('check-hero-route');
|
||||
if (hero) hero.textContent = 'สาย ' + rid + (route.route_name_th ? ' · ' + route.route_name_th : '');
|
||||
|
||||
/* "อัปเดตล่าสุด N วันที่แล้ว" — วันที่จากฟิลด์ updated ของไฟล์ตารางสายนี้ (Schedules.updatedOf)
|
||||
แยกบรรทัดของตัวเอง (#check-updated-line) เพราะ #check-now-line แสดงเวลาปัจจุบันอยู่แล้ว */
|
||||
var updLine = $('check-updated-line');
|
||||
if (updLine) {
|
||||
var upd = (window.Schedules && Schedules.updatedOf) ? Schedules.updatedOf(rid) : null;
|
||||
var nDays = daysAgo(upd);
|
||||
updLine.textContent = nDays == null ? '' : t('check.updatedAgo', { ago: agoLabel(nDays) });
|
||||
}
|
||||
|
||||
/* จัดกลุ่มตามลำดับจุดจอดของสาย แล้วต่อด้วยจุดที่เหลือ (ถ้ามีข้อมูล) */
|
||||
var order = (route.station_ids || []).slice();
|
||||
/* schema 2: ใช้ station_order ที่ตรวจทิศทางมาแล้วจากไฟล์ (ถ้ามี) */
|
||||
var sched = window.Schedules ? Schedules.route(res[2], rid) : null;
|
||||
if (sched && sched.station_order.length) order = sched.station_order.slice();
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) === rid && order.indexOf(r.station_id) === -1) order.push(r.station_id);
|
||||
});
|
||||
|
||||
/* จุดที่เป็น "จุดขึ้นรถประจำทางอื่นๆ" (station 8) ให้ใช้ชื่อจริงของสายนั้น
|
||||
จาก 8 other_stop.json (จุดแรก) เช่น 954 → "ตลาดท่าช้าง" แทนชื่อกลาง ๆ */
|
||||
var firstSubName = null;
|
||||
if (window.OtherStop && OtherStop.allStops) {
|
||||
var allSub = OtherStop.allStops(OTHER_ENTRIES, rid, ROUTE_IDS);
|
||||
if (allSub.length) firstSubName = allSub[0].name; /* จุดแรกของจุดย่อย = ชื่อจริงของสายนี้ */
|
||||
}
|
||||
|
||||
var groups = order.map(function (sid) {
|
||||
var st = byId[sid] || null;
|
||||
var isOtherHub = String(sid) === '8'; /* จุดรวม "จุดขึ้นรถอื่นๆ" */
|
||||
return {
|
||||
sid: sid,
|
||||
st: st,
|
||||
name: isOtherHub && firstSubName ? firstSubName : (st ? st.station_name_th : 'จุดจอด ' + sid),
|
||||
city: st ? st.city_th : '',
|
||||
code: st ? st.station_code : '',
|
||||
recs: recs.filter(function (r) { return String(r.route_id) === rid && r.station_id === sid; })
|
||||
};
|
||||
}).filter(function (g) {
|
||||
return !ONLY_STOPS_WITH_SCHEDULE || g.recs.length;
|
||||
});
|
||||
|
||||
var listEl = $('check-schedule-list');
|
||||
if (listEl) {
|
||||
renderList(listEl, route, groups);
|
||||
/* จุดย่อยของสายนั้น (จาก 8 other_stop.json) — จุดที่ 2 เป็นต้นไปของสาย 8
|
||||
เช่น 2194: ① วัดหัวเวียง ② วัดถนน (เวลาจุดถัดไป = เวลาจุดแรก + offsets_min) */
|
||||
appendSubStopCards(listEl, rid, groups, res[2], recs);
|
||||
}
|
||||
|
||||
var desc = $('check-zone-desc');
|
||||
if (desc) {
|
||||
var names = groups.map(function (g) { return g.name; });
|
||||
/* บอกว่า "ตารางวันนี้" เป็นของวันไหน — เฉพาะสายที่มีการแยกตารางตามวัน (service) เท่านั้น
|
||||
สายอื่นข้อความเหมือนเดิมทุกตัวอักษร */
|
||||
/* ป้ายบอกว่า "ตารางที่เห็นอยู่นี้เป็นของวันไหน" — ใช้ผลตรวจวันจากตัวอ่านกลาง (ไม่คำนวณเองในหน้านี้) */
|
||||
var dayText = '';
|
||||
if (window.Schedules && Schedules.dayInfo && Schedules.directions) {
|
||||
var di = Schedules.dayInfo();
|
||||
var infos = (Schedules.directions(res[2], rid) || []).map(function (d) { return d.service || { from: 'ไม่ระบุ' }; });
|
||||
var conflict = infos.some(function (x) { return x.conflict; }); /* ทิศเดียวมีทั้งวันทำงาน+วันหยุด */
|
||||
var unknown = infos.some(function (x) { return x.unknown; }); /* ยังไม่ระบุวันเลย */
|
||||
var selectedByDay = infos.some(function (x) { return x.from === 'service' || x.from === 'ระบุตรง' || x.from === 'คำในโน้ต'; });
|
||||
if (unknown) {
|
||||
dayText = t('check.dayUnknown');
|
||||
} else if (conflict) {
|
||||
dayText = t('check.dayMixed');
|
||||
} else if (selectedByDay) {
|
||||
dayText = t(di.dayType === 'holiday' ? 'check.dayHoliday' : 'check.dayWeekday') +
|
||||
' (' + t('check.dayOfWeek') + ' ' + di.weekday_th + ')';
|
||||
}
|
||||
}
|
||||
/* แยกเป็นชิ้น ๆ เพื่อให้ตัดบรรทัดได้เป็นหน่วย (ไม่ตัดกลางชื่อสถานี/ชื่อวัน) */
|
||||
var segs = ['สาย ' + rid];
|
||||
if (names.length > 1) segs.push(names[0] + ' \u2192 ' + names[names.length - 1]);
|
||||
segs.push(groups.length + ' ' + t('check.stopsCount'));
|
||||
if (dayText) segs.push(dayText);
|
||||
setSegments(desc, segs);
|
||||
}
|
||||
|
||||
/* KPI */
|
||||
setStat('check-stat-stops', groups.length); /* นับจุดจอดที่แสดงจริง (ให้ตรงกับรายการด้านล่าง) */
|
||||
setStat('check-stat-provinces', route.province_ids ? route.province_ids.length : '');
|
||||
var trips = 0;
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) === rid) trips += (r.departure_times || []).length;
|
||||
});
|
||||
setStat('check-stat-trips', trips ? String(trips) : '');
|
||||
|
||||
refreshHighlights();
|
||||
if (timer) clearInterval(timer);
|
||||
timer = setInterval(refreshHighlights, REFRESH_MS);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('visibilitychange', function () {
|
||||
if (!document.hidden) refreshHighlights();
|
||||
});
|
||||
|
||||
export default function mount(): void {
|
||||
init();
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/home.init.js — logic unchanged; bootstrap converted to mount(). */
|
||||
/* ---- ported module body ---- */
|
||||
'use strict';
|
||||
|
||||
// แหล่งข้อมูลเดียว (source of truth) — อย่า hardcode รายชื่อจังหวัด/สถานีไว้ในไฟล์นี้
|
||||
var DATA_URL = {
|
||||
provinces: '/resource/data/provinces.json',
|
||||
stations: '/resource/data/stations.json',
|
||||
routeGroups: '/resource/data/route_groups.json',
|
||||
routes: '/resource/data/routes.json',
|
||||
routesMunicipal: '/resource/data/routes_municipal.json',
|
||||
schedules: '/resource/data/schedules.json',
|
||||
affiliates: '/resource/data/affiliates.json',
|
||||
};
|
||||
|
||||
// จังหวัดเริ่มต้น (home province ของเว็บนี้) — ใช้เป็นค่า default ของ hero + ตัวเลือก
|
||||
var DEFAULT_PROVINCE = 'อ่างทอง';
|
||||
|
||||
function fetchJSON(url) {
|
||||
return fetch(url, { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.catch(function () { return null; });
|
||||
}
|
||||
|
||||
/* สถานะที่ผู้ใช้เลือก (ใช้กรองการ์ด + สร้างลิงก์แชร์) */
|
||||
var state = { provinceId: null, provinceName: DEFAULT_PROVINCE, stationCode: '', stationId: null };
|
||||
var PROVINCES = []; /* [{ province_id, province_name_th }] */
|
||||
var STATIONS = []; /* [{ station_id, station_code, station_name_th, province_th }] */
|
||||
|
||||
function initHomeSelectors() {
|
||||
var provinceSelect = document.getElementById('province-select');
|
||||
var stationSelect = document.getElementById('station-select');
|
||||
var stationHint = document.getElementById('station-hint');
|
||||
var heroProvince = document.getElementById('hero-province');
|
||||
if (!provinceSelect || !stationSelect) return;
|
||||
|
||||
var tr = window.I18N ? window.I18N.t : function (k) { return k; };
|
||||
var q = (window.__route && window.__route.query) || {}; /* ลิงก์สั้น: #/?s=<รหัสสถานี> หรือ #/?p=<province_id> */
|
||||
|
||||
// โหลดจังหวัด + สถานี จาก resource/data/*.json (โหลดพร้อมกันรอบเดียว)
|
||||
Promise.all([
|
||||
fetchJSON(DATA_URL.provinces),
|
||||
fetchJSON(DATA_URL.stations)
|
||||
]).then(function (results) {
|
||||
PROVINCES = ((results[0] || {}).provinces) || [];
|
||||
STATIONS = ((results[1] || {}).stations) || [];
|
||||
if (!PROVINCES.length) return; // โหลดข้อมูลไม่สำเร็จ → ปล่อย select ว่างไว้
|
||||
|
||||
/* เลือกจังหวัดเริ่มต้น: จากลิงก์ (?p= / ?s=) → ไม่งั้นใช้จังหวัดหลักของเว็บ */
|
||||
var startProvinceId = null;
|
||||
var startStationCode = q.s ? String(q.s) : '';
|
||||
if (startStationCode) {
|
||||
var st0 = STATIONS.filter(function (s) { return s.station_code === startStationCode; })[0];
|
||||
if (st0) {
|
||||
var pr0 = PROVINCES.filter(function (p) { return p.province_name_th === (st0.province_th || DEFAULT_PROVINCE); })[0];
|
||||
if (pr0) startProvinceId = pr0.province_id;
|
||||
}
|
||||
}
|
||||
if (startProvinceId === null && q.p) startProvinceId = parseInt(q.p, 10);
|
||||
if (startProvinceId === null) {
|
||||
var def = PROVINCES.filter(function (p) { return p.province_name_th === DEFAULT_PROVINCE; })[0];
|
||||
startProvinceId = def ? def.province_id : PROVINCES[0].province_id;
|
||||
}
|
||||
|
||||
provinceSelect.innerHTML = '';
|
||||
PROVINCES.forEach(function (p) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = p.province_id;
|
||||
opt.textContent = p.province_name_th;
|
||||
if (p.province_id === startProvinceId) opt.selected = true;
|
||||
provinceSelect.appendChild(opt);
|
||||
});
|
||||
|
||||
function provinceName(id) {
|
||||
var p = PROVINCES.filter(function (x) { return x.province_id === id; })[0];
|
||||
return p ? p.province_name_th : '';
|
||||
}
|
||||
|
||||
function stationsFor(provinceId) {
|
||||
var name = provinceName(provinceId);
|
||||
return STATIONS.filter(function (s) {
|
||||
// สถานีที่ไม่มี province (เช่น "จุดขึ้นรถประจำทางอื่นๆ") ให้ถือว่าอยู่ในจังหวัดหลัก
|
||||
return (s.province_th || DEFAULT_PROVINCE) === name;
|
||||
});
|
||||
}
|
||||
|
||||
function populateStations(provinceId, preferredCode) {
|
||||
stationSelect.innerHTML = '';
|
||||
var list = stationsFor(provinceId);
|
||||
|
||||
list.forEach(function (st) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = st.station_code; /* ใช้รหัสสถานี = ลิงก์สั้น อ่านง่าย */
|
||||
opt.textContent = st.station_name_th;
|
||||
stationSelect.appendChild(opt);
|
||||
});
|
||||
|
||||
if (!list.length) {
|
||||
var none = document.createElement('option'); /* ไม่มีสถานีในจังหวัดนี้ → บอกด้วยตัวเลือกว่าง */
|
||||
none.value = '';
|
||||
none.textContent = tr('home.stationEmpty');
|
||||
none.disabled = true;
|
||||
stationSelect.appendChild(none);
|
||||
if (stationHint) stationHint.textContent = tr('home.stationEmptyHint') + ' ' + provinceName(provinceId);
|
||||
} else if (stationHint) {
|
||||
stationHint.innerHTML = tr('home.stationCount', { n: list.length }) + ' ' + provinceName(provinceId);
|
||||
}
|
||||
|
||||
/* คืนค่าที่เลือกไว้ (จากลิงก์) ถ้ามีในจังหวัดนี้ */
|
||||
if (preferredCode && list.some(function (s) { return s.station_code === preferredCode; })) {
|
||||
stationSelect.value = preferredCode; /* จากลิงก์แชร์ (?s=) */
|
||||
} else if (list.length) {
|
||||
stationSelect.value = list[0].station_code; /* ไม่มีตัวเลือก "ทุกสถานี" แล้ว → เลือกสถานีแรก */
|
||||
} else {
|
||||
stationSelect.value = '';
|
||||
}
|
||||
|
||||
var prefix = tr('home.provincePrefix');
|
||||
var pname = provinceName(provinceId);
|
||||
// กรุงเทพมหานครเป็นเขตปกครองพิเศษ ไม่ใช่ "จังหวัด" → ไม่เติมคำนำหน้า
|
||||
var label = (prefix && pname !== 'กรุงเทพมหานคร') ? prefix + ' ' + pname : pname;
|
||||
if (heroProvince) heroProvince.textContent = label;
|
||||
}
|
||||
|
||||
/* อ่านสถานะจาก select แล้ววาดการ์ดใหม่ */
|
||||
function syncState() {
|
||||
state.provinceId = parseInt(provinceSelect.value, 10);
|
||||
state.provinceName = provinceName(state.provinceId);
|
||||
state.stationCode = stationSelect.value || '';
|
||||
var st = STATIONS.filter(function (s) { return s.station_code === state.stationCode; })[0];
|
||||
state.stationId = st ? st.station_id : null;
|
||||
}
|
||||
|
||||
provinceSelect.addEventListener('change', function () {
|
||||
populateStations(parseInt(provinceSelect.value, 10));
|
||||
syncState();
|
||||
renderZones();
|
||||
});
|
||||
|
||||
stationSelect.addEventListener('change', function () {
|
||||
syncState();
|
||||
renderZones();
|
||||
});
|
||||
|
||||
populateStations(startProvinceId, startStationCode);
|
||||
syncState();
|
||||
renderZones();
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
ไทล์พาร์ทเนอร์ (marquee) — สร้างจาก resource/data/affiliates.json
|
||||
· แก้รายชื่อ/รูป/ลิงก์ที่ไฟล์ JSON ไม่ต้องแตะโค้ด
|
||||
· affiliate_link ว่าง = ยังไม่มีลิงก์ → แสดงเป็นไทล์เฉย ๆ (ไม่เป็นลิงก์ กดไม่ได้)
|
||||
· โหลด JSON ไม่ได้/ว่าง → คงไทล์เดิมที่ฝังใน HTML (fallback ไม่ให้หน้าว่าง)
|
||||
============================================================ */
|
||||
/* path รูปไทล์ — JSON เก็บแบบ ".image/partners/x.png" (แบบ mock)
|
||||
แต่ Next เสิร์ฟรูปที่ /image/... → ต้องทำเป็น absolute path */
|
||||
function tileSrc(raw) {
|
||||
var v = String(raw == null ? '' : raw).trim();
|
||||
if (/^https?:\/\//i.test(v) || v.indexOf('//') === 0) return v;
|
||||
v = v.replace(/^@url:\s*/i, '').replace(/`/g, '').trim();
|
||||
v = v.replace(/^(\.\.\/)+/, '').replace(/^\.\//, '').replace(/^\/+/, '');
|
||||
if (v.indexOf('.image/') === 0) v = 'image/' + v.slice(7);
|
||||
return '/' + v;
|
||||
}
|
||||
|
||||
function initSponsors() {
|
||||
var track = document.querySelector('.mu-marquee-track');
|
||||
if (!track) return Promise.resolve();
|
||||
|
||||
return fetchJSON(DATA_URL.affiliates).then(function (d) {
|
||||
var list = (d && d.partners) || [];
|
||||
var tiles = list.filter(function (p) { return p && p.in_footer_marquee && p.tile_image; });
|
||||
if (!tiles.length) return; /* ไม่มีข้อมูล → คงไทล์เดิม */
|
||||
|
||||
var frag = document.createDocumentFragment();
|
||||
tiles.forEach(function (p) {
|
||||
var link = String(p.affiliate_link || '').trim();
|
||||
/* มีลิงก์ = <a> · ยังไม่มี = <span> (กดไม่ได้ ไม่พาไปหน้าเปล่า) */
|
||||
var node = document.createElement(link ? 'a' : 'span');
|
||||
node.className = 'mu-marquee-tile';
|
||||
node.setAttribute('aria-label', p.brand || '');
|
||||
|
||||
var img = document.createElement('img');
|
||||
var src = tileSrc(p.tile_image);
|
||||
img.src = (window.ImgURL && ImgURL.of) ? ImgURL.of(src) : src;
|
||||
img.alt = p.brand || '';
|
||||
img.decoding = 'async';
|
||||
node.appendChild(img);
|
||||
|
||||
if (link) {
|
||||
node.href = link;
|
||||
node.target = '_blank';
|
||||
node.rel = 'noopener sponsored'; /* ลิงก์ affiliate → ระบุ sponsored */
|
||||
} else {
|
||||
node.setAttribute('title', p.brand || '');
|
||||
}
|
||||
frag.appendChild(node);
|
||||
});
|
||||
track.innerHTML = '';
|
||||
track.appendChild(frag);
|
||||
});
|
||||
}
|
||||
|
||||
function initMarquee() {
|
||||
var track = document.querySelector('.mu-marquee-track');
|
||||
if (!track || track.dataset.cloned) return;
|
||||
var reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
if (!reduce) {
|
||||
track.innerHTML += track.innerHTML;
|
||||
track.dataset.cloned = '1';
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
การ์ดหมวดเส้นทาง — สร้างจาก route_groups.json + routes.json
|
||||
(หมวดเทศบาลอ่านเพิ่มจาก routes_municipal.json ซึ่งเป็นไฟล์เปล่า
|
||||
พร้อมคีย์ครบ — เติมเมื่อไหร่การ์ดก็ขึ้นเอง)
|
||||
============================================================ */
|
||||
var GROUP_META = {
|
||||
municipal: { tag: 'tag-yellow', i18n: 'zone.municipal', desc: 'zone.municipalDesc', empty: 'zone.municipalNA' },
|
||||
bangkok: { tag: 'tag-sky', i18n: 'zone.bangkok', desc: 'zone.bangkokDesc' },
|
||||
interprovincial: { tag: 'tag-purple', i18n: 'zone.interprov', desc: 'zone.interprovDesc' },
|
||||
in_province: { tag: 'tag-pink', i18n: 'zone.inprov', desc: 'zone.inprovDesc' }
|
||||
};
|
||||
/* สีชิปหมุนวนตามลำดับการ์ด; ค่าที่เคยกำหนดเฉพาะสายไว้เดิมอยู่ใน FIXED_BADGE
|
||||
(ถ้าต้องการย้ายมาคุมจาก JSON ให้ใส่คีย์ "badge" ใน routes.json) */
|
||||
var BADGE_CYCLE = ['badge-purple', 'badge-sky', 'badge-pink', 'badge-mint'];
|
||||
var FIXED_BADGE = { '324': 'badge-pink', '1011': 'badge-mint', '2231': 'badge-purple', '999': 'badge-sky' };
|
||||
var ICON = { next: 'ic-alarm-clock', schedule: 'ic-check', none: 'ic-hourglass' };
|
||||
var chipSlots = []; /* { wrap, routeId } ไว้รีเฟรชทุกนาที */
|
||||
|
||||
function toMin(hhmm) {
|
||||
var a = String(hhmm).split(':');
|
||||
return (parseInt(a[0], 10) || 0) * 60 + (parseInt(a[1], 10) || 0);
|
||||
}
|
||||
function nowMin() { var d = new Date(); return d.getHours() * 60 + d.getMinutes(); }
|
||||
|
||||
/* เที่ยวถัดไปของสาย = เที่ยวแรกที่ยังไม่ผ่าน (ไม่วนไปพรุ่งนี้ — ตรงกับหน้าเช็กเวลา) */
|
||||
function nextTripOf(times) {
|
||||
var now = nowMin();
|
||||
var sorted = times.slice().sort();
|
||||
for (var i = 0; i < sorted.length; i++) {
|
||||
if (toMin(sorted[i]) >= now) return sorted[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* โหลดข้อมูลหมวด/เส้นทาง/เวลา ครั้งเดียว แล้วเก็บไว้ใช้ซ้ำ */
|
||||
var ZDATA = { loaded: false, groups: [], routes: [], timesByRoute: {} };
|
||||
|
||||
function loadZoneData() {
|
||||
if (ZDATA.loaded) return Promise.resolve();
|
||||
return Promise.all([
|
||||
fetchJSON(DATA_URL.routeGroups),
|
||||
fetchJSON(DATA_URL.routes),
|
||||
fetchJSON(DATA_URL.routesMunicipal),
|
||||
(window.Schedules ? Schedules.load().then(function (sd) { return Schedules.normSub(sd); }) : fetchJSON(DATA_URL.schedules))
|
||||
]).then(function (res) {
|
||||
var groups = ((res[0] || {}).route_groups) || [];
|
||||
var routes = ((res[1] || {}).routes) || [];
|
||||
var municipal = ((res[2] || {}).routes) || [];
|
||||
var recs = window.Schedules ? Schedules.records(res[3]) : ((res[3] || {}).schedules || res[3] || []);
|
||||
if (!groups.length || !routes.length) return;
|
||||
|
||||
/* รวมเส้นทางหมวดเทศบาลจากไฟล์แยก (ข้ามแถวที่ยังไม่ได้กรอก) */
|
||||
ZDATA.groups = groups.filter(function (g) { return g.is_active !== false; })
|
||||
.slice()
|
||||
.sort(function (a, b) { return (a.display_order || 0) - (b.display_order || 0); });
|
||||
ZDATA.routes = routes.concat(municipal.filter(function (r) { return r && r.route_id; }));
|
||||
|
||||
var t = {};
|
||||
recs.forEach(function (r) {
|
||||
var k = String(r.route_id);
|
||||
t[k] = (t[k] || []).concat(r.departure_times || []);
|
||||
});
|
||||
ZDATA.timesByRoute = t;
|
||||
ZDATA.loaded = true;
|
||||
});
|
||||
}
|
||||
|
||||
/* กรองเส้นทางตามที่เลือก: สถานี → จังหวัด → ทั้งหมด */
|
||||
function routesForSelection() {
|
||||
if (state.stationId) {
|
||||
return ZDATA.routes.filter(function (r) {
|
||||
return (r.station_ids || []).indexOf(state.stationId) !== -1;
|
||||
});
|
||||
}
|
||||
if (state.provinceId) {
|
||||
return ZDATA.routes.filter(function (r) {
|
||||
return (r.province_ids || []).indexOf(state.provinceId) !== -1;
|
||||
});
|
||||
}
|
||||
return ZDATA.routes;
|
||||
}
|
||||
|
||||
function renderZones() {
|
||||
var host = document.getElementById('route-zones');
|
||||
if (!host) return;
|
||||
var tr = window.I18N ? window.I18N.t : function (k) { return k; };
|
||||
|
||||
loadZoneData().then(function () {
|
||||
if (!ZDATA.loaded) return;
|
||||
var mine = routesForSelection();
|
||||
|
||||
host.innerHTML = '';
|
||||
chipSlots = []; /* กันชิปซ้ำหลังวาดใหม่ */
|
||||
ZDATA.groups.forEach(function (g) {
|
||||
host.appendChild(zoneSection(g, mine, ZDATA.timesByRoute, tr));
|
||||
});
|
||||
|
||||
if (shareRefresh) shareRefresh(); /* อัปเดตลิงก์สั้นตามที่เลือก */
|
||||
if (!zoneTimer && chipSlots.length) {
|
||||
zoneTimer = setInterval(refreshChips, 60000);
|
||||
document.addEventListener('visibilitychange', function () {
|
||||
if (!document.hidden) refreshChips();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var zoneTimer = null;
|
||||
var shareRefresh = null;
|
||||
|
||||
function zoneSection(group, allRoutes, timesByRoute, tr) {
|
||||
var meta = GROUP_META[group.route_group] || {};
|
||||
var mine = allRoutes.filter(function (r) { return r.route_group === group.route_group; });
|
||||
|
||||
var sec = document.createElement('section');
|
||||
sec.className = 'mu-zone';
|
||||
sec.setAttribute('data-group', group.route_group);
|
||||
|
||||
/* หมวดใหม่ที่ยังไม่มีคีย์แปล → ใช้ชื่อจาก route_groups.json ตรง ๆ */
|
||||
var label = meta.i18n ? tr(meta.i18n) : (group.route_group_label || group.route_group);
|
||||
var labelAttr = meta.i18n ? ' data-i18n="' + meta.i18n + '"' : '';
|
||||
var desc = meta.desc ? tr(meta.desc) : '';
|
||||
var descAttr = meta.desc ? ' data-i18n="' + meta.desc + '"' : '';
|
||||
|
||||
var head = document.createElement('div');
|
||||
head.className = 'mu-zone-head';
|
||||
head.innerHTML =
|
||||
'<span class="mu-zone-tag ' + (meta.tag || 'tag-sky') + '"' + labelAttr + '>' + esc(label) + '</span>' +
|
||||
'<p class="mu-zone-desc">' + (desc ? '<span' + descAttr + '>' + esc(desc) + '</span> · ' : '') +
|
||||
mine.length + ' <span data-i18n="common.routes">' + esc(tr('common.routes')) + '</span></p>';
|
||||
sec.appendChild(head);
|
||||
|
||||
var grid = document.createElement('div');
|
||||
grid.className = 'mu-grid';
|
||||
|
||||
if (!mine.length) {
|
||||
grid.innerHTML =
|
||||
'<div class="mu-card is-empty">' +
|
||||
'<div class="mu-card-head"><p class="mu-route-number">N/A</p></div>' +
|
||||
'<div class="mu-route-info">' +
|
||||
'<p class="mu-route-name" data-i18n="' + (meta.empty || 'card.noData') + '">' + esc(tr(meta.empty || 'card.noData')) + '</p>' +
|
||||
'<div class="mu-route-chip-wrap"><span class="mu-next-trip badge-gray" data-i18n="card.noData">' + esc(tr('card.noData')) + '</span></div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
} else {
|
||||
mine.forEach(function (r, i) {
|
||||
var badge = r.badge ? 'badge-' + r.badge : (FIXED_BADGE[r.route_id] || BADGE_CYCLE[i % BADGE_CYCLE.length]);
|
||||
var a = document.createElement('a');
|
||||
a.className = 'mu-card';
|
||||
a.setAttribute('data-route', r.route_id);
|
||||
a.href = '/routes/' + encodeURIComponent(r.route_id);
|
||||
a.innerHTML =
|
||||
'<div class="mu-card-head"><p class="mu-route-number">' + esc(r.route_id) + '</p></div>' +
|
||||
'<div class="mu-route-info">' +
|
||||
'<p class="mu-route-name">' + esc(r.route_name_th || '') + '</p>' +
|
||||
'<div class="mu-route-chip-wrap"></div>' +
|
||||
'</div>';
|
||||
var wrap = a.querySelector('.mu-route-chip-wrap');
|
||||
var times = timesByRoute[String(r.route_id)] || [];
|
||||
wrap.appendChild(chipNode(chipState(times), badge, tr));
|
||||
chipSlots.push({ wrap: wrap, badge: badge, times: times });
|
||||
grid.appendChild(a);
|
||||
});
|
||||
}
|
||||
|
||||
sec.appendChild(grid);
|
||||
return sec;
|
||||
}
|
||||
|
||||
/* 3 สถานะของชิป (ตรงกับที่ออกแบบไว้เดิม): มีเที่ยวถัดไป → ดูตาราง → ยังไม่มีตาราง */
|
||||
function chipState(times) {
|
||||
var next = nextTripOf(times);
|
||||
if (next) return { icon: ICON.next, key: 'card.nextTrip', next: next };
|
||||
if (times.length) return { icon: ICON.schedule, key: 'card.schedule', next: null };
|
||||
return { icon: ICON.none, key: 'card.noSchedule', next: null };
|
||||
}
|
||||
|
||||
function chipNode(state, badge, tr) {
|
||||
var span = document.createElement('span');
|
||||
span.className = 'mu-next-trip ' + badge;
|
||||
span.innerHTML = '<svg class="ic" aria-hidden="true"><use href="#' + state.icon + '"/></svg> ' +
|
||||
'<span data-i18n="' + state.key + '">' + esc(tr(state.key)) + '</span>' + (state.next ? ' ' + esc(state.next) : '');
|
||||
return span;
|
||||
}
|
||||
|
||||
/* รีเฟรชชิปทุกนาที ให้เวลา "เที่ยวถัดไป" ตรงกับเวลาจริง */
|
||||
function refreshChips() {
|
||||
var tr = window.I18N ? window.I18N.t : function (k) { return k; };
|
||||
chipSlots.forEach(function (slot) {
|
||||
if (!slot.wrap.isConnected || !slot.times.length) return;
|
||||
slot.wrap.innerHTML = '';
|
||||
slot.wrap.appendChild(chipNode(chipState(slot.times), slot.badge, tr));
|
||||
});
|
||||
}
|
||||
|
||||
function esc(v) {
|
||||
return String(v == null ? '' : v).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
ลิงก์สั้นสำหรับแชร์ (ส่งไลน์หากัน)
|
||||
#/?s=<รหัสสถานี> = เปิดหน้าแรกพร้อมเลือกสถานีนั้น
|
||||
#/?p=<province_id> = เปิดพร้อมเลือกจังหวัด
|
||||
============================================================ */
|
||||
function shortUrl() {
|
||||
var base = location.origin + location.pathname.replace(/index\.html$/, '');
|
||||
var q = state.stationCode ? 's=' + encodeURIComponent(state.stationCode)
|
||||
: (state.provinceId ? 'p=' + state.provinceId : '');
|
||||
return base + (q ? '/?' + q : '/');
|
||||
}
|
||||
|
||||
function initShare() {
|
||||
var btn = document.getElementById('share-btn');
|
||||
var status = document.getElementById('share-status');
|
||||
if (!btn) return;
|
||||
var tr = window.I18N ? window.I18N.t : function (k) { return k; };
|
||||
|
||||
function paint(msg) {
|
||||
if (!status) return;
|
||||
status.innerHTML = esc(msg) + ' <code class="mu-share-url">' + esc(shortUrl()) + '</code> ' +
|
||||
'<a class="mu-share-line" href="https://social-plugins.line.me/lineit/share?url=' +
|
||||
encodeURIComponent(shortUrl()) + '" target="_blank" rel="noopener">' + esc(tr('share.line')) + '</a>';
|
||||
}
|
||||
|
||||
shareRefresh = function () { if (status && status.dataset.shown) paint(status.dataset.msg || ''); };
|
||||
|
||||
btn.addEventListener('click', function () {
|
||||
var url = shortUrl();
|
||||
if (navigator.share) {
|
||||
navigator.share({ title: document.title, url: url }).catch(function () { /* ผู้ใช้ยกเลิก */ });
|
||||
}
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(url).then(function () {
|
||||
status.dataset.shown = '1'; status.dataset.msg = tr('share.copied'); paint(tr('share.copied'));
|
||||
}, function () {
|
||||
status.dataset.shown = '1'; status.dataset.msg = tr('share.short'); paint(tr('share.short'));
|
||||
});
|
||||
} else {
|
||||
status.dataset.shown = '1'; status.dataset.msg = tr('share.short'); paint(tr('share.short'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
initHomeSelectors();
|
||||
initSponsors().then(initMarquee); /* เติมไทล์จาก JSON ก่อน แล้วค่อย clone (ไม่งั้นไทล์ที่เพิ่มจะไม่ถูก clone) */
|
||||
initShare();
|
||||
|
||||
export default function mount(): void {
|
||||
initHomeSelectors();
|
||||
initSponsors().then(initMarquee);
|
||||
initShare();
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/i18n.js — logic unchanged. */
|
||||
/* ============================================================
|
||||
Atroute — ระบบหลายภาษา (i18n)
|
||||
------------------------------------------------------------
|
||||
คำแปลแยกเป็นไฟล์ต่อภาษา: ui/locales/<รหัสภาษา>.json (แบน: "key": "ข้อความ")
|
||||
เพิ่มภาษาใหม่ = วางไฟล์ + เพิ่มรหัสใน SUPPORTED (ไม่ต้องแก้โค้ดอื่น)
|
||||
|
||||
วิธีใช้:
|
||||
1. ข้อความใน HTML: <span data-i18n="nav.home">หน้าแรก</span>
|
||||
(ข้อความในแท็ก = fallback ถ้าโหลดไฟล์ภาษาไม่สำเร็จ)
|
||||
2. attribute: data-i18n-attr="placeholder:search.ph,aria-label:search.ph"
|
||||
ใส่ html: data-i18n-attr="html:key" (ระวัง — เป็น innerHTML)
|
||||
ตัวเลขในข้อความ: data-i18n-n="3" + คำแปลมี {n}
|
||||
3. ใน JS: I18N.t('key') · I18N.t('key', { n: 3 })
|
||||
4. ปุ่มสลับภาษา: <button data-i18n-switch="en">EN</button>
|
||||
|
||||
ลำดับการโหลด: รอ I18N.ready ก่อนวาดหน้าแรก (router ทำให้แล้ว)
|
||||
ถ้าโหลดไม่สำเร็จ: คงข้อความ fallback ใน HTML ไว้ (ไม่เขียนทับด้วย key)
|
||||
============================================================ */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var LS_KEY = 'at_lang';
|
||||
var SUPPORTED = ['th', 'en'];
|
||||
var BASE = 'th'; /* ภาษาตั้งต้น — ใช้เมื่อคีย์ขาดในภาษาปัจจุบัน */
|
||||
var DIR = '/locales/';
|
||||
|
||||
var CACHE = {}; /* lang -> dict */
|
||||
var current = detect();
|
||||
var resolveReady;
|
||||
var ready = new Promise(function (r) { resolveReady = r; });
|
||||
|
||||
/* ---------- ตรวจจับภาษาเริ่มต้น ---------- */
|
||||
function detect() {
|
||||
try {
|
||||
var saved = localStorage.getItem(LS_KEY);
|
||||
if (saved && SUPPORTED.indexOf(saved) !== -1) return saved;
|
||||
} catch (e) { /* localStorage ไม่พร้อมใช้งาน */ }
|
||||
var nav = (navigator.language || BASE).toLowerCase();
|
||||
return nav.indexOf('en') === 0 ? 'en' : BASE;
|
||||
}
|
||||
|
||||
/* ---------- โหลดไฟล์ภาษา (cache ต่อภาษา · ล้มเหลว = {} ไม่ให้พัง) ---------- */
|
||||
function dict(lang) {
|
||||
if (CACHE[lang]) return Promise.resolve(CACHE[lang]);
|
||||
return fetch(DIR + lang + '.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : {}; })
|
||||
.then(function (d) { CACHE[lang] = d || {}; return CACHE[lang]; })
|
||||
.catch(function () { CACHE[lang] = {}; return CACHE[lang]; });
|
||||
}
|
||||
function loaded() { return !!(CACHE[current] || CACHE[BASE]); }
|
||||
|
||||
/* ---------- แปลข้อความ ---------- */
|
||||
function t(key, vars) {
|
||||
var cur = CACHE[current], bak = CACHE[BASE];
|
||||
var val = (cur && cur[key] !== undefined) ? cur[key]
|
||||
: (bak && bak[key] !== undefined) ? bak[key] : undefined;
|
||||
if (val === undefined) return key;
|
||||
if (vars) {
|
||||
Object.keys(vars).forEach(function (k) {
|
||||
val = val.split('{' + k + '}').join(vars[k]);
|
||||
});
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/* ---------- ใช้คำแปลกับ element ---------- */
|
||||
function apply(root) {
|
||||
if (!loaded()) return; /* ยังไม่มีคำแปล → คงข้อความ fallback ใน HTML */
|
||||
var scope = root || document;
|
||||
|
||||
scope.querySelectorAll('[data-i18n]').forEach(function (el) {
|
||||
var vars = null;
|
||||
var n = el.getAttribute('data-i18n-n');
|
||||
if (n !== null) vars = { n: n };
|
||||
el.textContent = t(el.getAttribute('data-i18n'), vars);
|
||||
});
|
||||
scope.querySelectorAll('[data-i18n-attr]').forEach(function (el) {
|
||||
el.getAttribute('data-i18n-attr').split(',').forEach(function (pair) {
|
||||
var parts = pair.split(':');
|
||||
if (parts.length === 2) {
|
||||
var attr = parts[0].trim();
|
||||
var key = parts[1].trim();
|
||||
if (attr === 'html') {
|
||||
el.innerHTML = t(key);
|
||||
} else {
|
||||
el.setAttribute(attr, t(key));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.documentElement.lang = current;
|
||||
|
||||
/* ไฮไลต์ปุ่มภาษาที่ active */
|
||||
document.querySelectorAll('[data-i18n-switch]').forEach(function (btn) {
|
||||
btn.classList.toggle('active', btn.getAttribute('data-i18n-switch') === current);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- สลับภาษา (โหลดไฟล์ภาษาก่อน แล้วค่อยบอกให้หน้าวาดใหม่) ---------- */
|
||||
function setLang(lang) {
|
||||
if (SUPPORTED.indexOf(lang) === -1) lang = BASE;
|
||||
if (lang === current) return Promise.resolve(current);
|
||||
current = lang;
|
||||
try { localStorage.setItem(LS_KEY, lang); } catch (e) {}
|
||||
return dict(current).then(function () {
|
||||
window.dispatchEvent(new CustomEvent('langchange', { detail: lang }));
|
||||
return lang;
|
||||
});
|
||||
}
|
||||
|
||||
window.I18N = {
|
||||
t: t,
|
||||
apply: apply,
|
||||
setLang: setLang,
|
||||
getLang: function () { return current; },
|
||||
langs: SUPPORTED,
|
||||
default: BASE, /* ภาษาที่ใช้เมื่อคีย์ขาด */
|
||||
ready: ready, /* Promise — รอคำแปลโหลดเสร็จก่อนวาดหน้าแรก */
|
||||
};
|
||||
|
||||
/* ปุ่มสลับภาษา [data-i18n-switch] — ฟังคลิกทั่วทั้งหน้า */
|
||||
document.addEventListener('click', function (e) {
|
||||
var btn = e.target.closest('[data-i18n-switch]');
|
||||
if (btn) setLang(btn.getAttribute('data-i18n-switch'));
|
||||
});
|
||||
|
||||
/* โหลดภาษาปัจจุบัน (+ ภาษาตั้งต้นสำหรับ fallback) แล้วจึงพร้อมใช้งาน */
|
||||
Promise.all([dict(BASE), dict(current)]).then(function () {
|
||||
apply();
|
||||
resolveReady();
|
||||
});
|
||||
})();
|
||||
export {};
|
||||
@@ -0,0 +1,34 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/imageurl.js — logic unchanged. */
|
||||
/* ============================================================
|
||||
Atroute — ตัวช่วยเติมเวอร์ชันให้ URL รูป (cache busting)
|
||||
------------------------------------------------------------
|
||||
ปัญหา: SW ใช้ cache-first กับรูป → อัปรูปทับชื่อเดิมแล้วไม่เห็นรูปใหม่
|
||||
วิธีแก้ (แนวทาง B2): เติม ?v=<SW VERSION> ต่อท้าย URL รูปทุกตัว
|
||||
→ bump VERSION ใน sw.js = รูปทั้งหมดโหลดใหม่พร้อมกัน
|
||||
|
||||
ใช้: ImgURL.of(url) → '/image/x.jpg?v=2026.09.27.23'
|
||||
ImgURL.version() → '2026.09.27.23'
|
||||
============================================================ */
|
||||
(function () {
|
||||
'use strict';
|
||||
var V = null; /* cache ของเวอร์ชัน */
|
||||
|
||||
function version() {
|
||||
if (V) return V;
|
||||
/* อ่านเวอร์ชันจาก <meta name="app-version"> ถ้ามี (set ใน index.html) */
|
||||
var m = document.querySelector('meta[name="app-version"]');
|
||||
V = (m && m.content) ? m.content : '0';
|
||||
return V;
|
||||
}
|
||||
/* เติม ?v= ให้ URL รูป (ข้าม URL ภายนอก/ไฟล์ข้อมูล/ที่เติม ?v= แล้ว) */
|
||||
function of(url) {
|
||||
var u = String(url == null ? '' : url);
|
||||
if (!u || u.indexOf('data:') === 0 || u.indexOf('blob:') === 0) return u;
|
||||
if (u.indexOf('//') === 0 || /^https?:\/\//i.test(u)) return u; /* URL เต็ม/ภายนอก — ไม่แตะ */
|
||||
if (/[?&]v=/.test(u)) return u;
|
||||
return u + (u.indexOf('?') > -1 ? '&' : '?') + 'v=' + encodeURIComponent(version());
|
||||
}
|
||||
window.ImgURL = { of: of, version: version };
|
||||
})();
|
||||
export {};
|
||||
@@ -0,0 +1,767 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/map.js — logic unchanged. */
|
||||
/* ============================================================
|
||||
Atroute — แผนที่เส้นทาง (Leaflet, vanilla)
|
||||
------------------------------------------------------------
|
||||
ข้อมูล:
|
||||
<base>geojson-web/<route_id>.geojson เส้นทางจริงจาก QGIS (WGS84)
|
||||
<base>busstop_list.json 154 ป้าย (มีพิกัด + buses-line)
|
||||
<base>stations.json 19 สถานีของเรา (13 มีพิกัด)
|
||||
<base>routes.json สาย ↔ สถานี
|
||||
|
||||
ธีม DESIGN.md §5: เส้นทาง --green-700 หนา 5px · หมุดสี่เหลี่ยมมน
|
||||
ออฟไลน์: ยังวาดเส้นทาง/หมุดจากข้อมูลในเครื่องได้โดยไม่ต้องมี tile
|
||||
|
||||
API:
|
||||
ATMap.route(el, '101') #/routes/:id
|
||||
ATMap.forStop(el, 'at_main_terminal') #/stops/:code
|
||||
ATMap.nearMe(button, resultEl) #/stops (ป้ายใกล้ฉัน)
|
||||
ทุกตัวรับ opts = { base, stopHref } (สำหรับหน้า static นอก SPA)
|
||||
============================================================ */
|
||||
window.ATMap = (function () {
|
||||
'use strict';
|
||||
|
||||
var DEF_BASE = '/resource/data/';
|
||||
/* station_id 8 = "จุดขึ้นรถประจำทางอื่นๆ" (ใช้ร่วมหลายสาย) → ต้องจับคู่ route_id
|
||||
ในไฟล์ '8 other_stop.json' เพื่อเอาชื่อ/พิกัดจริงของสายนั้น (สายเดียวมีได้หลายจุด) */
|
||||
var OTHER_STOP_ID = 8;
|
||||
var OTHER_STOP_FILE = '8%20other_stop.json';
|
||||
var OFF_ROUTE_M = 2000; /* ห่างจากเส้นเกินนี้ → แจ้ง "นอกเส้นทาง" */
|
||||
var TILES = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
var ATTRIB = '© OpenStreetMap';
|
||||
var NEAR_M = 40; /* ป้ายอยู่ "บนเส้นทาง" ถ้าใกล้ ≤ 40 ม. */
|
||||
var STATION_NEAR_M = 80; /* สถานีอยู่ "ตามเส้นทาง" ถ้าใกล้ ≤ 80 ม. */
|
||||
var LINE_W = 5;
|
||||
var LINE_MAIN = '#14532d'; /* --green-700 */
|
||||
var SHADES = ['#14532d', '#1f7a3d', '#2f8f5b', '#4a7c59', '#166534'];
|
||||
var TH = { minLng: 97, maxLng: 103, minLat: 12, maxLat: 17.5 };
|
||||
var cache = {};
|
||||
|
||||
/* ---------- พื้นฐาน ---------- */
|
||||
function t(k, vars) { return window.I18N ? I18N.t(k, vars) : k; }
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
function num(v) {
|
||||
var n = typeof v === 'number' ? v : parseFloat(v);
|
||||
return isFinite(n) ? n : null;
|
||||
}
|
||||
function pointOf(o) {
|
||||
var lat = num(o && o.latitude), lng = num(o && o.longitude);
|
||||
return (lat === null || lng === null) ? null : [lng, lat];
|
||||
}
|
||||
function url(o, path) { return ((o && o.base) || DEF_BASE) + path; }
|
||||
function href(o, code) {
|
||||
return (o && o.stopHref) ? o.stopHref(code) : '/stops/' + encodeURIComponent(code);
|
||||
}
|
||||
function fetchJSON(u) {
|
||||
return fetch(u, { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; });
|
||||
}
|
||||
|
||||
/* ---------- เรขาคณิต ---------- */
|
||||
function hav(a, b) {
|
||||
var R = 6371000, p1 = a[1] * Math.PI / 180, p2 = b[1] * Math.PI / 180;
|
||||
var dp = p2 - p1, dl = (b[0] - a[0]) * Math.PI / 180;
|
||||
var x = Math.sin(dp / 2) * Math.sin(dp / 2) + Math.cos(p1) * Math.cos(p2) * Math.sin(dl / 2) * Math.sin(dl / 2);
|
||||
return 2 * R * Math.asin(Math.sqrt(x));
|
||||
}
|
||||
function segDist(p, a, b) {
|
||||
var lat0 = (a[1] + b[1]) / 2 * Math.PI / 180, k = 111320;
|
||||
var ax = a[0] * Math.cos(lat0) * k, ay = a[1] * k;
|
||||
var bx = b[0] * Math.cos(lat0) * k, by = b[1] * k;
|
||||
var px = p[0] * Math.cos(lat0) * k, py = p[1] * k;
|
||||
var dx = bx - ax, dy = by - ay, L2 = dx * dx + dy * dy;
|
||||
if (!L2) return { d: Math.hypot(px - ax, py - ay), t: 0 };
|
||||
var u = Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / L2));
|
||||
return { d: Math.hypot(px - (ax + u * dx), py - (ay + u * dy)), t: u };
|
||||
}
|
||||
function linesOf(geom) {
|
||||
if (!geom) return [];
|
||||
var out = geom.type === 'LineString' ? [geom.coordinates] : (geom.coordinates || []);
|
||||
return out.map(function (l) {
|
||||
return l.filter(function (c) { return c[0] > TH.minLng && c[0] < TH.maxLng && c[1] > TH.minLat && c[1] < TH.maxLat; });
|
||||
}).filter(function (l) { return l.length >= 2; });
|
||||
}
|
||||
function flatten(geo) {
|
||||
return geo ? geo.features.reduce(function (a, f) { return a.concat(linesOf(f.geometry)); }, []) : [];
|
||||
}
|
||||
function lineLengthKm(lines) {
|
||||
var m = 0;
|
||||
lines.forEach(function (l) { for (var i = 1; i < l.length; i++) m += hav(l[i - 1], l[i]); });
|
||||
return m / 1000;
|
||||
}
|
||||
function toLatLngs(lines) {
|
||||
return lines.map(function (l) { return l.map(function (c) { return [c[1], c[0]]; }); });
|
||||
}
|
||||
/* ระยะสะสม (กม.) จากต้นทางถึงจุดที่ใกล้จุด p ที่สุด บนเส้นที่ยาวที่สุด */
|
||||
function kmFromStart(mainLine, p) {
|
||||
var best = { d: Infinity, km: 0 }, cum = 0;
|
||||
for (var i = 1; i < mainLine.length; i++) {
|
||||
var a = mainLine[i - 1], b = mainLine[i], seg = hav(a, b), r = segDist(p, a, b);
|
||||
if (r.d < best.d) best = { d: r.d, km: (cum + r.t * seg) / 1000 };
|
||||
cum += seg;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
function longest(lines) {
|
||||
return lines.slice().sort(function (a, b) {
|
||||
var la = 0, lb = 0;
|
||||
for (var i = 1; i < a.length; i++) la += hav(a[i - 1], a[i]);
|
||||
for (var j = 1; j < b.length; j++) lb += hav(b[j - 1], b[j]);
|
||||
return lb - la;
|
||||
})[0];
|
||||
}
|
||||
|
||||
/* ---------- โหลดข้อมูล (cache) ---------- */
|
||||
function loadGeo(id, o) {
|
||||
var key = 'geo:' + id;
|
||||
if (cache[key] === undefined) cache[key] = fetchJSON(url(o, 'geojson-web/' + id + '.geojson'));
|
||||
return Promise.resolve(cache[key]);
|
||||
}
|
||||
function loadJson(file, key, o) {
|
||||
if (cache[key] === undefined) cache[key] = fetchJSON(url(o, file));
|
||||
return Promise.resolve(cache[key]);
|
||||
}
|
||||
function stops(o) { return loadJson('busstop_list.json', 'stops', o).then(function (d) { return d || []; }); }
|
||||
function stationList(o) { return loadJson('stations.json', 'stations', o).then(function (d) { return (d || {}).stations || []; }); }
|
||||
function otherStopList(o) { return loadJson(OTHER_STOP_FILE, 'otherStops', o).then(function (d) { return (d || {}).other_stop || []; }); }
|
||||
function routeList(o) { return loadJson('routes.json', 'routes', o).then(function (d) { return (d || {}).routes || []; }); }
|
||||
|
||||
/* จุดจอดตามเส้นทาง = routes.json → station_ids (ตามลำดับของสาย)
|
||||
- station_id 8 → จับคู่ route_id ใน '8 other_stop.json' (ถ้าไม่มีคู่ จับคู่ไม่ได้ → ใช้สถานี 8 ตามเดิม)
|
||||
- กม. จากต้นทาง = วัดตามเส้น geometry โดยเลือกปลายที่ใกล้จุดจอดแรกที่สุดเป็น "ต้นทาง"
|
||||
- พิกัดที่ห่างจากเส้นเกิน OFF_ROUTE_M → ขึ้น "นอกเส้นทาง" แทนตัวเลข กม. (กันเลขหลอก) */
|
||||
function routeStopRows(route, stations, others, main, validIds) {
|
||||
var byId = {};
|
||||
stations.forEach(function (st) { byId[st.station_id] = st; });
|
||||
|
||||
var stops = [];
|
||||
(route.station_ids || []).forEach(function (sid) {
|
||||
if (sid === OTHER_STOP_ID) {
|
||||
/* จับคู่ route → ชื่อสถานที่จริง (รองรับรหัสเพี้ยน เช่น 1101 = สาย 1011) ผ่าน OtherStop */
|
||||
var hit = (window.OtherStop && OtherStop.forRouteAll)
|
||||
? OtherStop.forRouteAll(others, route.route_id, validIds)
|
||||
: (others || []).filter(function (o) { return String(o.route_id) === String(route.route_id); });
|
||||
if (hit.length) {
|
||||
hit.forEach(function (o) {
|
||||
/* แตกเป็น "จุดจริง" ทีละจุด — ชื่อ ↔ พิกัด จับคู่ตามลำดับ (จุดที่ไม่มีพิกัด = ไม่ปักหมุด) */
|
||||
var subs = (window.OtherStop && OtherStop.stopsOf) ? OtherStop.stopsOf(o) : [];
|
||||
if (!subs.length) subs = [{ name: o.station_name_th, hasCoord: false, lat: null, lng: null }];
|
||||
subs.forEach(function (sub, si) {
|
||||
stops.push({
|
||||
name: sub.name,
|
||||
pt: sub.hasCoord ? [sub.lng, sub.lat] : null,
|
||||
code: null,
|
||||
note: o.note || null,
|
||||
subStop: true, /* ★ จุดย่อย: ลิงก์ไปหน้ารวมจุดขึ้นรถของสายนี้ */
|
||||
subRoute: String(route.route_id),
|
||||
subFirst: si === 0 /* จุดแรก = จุดอ้างอิง (อยู่บน timetable แล้ว) */
|
||||
});
|
||||
});
|
||||
});
|
||||
return; /* จับคู่ได้ → ไม่ใช้ชื่อสถานีรวม */
|
||||
}
|
||||
}
|
||||
var st = byId[sid];
|
||||
if (st) stops.push({ name: st.station_name_th, pt: pointOf(st), code: st.station_code });
|
||||
});
|
||||
|
||||
var total = lineLengthKm([main]);
|
||||
var first = stops.filter(function (s) { return s.pt; })[0];
|
||||
var fromEnd = first ? kmFromStart(main, first.pt).km > total / 2 : false;
|
||||
|
||||
stops.forEach(function (s) {
|
||||
if (!s.pt) { s.km = null; s.off = false; return; }
|
||||
var k = kmFromStart(main, s.pt);
|
||||
var km = fromEnd ? total - k.km : k.km;
|
||||
s.off = k.d > OFF_ROUTE_M;
|
||||
s.km = Math.max(0, km).toFixed(1);
|
||||
if (s.subStop) s.sub = true; /* คงธงจุดย่อยไว้ให้ตัววาดหมุด */
|
||||
});
|
||||
return stops;
|
||||
}
|
||||
|
||||
/* ---------- องค์ประกอบแผนที่ ---------- */
|
||||
/* แผนที่ทั้งหมดที่สร้างในหน้านี้ (ไว้จัดการ resize + ตรวจสอบ) */
|
||||
var MAPS = [];
|
||||
|
||||
function mapOptions() {
|
||||
return {
|
||||
zoomControl: true,
|
||||
attributionControl: true,
|
||||
scrollWheelZoom: true, /* ล้อเมาส์: หมุนเข้า/ออก = ซูม */
|
||||
touchZoom: true, /* มือถือ: ใช้นิ้ว 2 นิ้วจีบ/กาง = ซูม */
|
||||
doubleClickZoom: true,
|
||||
boxZoom: true,
|
||||
keyboard: true,
|
||||
wheelDebounceTime: 40 /* หน่วงนิดเดียว ไม่ให้ซูมกระโดดตอนหมุนเร็ว */
|
||||
};
|
||||
}
|
||||
|
||||
function makeMap(el) {
|
||||
var offline = navigator.onLine === false;
|
||||
if (offline) el.classList.add('is-offline');
|
||||
var map = L.map(el, mapOptions());
|
||||
map.setView([14.588, 100.455], 11);
|
||||
if (!offline) L.tileLayer(TILES, { maxZoom: 18, minZoom: 8, attribution: ATTRIB }).addTo(map);
|
||||
MAPS.push({ map: map, el: el, bounds: null });
|
||||
return { map: map, offline: offline };
|
||||
}
|
||||
|
||||
/* ถ้าหน้าต่างเปลี่ยนขนาด (หรือหมุนมือถือ) → อัปเดตขนาด + ซูมให้พอดีเส้นทางอีกครั้ง */
|
||||
var resizeTimer = null;
|
||||
window.addEventListener('resize', function () {
|
||||
clearTimeout(resizeTimer);
|
||||
resizeTimer = setTimeout(function () {
|
||||
MAPS.forEach(function (rec) {
|
||||
rec.map.invalidateSize();
|
||||
if (rec.bounds) rec.map.fitBounds(rec.bounds, { padding: [24, 24], maxZoom: 15 });
|
||||
});
|
||||
}, 200);
|
||||
});
|
||||
function pinIcon(kind) {
|
||||
return L.divIcon({ className: 'at-pin-wrap', html: '<span class="at-pin ' + kind + '"></span>', iconSize: [16, 16], iconAnchor: [8, 8] });
|
||||
}
|
||||
function legend(el, rows) {
|
||||
var box = document.createElement('div');
|
||||
box.className = 'at-legend';
|
||||
rows.forEach(function (r) {
|
||||
var d = document.createElement('div'), sw = document.createElement('i');
|
||||
if (r.square) sw.className = 'sq';
|
||||
sw.style.background = r.color;
|
||||
d.appendChild(sw);
|
||||
d.appendChild(document.createTextNode(r.label));
|
||||
box.appendChild(d);
|
||||
});
|
||||
el.appendChild(box);
|
||||
}
|
||||
function caption(el, html) {
|
||||
var c = el.parentNode && el.parentNode.querySelector('.at-map-caption');
|
||||
if (c) c.innerHTML = html;
|
||||
}
|
||||
function fitAll(map, latlngs) {
|
||||
var all = [];
|
||||
latlngs.forEach(function (l) {
|
||||
/* รับได้ทั้ง "เส้น" ([ [lat,lng], ... ]) และ "จุดเดี่ยว" ([lat, lng]) */
|
||||
if (l && typeof l[0] === 'number' && typeof l[1] === 'number') all.push([l[0], l[1]]);
|
||||
else if (l && l.length) all = all.concat(l);
|
||||
});
|
||||
if (!all.length) return;
|
||||
var rec = mapsFor(map);
|
||||
if (all.length === 1) {
|
||||
if (rec) rec.bounds = L.latLngBounds(all);
|
||||
map.setView(all[0], 14);
|
||||
return;
|
||||
}
|
||||
var bounds = L.latLngBounds(all);
|
||||
if (rec) rec.bounds = bounds;
|
||||
map.invalidateSize(); /* ให้แน่ใจว่าขนาดถูกก่อนคำนวณซูม */
|
||||
map.fitBounds(bounds, { padding: [24, 24], maxZoom: 15 });
|
||||
}
|
||||
|
||||
function mapsFor(map) {
|
||||
for (var i = 0; i < MAPS.length; i++) if (MAPS[i].map === map) return MAPS[i];
|
||||
return null;
|
||||
}
|
||||
function mapsLink(lat, lng) {
|
||||
return 'https://www.google.com/maps/search/?api=1&query=' + lat + ',' + lng;
|
||||
}
|
||||
|
||||
/* วาดเส้นทาง: ขอบสีครีม (เห็นชัดบนพื้นแผนที่) แล้วทับด้วยเส้นสีจริง 5px ตาม DESIGN.md §5 */
|
||||
function drawLines(group, specs) {
|
||||
specs.forEach(function (sp) {
|
||||
L.polyline(sp.latlngs, {
|
||||
color: '#fffdf6', weight: LINE_W + 4, opacity: 0.95, lineJoin: 'round', lineCap: 'round', smoothFactor: 0.6
|
||||
}).addTo(group);
|
||||
});
|
||||
specs.forEach(function (sp) {
|
||||
L.polyline(sp.latlngs, {
|
||||
color: sp.color, weight: LINE_W, opacity: 1, lineJoin: 'round', lineCap: 'round', smoothFactor: 0.6
|
||||
}).addTo(group);
|
||||
});
|
||||
}
|
||||
|
||||
/* ป้ายหยุดรถ: hover = ข้อมูลย่อ · คลิก = popup (ประเภท/กม./ด้านทาง/สายที่ผ่าน + Google Maps) */
|
||||
function drawShelters(map, hits, group) {
|
||||
hits.forEach(function (h) {
|
||||
var s = h.stop, pt = pointOf(s);
|
||||
if (!pt) return;
|
||||
var short = [];
|
||||
if (s.kilometer) short.push('กม. ' + 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.position) meta.push(s.position);
|
||||
if (s.type && s.place) meta.push(s.type); /* ซ้ำกับหัวข้อเมื่อไม่มีชื่อสถานที่ */
|
||||
if (meta.length) html += '<span>' + esc(meta.join(' · ')) + '</span>';
|
||||
var bl = s['buses-line'] || [];
|
||||
if (bl.length) html += '<span>' + esc(t('map.servedBy')) + ': <b>' + esc(bl.join(', ')) + '</b></span>';
|
||||
html += '<a href="' + mapsLink(s.latitude, s.longitude) + '" target="_blank" rel="noopener">' + esc(t('map.openInMaps')) + '</a>';
|
||||
html += '</div>';
|
||||
|
||||
L.marker([pt[1], pt[0]], { icon: pinIcon('stop') })
|
||||
.bindTooltip(esc(short.join(' · ')), { direction: 'top', offset: [0, -8] })
|
||||
.bindPopup(html, { closeButton: false, offset: [0, -6] })
|
||||
.addTo(group);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* จุดย่อยของ "จุดขึ้นรถประจำทางอื่นๆ" (จาก 8 other_stop.json) — ปักหมุดสี่เหลี่ยมม่วง
|
||||
คลิก = popup ชื่อ + กม. + ลิงก์ไปหน้ารวมจุดขึ้นรถของสายนั้น */
|
||||
function drawSubStops(map, rows, routeId, group) {
|
||||
(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>';
|
||||
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 })
|
||||
.bindTooltip(esc(r.name), { direction: 'top', offset: [0, -8] })
|
||||
.bindPopup(html, { closeButton: false, offset: [0, -6] })
|
||||
.addTo(group);
|
||||
});
|
||||
}
|
||||
|
||||
/* สถานีของเรา: ชื่อ + คลิกไปหน้ารายละเอียดป้าย (opts.stopHref) */
|
||||
function drawStations(map, hits, opts, group) {
|
||||
hits.forEach(function (h) {
|
||||
var s = h.station, pt = pointOf(s);
|
||||
if (!pt) return;
|
||||
var html = '<div class="at-pop"><b>' + esc(s.station_name_th) + '</b>';
|
||||
html += '<span>' + esc([s.city_th, s.province_th].filter(Boolean).join(' · ')) + '</span>';
|
||||
if (s.station_code) html += '<a href="' + esc(href(opts, s.station_code)) + '">' + esc(t('map.viewStopPage')) + '</a>';
|
||||
html += '</div>';
|
||||
L.marker([pt[1], pt[0]], { icon: pinIcon('term') })
|
||||
.bindTooltip('<b>' + esc(s.station_name_th) + '</b><br>' + esc(s.province_th || ''), { direction: 'top', offset: [0, -9] })
|
||||
.bindPopup(html, { closeButton: false, offset: [0, -6] })
|
||||
.addTo(group);
|
||||
});
|
||||
}
|
||||
|
||||
/* สถานีที่จะปักหมุด (ไอคอนเหลือง)
|
||||
- allowedIds = routes.json → station_ids ของสายนั้น (ปักเฉพาะที่ระบุไว้ — ให้ตรงกับตาราง)
|
||||
- ไม่ส่ง allowedIds = พฤติกรรมเดิม (ปักทุกสถานีที่อยู่ใกล้เส้น) */
|
||||
function stationsNear(lines, maxM, o, allowedIds) {
|
||||
return stationList(o).then(function (list) {
|
||||
var hits = [];
|
||||
var allow = (allowedIds && allowedIds.length) ? allowedIds.map(String) : null;
|
||||
list.forEach(function (s) {
|
||||
if (allow && allow.indexOf(String(s.station_id)) === -1) return; /* ไม่อยู่ในสายนี้ → ไม่ปัก */
|
||||
var pt = pointOf(s);
|
||||
if (!pt) return;
|
||||
var best = Infinity;
|
||||
for (var i = 0; i < lines.length && best > maxM; i++) {
|
||||
var l = lines[i];
|
||||
for (var j = 1; j < l.length; j++) {
|
||||
var r = segDist(pt, l[j - 1], l[j]);
|
||||
if (r.d < best) best = r.d;
|
||||
}
|
||||
}
|
||||
if (best <= maxM) hits.push({ station: s, dist: best });
|
||||
});
|
||||
return hits;
|
||||
});
|
||||
}
|
||||
function stopsNear(lines, o) {
|
||||
return stops(o).then(function (list) {
|
||||
var hits = [];
|
||||
list.forEach(function (s) {
|
||||
var pt = pointOf(s);
|
||||
if (!pt) return;
|
||||
var best = Infinity;
|
||||
for (var i = 0; i < lines.length && best > NEAR_M; i++) {
|
||||
var l = lines[i];
|
||||
for (var j = 1; j < l.length; j++) {
|
||||
var r = segDist(pt, l[j - 1], l[j]);
|
||||
if (r.d < best) best = r.d;
|
||||
}
|
||||
}
|
||||
if (best <= NEAR_M) hits.push({ stop: s, dist: Math.round(best) });
|
||||
});
|
||||
return hits;
|
||||
});
|
||||
}
|
||||
|
||||
/* รายการสถานีตามเส้นทาง พร้อม กม. จากต้นทาง */
|
||||
function renderKmList(el, list) {
|
||||
var host = document.getElementById(el);
|
||||
if (!host) return;
|
||||
host.innerHTML = '';
|
||||
if (!list.length) return;
|
||||
list.forEach(function (x) {
|
||||
var li = document.createElement('li');
|
||||
var row = document.createElement(x.href ? 'a' : 'div');
|
||||
if (x.href) row.href = x.href;
|
||||
row.className = 'at-km-row' + (x.href ? '' : ' is-plain') + (x.sub ? ' is-sub' : '');
|
||||
if (x.note) row.title = x.note;
|
||||
var val = x.off ? '<span class="is-off">' + esc(t('map.offRoute')) + '</span>'
|
||||
: (x.km === null || x.km === '' ? '–' : x.km + ' ' + esc(t('map.km')));
|
||||
row.innerHTML = '<span class="at-km-dot" aria-hidden="true"></span>' +
|
||||
'<span class="at-km-name">' + esc(x.name) + '</span>' +
|
||||
'<span class="at-km-val">' + val + '</span>';
|
||||
li.appendChild(row);
|
||||
host.appendChild(li);
|
||||
});
|
||||
var wrap = host.closest('.at-km-wrap');
|
||||
if (wrap) wrap.hidden = false;
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
#/routes/:id — เส้นทาง + สถานีตามเส้นทาง (พร้อม กม.) + ป้าย
|
||||
============================================================ */
|
||||
function route(el, routeId, opts) {
|
||||
if (!el || !window.L) return;
|
||||
opts = opts || {};
|
||||
|
||||
loadGeo(routeId, opts).then(function (geo) {
|
||||
var lines = flatten(geo);
|
||||
if (!lines.length) {
|
||||
el.classList.add('is-offline');
|
||||
caption(el, '<span class="at-offline">' + esc(t('map.empty')) + '</span>');
|
||||
return;
|
||||
}
|
||||
|
||||
var m = makeMap(el), map = m.map, group = L.layerGroup().addTo(map);
|
||||
var latlngs = toLatLngs(lines);
|
||||
|
||||
drawLines(group, latlngs.map(function (l) { return { latlngs: l, color: LINE_MAIN }; }));
|
||||
/* ต้นทาง/ปลายทาง */
|
||||
[[latlngs[0][0], t('map.origin')], [latlngs[latlngs.length - 1][latlngs[latlngs.length - 1].length - 1], t('map.destination')]]
|
||||
.forEach(function (e) {
|
||||
L.marker(e[0], { icon: pinIcon('term') })
|
||||
.bindTooltip(esc(e[1]), { direction: 'top', offset: [0, -8] }).addTo(group);
|
||||
});
|
||||
|
||||
Promise.all([stopsNear(lines, opts), routeList(opts),
|
||||
stationList(opts), otherStopList(opts)]).then(function (res) {
|
||||
var shelters = res[0], routesDoc = res[1], stations = res[2], others = res[3];
|
||||
var routeDoc = (routesDoc || []).filter(function (r) { return String(r.route_id) === String(routeId); })[0];
|
||||
var allowed = routeDoc ? (routeDoc.station_ids || []) : null; /* ★ ปักเฉพาะสถานีที่สายระบุ */
|
||||
drawShelters(map, shelters, group);
|
||||
stationsNear(lines, STATION_NEAR_M, opts, allowed).then(function (sts) {
|
||||
drawStations(map, sts, opts, group);
|
||||
});
|
||||
fitAll(map, latlngs);
|
||||
|
||||
/* จุดจอดตามเส้นทาง + กม. จากต้นทาง — ใช้ routes.json → station_ids เป็นหลัก
|
||||
(station 8 → จับคู่ route_id ใน 8 other_stop.json) ถ้าหา route ไม่ได้จึงใช้ระยะใกล้เส้นแบบเดิม */
|
||||
var main = longest(lines);
|
||||
var route = routeDoc;
|
||||
var rows;
|
||||
if (route && (route.station_ids || []).length) {
|
||||
rows = routeStopRows(route, stations, others, main, (routesDoc || []).map(function (r) { return String(r.route_id); })).map(function (x) {
|
||||
/* จุดย่อย → ลิงก์ไป #/stops/other_stop?route=<รหัสสาย> (หน้ารวมจุดขึ้นรถของสายนั้น) */
|
||||
var linkHref = x.code ? href(opts, x.code)
|
||||
: (x.subStop ? '/stops/other_stop?route=' + encodeURIComponent(x.subRoute) : null);
|
||||
return { name: x.name, km: x.km, off: x.off, note: x.note, href: linkHref, sub: !!x.subStop };
|
||||
}).sort(function (a, b) { /* เรียงตาม กม. ตามเส้นทาง (อ่านเป็นเส้นทางเดินรถ) */
|
||||
if (a.km === null || a.km === '') return 1;
|
||||
if (b.km === null || b.km === '') return -1;
|
||||
return parseFloat(a.km) - parseFloat(b.km);
|
||||
});
|
||||
} else {
|
||||
rows = sts.map(function (h) {
|
||||
var k = kmFromStart(main, pointOf(h.station));
|
||||
return { name: h.station.station_name_th, km: k.km.toFixed(1), off: false, href: href(opts, h.station.station_code) };
|
||||
}).sort(function (a, b) { return parseFloat(a.km) - parseFloat(b.km); });
|
||||
}
|
||||
renderKmList('route-map-list', rows);
|
||||
drawSubStops(map, routeStopRows(route, stations, others, main,
|
||||
(routesDoc || []).map(function (r) { return String(r.route_id); })), route.route_id, group);
|
||||
|
||||
var parts = ['<b>' + esc(routeId) + '</b> · ' + esc(t('map.captionRoute', { km: lineLengthKm(lines).toFixed(1), n: shelters.length }))];
|
||||
if (rows.length) parts.push(esc(t('map.stations')) + ' <b>' + rows.length + '</b>');
|
||||
if (m.offline) parts.push('<span class="at-offline">' + esc(t('map.offline')) + '</span>');
|
||||
caption(el, parts.join(' · '));
|
||||
});
|
||||
|
||||
legend(el, [
|
||||
{ color: LINE_MAIN, label: t('map.legendRoute') },
|
||||
{ color: '#1f7a3d', square: true, label: t('map.legendStop') },
|
||||
{ color: '#f2a900', square: true, label: t('map.legendTerminal') },
|
||||
{ color: '#7a4cc0', square: true, label: t('map.legendSubStop') }
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
#/stops/:code — เส้นทางที่ผ่านป้ายนี้ + หมุดตัวป้าย
|
||||
============================================================ */
|
||||
function forStop(el, code, opts) {
|
||||
if (!el || !window.L) return;
|
||||
opts = opts || {};
|
||||
|
||||
Promise.all([stationList(opts), loadJson('routes.json', 'routes', opts)]).then(function (res) {
|
||||
var list = res[0], routes = (res[1] || {}).routes || [];
|
||||
var st = list.filter(function (s) { return s.station_code === code; })[0];
|
||||
var serving = st ? routes.filter(function (r) { return (r.station_ids || []).indexOf(st.station_id) !== -1; }) : [];
|
||||
if (opts.onlyRoutes && opts.onlyRoutes.length) {
|
||||
serving = serving.filter(function (r) { return opts.onlyRoutes.indexOf(String(r.route_id)) !== -1; });
|
||||
}
|
||||
var ids = serving.map(function (r) { return r.route_id; });
|
||||
|
||||
if (!st || !ids.length) {
|
||||
el.classList.add('is-offline');
|
||||
caption(el, '<span class="at-offline">' + esc(t(st ? 'map.noRoutesHere' : 'map.empty')) + '</span>');
|
||||
return;
|
||||
}
|
||||
|
||||
Promise.all(ids.map(function (id) { return loadGeo(id, opts); })).then(function (geos) {
|
||||
var m = makeMap(el), map = m.map, group = L.layerGroup().addTo(map);
|
||||
var all = [], allLines = [], legendRows = [], drawn = 0, specs = [];
|
||||
|
||||
geos.forEach(function (g, idx) {
|
||||
var lines = flatten(g);
|
||||
if (!lines.length) return;
|
||||
var color = SHADES[drawn % SHADES.length];
|
||||
drawn++;
|
||||
allLines = allLines.concat(lines);
|
||||
toLatLngs(lines).forEach(function (l) {
|
||||
specs.push({ latlngs: l, color: color });
|
||||
all.push(l);
|
||||
});
|
||||
legendRows.push({ color: color, label: t('map.route') + ' ' + ids[idx] });
|
||||
});
|
||||
|
||||
if (!all.length) {
|
||||
el.classList.add('is-offline');
|
||||
caption(el, '<span class="at-offline">' + esc(t('map.empty')) + '</span>');
|
||||
return;
|
||||
}
|
||||
drawLines(group, specs);
|
||||
|
||||
stopsNear(allLines, opts).then(function (shelters) {
|
||||
drawShelters(map, shelters, group);
|
||||
/* opts.focus = จุดจริงของสายที่เลือก (เช่น จุดขึ้นรถประจำทางอื่นๆ → วัดสีบัวทอง) */
|
||||
var stPt = opts.focus ? pointOf(opts.focus) : pointOf(st);
|
||||
var focusFirst = (opts.focus && window.OtherStop && OtherStop.firstName) ? OtherStop.firstName(opts.focus) : null;
|
||||
var pinName = focusFirst || (opts.focus && opts.focus.station_name_th) || st.station_name_th;
|
||||
if (stPt) {
|
||||
L.marker([stPt[1], stPt[0]], { icon: pinIcon('here'), zIndexOffset: 1000 })
|
||||
.bindTooltip('<b>' + esc(pinName) + '</b><br>' + esc(t('map.thisStop')), { direction: 'top', offset: [0, -11] })
|
||||
.addTo(group);
|
||||
all.push([[stPt[1], stPt[0]]]);
|
||||
}
|
||||
fitAll(map, all);
|
||||
|
||||
var parts = [esc(t('map.captionStop', { r: drawn, n: shelters.length }))];
|
||||
parts.push(stPt ? esc(t('map.stationPinned')) : esc(t('map.noStationPin')));
|
||||
if (m.offline) parts.push('<span class="at-offline">' + esc(t('map.offline')) + '</span>');
|
||||
caption(el, parts.join(' · '));
|
||||
});
|
||||
|
||||
legendRows.push({ color: '#1f7a3d', square: true, label: t('map.legendStop') });
|
||||
legendRows.push({ color: '#f2a900', square: true, label: t('map.legendHere') });
|
||||
legend(el, legendRows);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
ป้ายใกล้ฉัน — geolocation → ป้ายที่ใกล้ที่สุด + แผนที่
|
||||
============================================================ */
|
||||
function nearMe(button, resultEl, opts) {
|
||||
if (!button || !resultEl) return;
|
||||
opts = opts || {};
|
||||
|
||||
if (!navigator.geolocation) {
|
||||
button.disabled = true;
|
||||
resultEl.innerHTML = '<p class="at-near-msg">' + esc(t('map.noGeo')) + '</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
button.addEventListener('click', function () {
|
||||
button.disabled = true;
|
||||
resultEl.hidden = false;
|
||||
resultEl.innerHTML = '<p class="at-near-msg">' + esc(t('map.locating')) + '</p>';
|
||||
|
||||
navigator.geolocation.getCurrentPosition(function (pos) {
|
||||
var me = [pos.coords.longitude, pos.coords.latitude];
|
||||
Promise.all([stops(opts), stationList(opts)]).then(function (res) {
|
||||
var items = [];
|
||||
res[0].forEach(function (s) {
|
||||
var pt = pointOf(s);
|
||||
if (pt) items.push({ kind: 'stop', o: s, pt: pt, d: hav(me, pt) });
|
||||
});
|
||||
res[1].forEach(function (s) {
|
||||
var pt = pointOf(s);
|
||||
if (pt) items.push({ kind: 'station', o: s, pt: pt, d: hav(me, pt) });
|
||||
});
|
||||
items.sort(function (a, b) { return a.d - b.d; });
|
||||
var near = items.slice(0, opts.limit || 8);
|
||||
renderNear(resultEl, near, me, opts);
|
||||
});
|
||||
}, function () {
|
||||
button.disabled = false;
|
||||
resultEl.innerHTML = '<p class="at-near-msg at-near-err">' + esc(t('map.geoDenied')) + '</p>';
|
||||
}, { enableHighAccuracy: true, timeout: 10000, maximumAge: 60000 });
|
||||
});
|
||||
}
|
||||
|
||||
function renderNear(host, near, me, opts) {
|
||||
host.hidden = false;
|
||||
host.innerHTML = '';
|
||||
|
||||
var box = document.createElement('div');
|
||||
box.className = 'at-map';
|
||||
box.id = 'near-me-map';
|
||||
host.appendChild(box);
|
||||
var cap = document.createElement('p');
|
||||
cap.className = 'at-map-caption';
|
||||
cap.textContent = t('map.nearestTitle');
|
||||
host.appendChild(cap);
|
||||
|
||||
var ul = document.createElement('ul');
|
||||
ul.className = 'at-near-list';
|
||||
near.forEach(function (x) {
|
||||
var li = document.createElement('li');
|
||||
var name = x.kind === 'station' ? x.o.station_name_th : (x.o.place || x.o.type);
|
||||
var meta = [];
|
||||
if (x.kind === 'station') meta.push(t('map.legendTerminal'));
|
||||
else {
|
||||
if (x.o.kilometer) meta.push('กม. ' + x.o.kilometer);
|
||||
if (x.o.position) meta.push(x.o.position);
|
||||
if (x.o.type && x.o.place) meta.push(x.o.type);
|
||||
}
|
||||
var bl = x.o['buses-line'] || [];
|
||||
if (bl.length) meta.push(t('map.servedBy') + ' ' + bl.join(', '));
|
||||
|
||||
var link = document.createElement('a');
|
||||
link.className = 'at-near-row';
|
||||
link.href = x.kind === 'station' ? href(opts, x.o.station_code) : mapsLink(x.o.latitude, x.o.longitude);
|
||||
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>';
|
||||
li.appendChild(link);
|
||||
ul.appendChild(li);
|
||||
});
|
||||
host.appendChild(ul);
|
||||
|
||||
drawNearMap(box, near, me);
|
||||
}
|
||||
|
||||
function drawNearMap(box, near, me) {
|
||||
var offline = navigator.onLine === false;
|
||||
var map = L.map(box, mapOptions());
|
||||
map.setView([me[1], me[0]], 13);
|
||||
if (!offline) L.tileLayer(TILES, { maxZoom: 18, minZoom: 8, attribution: ATTRIB }).addTo(map);
|
||||
else box.classList.add('is-offline');
|
||||
|
||||
L.marker([me[1], me[0]], { icon: L.divIcon({ className: 'at-pin-wrap', html: '<span class="at-pin here"></span>', iconSize: [18, 18], iconAnchor: [9, 9] }) })
|
||||
.bindTooltip(esc(t('map.youAreHere')), { direction: 'top', offset: [0, -11] }).addTo(map);
|
||||
|
||||
var pts = [[me[1], me[0]]];
|
||||
near.forEach(function (x) {
|
||||
var kind = x.kind === 'station' ? 'term' : 'stop';
|
||||
L.marker([x.pt[1], x.pt[0]], { icon: pinIcon(kind) })
|
||||
.bindTooltip(esc(x.kind === 'station' ? x.o.station_name_th : (x.o.place || x.o.type)), { direction: 'top', offset: [0, -8] })
|
||||
.addTo(map);
|
||||
pts.push([x.pt[1], x.pt[0]]);
|
||||
});
|
||||
map.fitBounds(L.latLngBounds(pts), { padding: [28, 28] });
|
||||
}
|
||||
|
||||
/* ---------- แผนที่ "เส้นทางที่เสนอ" (ยังไม่มีจริง — วาดจากโครงข้อมูลที่ผู้ใช้กำหนด) ----------
|
||||
spec = { origin:{lat,lng,label}, routes:[{ id, line_color, line_name,
|
||||
dest:{name,lat,lng}, via:[{name,lat,lng}] }] }
|
||||
เส้นที่ยังไม่ใส่พิกัดปลายทาง = ข้ามการวาด (ไปโผล่ในรายการฝั่งผู้เรียกแทน)
|
||||
onPick(route) เรียกเมื่อคลิกเส้น/จุด — ผู้เรียกเป็นคนแสดงรายละเอียดเอง */
|
||||
/* อ่านพิกัดจากได้ทั้ง 2 แบบ: coords = [lat, lng] (แบบใหม่) หรือ lat/lng แยก (แบบเดิม) */
|
||||
function coordOf(o) {
|
||||
o = o || {};
|
||||
if (Array.isArray(o.coords) && o.coords.length >= 2) {
|
||||
var a = num(o.coords[0]), b = num(o.coords[1]);
|
||||
return (a == null || b == null) ? null : [a, b];
|
||||
}
|
||||
var la = num(o.lat), ln = num(o.lng);
|
||||
return (la == null || ln == null) ? null : [la, ln];
|
||||
}
|
||||
|
||||
function proposal(el, spec, onPick) {
|
||||
var mk = makeMap(el), map = mk.map;
|
||||
var group = L.featureGroup().addTo(map);
|
||||
var pts = [];
|
||||
var o = spec.origin || {};
|
||||
var org = coordOf(o);
|
||||
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' })
|
||||
.addTo(group);
|
||||
|
||||
var pending = []; /* เส้นที่พิกัดปลายทางมาจาก geojson (โหลด async) */
|
||||
(spec.routes || []).forEach(function (r) {
|
||||
var d = r.dest || {};
|
||||
if (r.geo_id) { /* มีไฟล์เส้นทาง → โหลดเพื่อวาดเส้นจริง */
|
||||
pending.push(loadGeo(r.geo_id, spec).then(function (geo) {
|
||||
var ls = flatten(geo);
|
||||
r.__shape = toLatLngs(ls); /* ★ เส้นจริงจาก geojson (วาดตามที่ลากใน QGIS) */
|
||||
if (!coordOf(d)) { /* dest ยังไม่มีพิกัด → เดาจากจุดไกลสุดของเส้น */
|
||||
var ps = [];
|
||||
ls.forEach(function (l) { if (l && l.length) { ps.push(l[0]); ps.push(l[l.length - 1]); } });
|
||||
if (!ps.length) return;
|
||||
var ref = ps[0], far = ps[0], best = -1;
|
||||
ps.forEach(function (pt) {
|
||||
var dd = Math.pow(num(pt[0]) - num(ref[0]), 2) + Math.pow(num(pt[1]) - num(ref[1]), 2);
|
||||
if (dd > best) { best = dd; far = pt; }
|
||||
});
|
||||
d.coords = [num(far[1]), num(far[0])]; /* geojson = [lng, lat] → [lat, lng] */
|
||||
}
|
||||
r.__geoOk = true;
|
||||
}).catch(function () { /* อ่านไม่ได้ → ใช้ coords ที่มี (ถ้ามี) */ }));
|
||||
}
|
||||
});
|
||||
var drawAll = function () {
|
||||
(spec.routes || []).forEach(function (r) {
|
||||
var d = r.dest || {};
|
||||
var dl = coordOf(d);
|
||||
if (!dl) return; /* ยังไม่มีพิกัด → ข้าม */
|
||||
var col = r.line_color || '#7a4cc0';
|
||||
|
||||
/* เส้นจริงจาก geojson (ถ้ามี) → วาดตามเส้นที่ลากไว้ · ไม่มี → เส้นตรงต้นทาง→ปลายทาง + จุดแวะ */
|
||||
var segs = (r.__shape && r.__shape.length) ? r.__shape : [[org].concat(
|
||||
(r.via || []).map(coordOf).filter(Boolean), dl)];
|
||||
|
||||
/* smoothFactor 0.5 = ลดจุดน้อยลง (ค่าเริ่มต้น Leaflet = 1.0 ทำให้เส้นดูตรงตอนซูมออก) */
|
||||
var line = L.featureGroup(segs.map(function (seg) {
|
||||
return L.polyline(seg, { color: col, weight: 4, opacity: .85, dashArray: '10 8', smoothFactor: 0.5 });
|
||||
})).addTo(group);
|
||||
/* FeatureGroup ไม่มี setStyle → แนบ helper ให้ผู้เรียกใช้ได้เหมือน polyline เดี่ยว */
|
||||
line.setStyle = function (st) { this.eachLayer(function (l) { l.setStyle(st); }); return this; };
|
||||
var dot = L.circleMarker(dl, { radius: 7, color: '#fff', weight: 2, fillColor: col, fillOpacity: 1 })
|
||||
.bindTooltip(esc(d.name || ''), { direction: 'top', offset: [0, -6] }).addTo(group);
|
||||
pts.push(dl);
|
||||
|
||||
function pick(e) {
|
||||
if (e && e.originalEvent) L.DomEvent.stopPropagation(e);
|
||||
if (onPick) onPick(r, { line: line, dot: dot });
|
||||
}
|
||||
line.on('click', pick);
|
||||
dot.on('click', pick);
|
||||
r.__layer = { line: line, dot: dot }; /* ให้ผู้เรียกไฮไลต์ได้ */
|
||||
});
|
||||
|
||||
};
|
||||
/* มีเส้นที่ต้องอ่านพิกัดจาก geojson → รอให้ครบก่อนวาด · ไม่มี → วาดเลย */
|
||||
(pending.length ? Promise.all(pending) : Promise.resolve()).then(function () {
|
||||
drawAll();
|
||||
fitAll(map, pts);
|
||||
setTimeout(function () { map.invalidateSize(); }, 60);
|
||||
});
|
||||
return { map: map, group: group };
|
||||
}
|
||||
|
||||
return {
|
||||
route: route, forStop: forStop, proposal: proposal, nearMe: nearMe,
|
||||
NEAR_M: NEAR_M, LINE_MAIN: LINE_MAIN,
|
||||
maps: MAPS /* ไว้ตรวจสอบ/ทดสอบจากคอนโซล */
|
||||
};
|
||||
})();
|
||||
export {};
|
||||
@@ -0,0 +1,154 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/otherStop.js — logic unchanged. */
|
||||
/* ============================================================
|
||||
otherStop.js — ตัวอ่าน '8 other_stop.json' (ใช้ร่วมทุกหน้า)
|
||||
|
||||
ทำไมต้องมี: จุดจอด station_id 8 คือ "จุดขึ้นรถประจำทางอื่นๆ" ซึ่งเป็นชื่อรวม ๆ
|
||||
ของทุกสาย — ตัวจริงของแต่ละสายอยู่ใน '8 other_stop.json' เช่น
|
||||
|
||||
{ "route_id": "1101", "station_name_th": "วัดสีบัวทอง", ... } ← 1101 คือสาย 1011
|
||||
|
||||
ไฟล์นี้จึงต้อง "จับคู่ route id" ก่อน แล้วค่อยเอาชื่อ/พิกัดจริงของสายนั้นไปแสดง
|
||||
(เช่น หน้าป้ายต้องขึ้น "จุดขึ้นรถประจำทางอื่นๆ · วัดสีบัวทอง")
|
||||
|
||||
API:
|
||||
OtherStop.load() → Promise<entry[]> (โหลดครั้งเดียวแล้ว cache)
|
||||
OtherStop.fileRouteId(entry) → รหัสสายตามที่เขียนในไฟล์
|
||||
OtherStop.resolve(fileRouteId, validIds) → { id, alias } | null
|
||||
OtherStop.forRoute(entries, routeId, validIds) → entry | null
|
||||
OtherStop.forStation(entries, station, routeId, validIds) → entry | null
|
||||
OtherStop.stopsOf(entry) → [{ name, lat, lng, hasCoord, city_th, province_th, index }]
|
||||
OtherStop.firstName(entry) → ชื่อจุดแรก (ใช้เป็นชื่อย่อของสาย)
|
||||
OtherStop.allStops(entries, routeId, validIds) → รายการจุดจริง "ทุกจุด" ของสายนั้น
|
||||
· แต่ละจุดมี offsetMin = นาทีจากจุดแรก (ถ้าไฟล์ใส่ "offsets_min") → ใช้คำนวณเวลาของจุดนั้นได้
|
||||
· ฟิลด์ในไฟล์: station_name_th[], latitude[], longitude[], offsets_min[] (จับคู่ตามลำดับ)
|
||||
============================================================ */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var URL = '/resource/data/8%20other_stop.json';
|
||||
var cache = null;
|
||||
|
||||
/* โหลดครั้งเดียว — คืน promise เดิมซ้ำ (ไม่ยิง fetch ซ้ำทุกหน้า) */
|
||||
function load() {
|
||||
if (cache) return cache;
|
||||
cache = fetch(URL, { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) { return (d && d.other_stop) || []; })
|
||||
.catch(function () { return []; });
|
||||
return cache;
|
||||
}
|
||||
|
||||
function fileRouteId(entry) {
|
||||
return String((entry && entry.route_id) != null ? entry.route_id : '');
|
||||
}
|
||||
|
||||
/* เทียบรหัสสายแบบ "ทนรหัสเพี้ยน": 1101 → 1011 (ตัวเลขชุดเดียวกัน สลับตำแหน่ง)
|
||||
ใช้เฉพาะเมื่อรหัสในไฟล์ "ไม่มีจริง" ใน routes.json และหาคู่ได้ไม่กำกวม (1 ตัวเท่านั้น) */
|
||||
function sameDigits(a, b) {
|
||||
var na = String(a).replace(/\D/g, ''), nb = String(b).replace(/\D/g, '');
|
||||
if (!na || na.length !== nb.length) return false;
|
||||
return na.split('').sort().join('') === nb.split('').sort().join('');
|
||||
}
|
||||
|
||||
function resolve(fid, validIds) {
|
||||
var want = String(fid);
|
||||
var valid = (validIds || []).map(String);
|
||||
if (valid.indexOf(want) !== -1) return { id: want, alias: false };
|
||||
/* เทียบแบบสลับตำแหน่ง (1101 → 1011) เฉพาะรหัสยาว ≥3 หลัก
|
||||
— รหัสสั้นอย่าง "51"/"15" มีโอกาสสลับกันได้จริง → ไม่เดา */
|
||||
var digits = want.replace(/\D/g, '');
|
||||
if (digits.length < 3) return null;
|
||||
var cands = valid.filter(function (v) { return sameDigits(v, want); });
|
||||
if (cands.length === 1) return { id: cands[0], alias: true };
|
||||
return null; /* ไม่รู้จัก หรือกำกวม → ไม่เดา */
|
||||
}
|
||||
|
||||
function forRoute(entries, routeId, validIds) {
|
||||
var want = String(routeId);
|
||||
var hit = (entries || []).filter(function (e) { return fileRouteId(e) === want; })[0];
|
||||
if (hit) return hit;
|
||||
/* ถ้ายังไม่เจอ → หา entry ที่รหัสในไฟล์หมายถึงสายนี้ (เช่น 1101 → 1011) */
|
||||
var found = null;
|
||||
(entries || []).forEach(function (e) {
|
||||
if (found) return;
|
||||
var r = resolve(fileRouteId(e), validIds);
|
||||
if (r && r.id === want) found = e;
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
/* ทุก entry ที่หมายถึงสายนี้ (สายเดียวมีได้หลายจุดจริง) */
|
||||
function forRouteAll(entries, routeId, validIds) {
|
||||
var want = String(routeId);
|
||||
return (entries || []).filter(function (e) {
|
||||
if (fileRouteId(e) === want) return true;
|
||||
var r = resolve(fileRouteId(e), validIds);
|
||||
return !!(r && r.id === want);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* ---------- แตก entry → รายการ "จุดจริง" ของสายนั้น ----------
|
||||
กติกาข้อมูล (เจ้าของข้อมูลกำหนด):
|
||||
· station_name_th เป็นได้ทั้งข้อความเดียว หรือรายการหลายชื่อ (เช่น 954 = 4 จุด)
|
||||
· latitude/longitude เป็นได้ทั้งตัวเลขเดียว หรือรายการ — จับคู่กับชื่อ "ตามลำดับ"
|
||||
· "พิกัดเป็นของชื่อแรก" → ถ้ามีพิกัดเดียว ชื่อที่ 2 เป็นต้นไป = ยังไม่มีพิกัด (ไม่เดา) */
|
||||
function num(v) { var n = parseFloat(v); return isNaN(n) ? null : n; }
|
||||
function stopsOf(entry) {
|
||||
if (!entry) return [];
|
||||
var names = [].concat(entry.station_name_th == null ? [] : entry.station_name_th)
|
||||
.map(function (x) { return String(x == null ? '' : x).trim(); })
|
||||
.filter(Boolean);
|
||||
var lats = [].concat(entry.latitude == null ? [] : entry.latitude);
|
||||
var lngs = [].concat(entry.longitude == null ? [] : entry.longitude);
|
||||
var offs = [].concat(entry.offsets_min == null ? [] : entry.offsets_min); /* นาทีจากจุดแรก (0 = จุดแรกเอง) */
|
||||
return names.map(function (name, i) {
|
||||
var lat = num(lats[i]), lng = num(lngs[i]);
|
||||
return {
|
||||
index: i,
|
||||
name: name,
|
||||
/* city/province ในไฟล์อธิบาย "จุดแรก" — จุดอื่นไม่ทราบ ไม่เดา */
|
||||
city_th: i === 0 ? (entry.city_th || null) : null,
|
||||
province_th: i === 0 ? (entry.province_th || null) : null,
|
||||
station_type: entry.station_type || null,
|
||||
note: entry.note || null,
|
||||
lat: lat, lng: lng,
|
||||
offsetMin: num(offs[i]), /* ระยะเวลาจากจุดแรก (นาที) — ไม่ใส่ = ไม่ทราบ */
|
||||
hasCoord: lat != null && lng != null,
|
||||
entry: entry
|
||||
};
|
||||
});
|
||||
}
|
||||
function firstName(entry) { var st = stopsOf(entry)[0]; return st ? st.name : null; }
|
||||
function allStops(entries, routeId, validIds) {
|
||||
var out = [];
|
||||
forRouteAll(entries, routeId, validIds).forEach(function (e) { out = out.concat(stopsOf(e)); });
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ใช้กับ "สถานี 8" (จุดขึ้นรถประจำทางอื่นๆ) เท่านั้น */
|
||||
function isOtherStop(station) {
|
||||
if (!station) return false;
|
||||
return String(station.station_code) === 'other_stop' || Number(station.station_id) === 8;
|
||||
}
|
||||
|
||||
function forStation(entries, station, routeId, validIds) {
|
||||
if (!isOtherStop(station)) return null;
|
||||
return forRoute(entries, routeId, validIds);
|
||||
}
|
||||
|
||||
window.OtherStop = {
|
||||
load: load,
|
||||
fileRouteId: fileRouteId,
|
||||
resolve: resolve,
|
||||
forRoute: forRoute,
|
||||
forRouteAll: forRouteAll,
|
||||
isOtherStop: isOtherStop,
|
||||
forStation: forStation,
|
||||
stopsOf: stopsOf,
|
||||
firstName: firstName,
|
||||
allStops: allStops
|
||||
};
|
||||
})();
|
||||
export {};
|
||||
@@ -0,0 +1,128 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/popular.js — logic unchanged. */
|
||||
/* popular.js — อัลกอริทึมนับ "สายที่เปิดดูบ่อย" สำหรับ footer (ฝั่งเบราว์เซอร์ ไม่มี backend)
|
||||
|
||||
กลไก
|
||||
• จับการเปิดดูสาย: Popular.hit(route_id) — เรียกจาก busDetail.init.js / stopDetail / รายการสาย
|
||||
• เก็บใน localStorage: { "102": [hits, lastTs], ... } (id → [จำนวนครั้ง, เวลาล่าสุด])
|
||||
• คะแนนไม่เฟ้อ: score = hits × 0.5 ^ (อายุวัน / HALF_LIFE) ← ครึ่งชีวิต 30 วัน
|
||||
สายที่ไม่มีคนเปิดนาน ๆ จะค่อย ๆ ตกลงเองโดยไม่ต้องลบข้อมูล
|
||||
• แสดง 4 อันดับใน footer · ไม่มีข้อมูลพอ → ใช้ DEFAULT_IDS (ของเดิม) เป็น fallback
|
||||
• ประหยัดพื้นที่: เก็บแค่ 2 ตัวเลข/สาย · ทิ้งข้อมูลที่ตายเกิน PRUNE_DAYS วัน
|
||||
|
||||
ไม่มี dependency — โหลดก่อน router.js (หลัง i18n.js เพื่อให้ข้อความถูกภาษา)
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var KEY = 'at_route_hits'; /* คีย์ใน localStorage */
|
||||
var HALF_LIFE = 30; /* วัน — คะแนนลดครึ่งเมื่อไม่ถูกเปิดนาน 30 วัน */
|
||||
var PRUNE_DAYS = 180; /* ทิ้งข้อมูลที่ไม่ถูกเปิดเกิน 180 วัน (กันบวม) */
|
||||
var TOP_N = 4; /* จำนวนที่แสดงใน footer */
|
||||
var DAY_MS = 86400000;
|
||||
|
||||
/* ค่าเริ่มต้น (ของเดิมใน footer) — ใช้เมื่อยังไม่มีข้อมูลจริง หรือมีไม่ครบ TOP_N */
|
||||
var DEFAULT_IDS = ['101', '902', '15', '464'];
|
||||
|
||||
function now() { return Date.now(); }
|
||||
|
||||
/* ── อ่าน/เขียน storage (ทน localStorage ใช้ไม่ได้ เช่น โหมดส่วนตัว) ── */
|
||||
function read() {
|
||||
try {
|
||||
var raw = localStorage.getItem(KEY);
|
||||
if (!raw) return {};
|
||||
var d = JSON.parse(raw);
|
||||
return (d && typeof d === 'object') ? d : {};
|
||||
} catch (e) { return {}; }
|
||||
}
|
||||
|
||||
function write(d) {
|
||||
try { localStorage.setItem(KEY, JSON.stringify(d)); } catch (e) { /* เงียบ */ }
|
||||
}
|
||||
|
||||
/* คะแนนของรายการเดียว: hits × 0.5^(อายุวัน/ครึ่งชีวิต) */
|
||||
function score(entry, ts) {
|
||||
if (!entry || !entry.length) return 0;
|
||||
var hits = Number(entry[0]) || 0;
|
||||
var last = Number(entry[1]) || 0;
|
||||
if (hits <= 0 || last <= 0) return 0;
|
||||
var ageDays = Math.max(0, (ts - last) / DAY_MS);
|
||||
return hits * Math.pow(0.5, ageDays / HALF_LIFE);
|
||||
}
|
||||
|
||||
/* ตัดข้อมูลที่ตายเกิน PRUNE_DAYS ทิ้ง (คืนค่า true ถ้ามีการแก้) */
|
||||
function prune(d, ts) {
|
||||
var cut = PRUNE_DAYS * DAY_MS;
|
||||
var changed = false;
|
||||
Object.keys(d).forEach(function (id) {
|
||||
var e = d[id];
|
||||
var last = (e && Number(e[1])) || 0;
|
||||
if (!last || (ts - last) > cut) { delete d[id]; changed = true; }
|
||||
});
|
||||
return changed;
|
||||
}
|
||||
|
||||
var Popular = {
|
||||
/* นับการเปิดดูสาย 1 ครั้ง */
|
||||
hit: function (routeId) {
|
||||
var id = String(routeId == null ? '' : routeId).trim();
|
||||
if (!id) return;
|
||||
var ts = now();
|
||||
var d = read();
|
||||
var e = d[id];
|
||||
d[id] = [(e && Number(e[0]) || 0) + 1, ts];
|
||||
prune(d, ts);
|
||||
write(d);
|
||||
},
|
||||
|
||||
/* อันดับ id เรียงจากคะแนนมาก→น้อย · ไม่มีข้อมูล → DEFAULT_IDS */
|
||||
ranked: function (n) {
|
||||
var ts = now();
|
||||
var d = read();
|
||||
if (prune(d, ts)) write(d);
|
||||
|
||||
var rows = Object.keys(d).map(function (id) {
|
||||
return { id: id, score: score(d[id], ts) };
|
||||
}).filter(function (r) { return r.score > 0; });
|
||||
|
||||
rows.sort(function (a, b) { return b.score - a.score || (a.id < b.id ? -1 : 1); });
|
||||
|
||||
var top = rows.slice(0, n || TOP_N).map(function (r) { return r.id; });
|
||||
/* เติมด้วยค่าเริ่มต้นถ้ายังไม่ครบ (ไม่ให้ footer ว่าง) */
|
||||
DEFAULT_IDS.forEach(function (id) {
|
||||
if (top.length < (n || TOP_N) && top.indexOf(id) < 0) top.push(id);
|
||||
});
|
||||
return top.slice(0, n || TOP_N);
|
||||
},
|
||||
|
||||
/* เรนเดอร์รายการใน footer (เรียกหลัง i18n พร้อม — ชื่อสายตามภาษา) */
|
||||
mount: function (ulId, routes) {
|
||||
var ul = document.getElementById(ulId || 'footer-popular-list');
|
||||
if (!ul || !routes || !routes.length) return false;
|
||||
|
||||
var byId = {};
|
||||
routes.forEach(function (r) { byId[String(r.route_id)] = r; });
|
||||
|
||||
var ids = Popular.ranked(TOP_N);
|
||||
ul.innerHTML = '';
|
||||
ids.forEach(function (id) {
|
||||
var r = byId[id];
|
||||
if (!r) return;
|
||||
var li = document.createElement('li');
|
||||
var a = document.createElement('a');
|
||||
a.href = '/routes/' + id;
|
||||
a.textContent = 'สาย ' + id + (r.route_name_th ? ' · ' + r.route_name_th : '');
|
||||
li.appendChild(a);
|
||||
ul.appendChild(li);
|
||||
});
|
||||
return ul.children.length > 0;
|
||||
},
|
||||
|
||||
/* สำหรับทดสอบ/debug */
|
||||
_score: score,
|
||||
_key: KEY
|
||||
};
|
||||
|
||||
window.Popular = Popular;
|
||||
})();
|
||||
export {};
|
||||
@@ -0,0 +1,378 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/busDetail.init.js — logic unchanged; bootstrap converted to mount(). */
|
||||
/* ============================================================
|
||||
busDetail.init.js — เติมข้อมูลหน้า #/routes/<รหัสสาย> จาก JSON
|
||||
------------------------------------------------------------
|
||||
ชื่อสาย/ตัวเลือก/เบอร์โทร resource/data/routes.json
|
||||
รูปรถ/คำอธิบาย/QR resource/data/captions/caption<รหัส>.json
|
||||
รอบต่อวัน/รอบถัดไป resource/data/schedules.json
|
||||
แผนที่ resource/data/geojson-web/<รหัส>.geojson (ATMap)
|
||||
รูปรถ: .image/routes/<รหัส>/ ตั้งชื่อไฟล์ขึ้นต้นด้วย car หรือ boat
|
||||
QR: .image/qrcode/<รหัส>.png
|
||||
============================================================ */
|
||||
/* ---- ported module body ---- */
|
||||
'use strict';
|
||||
|
||||
var DATA = '/resource/data/';
|
||||
var IMG_ROUTES = '/image/routes/';
|
||||
var IMG_QR = '/image/qrcode/';
|
||||
var CAR_NAMES = ['car', 'boat']; /* ลำดับชื่อไฟล์รูปรถที่ยอมรับ */
|
||||
var CAR_EXTS = ['jpeg', 'jpg', 'webp', 'png'];
|
||||
var QR_EXTS = ['png', 'PNG', 'jpg', 'JPG', 'jpeg', 'JPEG', 'webp'];
|
||||
var FALLBACK_ID = '101'; /* เข้า #/routes ตรง ๆ ไม่มีรหัสสาย */
|
||||
|
||||
function $(id) { return document.getElementById(id); }
|
||||
function t(k, v) { return window.I18N ? I18N.t(k, v) : k; }
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
function fetchJSON(u) {
|
||||
return fetch(u, { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; });
|
||||
}
|
||||
function setText(id, s) {
|
||||
var el = $(id);
|
||||
if (!el) return;
|
||||
var v = (s == null ? '' : String(s)).trim();
|
||||
el.textContent = v;
|
||||
el.hidden = !v;
|
||||
}
|
||||
/* ตัวเลขสรุป: ไม่มีข้อมูลให้แสดง – เพื่อให้การ์ดทั้ง 4 ช่องเท่ากัน */
|
||||
function setStat(id, s) {
|
||||
var el = $(id);
|
||||
if (!el) return;
|
||||
var v = (s == null ? '' : String(s)).trim();
|
||||
el.textContent = v || '–';
|
||||
el.hidden = false;
|
||||
}
|
||||
function uniq(a) { return a.filter(function (u, i) { return u && a.indexOf(u) === i; }); }
|
||||
|
||||
/* ลองโหลดรูปตามลำดับ — พลาดก็ลองตัวถัดไป ไม่มีเลยก็ซ่อน (ไม่ทิ้งไอคอนรูปแตก) */
|
||||
function tryImage(img, urls, alt, onDone) {
|
||||
var i = 0;
|
||||
img.alt = alt || '';
|
||||
img.loading = 'eager'; /* ห้าม lazy: รูปที่ซ่อนอยู่จะไม่ถูกโหลด แล้ว onload ไม่ยิง */
|
||||
img.onload = function () { img.hidden = false; if (onDone) onDone(true); };
|
||||
img.onerror = function () {
|
||||
if (i >= urls.length) { img.hidden = true; if (onDone) onDone(false); return; }
|
||||
img.src = urls[i++];
|
||||
};
|
||||
img.onerror();
|
||||
}
|
||||
/* เติม ?v=<เวอร์ชันแอป> ให้ URL รูป — bump VERSION ใน sw.js = รูปโหลดใหม่ทั้งหมด
|
||||
(browser/SW แคชรูปไว้แบบ cache-first จึงต้องเปลี่ยน URL เพื่อบังคับดึงใหม่) */
|
||||
function bust(u) { return (window.ImgURL && ImgURL.of) ? ImgURL.of(u) : u; }
|
||||
|
||||
function vehicleUrls(rid, cap) {
|
||||
var base = IMG_ROUTES + encodeURIComponent(rid) + '/', out = [];
|
||||
if (cap && cap.vehicle_image) out.push(bust(base + cap.vehicle_image));
|
||||
CAR_NAMES.forEach(function (n) { CAR_EXTS.forEach(function (e) { out.push(bust(base + n + '.' + e)); }); });
|
||||
return uniq(out);
|
||||
}
|
||||
function qrUrls(rid, cap) {
|
||||
var out = [];
|
||||
if (cap && cap.qr_image) out.push(bust(IMG_QR + cap.qr_image));
|
||||
QR_EXTS.forEach(function (e) { out.push(bust(IMG_QR + encodeURIComponent(rid) + '.' + e)); });
|
||||
return uniq(out);
|
||||
}
|
||||
|
||||
/* จัดรูปแบบเบอร์ให้อ่านง่าย — รองรับทั้งมือถือ (+66xx xxx xxxx) และเบอร์บ้าน (0-xxxx-xxxx) */
|
||||
function fmtPhone(p) {
|
||||
var raw = String(p == null ? '' : p).trim();
|
||||
var digits = raw.replace(/[^\d+]/g, '');
|
||||
if (!digits) return '';
|
||||
var intl = /^\+?66/.test(digits);
|
||||
var nat = intl ? digits.replace(/^\+?66/, '') : digits;
|
||||
if (nat.charAt(0) === '0') return nat.slice(0, 1) + ' ' + nat.slice(1, 5) + ' ' + nat.slice(5);
|
||||
if (nat.length === 9) return '+66 ' + nat.slice(0, 2) + ' ' + nat.slice(2, 5) + ' ' + nat.slice(5);
|
||||
if (nat.length === 8) return '+66 ' + nat.slice(0, 2) + ' ' + nat.slice(2);
|
||||
return raw;
|
||||
}
|
||||
function telHref(p) { return 'tel:' + String(p == null ? '' : p).replace(/[^\d+]/g, ''); }
|
||||
|
||||
/* ---------- ลิงก์ติดต่อ (web_url ใน routes.json) — ไอคอน/ชื่อ/สี เปลี่ยนตามชนิด URL ----------
|
||||
facebook → ไอคอน facebook + โทนฟ้า · line (line.me / lin.ee / linevoom) → LINE + โทนเขียว
|
||||
อื่น ๆ (www) → ไอคอนลูกโลก + โทนม่วง */
|
||||
var LINK_KINDS = [
|
||||
{ key: 'facebook', icon: 'ic-facebook', tone: 'tone-sky', match: /facebook\.com|fb\.(me|com)/i },
|
||||
{ key: 'line', icon: 'ic-message-circle', tone: 'tone-green', match: /line\.me|lin\.ee|linevoom|line\.at/i },
|
||||
{ key: 'www', icon: 'ic-globe', tone: 'tone-purple', match: /^https?:/i }
|
||||
];
|
||||
/* routes.json เก็บ web_url ได้ 2 แบบ:
|
||||
["facebook", "https://..."] ← อาร์เรย์ [ชนิดลิงก์, URL] (แบบใหม่ — ใช้ชนิดที่ระบุไว้เลย)
|
||||
"https://..." ← สตริงเดี่ยว (แบบเก่า — เดาชนิดจาก URL)
|
||||
คืน { kind, url } · ไม่มีข้อมูล = null */
|
||||
function parseWebUrl(raw) {
|
||||
var kindKey = null, url = '';
|
||||
if (Array.isArray(raw)) {
|
||||
raw.forEach(function (x) {
|
||||
var v = String(x == null ? '' : x).trim();
|
||||
if (!v) return;
|
||||
if (/^https?:\/\//i.test(v)) url = v;
|
||||
else if (LINK_KINDS.some(function (k) { return k.key === v.toLowerCase(); })) kindKey = v.toLowerCase();
|
||||
else if (!url) url = v; /* ค่าแปลก ๆ → กันข้อมูลหาย */
|
||||
});
|
||||
} else {
|
||||
url = String(raw == null ? '' : raw).trim();
|
||||
}
|
||||
if (!url && !kindKey) return null;
|
||||
return { kind: kindKey ? byKind(kindKey) : linkKind(url), url: url };
|
||||
}
|
||||
function byKind(key) {
|
||||
for (var i = 0; i < LINK_KINDS.length; i++) { if (LINK_KINDS[i].key === key) return LINK_KINDS[i]; }
|
||||
return { key: 'www', icon: 'ic-globe', tone: 'tone-purple' };
|
||||
}
|
||||
function linkKind(url) {
|
||||
var u = String(url || '').trim();
|
||||
if (!u) return null;
|
||||
for (var i = 0; i < LINK_KINDS.length; i++) { if (LINK_KINDS[i].match.test(u)) return LINK_KINDS[i]; }
|
||||
return { key: 'www', icon: 'ic-globe', tone: 'tone-purple' };
|
||||
}
|
||||
function prettyUrl(url) {
|
||||
return String(url || '').trim().replace(/^https?:\/\//i, '').replace(/\/+$/, '');
|
||||
}
|
||||
|
||||
/* ---------- การ์ดติดต่อ (LINE + QR + ลิงก์ + เบอร์โทรจาก routes.json) ---------- */
|
||||
function buildContact(rid, route, cap) {
|
||||
var host = $('route-contact');
|
||||
if (!host) return;
|
||||
host.innerHTML = '';
|
||||
|
||||
var web = parseWebUrl(route.web_url); /* รองรับ ["kind","url"] และสตริงเดี่ยว */
|
||||
var kind = web ? web.kind : null;
|
||||
var webUrl = web ? web.url : '';
|
||||
var line = document.createElement('div');
|
||||
line.className = 'mu-contact-item';
|
||||
line.innerHTML =
|
||||
'<span class="ic-wrap ' + (kind ? kind.tone : 'tone-green') + '"><svg class="ic" aria-hidden="true">' +
|
||||
'<use href="#' + (kind ? kind.icon : 'ic-message-circle') + '"/></svg></span>' +
|
||||
'<div class="txt"><strong>' + esc(kind ? t('route.link.' + kind.key) : 'LINE Official') + '</strong>' +
|
||||
'<span id="route-line-note"></span></div>';
|
||||
var qr = document.createElement('img');
|
||||
qr.className = 'mu-qr-img';
|
||||
qr.loading = 'lazy';
|
||||
qr.decoding = 'async';
|
||||
qr.hidden = true;
|
||||
/* กดที่ QR → ขยายลอยกลางจอให้สแกนง่าย (ปุ่มจริง เผื่อคีย์บอร์ด/อ่านหน้าจอ) */
|
||||
var qrBtn = document.createElement('button');
|
||||
qrBtn.type = 'button';
|
||||
qrBtn.className = 'mu-qr-btn';
|
||||
qrBtn.hidden = true;
|
||||
qrBtn.setAttribute('aria-label', t('route.zoomQr'));
|
||||
qrBtn.appendChild(qr);
|
||||
line.appendChild(qrBtn);
|
||||
host.appendChild(line);
|
||||
|
||||
var note = (cap && cap.line_note) ? String(cap.line_note).trim() : '';
|
||||
setText('route-line-note', note);
|
||||
var phones = (route.phone || []).filter(Boolean);
|
||||
tryImage(qr, qrUrls(rid, cap), 'LINE QR สาย ' + rid, function (ok) {
|
||||
qrBtn.hidden = !ok; /* ไม่มีรูป = ไม่มีปุ่มขยาย */
|
||||
if (ok) {
|
||||
var label = (kind ? t('route.link.' + kind.key) : 'LINE Official');
|
||||
qrBtn.addEventListener('click', function () { openQrModal(qr.src, label, webUrl); });
|
||||
}
|
||||
line.hidden = !ok && !note; /* ไม่มีทั้ง QR และข้อความ = ไม่ต้องแสดงแถวนี้ */
|
||||
host.hidden = line.hidden && !phones.length; /* ไม่มีอะไรจะแสดงเลย */
|
||||
});
|
||||
|
||||
phones.forEach(function (p) {
|
||||
var a = document.createElement('a');
|
||||
a.className = 'mu-contact-item';
|
||||
a.href = telHref(p);
|
||||
a.innerHTML =
|
||||
'<span class="ic-wrap"><svg class="ic" aria-hidden="true"><use href="#ic-phone"/></svg></span>' +
|
||||
'<div class="txt"><strong>' + esc(t('route.call')) + '</strong><span>' + esc(fmtPhone(p)) + '</span></div>';
|
||||
host.appendChild(a);
|
||||
});
|
||||
|
||||
/* ปุ่ม "เปิดลิงก์" แยกต่างหาก — ชัดเจนบนมือถือ (แสดงเมื่อ routes.json มี web_url) */
|
||||
if (kind && /^https?:\/\//i.test(webUrl)) {
|
||||
var open = document.createElement('a');
|
||||
open.className = 'mu-contact-item';
|
||||
open.href = webUrl;
|
||||
open.target = '_blank';
|
||||
open.rel = 'noopener noreferrer';
|
||||
open.setAttribute('aria-label', t('route.openLink') + ': ' + prettyUrl(webUrl));
|
||||
open.innerHTML =
|
||||
'<span class="ic-wrap ' + kind.tone + '"><svg class="ic" aria-hidden="true"><use href="#' + kind.icon + '"/></svg></span>' +
|
||||
'<div class="txt"><strong>' + esc(t('route.openLink')) + '</strong></div>' + /* ไม่แสดง URL — กันล้นปุ่ม */
|
||||
'<span class="mu-link-go"><svg class="ic" aria-hidden="true"><use href="#ic-arrow-right"/></svg></span>';
|
||||
host.appendChild(open);
|
||||
host.hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ---------- ขยาย QR ลอยกลางจอ (ให้สแกนง่ายจากจออื่น) ----------
|
||||
ใช้ <dialog> ของเบราว์เซอร์: กด Esc ปิดได้เอง · คลิกพื้นหลังปิด · ไม่ต้องพึ่งไลบรารี
|
||||
ปุ่ม "เปิดลิงก์" เปิดแท็บใหม่ (target=_blank) */
|
||||
function openQrModal(src, label, url) {
|
||||
if (!src) return;
|
||||
var old = $('qr-modal');
|
||||
if (old) old.remove();
|
||||
var hasUrl = url && /^https?:\/\//i.test(String(url).trim());
|
||||
var dlg = document.createElement('dialog');
|
||||
dlg.id = 'qr-modal';
|
||||
dlg.className = 'mu-qr-modal';
|
||||
/* กดรูป QR = เปิดลิงก์ (ตามที่เจ้าของข้อมูลต้องการ) · มีปุ่ม "เปิดลิงก์" + "คัดลอกลิงก์" เป็นทางเลือกชัดเจน */
|
||||
var qrImg = hasUrl
|
||||
? '<a class="mu-qr-link" href="' + esc(String(url).trim()) + '" target="_blank" rel="noopener noreferrer"' +
|
||||
' aria-label="' + esc(t('route.openLink')) + '"><img class="mu-qr-big" src="' + esc(src) +
|
||||
'" alt="' + esc(label || 'QR') + '" decoding="async"></a>'
|
||||
: '<img class="mu-qr-big" src="' + esc(src) + '" alt="' + esc(label || 'QR') + '" decoding="async">';
|
||||
var acts = hasUrl
|
||||
? '<div class="mu-qr-actions">' +
|
||||
'<a class="mu-btn" href="' + esc(String(url).trim()) + '" target="_blank" rel="noopener noreferrer">' +
|
||||
esc(t('route.openLink')) + ' <svg class="ic" aria-hidden="true"><use href="#ic-arrow-right"/></svg></a>' +
|
||||
'<button type="button" class="mu-btn ghost mu-copy-link">' +
|
||||
'<svg class="ic" aria-hidden="true"><use href="#ic-copy"/></svg> ' + esc(t('route.copyLink')) + '</button>' +
|
||||
'</div>'
|
||||
: '';
|
||||
dlg.innerHTML =
|
||||
'<div class="mu-qr-modal-card">' +
|
||||
'<button type="button" class="mu-qr-close" aria-label="' + esc(t('common.close')) + '">' +
|
||||
'<svg class="ic" aria-hidden="true"><use href="#ic-x"/></svg></button>' +
|
||||
qrImg +
|
||||
'<strong>' + esc(label || '') + '</strong>' +
|
||||
acts +
|
||||
'</div>';
|
||||
document.body.appendChild(dlg);
|
||||
dlg.addEventListener('click', function (e) { /* คลิกพื้นหลัง = ปิด */
|
||||
if (e.target === dlg) dlg.close();
|
||||
});
|
||||
dlg.addEventListener('close', function () { dlg.remove(); });
|
||||
dlg.querySelector('.mu-qr-close').addEventListener('click', function () { dlg.close(); });
|
||||
|
||||
/* คัดลอกลิงก์ — ใช้ Clipboard API ก่อน, ถ้าไม่ให้สิทธิ์ถอยไป execCommand */
|
||||
var copyBtn = dlg.querySelector('.mu-copy-link');
|
||||
if (copyBtn) {
|
||||
copyBtn.addEventListener('click', function () {
|
||||
var target = String(url).trim();
|
||||
var done = function () {
|
||||
copyBtn.classList.add('is-done');
|
||||
var old2 = copyBtn.innerHTML;
|
||||
copyBtn.textContent = t('route.copied');
|
||||
setTimeout(function () { copyBtn.innerHTML = old2; copyBtn.classList.remove('is-done'); }, 1400);
|
||||
};
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(target).then(done).catch(function () { legacyCopy(target); done(); });
|
||||
} else { legacyCopy(target); done(); }
|
||||
});
|
||||
}
|
||||
if (typeof dlg.showModal === 'function') dlg.showModal(); else dlg.setAttribute('open', '');
|
||||
}
|
||||
|
||||
/* คัดลอกแบบเก่า (เบราว์เซอร์ไม่รองรับ Clipboard API / ไม่ได้ https) */
|
||||
function legacyCopy(text) {
|
||||
try {
|
||||
var ta = document.createElement('textarea');
|
||||
ta.value = text;
|
||||
ta.setAttribute('readonly', '');
|
||||
ta.style.position = 'fixed';
|
||||
ta.style.top = '-1000px';
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(ta);
|
||||
return true;
|
||||
} catch (e) { return false; }
|
||||
}
|
||||
|
||||
/* ---------- รอบต่อวัน / รอบถัดไป จาก schedules.json ---------- */
|
||||
function toMin(hhmm) {
|
||||
var a = String(hhmm).split(':');
|
||||
return (parseInt(a[0], 10) || 0) * 60 + (parseInt(a[1], 10) || 0);
|
||||
}
|
||||
function nextTrip(times) {
|
||||
if (!times.length) return null;
|
||||
var uniqTimes = times.slice().sort();
|
||||
var now = new Date(), mins = now.getHours() * 60 + now.getMinutes();
|
||||
for (var i = 0; i < uniqTimes.length; i++) {
|
||||
if (toMin(uniqTimes[i]) >= mins) return uniqTimes[i];
|
||||
}
|
||||
return uniqTimes[0]; /* หมดรอบของวันนี้ → รอบแรกของวันถัดไป */
|
||||
}
|
||||
function loadTrips(rid) {
|
||||
return Schedules.load().then(function (sd) { return Schedules.normSub(sd); }).then(function (d) {
|
||||
var recs = window.Schedules ? Schedules.records(d) : ((d && (d.schedules || d)) || []);
|
||||
var out = [];
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) === String(rid)) out = out.concat(r.departure_times || []);
|
||||
});
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
||||
function fillVehicle(rid, route, cap) {
|
||||
cap = cap || {};
|
||||
var img = $('route-vehicle-img');
|
||||
var card = $('route-vehicle-card');
|
||||
if (img) {
|
||||
tryImage(img, vehicleUrls(rid, cap), 'รถของสาย ' + rid, function (ok) {
|
||||
if (card) card.classList.toggle('no-photo', !ok);
|
||||
});
|
||||
}
|
||||
setText('route-vehicle-title', cap.vehicle_title);
|
||||
setText('route-vehicle-desc', cap.vehicle_desc);
|
||||
buildContact(rid, route, cap);
|
||||
}
|
||||
|
||||
function init() {
|
||||
var params = (window.__route && window.__route.params) || {};
|
||||
fetchJSON(DATA + 'routes.json').then(function (d) {
|
||||
var list = (d && d.routes) || [];
|
||||
if (!list.length) return;
|
||||
|
||||
var want = String(params.routeId || '');
|
||||
var route = list.filter(function (r) { return String(r.route_id) === want; })[0] ||
|
||||
list.filter(function (r) { return String(r.route_id) === FALLBACK_ID; })[0] || list[0];
|
||||
var rid = String(route.route_id);
|
||||
|
||||
/* หัวเรื่อง (chip + ชื่อสาย) — สี chip เปลี่ยนตามหมวดเส้นทาง (route_group) */
|
||||
setText('route-chip', rid);
|
||||
var chipEl = $('route-chip');
|
||||
if (chipEl) {
|
||||
chipEl.className = 'mu-route-chip' + (route.route_group ? ' grp-' + route.route_group : '');
|
||||
}
|
||||
setText('route-title', route.route_name_th);
|
||||
document.title = 'Atroute — สาย ' + rid + (route.route_name_th ? ' ' + route.route_name_th : '');
|
||||
|
||||
/* dropdown: เติมจาก routes.json (ลำดับตามไฟล์) + เปลี่ยนแล้วไปสายนั้น */
|
||||
var sel = $('route-select');
|
||||
if (sel) {
|
||||
sel.innerHTML = '';
|
||||
list.forEach(function (r) {
|
||||
var o = document.createElement('option');
|
||||
o.value = r.route_id;
|
||||
o.textContent = 'สาย ' + r.route_id + (r.route_name_th ? ' - ' + r.route_name_th : '');
|
||||
sel.appendChild(o);
|
||||
});
|
||||
sel.value = rid;
|
||||
sel.addEventListener('change', function () {
|
||||
window.location.href = '/routes/' + encodeURIComponent(sel.value);
|
||||
});
|
||||
}
|
||||
|
||||
/* สรุปเส้นทาง */
|
||||
setStat('stat-stops', route.station_ids ? route.station_ids.length : '');
|
||||
setStat('stat-provinces', route.province_ids ? route.province_ids.length : '');
|
||||
loadTrips(rid).then(function (times) {
|
||||
setStat('stat-trips', times.length ? String(times.length) : '');
|
||||
setStat('stat-next', nextTrip(times) || '');
|
||||
});
|
||||
|
||||
/* รูปรถ/คำอธิบาย/QR/เบอร์โทร */
|
||||
fetchJSON(DATA + 'captions/caption' + encodeURIComponent(rid) + '.json').then(function (cap) {
|
||||
fillVehicle(rid, route, cap);
|
||||
});
|
||||
|
||||
/* แผนที่เส้นทาง */
|
||||
var mapEl = $('route-map');
|
||||
if (mapEl && window.ATMap) ATMap.route(mapEl, rid);
|
||||
});
|
||||
}
|
||||
|
||||
export default function mount(): void {
|
||||
init();
|
||||
}
|
||||
@@ -0,0 +1,630 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/schedules.js — logic unchanged. */
|
||||
/* ============================================================
|
||||
schedules.js — ตัวอ่านข้อมูลตารางเวลา (ใช้ร่วมทุกหน้า)
|
||||
|
||||
***APIs นี้ไม่เปลี่ยนชื่อ/รูปเดิม*** — หน้า check/busDetail/home/stopDetail เรียกเหมือนเดิม
|
||||
ที่เพิ่มเข้ามาคือ "สมองเรื่องวันทำงาน/วันหยุด" ซึ่งทำงานอยู่ในไฟล์นี้ที่เดียว
|
||||
|
||||
รองรับ schedules.json 2 รูปแบบ:
|
||||
schema 1 (เดิม): { "schedules": [ { route_id, station_id, direction_note, departure_times[], schedule_note } ] }
|
||||
schema 2 (ใหม่): { "schema": 2, "routes": [ { route_id, station_order[], directions: [
|
||||
{ direction_id, direction_label, service?, stops: [ { station_id, times[], direction_note?, note?, groups? } ] } ] } ] }
|
||||
|
||||
── เรื่องวันทำงาน / วันหยุด (ไม่ต้องแก้โค้ดหน้าไหนเลย) ────────────────
|
||||
เพิ่มฟิลด์ "ไม่บังคับ" 2 ระดับ:
|
||||
1) ระดับทิศทาง: "service": "all" | "weekday" | "holiday"
|
||||
- ทั้งทิศทางใช้เฉพาะวันนั้น (เช่น ทิศ 'ตารางวันหยุด' → service: "holiday")
|
||||
- ไม่ใส่ = "all" (ทุกวัน) → ไฟล์เดิมไม่ต้องแก้อะไร พฤติกรรมเหมือนเดิมเป๊ะ
|
||||
2) ระดับจุดจอด: "groups": [ { "label": "วันหยุด", "dayType": "holiday", "times": ["10:00"] } ]
|
||||
- เวลาที่ "เพิ่มเข้ามาเฉพาะบางวัน" (ตรงกับโน้ตเดิม เช่น "10:00 มีเฉพาะวันหยุด")
|
||||
- times[] ยังเป็นตารางพื้นฐานที่ใช้ทุกวัน
|
||||
|
||||
ค่าเริ่มต้น: ตรวจจากวันที่ของเครื่องเอง (เสาร์–อาทิตย์ = วันหยุด + วันนักขัตฤกษ์จาก holidays.json)
|
||||
ความปลอดภัย: ถ้ากรองตามวันแล้วไม่เหลือทิศทางใดเลย → ถอยไปใช้ทั้งหมด + ติดธง fallback (หน้าเว็บไม่ว่าง)
|
||||
|
||||
API:
|
||||
Schedules.records(doc, opts) → record แบน (schema เดิม) สำหรับโค้ดเดิม
|
||||
Schedules.route(doc, routeId, opts) → { route_id, station_order[], directions[], entries[] }
|
||||
Schedules.directions(doc, routeId, opts) → [{ direction_id, direction_label, service, dayType, fallback, stops[] }]
|
||||
Schedules.times(doc, routeId, opts) → เวลาทั้งหมดของสาย (เรียงแล้ว)
|
||||
Schedules.countTrips(doc, routeId, opts) → จำนวนเที่ยวของสาย
|
||||
Schedules.todayType() → 'weekday' | 'holiday'
|
||||
Schedules.dayInfo(date) → { dayType, label_th, date }
|
||||
Schedules.ready → promise (โหลด holidays.json เสร็จ)
|
||||
opts ที่รับได้: { dayType: 'all' | 'weekday' | 'holiday' } (ไม่ส่ง = ตรวจจากวันนี้)
|
||||
============================================================ */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var DATA_URL = '/resource/data/';
|
||||
var HOLIDAYS = [];
|
||||
var ALIAS = { weekend: 'holiday', 'sat-sun': 'holiday', saturday: 'holiday', sunday: 'holiday', workday: 'weekday', weekday: 'weekday', holiday: 'holiday', all: 'all' };
|
||||
|
||||
/* ความเร็วเฉลี่ยตั้งต้นสำหรับคำนวณเวลาจุดที่ไม่มีตาราง (ปรับต่อทิศได้ด้วย "speedKmh") */
|
||||
var DEFAULT_SPEED_KMH = 40;
|
||||
|
||||
function pad2(n) { return (n < 10 ? '0' : '') + n; }
|
||||
function toMin(hhmm) {
|
||||
var a = String(hhmm).split(':');
|
||||
var h = parseInt(a[0], 10), m = parseInt(a[1], 10);
|
||||
return (isNaN(h) ? 0 : h) * 60 + (isNaN(m) ? 0 : m);
|
||||
}
|
||||
|
||||
/* คำนวณเวลาของจุดที่ไม่มีตาราง จากจุดที่มีเวลาแล้วซึ่งอยู่ใกล้ที่สุดตามระยะทาง (กม.)
|
||||
คืน null เมื่อคำนวณไม่ได้ (ไม่มี กม. หรือไม่มีจุดอ้างอิง) */
|
||||
function computeTimes(stop, siblings, opts) {
|
||||
var o = (typeof opts === 'number') ? { speedKmh: opts } : (opts || {});
|
||||
var speed = Number(o.speedKmh) > 0 ? Number(o.speedKmh) : DEFAULT_SPEED_KMH;
|
||||
if (!stop || typeof stop.km !== 'number') return null;
|
||||
var cands = siblings.filter(function (s) {
|
||||
return s !== stop && typeof s.km === 'number' && (s.times || []).length;
|
||||
});
|
||||
if (!cands.length) return null;
|
||||
var base = null;
|
||||
if (o.baseSid != null) { /* ผู้ใช้เลือกจุดอ้างอิงเอง (จากเครื่องมือแก้ไข) */
|
||||
base = cands.filter(function (s) { return String(s.station_id) === String(o.baseSid); })[0] || null;
|
||||
}
|
||||
if (!base && o.baseEnd === 'first') { /* ใช้เวลาจริงจากจุดต้นทาง (กม. น้อยสุด) */
|
||||
base = cands.reduce(function (a, b) { return a.km <= b.km ? a : b; });
|
||||
} else if (!base && o.baseEnd === 'last') { /* ใช้เวลาจริงจากจุดปลายทาง (กม. มากสุด) */
|
||||
base = cands.reduce(function (a, b) { return a.km >= b.km ? a : b; });
|
||||
} else if (!base) { /* อัตโนมัติ: จุดที่มีเวลาซึ่งใกล้ที่สุด */
|
||||
base = cands.reduce(function (a, b) { return Math.abs(b.km - stop.km) < Math.abs(a.km - stop.km) ? b : a; });
|
||||
}
|
||||
var delta = (stop.km - base.km) / speed * 60; /* นาที (+ ไปข้างหน้า, - ย้อนหลัง) */
|
||||
return base.times.map(function (t) {
|
||||
var tot = Math.round(toMin(t) + delta);
|
||||
tot = ((tot % 1440) + 1440) % 1440;
|
||||
return pad2(Math.floor(tot / 60)) + ':' + pad2(tot % 60);
|
||||
});
|
||||
}
|
||||
|
||||
/* ความเร็วที่ใช้จริงของทิศหนึ่ง ๆ: มาจาก travelMin (เวลาเดินทางทั้งเส้น) ถ้ามี ไม่งั้นใช้ speedKmh/ค่าตั้งต้น */
|
||||
function speedOf(dir) {
|
||||
if (Number(dir.travelMin) > 0) {
|
||||
var kms = (dir.stops || []).map(function (s) { return s.km; }).filter(function (x) { return typeof x === 'number'; });
|
||||
if (kms.length > 1) {
|
||||
var span = Math.max.apply(null, kms) - Math.min.apply(null, kms);
|
||||
if (span > 0) return { kmh: span / Number(dir.travelMin) * 60, span: span, source: 'travelMin' };
|
||||
}
|
||||
}
|
||||
return { kmh: Number(dir.speedKmh) > 0 ? Number(dir.speedKmh) : DEFAULT_SPEED_KMH, span: null, source: 'speedKmh' };
|
||||
}
|
||||
|
||||
function hasSchema2(doc) {
|
||||
return !!(doc && doc.schema === 2 && Array.isArray(doc.routes));
|
||||
}
|
||||
function normSub(doc) { /* เตรียมไฟล์ย่อยให้อยู่ในรูป { routes: [...] } */
|
||||
if (!doc) return null;
|
||||
if (doc.route_id != null && !Array.isArray(doc.routes)) {
|
||||
var dirs = isSchema3(doc) ? directionsFromSchema3(doc) : (doc.directions || []);
|
||||
return { schema: 2, routes: [{ route_id: doc.route_id, station_order: doc.station_order || [], directions: dirs }] };
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
/* ---------- schema 3: { weekday:{directions:{...}}, holiday:{directions:{...}} } ----------
|
||||
โครงอ่านง่ายสำหรับเจ้าของข้อมูล (กลุ่มวัน → ทิศทาง) · แปลงเป็นทิศภายในให้ทุกหน้าใช้ต่อได้เหมือนเดิม
|
||||
กติกา: จุดที่ระบุเวลามา = จุดตั้งต้นของทิศนั้น · จุดอื่นใน station_order คำนวณจาก กม.+ความเร็ว (ถ้าเปิด autoTimes) */
|
||||
var DAYGROUP = { weekday: 'weekday', holiday: 'holiday' };
|
||||
function isSchema3(doc) { return !!(doc && doc.schema === 3 && (doc.weekday || doc.holiday)); }
|
||||
function directionsFromSchema3(doc) {
|
||||
var out = [];
|
||||
['weekday', 'holiday'].forEach(function (kind) {
|
||||
var grp = doc[kind];
|
||||
if (!grp || !grp.directions) return;
|
||||
Object.keys(grp.directions).forEach(function (name) {
|
||||
var src = grp.directions[name] || {};
|
||||
var times = (src.departures || src.times || []).slice();
|
||||
var from = (src.from_station_id != null) ? Number(src.from_station_id) : null;
|
||||
var stops = [];
|
||||
if (from != null && times.length) {
|
||||
stops.push({ station_id: from, times: times, direction_note: grp.label || null });
|
||||
} else if (from != null) {
|
||||
stops.push({ station_id: from, times: [], direction_note: grp.label || null });
|
||||
}
|
||||
out.push({
|
||||
direction_id: kind + ':' + name,
|
||||
direction_label: name,
|
||||
service: { day: kind, from: 'schema 3', matches: kind === todayType() },
|
||||
station_order: doc.station_order || [],
|
||||
stops: stops,
|
||||
/* จุดตั้งต้นมีเวลาแล้ว → ให้จุดอื่นคำนวณต่อจาก กม. เฉพาะเมื่อเปิด autoTimes */
|
||||
autoTimes: !!doc.autoTimes
|
||||
});
|
||||
});
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------- ชื่อจุดจอด (สำหรับข้อความ "คำนวณจาก ...") ----------
|
||||
โหลดเบื้องหลังครั้งเดียว — ถ้ายังไม่ทัน ก็ถอยไปใช้รหัสจุดในข้อความ (ไม่พัง) */
|
||||
var STATION_NAMES = {};
|
||||
var namesWarmed = false;
|
||||
function warmStations() {
|
||||
if (namesWarmed) return;
|
||||
namesWarmed = true;
|
||||
fetch(DATA_URL + 'stations.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
((d && d.stations) || []).forEach(function (st) { STATION_NAMES[String(st.station_id)] = st.station_name_th; });
|
||||
})
|
||||
.catch(function () {});
|
||||
}
|
||||
function stationNameOf(id) { return STATION_NAMES[String(id)] || null; }
|
||||
/* หน้าเว็บที่โหลด stations.json อยู่แล้วส่งชื่อเข้ามาได้ → ข้อความหมายเหตุมีชื่อทันที (ไม่ต้องรอ fetch) */
|
||||
function setStationNames(list) {
|
||||
((list && list.stations) || list || []).forEach(function (st) {
|
||||
if (st && st.station_id != null) STATION_NAMES[String(st.station_id)] = st.station_name_th;
|
||||
});
|
||||
}
|
||||
/* เรียกทันทีตอนไฟล์ถูกโหลด — จะทันรอบเรนเดอร์แรก (ชื่อจุดอ้างอิงในข้อความ "คำนวณจาก ...") */
|
||||
warmStations();
|
||||
|
||||
/* ---------- เลื่อนเวลาเป็นนาที (กฎ derive: จุดนี้ = เวลาจุดอ้างอิง ± offset) ----------
|
||||
คืน HH:MM เรียงใหม่ · เกินเที่ยงคืน = วนกลับ (ไม่พัง) */
|
||||
function shiftTimes(times, offsetMin) {
|
||||
var off = Number(offsetMin) || 0;
|
||||
return (times || []).map(function (t) {
|
||||
var a = String(t).split(':');
|
||||
var m = (parseInt(a[0], 10) || 0) * 60 + (parseInt(a[1], 10) || 0) + off;
|
||||
m = ((m % 1440) + 1440) % 1440;
|
||||
var hh = Math.floor(m / 60), mm = m % 60;
|
||||
return (hh < 10 ? '0' : '') + hh + ':' + (mm < 10 ? '0' : '') + mm;
|
||||
}).sort();
|
||||
}
|
||||
/* ป้ายผลต่างเวลา เช่น +30 / −15 (ใช้ในข้อความหมายเหตุ) */
|
||||
function offsetLabel(min) {
|
||||
var n = Number(min) || 0;
|
||||
var sign = n < 0 ? '\u2212' : '+';
|
||||
return sign + Math.abs(n);
|
||||
}
|
||||
|
||||
/* ---------- เครื่องยนต์ตรวจวัน (จันทร์–อาทิตย์) ----------
|
||||
ทำงานที่ท่อกลางนี้ที่เดียว → ทุกหน้าได้ผลเหมือนกัน ไม่ต้องแก้โค้ดหน้าไหน
|
||||
ลำดับการตัดสิน:
|
||||
1) ถ้าทิศมี "days" ระบุตรง ๆ (อา จ อ พ พฤ ศ ส) → ใช้ตามนั้น (แม่นสุด)
|
||||
2) ถ้ามี service = weekday/holiday → เทียบกับวันนี้
|
||||
3) ถ้าไม่มีอะไรระบุ → อ่านคำใน direction_label / direction_note / note ของสายนั้น (ตรวจคำอัตโนมัติ)
|
||||
4) ตัดสินไม่ได้ → แสดงทุกวัน (ไม่ซ่อนข้อมูล) พร้อมป้ายว่า "ยังไม่ระบุวัน" */
|
||||
var DAYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; /* ตรงกับ Date.getDay() */
|
||||
var DAY_TH = { sun: 'อาทิตย์', mon: 'จันทร์', tue: 'อังคาร', wed: 'พุธ', thu: 'พฤหัสบดี', fri: 'ศุกร์', sat: 'เสาร์' };
|
||||
var DAY_ABBR = { sun: 'อา', mon: 'จ', tue: 'อ', wed: 'พ', thu: 'พฤ', fri: 'ศ', sat: 'ส' };
|
||||
var DAY_ALIAS = { /* รับได้หลายชื่อ */
|
||||
weekday: 'weekday', workday: 'weekday', 'วันทำงาน': 'weekday', 'จ-ศ': 'weekday', 'จ–ศ': 'weekday',
|
||||
holiday: 'holiday', weekend: 'holiday', 'วันหยุด': 'holiday', 'ส-อา': 'holiday', 'ส–อา': 'holiday', 'เสาร์-อาทิตย์': 'holiday',
|
||||
all: 'all', ทุกวัน: 'all', daily: 'all'
|
||||
};
|
||||
var DAY_WORDS_HOLIDAY = ['วันหยุด', 'นักขัตฤกษ์', 'เสาร์-อาทิตย์', 'เสาร์–อาทิตย์', 'ส-อา', 'ส–อา', 'weekend', 'holiday'];
|
||||
var DAY_WORDS_WEEKDAY = ['วันทำงาน', 'วันธรรมดา', 'จ-ศ', 'จ–ศ', 'จันทร์ถึงศุกร์', 'weekday', 'workday'];
|
||||
|
||||
function ymd(d) {
|
||||
var m = d.getMonth() + 1, day = d.getDate();
|
||||
return d.getFullYear() + '-' + (m < 10 ? '0' : '') + m + '-' + (day < 10 ? '0' : '') + day;
|
||||
}
|
||||
function dayKey(date) { return DAYS[(date || new Date()).getDay()]; }
|
||||
function isHolidayDate(date, list) {
|
||||
var list_ = list || HOLIDAYS;
|
||||
if (list_.indexOf(ymd(date)) !== -1) return true; /* นักขัตฤกษ์ */
|
||||
var wd = (date.getDay() + 6) % 7; /* 0 = จันทร์ */
|
||||
return wd >= 5; /* เสาร์–อาทิตย์ = วันหยุด */
|
||||
}
|
||||
function dayTypeOf(date, list) { return isHolidayDate(date || new Date(), list) ? 'holiday' : 'weekday'; }
|
||||
function todayType(date) { return dayTypeOf(date); }
|
||||
function dayInfo(date) {
|
||||
var d = date || new Date();
|
||||
var t = dayTypeOf(d);
|
||||
return { dayType: t, weekday: DAYS[d.getDay()], weekday_th: DAY_TH[DAYS[d.getDay()]], date: ymd(d),
|
||||
label_th: t === 'holiday' ? 'วันหยุด (ส–อา/นักขัตฤกษ์)' : 'วันทำงาน (จ–ศ)' };
|
||||
}
|
||||
/* ตรวจคำในข้อความ (direction_label / direction_note / note) ว่าหมายถึงวันไหน */
|
||||
function detectDay(text) {
|
||||
var t = String(text == null ? '' : text).trim();
|
||||
if (!t) return null;
|
||||
var low = t.toLowerCase();
|
||||
var hitH = DAY_WORDS_HOLIDAY.filter(function (w) { return low.indexOf(w.toLowerCase()) !== -1; })[0];
|
||||
var hitW = DAY_WORDS_WEEKDAY.filter(function (w) { return low.indexOf(w.toLowerCase()) !== -1; })[0];
|
||||
if (hitH && !hitW) return { day: 'holiday', from: 'คำ', text: t };
|
||||
if (hitW && !hitH) return { day: 'weekday', from: 'คำ', text: t };
|
||||
return null; /* เจอทั้งคู่/ไม่เจอ = ไม่เดา */
|
||||
}
|
||||
/* รวบข้อความทั้งหมดของทิศ (label + โน้ตของทุกจุด) แล้วตรวจหา "วัน" ให้สอดคล้องกันทั้งทิศ
|
||||
คืน { day, from, text } หรือ null (ยังไม่ระบุ) */
|
||||
function detectDayOfDir(d) {
|
||||
var texts = [];
|
||||
if (d && (d.direction_label || d.dir_label)) texts.push((d.direction_label || d.dir_label));
|
||||
((d && d.stops) || []).forEach(function (s) {
|
||||
if ((s.direction_note || s.dir_note)) texts.push((s.direction_note || s.dir_note));
|
||||
if (s.note) texts.push(s.note);
|
||||
});
|
||||
var verdicts = [], conflicts = false, hasHol = false, hasWk = false, sample = null;
|
||||
texts.forEach(function (t) {
|
||||
var v = detectDay(t);
|
||||
if (!v) { return; }
|
||||
if (v.day === 'holiday') { hasHol = true; } else { hasWk = true; }
|
||||
verdicts.push(v); if (!sample) sample = v;
|
||||
});
|
||||
if (!verdicts.length) return null;
|
||||
if (hasHol && hasWk) { /* ทิศเดียวมีทั้งสองวัน */
|
||||
return { day: 'all', from: 'ปนกัน', text: sample.text, conflict: true };
|
||||
}
|
||||
return { day: verdicts[0].day, from: 'คำในโน้ต', text: sample.text };
|
||||
}
|
||||
/* วันนี้ตรงกับทิศนี้ไหม + บอกเหตุผล (ใช้แสดงบนหน้าเว็บได้) */
|
||||
function serviceOf(obj, dirForDetect) {
|
||||
if (obj && obj.days && obj.days.length) { /* ระบุวันตรง ๆ มาก่อน */
|
||||
return { day: 'custom', days: obj.days.map(String), from: 'ระบุตรง', matches: obj.days.map(String).indexOf(dayKey()) !== -1 };
|
||||
}
|
||||
var s = (obj && obj.service) ? String(obj.service).toLowerCase() : '';
|
||||
var alias = DAY_ALIAS[s] || (DAY_ALIAS[String(obj && obj.service)] || '');
|
||||
if (alias === 'weekday' || alias === 'holiday') {
|
||||
return { day: alias, from: 'service', matches: alias === todayType() };
|
||||
}
|
||||
if (alias === 'all') return { day: 'all', from: 'service', matches: true };
|
||||
var det = detectDayOfDir(dirForDetect || obj); /* ไม่ระบุ → ตรวจจากคำ */
|
||||
if (det) {
|
||||
if (det.day === 'all') return { day: 'all', from: det.from + ' (ปนกัน)', text: det.text, conflict: true, matches: true };
|
||||
return { day: det.day, from: det.from, text: det.text, matches: det.day === todayType() };
|
||||
}
|
||||
return { day: 'all', from: 'ไม่ระบุ', unknown: true, matches: true }; /* ไม่รู้ = แสดง (ไม่ซ่อนข้อมูล) */
|
||||
}
|
||||
function normDay(opts) {
|
||||
if (opts && opts.dayType) return DAY_ALIAS[String(opts.dayType).toLowerCase()] || 'all';
|
||||
return todayType();
|
||||
}
|
||||
|
||||
/* ตัดสินว่าทิศนี้ใช้กับวันที่กำลังดูอยู่ไหม
|
||||
service = ผลจาก serviceOf() → { day, matches, conflict?, unknown? } */
|
||||
function applies(info, day) {
|
||||
if (!day || day === 'all') return true; /* ไม่ระบุวัน = ดูทุกวัน */
|
||||
if (!info || typeof info !== 'object') return true;
|
||||
if (info.unknown) return true; /* ยังไม่ระบุวัน → แสดง (ไม่ซ่อนข้อมูล) */
|
||||
if (info.conflict) return true; /* ทิศเดียวมีทั้ง 2 ตาราง → ซ่อนไม่ได้ (จะหายข้อมูล) */
|
||||
if (info.day === 'custom') { /* ระบุวันตรง ๆ (days[]) */
|
||||
return !info.days || info.days.indexOf(dayKey(dayDate(day))) !== -1;
|
||||
}
|
||||
return info.day === 'all' || info.day === day; /* เทียบกับวันที่กำลังดู ไม่ใช่ค่าของวันนี้ */
|
||||
}
|
||||
/* 'weekday' / 'holiday' → วันที่สมมติขึ้นมา (ใช้ตรวจ days[] ให้ตรงกับวันที่ขอ) */
|
||||
function dayDate(day) {
|
||||
var d = new Date();
|
||||
if (day === 'weekday') { var wd = (d.getDay() + 6) % 7; d.setDate(d.getDate() - wd); }
|
||||
else if (day === 'holiday') { var wd2 = (d.getDay() + 6) % 7; d.setDate(d.getDate() + (5 - wd2)); }
|
||||
return d;
|
||||
}
|
||||
function normDay(opts) {
|
||||
if (opts && opts.dayType) return ALIAS[String(opts.dayType).toLowerCase()] || 'all';
|
||||
return todayType(); /* ค่าเริ่มต้น: ตรวจจากวันนี้ */
|
||||
}
|
||||
|
||||
/* เวลาของจุดจอด ณ วันหนึ่ง ๆ = times พื้นฐาน + groups ที่ตรงกับวันนั้น */
|
||||
/* timesFor(stop, day) — day ที่ส่งมา (weekday/holiday) = "วันเป้าหมาย" ที่ต้องการดู
|
||||
ทิศที่ผ่านการกรองวันมาแล้วจะส่ง day='all' → คืน times ตรง ๆ · ส่วนที่ยังไม่แยกวันใช้ groups แยกเอง */
|
||||
function timesFor(stop, day) {
|
||||
var groups = (stop && stop.groups) || [];
|
||||
if (!groups.length) return (stop && stop.times ? stop.times : []).slice();
|
||||
var out = ((stop && stop.times) || []).slice(); /* เวลาที่ไม่ผูกวัน = ใช้ทุกวัน */
|
||||
groups.forEach(function (g) {
|
||||
var gt = g.dayType ? (ALIAS[String(g.dayType).toLowerCase()] || 'all') : 'all';
|
||||
if (gt !== 'all' && day && day !== 'all' && gt !== day) return;
|
||||
out = out.concat(g.times || []);
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------- โหลดข้อมูล: schedules.json เป็นได้ทั้ง "ไฟล์รวม" และ "สารบัญ" ----------
|
||||
- สารบัญ (index: true): routes[] มี { route_id, file } → โหลดเฉพาะไฟล์ของสายที่ขอ (lazy + cache)
|
||||
- ไฟล์รวม (schema 2 เดิม): มี routes[] พร้อม directions ในตัว → ใช้ได้เหมือนเดิมไม่ต้องแก้โค้ดเก่า
|
||||
- schema 1 เดิม: { schedules: [...] } → ใช้ได้เหมือนเดิม */
|
||||
var SUBS = {}; /* cache ไฟล์ย่อยต่อสาย */
|
||||
var subsReady = null;
|
||||
function loadSubs() {
|
||||
if (subsReady) return subsReady;
|
||||
subsReady = fetch(DATA_URL + 'schedules.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
if (!d || !d.index) return d; /* ไฟล์รวม → คืนทั้งไฟล์ */
|
||||
var rows = d.routes || [];
|
||||
return Promise.all(rows.map(function (row) {
|
||||
var file = row.file || ('schedules' + row.route_id + '.json');
|
||||
return fetch(DATA_URL + 'scheduleslist/' + file, { cache: 'no-store' })
|
||||
.then(function (x) { return x.ok ? x.json() : null; })
|
||||
.then(function (sub) {
|
||||
if (!sub) return null;
|
||||
var dirs = isSchema3(sub) ? directionsFromSchema3(sub) : (sub.directions || []);
|
||||
SUBS[String(sub.route_id)] = { route_id: sub.route_id, station_order: sub.station_order || [],
|
||||
directions: dirs, schema3: isSchema3(sub),
|
||||
updated: sub.updated || null };
|
||||
return SUBS[String(sub.route_id)];
|
||||
}).catch(function () { return null; });
|
||||
})).then(function (list) {
|
||||
var routes = list.filter(Boolean);
|
||||
return { schema: 2, index: true, routes: routes };
|
||||
});
|
||||
})
|
||||
.catch(function () { return null; });
|
||||
return subsReady;
|
||||
}
|
||||
/* โหลดสายเดียว (เร็ว — ใช้ตอนเปิดหน้า check/routes ของสายนั้น) */
|
||||
/* วันที่อัปเดตไฟล์ตารางของสาย (ฟิลด์ "updated" ใน scheduleslist/schedules<id>.json)
|
||||
— ค่ามาจาก mtime ของไฟล์จริง (เติมโดย resource/tools/stamp-schedules.py) */
|
||||
function updatedOf(rid) {
|
||||
var s = SUBS[String(rid)];
|
||||
return (s && s.updated) ? String(s.updated) : null;
|
||||
}
|
||||
|
||||
function loadRoute(rid) {
|
||||
var key = String(rid);
|
||||
if (SUBS[key]) return Promise.resolve({ schema: 2, routes: [SUBS[key]] });
|
||||
if (!subsReady) return loadSubs().then(function () { return SUBS[key] ? { schema: 2, routes: [SUBS[key]] } : null; });
|
||||
return Promise.resolve(SUBS[key] ? { schema: 2, routes: [SUBS[key]] } : null);
|
||||
}
|
||||
|
||||
/* ---------- ระยะทาง กม. (ไฟล์แยก resource/data/stop-km.json — สร้างโดย resource/tools/stop-km.py) ----------
|
||||
แยกไฟล์เพราะ schedules.json เป็นไฟล์ที่คนแก้มือ ถ้าเอาค่าคำนวณไปฝังไว้ พอบันทึกทับจากสำเนาเก่าจะหายทั้งชุด */
|
||||
var KM = {};
|
||||
var kmReady = null;
|
||||
function loadKm() {
|
||||
if (kmReady) return kmReady;
|
||||
kmReady = fetch(DATA_URL + 'stop-km.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
KM = (d && typeof d === 'object') ? d : {};
|
||||
try { window.dispatchEvent(new CustomEvent('schedules:km', { detail: { routes: Object.keys(KM).length } })); } catch (e) { }
|
||||
return KM;
|
||||
})
|
||||
.catch(function () { KM = {}; return KM; });
|
||||
return kmReady;
|
||||
}
|
||||
function absKm(rid, sid) {
|
||||
var r = KM[String(rid)];
|
||||
if (!r) return null;
|
||||
var v = r[String(sid)];
|
||||
return (typeof v === 'number') ? v : null;
|
||||
}
|
||||
/* km ของจุดในทิศนั้น — พลิกให้ "เพิ่มขึ้นตามทางที่รถวิ่ง" เพื่อให้ผลต่างมีเครื่องหมายถูกต้องเอง
|
||||
(ลำดับจุดในทิศ + กม.จริงบนเส้น เป็นตัวบอกทิศ) */
|
||||
function relKms(rid, stops) {
|
||||
var abs = (stops || []).map(function (s, i) {
|
||||
var k = (s && typeof s.km === 'number') ? s.km : (s ? absKm(rid, s.station_id) : null);
|
||||
return (typeof k === 'number') ? { i: i, k: k } : null;
|
||||
});
|
||||
var known = abs.filter(Boolean);
|
||||
if (known.length < 2) {
|
||||
return (stops || []).map(function (s) {
|
||||
if (s && typeof s.km === 'number') return s.km;
|
||||
return s ? absKm(rid, s.station_id) : null;
|
||||
});
|
||||
}
|
||||
var forward = known[known.length - 1].k >= known[0].k; /* ทิศนี้วิ่งจาก กม. น้อย → มาก ใช่ไหม */
|
||||
var max = known.reduce(function (a, b) { return b.k > a ? b.k : a; }, known[0].k);
|
||||
return abs.map(function (x) { if (!x) return null; return forward ? x.k : (max - x.k); });
|
||||
}
|
||||
|
||||
/* โหลด holidays.json ครั้งเดียว (ถ้าไม่มีไฟล์ → ใช้กฎเสาร์–อาทิตย์) */
|
||||
var ready = null;
|
||||
function loadHolidays() {
|
||||
if (ready) return ready;
|
||||
ready = fetch(DATA_URL + 'holidays.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
HOLIDAYS = (d && Array.isArray(d.holidays)) ? d.holidays.slice() : [];
|
||||
try { window.dispatchEvent(new CustomEvent('schedules:ready', { detail: { holidays: HOLIDAYS.length } })); } catch (e) { }
|
||||
return HOLIDAYS;
|
||||
})
|
||||
.catch(function () { HOLIDAYS = []; return HOLIDAYS; });
|
||||
return ready;
|
||||
}
|
||||
|
||||
/* ---------- ทิศทางของสาย (กรองตามวัน + ถอยกลับถ้าว่าง) ---------- */
|
||||
function directions(doc, routeId, opts) {
|
||||
var rid = String(routeId);
|
||||
var list = [];
|
||||
if (hasSchema2(doc)) {
|
||||
var r = (doc.routes || []).filter(function (x) { return String(x.route_id) === rid; })[0];
|
||||
if (!r) return [];
|
||||
list = (r.directions || []).map(function (d) {
|
||||
return {
|
||||
direction_id: (d.direction_id || d.dir_id),
|
||||
direction_label: (d.direction_label || d.dir_label),
|
||||
days: Array.isArray(d.days) ? d.days.map(String) : null, /* ระบุวันตรง ๆ (อา จ อ พ พฤ ศ ส) */
|
||||
service: serviceOf(d, d), /* ตรวจวัน + เหตุผล (จากคำ/service/days) */
|
||||
autoTimes: !!d.autoTimes, /* true = คำนวณจุดที่ไม่มีตารางให้ */
|
||||
autoFor: Array.isArray(d.autoFor) ? d.autoFor.slice() : null, /* จำกัดเฉพาะจุดเหล่านี้ (ไม่ใส่ = ทุกจุดที่ว่าง) */
|
||||
travelMin: Number(d.travelMin) > 0 ? Number(d.travelMin) : null, /* เวลาเดินทางทั้งเส้น (นาที) */
|
||||
baseEnd: (d.baseEnd === 'first' || d.baseEnd === 'last') ? d.baseEnd : null, /* มีเวลาจริงที่ปลายไหน */
|
||||
baseSid: (d.baseSid != null ? d.baseSid : null), /* หรือระบุจุดอ้างอิงตรง ๆ */
|
||||
speedKmh: Number(d.speedKmh) > 0 ? Number(d.speedKmh) : DEFAULT_SPEED_KMH,
|
||||
stops: (d.stops || []).map(function (s) {
|
||||
return {
|
||||
station_id: s.station_id,
|
||||
times: s.times || [],
|
||||
km: (typeof s.km === 'number') ? s.km : null, /* กม. จากต้นทาง (วัดโดย resource/tools/stop-km.py) */
|
||||
direction_note: (s.direction_note || s.dir_note) || null,
|
||||
note: s.note || null,
|
||||
groups: s.groups || null,
|
||||
derive: s.derive || null /* กฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" */
|
||||
};
|
||||
})
|
||||
};
|
||||
});
|
||||
} else {
|
||||
/* schema 1 → ยังใช้ได้เหมือนเดิม (ไม่แยกวัน) */
|
||||
list = [{ direction_id: 'all', direction_label: null, service: 'all', stops: (doc && doc.schedules ? doc.schedules : []).filter(function (r) {
|
||||
return String(r.route_id) === rid;
|
||||
}).map(function (r) {
|
||||
return { station_id: r.station_id, times: r.departure_times || [], direction_note: r.direction_note || null, note: r.schedule_note || null, groups: null };
|
||||
}) }];
|
||||
}
|
||||
|
||||
var day = normDay(opts);
|
||||
var kept = list.filter(function (d) { return applies(d.service, day); }); /* service = ผลตรวจวันของทิศนั้น */
|
||||
var fallback = false;
|
||||
if (!kept.length && list.length) { kept = list.slice(); fallback = true; } /* ห้ามปล่อยว่าง */
|
||||
|
||||
warmStations(); /* เพื่อให้ข้อความ "คำนวณจาก ..." มีชื่อจุด */
|
||||
/* เวลาจริงรายจุดของ "ทั้งสาย" — กฎ derive อ้างจุดข้ามทิศได้ (เช่น 902: จุด 15 ← จุด 6 คนละทิศ) */
|
||||
var realByStation = {};
|
||||
(kept.length ? kept : list).forEach(function (d) {
|
||||
(d.stops || []).forEach(function (s) {
|
||||
var t0 = timesFor(s, day === 'all' ? 'all' : day);
|
||||
if (t0.length && !realByStation[String(s.station_id)]) realByStation[String(s.station_id)] = t0;
|
||||
});
|
||||
});
|
||||
|
||||
return kept.map(function (d) {
|
||||
var kms = relKms(rid, d.stops); /* km ตามทางที่รถวิ่ง (จากไฟล์ stop-km.json) */
|
||||
/* ใส่ km ให้ "ทุกจุด" ก่อน — ต้องมีครบทั้งชุด ระบบหาจุดอ้างอิง/คำนวณความเร็วถึงจะทำงานได้ */
|
||||
var withKm = d.stops.map(function (s, si) {
|
||||
var c = {};
|
||||
for (var k in s) c[k] = s[k];
|
||||
if (typeof c.km !== 'number' && typeof kms[si] === 'number') c.km = kms[si];
|
||||
return c;
|
||||
});
|
||||
var speed = speedOf({ travelMin: d.travelMin, speedKmh: d.speedKmh, stops: withKm });
|
||||
var stops = withKm.map(function (s) {
|
||||
var t = timesFor(s, day === 'all' ? 'all' : day);
|
||||
var est = false;
|
||||
var estFrom = null; /* ถ้าเป็นเวลาที่คำนวณ → ข้อมูลจุดอ้างอิง */
|
||||
/* ★ กฎของเจ้าของข้อมูล: "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" (เขียนครั้งเดียวในไฟล์สาย) */
|
||||
if (s.derive && s.derive.from_station_id != null) {
|
||||
var src = realByStation[String(s.derive.from_station_id)];
|
||||
if (src && src.length) {
|
||||
t = shiftTimes(src, s.derive.offset_min);
|
||||
est = true;
|
||||
estFrom = { station_id: Number(s.derive.from_station_id),
|
||||
name: stationNameOf(s.derive.from_station_id),
|
||||
offsetMin: Number(s.derive.offset_min) || 0,
|
||||
overrode: (timesFor(s, 'all').length > 0) };
|
||||
}
|
||||
}
|
||||
if (!est && d.autoTimes && !t.length) { /* ไม่มีตารางจริง → คำนวณจากจุดที่มีเวลา + กม. */
|
||||
var only = d.autoFor && d.autoFor.length
|
||||
? d.autoFor.map(String).indexOf(String(s.station_id)) !== -1
|
||||
: true; /* ไม่ระบุ autoFor = ทุกจุดที่ว่าง */
|
||||
if (only) {
|
||||
var calc = computeTimes(s, withKm, { speedKmh: speed.kmh, baseEnd: d.baseEnd, baseSid: d.baseSid });
|
||||
if (calc && calc.length) { t = calc; est = true; }
|
||||
}
|
||||
}
|
||||
return { station_id: s.station_id, times: t, km: s.km, direction_note: (s.direction_note || s.dir_note), note: s.note,
|
||||
groups: s.groups, estimated: est, estimateFrom: estFrom, derive: s.derive || null };
|
||||
});
|
||||
return { direction_id: (d.direction_id || d.dir_id), direction_label: (d.direction_label || d.dir_label), service: d.service, days: d.days, autoTimes: d.autoTimes,
|
||||
travelMin: d.travelMin, baseEnd: d.baseEnd, baseSid: d.baseSid, autoFor: d.autoFor,
|
||||
speedKmh: Math.round(speed.kmh * 10) / 10,
|
||||
speedFrom: speed.source, dayType: day, fallback: fallback, stops: stops };
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- schema 2 → record แบน (คง API เดิม) ---------- */
|
||||
function records(doc, opts) {
|
||||
if (!doc) return [];
|
||||
if (!hasSchema2(doc)) return doc.schedules || (Array.isArray(doc) ? doc : []);
|
||||
var out = [];
|
||||
(doc.routes || []).forEach(function (r) {
|
||||
directions(doc, r.route_id, opts).forEach(function (d) {
|
||||
(d.stops || []).forEach(function (s) {
|
||||
out.push({
|
||||
route_id: r.route_id,
|
||||
station_id: s.station_id,
|
||||
direction_note: (s.direction_note || s.dir_note) || null,
|
||||
direction_label: (d.direction_label || d.dir_label) || null, /* ชื่อทิศ (ป่าโมกไปอยุธยา ฯลฯ) — ใช้เป็นหัวแถว */
|
||||
departure_times: s.times || [],
|
||||
schedule_note: s.note || null,
|
||||
estimated: !!s.estimated, /* true = เวลาคำนวณ ไม่ใช่ตารางจริง */
|
||||
estimateFrom: s.estimateFrom || null, /* { station_id, name, offsetMin } เมื่อคำนวณ */
|
||||
km: s.km,
|
||||
direction_id: (d.direction_id || d.dir_id),
|
||||
service: d.service,
|
||||
days: d.days,
|
||||
dayType: d.dayType,
|
||||
fallback: d.fallback
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------- ข้อมูลของสายเดียว ---------- */
|
||||
function route(doc, routeId, opts) {
|
||||
var rid = String(routeId);
|
||||
var entries = records(doc, opts).filter(function (r) { return String(r.route_id) === rid; });
|
||||
var dirs = directions(doc, rid, opts);
|
||||
var order = [];
|
||||
if (hasSchema2(doc)) {
|
||||
var r = (doc.routes || []).filter(function (x) { return String(x.route_id) === rid; })[0];
|
||||
if (r && r.station_order) order = r.station_order.slice();
|
||||
}
|
||||
if (!order.length) {
|
||||
entries.forEach(function (r) { if (order.indexOf(r.station_id) === -1) order.push(r.station_id); });
|
||||
order.sort(function (a, b) { return a - b; });
|
||||
}
|
||||
return { route_id: rid, station_order: order, directions: dirs, entries: entries };
|
||||
}
|
||||
|
||||
/* ---------- เวลาทั้งหมดของสาย (ไม่ซ้ำ + เรียง) ---------- */
|
||||
function times(doc, routeId, opts) {
|
||||
var seen = {};
|
||||
records(doc, opts).forEach(function (r) {
|
||||
if (String(r.route_id) !== String(routeId)) return;
|
||||
(r.departure_times || []).forEach(function (t) { seen[t] = true; });
|
||||
});
|
||||
return Object.keys(seen).sort();
|
||||
}
|
||||
|
||||
/* ---------- จำนวนเที่ยวของสาย ---------- */
|
||||
function countTrips(doc, routeId, opts) {
|
||||
var n = 0;
|
||||
records(doc, opts).forEach(function (r) {
|
||||
if (String(r.route_id) === String(routeId)) n += (r.departure_times || []).length;
|
||||
});
|
||||
return n;
|
||||
}
|
||||
|
||||
loadHolidays(); /* เริ่มโหลดทันที (ไม่บล็อกการอ่าน) */
|
||||
loadKm();
|
||||
|
||||
window.Schedules = {
|
||||
hasSchema2: hasSchema2,
|
||||
load: loadSubs, /* โหลดทุกสาย (จากสารบัญหรือไฟล์รวม) */
|
||||
loadRoute: loadRoute, /* โหลดสายเดียว + ไฟล์ย่อยที่ยังไม่เคยโหลด */
|
||||
normSub: normSub,
|
||||
get subs() { return SUBS; },
|
||||
records: records,
|
||||
route: route,
|
||||
directions: directions,
|
||||
times: times,
|
||||
countTrips: countTrips,
|
||||
/* ส่วนของวันทำงาน/วันหยุด */
|
||||
todayType: todayType,
|
||||
dayTypeOf: dayTypeOf,
|
||||
dayInfo: dayInfo,
|
||||
dayKey: dayKey,
|
||||
DAYS: DAYS,
|
||||
DAY_TH: DAY_TH,
|
||||
DAY_ABBR: DAY_ABBR,
|
||||
detectDay: detectDay,
|
||||
detectDayOfDir: detectDayOfDir,
|
||||
offsetLabel: offsetLabel,
|
||||
stationNameOf: stationNameOf,
|
||||
setStationNames: setStationNames,
|
||||
shiftTimes: shiftTimes,
|
||||
serviceOf: serviceOf,
|
||||
timesFor: timesFor,
|
||||
computeTimes: computeTimes,
|
||||
updatedOf: updatedOf, /* วันที่อัปเดตไฟล์ตารางของสาย (ISO) — ใช้แสดง "อัปเดตล่าสุด ..." */
|
||||
speedOf: speedOf,
|
||||
absKm: absKm,
|
||||
relKms: relKms,
|
||||
loadKm: loadKm,
|
||||
get km() { return KM; },
|
||||
DEFAULT_SPEED_KMH: DEFAULT_SPEED_KMH,
|
||||
loadHolidays: loadHolidays,
|
||||
get holidays() { return HOLIDAYS.slice(); },
|
||||
ready: ready
|
||||
};
|
||||
})();
|
||||
export {};
|
||||
@@ -0,0 +1,583 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/stopDetail.init.js — logic unchanged; bootstrap converted to mount(). */
|
||||
/* ============================================================
|
||||
stopDetail.init.js — หน้ารายละเอียดป้าย (#/stops/<รหัส>)
|
||||
|
||||
เดิม: ข้อมูลทุกอย่างฝังตายใน stopDetail.html (ทุกป้ายแสดงเหมือนกันหมด)
|
||||
ใหม่: เรนเดอร์จาก JSON จริง 100% — เปลี่ยนข้อมูลที่ไหนก็แก้ที่ไฟล์ข้อมูล ไม่ต้องแก้ HTML
|
||||
|
||||
แหล่งข้อมูล:
|
||||
stations.json → ชื่อ/ประเภท/รหัส/จังหวัด/พิกัด (+ ฟิลด์เสริม photo/description/landmarks/facilities ถ้าใส่ไว้)
|
||||
routes.json → สายรถที่ผ่านป้ายนี้ (station_ids) + ชื่อสาย
|
||||
schedules.json → เวลารถของแต่ละสายที่ป้ายนี้ (schema 2 ผ่านตัวอ่านกลาง Schedules)
|
||||
.image/stations/ → รูปสถานี <station_id>.jpg (+ รูปเสริม <station_id>-2.jpg)
|
||||
|
||||
พารามิเตอร์ URL:
|
||||
#/stops/<รหัสป้าย> → แสดงป้ายนั้น
|
||||
#/stops/<รหัสป้าย>?route=<รหัสสาย> → กรอง/เปิดเฉพาะสายนั้นทันที
|
||||
============================================================ */
|
||||
/* ---- ported module body ---- */
|
||||
'use strict';
|
||||
|
||||
var DATA = '/resource/data/';
|
||||
var PHOTO_DIR = '/image/stations/'; /* รูปสถานี: <station_id>.<jpg|jpeg|webp|png> (ไล่ลองนามสกุลให้) */
|
||||
var PHOTO_EXTS = ['jpg', 'jpeg', 'webp', 'png'];
|
||||
var PHOTO_FALLBACK = '/image/stations/minibus-512x512.png'; /* รูปสำรองเมื่อสถานียังไม่มีรูป */
|
||||
|
||||
/* ประเภทป้าย → คีย์แปล + โทนสี */
|
||||
var TYPE_KEY = {
|
||||
main_terminal: 'type.terminal', local_terminal: 'type.local', local_stop: 'type.busstop',
|
||||
market: 'type.market', private_stop: 'type.marketOpt'
|
||||
};
|
||||
var TYPE_TONE = {
|
||||
main_terminal: 'purple', local_terminal: 'sky', local_stop: 'mint', market: 'mint', private_stop: 'sky'
|
||||
};
|
||||
|
||||
function $(id) { return document.getElementById(id); }
|
||||
function t(k, v) { return window.I18N ? I18N.t(k, v) : k; }
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
function fetchJSON(u) {
|
||||
return fetch(u, { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; });
|
||||
}
|
||||
function pad2(n) { return (n < 10 ? '0' : '') + n; }
|
||||
function toMin(s) {
|
||||
var m = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec(String(s || '').trim());
|
||||
return m ? Number(m[1]) * 60 + Number(m[2]) : null;
|
||||
}
|
||||
function nowMin() { var d = new Date(); return d.getHours() * 60 + d.getMinutes(); }
|
||||
function point(st) {
|
||||
if (!st || st.latitude === '' || st.longitude === '' || st.latitude == null) return null;
|
||||
return [parseFloat(st.longitude), parseFloat(st.latitude)];
|
||||
}
|
||||
|
||||
/* ---------- หาป้ายของเรา: รหัส URL → stations.json ---------- */
|
||||
function findStation(stations, code) {
|
||||
var want = String(code || '').trim();
|
||||
var hit = stations.filter(function (s) { return String(s.station_code) === want; })[0];
|
||||
if (hit) return hit;
|
||||
hit = stations.filter(function (s) { return String(s.station_code).toLowerCase() === want.toLowerCase(); })[0];
|
||||
if (hit) return hit;
|
||||
if (/^\d+$/.test(want)) {
|
||||
hit = stations.filter(function (s) { return String(s.station_id) === want; })[0];
|
||||
}
|
||||
return hit || null;
|
||||
}
|
||||
|
||||
/* ---------- สายรถที่ผ่านป้ายนี้ + เวลาที่ป้ายนี้ ---------- */
|
||||
function routesAtStation(routes, sched, sid) {
|
||||
var out = [];
|
||||
routes.forEach(function (r) {
|
||||
var ids = r.station_ids || [];
|
||||
if (ids.indexOf(sid) === -1) return;
|
||||
var legs = []; /* แต่ละทิศ = 1 รายการ */
|
||||
Schedules.directions(sched, r.route_id).forEach(function (d) {
|
||||
d.stops.forEach(function (s) {
|
||||
if (s.station_id !== sid) return;
|
||||
legs.push({ direction_id: (d.direction_id || d.dir_id), label: (s.direction_note || s.dir_note) || (d.direction_label || d.dir_label) || null, times: s.times || [], note: s.note || null, estimated: !!s.estimated, estimateFrom: s.estimateFrom || null });
|
||||
});
|
||||
});
|
||||
var trips = legs.reduce(function (n, l) { return n + l.times.length; }, 0);
|
||||
var pos = ids.indexOf(sid);
|
||||
out.push({
|
||||
route: r, legs: legs, trips: trips,
|
||||
isOrigin: pos === 0, isTerminus: pos === ids.length - 1, index: pos, total: ids.length
|
||||
});
|
||||
});
|
||||
/* เรียงตามลำดับใน routes.json (คงที่ — ตรงกับตัวเลือกสายในหน้าอื่น) */
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------- รูปสถานี: .image/stations/<station_id>.jpg ----------
|
||||
เลือกตาม station_id ใน stations.json · ไฟล์หาย → ไม่แสดงช่องว่าง (hero ยืดเต็ม) */
|
||||
function bust(u) { return (window.ImgURL && ImgURL.of) ? ImgURL.of(u) : u; }
|
||||
|
||||
function findPhoto(station) {
|
||||
if (station.photo) return station.photo; /* ระบุพาธเองได้ใน stations.json (ทับค่าเริ่มต้น) */
|
||||
var n = station.__seq || 1; /* รูปเสริมของสถานีเดียวกัน: 2-2.jpg, 2-3.jpeg … */
|
||||
var base = PHOTO_DIR + station.station_id + (n > 1 ? '-' + n : '');
|
||||
return PHOTO_EXTS.map(function (e) { /* เรียงตัวเลือกให้ renderHero ไล่ลอง */
|
||||
var u = base + '.' + e;
|
||||
return (window.ImgURL && ImgURL.of) ? ImgURL.of(u) : u; /* ?v= กัน cache-first ของ SW */
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- ตัวเลขสรุป ---------- */
|
||||
var HHMM = /^\d{1,2}:\d{2}$/; /* กันค่าหลอกในไฟล์ (เช่นข้อความ) ไม่ให้เพี้ยน KPI */
|
||||
|
||||
function summarise(rows) {
|
||||
var times = [], trips = 0;
|
||||
rows.forEach(function (x) {
|
||||
trips += x.trips;
|
||||
x.legs.forEach(function (l) {
|
||||
times = times.concat((l.times || []).filter(function (t) { return HHMM.test(String(t)); }));
|
||||
});
|
||||
});
|
||||
times.sort(function (a, b) { return toMin(a) - toMin(b); });
|
||||
return { rows: rows.length, trips: trips, first: times[0] || null, last: times[times.length - 1] || null };
|
||||
}
|
||||
|
||||
/* ---------- เรนเดอร์: หัวป้าย ---------- */
|
||||
function renderHero(st, sum, photo, place) {
|
||||
var baseName = st.station_name_th || ('ป้าย ' + st.station_code);
|
||||
/* จุดขึ้นรถประจำทางอื่นๆ: ต่อท้ายด้วยชื่อสถานที่จริงของสายที่กำลังดูอยู่ */
|
||||
var placeName = (place && window.OtherStop && OtherStop.firstName) ? OtherStop.firstName(place)
|
||||
: (place && place.station_name_th) ? place.station_name_th : null;
|
||||
var name = baseName + (placeName ? ' \u00b7 ' + placeName : '');
|
||||
var city = (place && place.city_th) || st.city_th || '';
|
||||
var prov = (place && place.province_th) || st.province_th || '';
|
||||
|
||||
var crumb = $('stop-breadcrumb');
|
||||
if (crumb) crumb.innerHTML = '<a href="/">' + esc(t('nav.home')) + '</a>/ <a href="/stops">' +
|
||||
esc(t('nav.stops')) + '</a>/ ' + esc(name);
|
||||
|
||||
var title = $('stop-title');
|
||||
if (title) title.textContent = name;
|
||||
|
||||
var sub = $('stop-sub');
|
||||
if (sub) {
|
||||
sub.textContent = st.description ||
|
||||
t('stop.subGeneric', { city: city || prov || t('stop.thisStop') });
|
||||
}
|
||||
|
||||
var meta = $('stop-meta');
|
||||
if (meta) {
|
||||
meta.innerHTML =
|
||||
'<span class="mu-meta-pill ' + (TYPE_TONE[st.station_type] || 'purple') + '">' +
|
||||
esc(t(TYPE_KEY[st.station_type] || 'type.busstop')) + '</span>' +
|
||||
'<span class="mu-meta-pill sky">' + esc(t('stop.code')) + ' ' + esc(st.station_code) + '</span>' +
|
||||
(city || prov ? '<span class="mu-meta-pill mint">' + esc([city, prov].filter(Boolean).join(' · ')) + '</span>' : '');
|
||||
}
|
||||
|
||||
var metrics = $('stop-metrics');
|
||||
if (metrics) {
|
||||
metrics.innerHTML =
|
||||
'<div class="mu-hero-metric"><p class="mu-hero-metric-label">' + esc(t('stop.statRoutes')) + '</p>' +
|
||||
'<p class="mu-hero-metric-value">' + sum.rows + '</p></div>' +
|
||||
'<div class="mu-hero-metric"><p class="mu-hero-metric-label">' + esc(t('stop.statTrips')) + '</p>' +
|
||||
'<p class="mu-hero-metric-value">' + sum.trips + '</p></div>' +
|
||||
'<div class="mu-hero-metric"><p class="mu-hero-metric-label">' + esc(t('stop.statHours')) + '</p>' +
|
||||
'<p class="mu-hero-metric-value">' + (sum.first ? esc(sum.first + ' - ' + sum.last) : '–') + '</p></div>' +
|
||||
'<div class="mu-hero-metric"><p class="mu-hero-metric-label">' + esc(t('stop.nextArrival')) + '</p>' +
|
||||
'<p class="mu-hero-metric-value" id="stop-next-trip">–</p></div>';
|
||||
}
|
||||
|
||||
var img = $('stop-photo');
|
||||
if (img) {
|
||||
img.alt = name;
|
||||
img.hidden = true; /* ซ่อนไว้ก่อน — รอผลตรวจว่ามีไฟล์จริง */
|
||||
var cands = [].concat(photo || []).filter(Boolean); /* รองรับทั้งสตริงเดียวและรายการนามสกุล */
|
||||
(function tryNext(i) {
|
||||
if (i >= cands.length) { /* ไม่มีรูปสถานี → ใช้รูปสำรอง ไม่ปล่อยช่องว่าง */
|
||||
img.classList.add('is-fallback');
|
||||
img.src = bust(PHOTO_FALLBACK);
|
||||
img.hidden = false;
|
||||
return;
|
||||
}
|
||||
var url = cands[i];
|
||||
fetch(url, { method: 'HEAD', cache: 'no-store' })
|
||||
.then(function (r) {
|
||||
if (!r.ok) return tryNext(i + 1); /* ลองนามสกุลถัดไป (.jpg → .jpeg → .webp → .png) */
|
||||
img.src = url;
|
||||
img.hidden = false;
|
||||
})
|
||||
.catch(function () { tryNext(i + 1); });
|
||||
})(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- เรนเดอร์: การ์ดสรุป 4 ใบ ---------- */
|
||||
function renderInfo(st, sum) {
|
||||
var box = $('stop-info');
|
||||
if (!box) return;
|
||||
var tones = [
|
||||
'background:linear-gradient(135deg, #f7f1ff, #f2e8ff);',
|
||||
'background:linear-gradient(135deg, #edf6ff, #e8f3ff); border-color:#d7e7fb;',
|
||||
'background:linear-gradient(135deg, #eefdf6, #e7f9f1); border-color:#d1efdf;',
|
||||
'background:linear-gradient(135deg, #fff5fa, #ffeef6); border-color:#f7d6e5;'
|
||||
];
|
||||
var cards = [
|
||||
[t('stop.statRoutes'), sum.rows ? t(sum.rows === 1 ? 'stop.nRoutes1' : 'stop.nRoutes', { n: sum.rows }) : '–'],
|
||||
[t('stop.statTrips'), sum.trips ? String(sum.trips) : '–'],
|
||||
[t('stop.statType'), t(TYPE_KEY[st.station_type] || 'type.busstop')],
|
||||
[t('stop.statHours'), sum.first ? sum.first + ' - ' + sum.last : '–']
|
||||
];
|
||||
box.innerHTML = cards.map(function (c, i) {
|
||||
return '<article class="mu-info-card" style="' + tones[i] + '">' +
|
||||
'<p class="label">' + esc(c[0]) + '</p><p class="value">' + esc(c[1]) + '</p></article>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
/* ---------- เรนเดอร์: สายรถที่ผ่านป้ายนี้ ---------- */
|
||||
function renderRoutes(rows, placeByRoute) {
|
||||
placeByRoute = placeByRoute || {};
|
||||
var list = $('stop-routes');
|
||||
var filter = $('mu-route-filter');
|
||||
if (!list) return;
|
||||
|
||||
if (!rows.length) {
|
||||
list.innerHTML = '<li><p class="mu-stop-sub">' + esc(t('stop.noRoutes')) + '</p></li>';
|
||||
if (filter) filter.disabled = true;
|
||||
setCount(0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
list.innerHTML = '';
|
||||
rows.forEach(function (x) {
|
||||
var r = x.route;
|
||||
var li = document.createElement('li');
|
||||
var det = document.createElement('details');
|
||||
det.className = 'mu-stop-expander';
|
||||
if (x.isOrigin || x.isTerminus) det.open = true;
|
||||
|
||||
var posLabel = x.isOrigin ? t('route.origin') : (x.isTerminus ? t('route.destination') : t('route.pass'));
|
||||
var place = placeByRoute[String(r.route_id)] || null;
|
||||
/* จุดขึ้นรถประจำทางอื่นๆ → แสดง "ชื่อจุดจริง · อำเภอ" แทนคำว่าจุดจอดที่ N */
|
||||
/* จุดขึ้นรถประจำทางอื่นๆ ที่มีหลายจุด → โชว์จุดแรก + "(+N จุด)" ไม่ยัดชื่อทั้งชุด */
|
||||
var subs = (place && window.OtherStop && OtherStop.stopsOf) ? OtherStop.stopsOf(place) : [];
|
||||
var pName = subs.length ? subs[0].name : (place && place.station_name_th) || '';
|
||||
var pMore = subs.length > 1 ? ' ' + t('stop.otherMore', { n: subs.length - 1 }) : '';
|
||||
var metaText = place
|
||||
? pName + pMore + (place.city_th ? ' \u00b7 ' + place.city_th : '')
|
||||
: posLabel + (x.total > 1 ? ' \u00b7 ' + (x.index + 1) + '/' + x.total : '');
|
||||
var sum = document.createElement('summary');
|
||||
sum.innerHTML =
|
||||
'<span class="mu-route-chip">' + esc(r.route_id) + '</span>' +
|
||||
'<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> ' +
|
||||
esc(r.vehicle_type_th || t('type.terminal')) + '</span>' +
|
||||
'<span class="mu-stop-summary-main">' +
|
||||
'<strong>' + esc(r.route_name_th || ('สาย ' + r.route_id)) + '</strong>' +
|
||||
'<span class="mu-stop-summary-meta">' + esc(metaText) + '</span>' +
|
||||
'</span>' +
|
||||
'<span class="mu-stop-summary-rail">' +
|
||||
'<span class="mu-status-pill info">' + esc(t(x.trips === 1 ? 'stop.tripsPerDay1' : 'stop.tripsPerDay', { n: x.trips })) + '</span>' +
|
||||
'<span class="mu-stop-chevron">\u2304</span>' +
|
||||
'</span>';
|
||||
det.appendChild(sum);
|
||||
|
||||
var body = document.createElement('div');
|
||||
body.className = 'mu-stop-expander-body';
|
||||
|
||||
if (!x.legs.length || !x.trips) {
|
||||
body.innerHTML = '<p class="mu-stop-sub">' + esc(t('stop.noTimes')) + '</p>';
|
||||
} else {
|
||||
x.legs.forEach(function (leg) {
|
||||
/* ทิศที่ยังไม่มีเวลา → ข้าม (แถวนี้มีการแสดงตารางของทิศอื่นอยู่แล้ว) */
|
||||
if (!(leg.times || []).length) return;
|
||||
if (leg.label) {
|
||||
var lab = document.createElement('p');
|
||||
lab.className = 'mu-stop-sub';
|
||||
lab.textContent = leg.label;
|
||||
body.appendChild(lab);
|
||||
}
|
||||
var grid = document.createElement('div');
|
||||
grid.className = 'mu-time-grid' + (leg.estimated ? ' is-est' : '');
|
||||
leg.times.forEach(function (tm) {
|
||||
var c = document.createElement('div');
|
||||
c.className = 'mu-time-chip';
|
||||
c.textContent = tm;
|
||||
grid.appendChild(c);
|
||||
});
|
||||
body.appendChild(grid);
|
||||
if (leg.estimated) {
|
||||
var estN = document.createElement('p');
|
||||
estN.className = 'mu-est-note';
|
||||
/* กฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" → บอกจุดอ้างอิง + เตือนเรื่องการจราจร */
|
||||
estN.textContent = leg.estimateFrom && window.Schedules.offsetLabel
|
||||
? t('time.derived', {
|
||||
base: leg.estimateFrom.name || ('#' + leg.estimateFrom.station_id),
|
||||
n: Schedules.offsetLabel(leg.estimateFrom.offsetMin)
|
||||
})
|
||||
: t('time.estimated');
|
||||
body.appendChild(estN);
|
||||
}
|
||||
if (leg.note) {
|
||||
var n = document.createElement('p');
|
||||
n.className = 'mu-schedule-note';
|
||||
n.innerHTML = '<svg class="ic" aria-hidden="true"><use href="#ic-triangle-alert"/></svg> ' + esc(leg.note);
|
||||
body.appendChild(n);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* ลิงก์ไปตารางเวลาเต็มของสายนั้น */
|
||||
var act = document.createElement('div');
|
||||
act.className = 'mu-inline-actions';
|
||||
act.innerHTML = '<a class="mu-btn ghost" href="/check/' + encodeURIComponent(r.route_id) + '">' +
|
||||
esc(t('stop.viewScheduleN', { n: r.route_id })) + '</a>';
|
||||
body.appendChild(act);
|
||||
|
||||
det.appendChild(body);
|
||||
li.appendChild(det);
|
||||
list.appendChild(li);
|
||||
});
|
||||
|
||||
setupFilter();
|
||||
}
|
||||
|
||||
function setCount(shown, total) {
|
||||
var el = $('mu-route-count');
|
||||
if (el) el.textContent = total ? t('stop.showing', { a: shown, b: total }) : '';
|
||||
}
|
||||
|
||||
/* ---------- กรองสายรถ (ค้นหา) ---------- */
|
||||
function applyFilter() {
|
||||
var input = $('mu-route-filter');
|
||||
var items = Array.prototype.slice.call(document.querySelectorAll('#stop-routes > li'));
|
||||
if (!items.length) return;
|
||||
var kw = (input ? input.value : '').trim().toLowerCase();
|
||||
var shown = 0;
|
||||
items.forEach(function (li) {
|
||||
var ok = !kw || li.textContent.toLowerCase().indexOf(kw) !== -1;
|
||||
li.style.display = ok ? '' : 'none';
|
||||
if (ok) shown++;
|
||||
});
|
||||
setCount(shown, items.length);
|
||||
}
|
||||
function setupFilter() {
|
||||
var input = $('mu-route-filter');
|
||||
if (input && !input.dataset.bound) {
|
||||
input.dataset.bound = '1';
|
||||
input.addEventListener('input', applyFilter);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- ไฮไลต์เที่ยวถัดไป + นาฬิกา (เดิมอยู่ใน partial) ---------- */
|
||||
function tick() {
|
||||
var clock = $('mu-current-time');
|
||||
var now = new Date();
|
||||
if (clock) clock.textContent = pad2(now.getHours()) + ':' + pad2(now.getMinutes());
|
||||
var nowm = nowMin();
|
||||
|
||||
var soonest = null;
|
||||
document.querySelectorAll('.mu-stop-expander').forEach(function (det) {
|
||||
var chips = Array.prototype.slice.call(det.querySelectorAll('.mu-time-chip'));
|
||||
chips.forEach(function (c) { c.classList.remove('next-live'); });
|
||||
var times = chips.map(function (c) { return { c: c, m: toMin(c.textContent) }; })
|
||||
.filter(function (x) { return x.m !== null; })
|
||||
.sort(function (a, b) { return a.m - b.m; });
|
||||
if (!times.length) return;
|
||||
|
||||
var next = times.filter(function (x) { return x.m >= nowm; })[0];
|
||||
var tomorrow = false;
|
||||
if (!next) { next = times[0]; tomorrow = true; }
|
||||
next.c.classList.add('next-live');
|
||||
if (!soonest || next.m < soonest.m) soonest = { m: next.m, time: next.c.textContent.trim(), tomorrow: tomorrow };
|
||||
|
||||
var rail = det.querySelector('.mu-stop-summary-rail');
|
||||
if (!rail) return;
|
||||
var el = rail.querySelector('.mu-next-arrival');
|
||||
if (!el) {
|
||||
el = document.createElement('span');
|
||||
el.className = 'mu-next-arrival';
|
||||
var chev = rail.querySelector('.mu-stop-chevron');
|
||||
chev ? rail.insertBefore(el, chev) : rail.appendChild(el);
|
||||
}
|
||||
var routeId = (det.querySelector('.mu-route-chip') || {}).textContent || '';
|
||||
el.textContent = (tomorrow ? t('stop.tomorrow') : t('stop.nextAt')) + ' ' + next.c.textContent.trim();
|
||||
el.dataset.route = routeId;
|
||||
});
|
||||
|
||||
var hero = $('stop-next-trip');
|
||||
if (hero) hero.textContent = soonest ? (soonest.tomorrow ? t('stop.tomorrow') + ' ' : '') + soonest.time : '–';
|
||||
}
|
||||
|
||||
/* ---------- ป้ายที่ไม่พบข้อมูล ---------- */
|
||||
function renderNotFound(code) {
|
||||
var main = document.querySelector('#view .mu-container') || document.querySelector('#view');
|
||||
if (!main) return;
|
||||
main.innerHTML =
|
||||
'<p class="mu-breadcrumb"><a href="/stops">' + esc(t('common.backStops')) + '</a></p>' +
|
||||
'<h1 class="mu-stop-hero-title">' + esc(t('stop.notFound')) + '</h1>' +
|
||||
'<p class="mu-stop-hero-sub">' + esc(t('stop.notFoundSub', { code: code })) + '</p>';
|
||||
}
|
||||
|
||||
/* ---------- เริ่มทำงาน ---------- */
|
||||
function init() {
|
||||
var route = window.__route || { params: {}, query: {} };
|
||||
var code = (route.params && route.params.code) || '';
|
||||
var wantRoute = (route.query && route.query.route) || '';
|
||||
|
||||
Promise.all([
|
||||
fetchJSON(DATA + 'stations.json'),
|
||||
fetchJSON(DATA + 'routes.json'),
|
||||
Schedules.load().then(function (sd) { return Schedules.normSub(sd); }),
|
||||
(window.OtherStop ? OtherStop.load() : Promise.resolve([]))
|
||||
]).then(function (res) {
|
||||
var stations = (res[0] || {}).stations || [];
|
||||
if (window.Schedules && Schedules.setStationNames) Schedules.setStationNames(stations); /* ให้ข้อความ "คำนวณจาก ..." มีชื่อจุด */
|
||||
var routes = (res[1] || {}).routes || [];
|
||||
var sched = res[2] || {};
|
||||
var others = res[3] || [];
|
||||
|
||||
var st = findStation(stations, code);
|
||||
if (!st) { renderNotFound(code); return; }
|
||||
|
||||
var rows = routesAtStation(routes, sched, st.station_id);
|
||||
var sum = summarise(rows);
|
||||
|
||||
/* สถานี 8 "จุดขึ้นรถประจำทางอื่นๆ" = ชื่อรวมของทุกสาย
|
||||
→ จับคู่ route id เพื่อเอาชื่อสถานที่จริงของสายนั้น (เช่น 1011 → วัดสีบัวทอง / 1101 ในไฟล์) */
|
||||
var validIds = routes.map(function (r) { return String(r.route_id); });
|
||||
var isOther = !!(window.OtherStop && OtherStop.isOtherStop(st));
|
||||
var placeByRoute = {};
|
||||
if (isOther) {
|
||||
routes.forEach(function (r) {
|
||||
var e = OtherStop.forRoute(others, r.route_id, validIds);
|
||||
if (e) placeByRoute[String(r.route_id)] = e;
|
||||
});
|
||||
}
|
||||
var focusPlace = (isOther && wantRoute) ? (placeByRoute[String(wantRoute)] || null) : null;
|
||||
|
||||
renderOtherStops(isOther, routes, others, validIds, wantRoute, sched);
|
||||
renderHero(st, sum, findPhoto(st), focusPlace);
|
||||
renderInfo(st, sum);
|
||||
renderToolbar(st, rows, wantRoute);
|
||||
renderNearby(st);
|
||||
renderChips(st, sum);
|
||||
renderRoutes(rows, placeByRoute);
|
||||
|
||||
var filter = $('mu-route-filter');
|
||||
if (filter && wantRoute) { filter.value = wantRoute; applyFilter(); }
|
||||
|
||||
tick();
|
||||
setInterval(tick, 30000);
|
||||
|
||||
/* แผนที่: ใช้เส้นทางของสายที่ผ่านป้ายนี้ */
|
||||
var mapEl = $('stop-map');
|
||||
if (mapEl && window.ATMap) {
|
||||
var mapOpts = {};
|
||||
if (isOther && wantRoute) mapOpts.onlyRoutes = [String(wantRoute)];
|
||||
if (focusPlace) mapOpts.focus = focusPlace;
|
||||
try { ATMap.forStop(mapEl, st.station_code, mapOpts); } catch (e) { /* แผนที่พังไม่ควรทำให้หน้าเจ๊ง */ }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- จุดขึ้นรถประจำทางอื่นๆ: แสดง "ทุกจุด" ของสายนั้น ----------
|
||||
สายเดียวผ่านได้หลายจุด (เช่น 954 = ตลาดท่าช้าง · สามโก้ · วิเศษชัยชาญ · อ่างทอง)
|
||||
จุดที่ยังไม่มีพิกัด → แสดงชื่อพร้อมป้าย "ยังไม่มีพิกัด" (ไม่ซ่อนข้อมูล) */
|
||||
function renderOtherStops(isOther, routes, others, validIds, wantRoute, sched) {
|
||||
var host = $('stop-other-stops');
|
||||
if (!host) {
|
||||
if (!isOther) return;
|
||||
host = document.createElement('section');
|
||||
host.className = 'mu-other-stops';
|
||||
host.id = 'stop-other-stops';
|
||||
var bar = $('stop-toolbar');
|
||||
if (bar && bar.parentNode) bar.parentNode.insertBefore(host, bar);
|
||||
else return;
|
||||
}
|
||||
if (!isOther) { host.hidden = true; return; }
|
||||
|
||||
var list = []; /* { route_id, stop } */
|
||||
routes.forEach(function (r) {
|
||||
if (wantRoute && String(r.route_id) !== String(wantRoute)) return;
|
||||
OtherStop.allStops(others, r.route_id, validIds).forEach(function (st) {
|
||||
list.push({ route_id: String(r.route_id), stop: st });
|
||||
});
|
||||
});
|
||||
if (!list.length) { host.hidden = true; return; }
|
||||
|
||||
var one = !!wantRoute && routes.filter(function (r) { return String(r.route_id) === String(wantRoute); }).length === 1;
|
||||
|
||||
/* เวลาของ "จุดแรก" ของแต่ละสาย (แถว station 8 ในตารางเวลา) = ฐานสำหรับคำนวณจุดถัดไป
|
||||
offsets_min ใน 8 other_stop.json บอกว่าแต่ละจุดห่างจากจุดแรกกี่นาที */
|
||||
var baseByRoute = {};
|
||||
if (window.Schedules && sched && Schedules.records) {
|
||||
(Schedules.records(sched) || []).forEach(function (r) {
|
||||
if (String(r.station_id) !== '8') return;
|
||||
var rid = String(r.route_id), t2 = r.departure_times || [];
|
||||
if (t2.length && (!baseByRoute[rid] || t2.length > baseByRoute[rid].length)) baseByRoute[rid] = t2;
|
||||
});
|
||||
}
|
||||
var canShift = !!(window.Schedules && Schedules.shiftTimes && Schedules.offsetLabel);
|
||||
|
||||
host.hidden = false;
|
||||
host.innerHTML =
|
||||
'<h2 class="sect">' + esc(one
|
||||
? t('stop.otherStopsTitle', { n: wantRoute, m: list.length })
|
||||
: t('stop.otherStopsAll', { m: list.length })) + '</h2>' +
|
||||
'<ul class="mu-list mu-other-list">' + list.map(function (x) {
|
||||
var st = x.stop;
|
||||
var where = [st.city_th, st.province_th].filter(Boolean).join(' · ');
|
||||
var base = baseByRoute[String(x.route_id)] || null;
|
||||
var hasOff = (st.offsetMin != null);
|
||||
var times = (hasOff && base && canShift) ? Schedules.shiftTimes(base, st.offsetMin) : null;
|
||||
var first = (hasOff && base) ? list.filter(function (y) { return String(y.route_id) === String(x.route_id); })[0] : null;
|
||||
return '<li class="mu-other-item">' +
|
||||
'<div class="mu-other-row">' +
|
||||
'<span class="mu-other-idx">' + (st.index + 1) + '</span>' +
|
||||
'<div class="mu-other-txt"><strong>' + esc(st.name) + '</strong>' +
|
||||
(where ? '<span>' + esc(where) + '</span>' : '') +
|
||||
(one ? '' : '<span>' + esc(t('stops.busPrefix')) + ' ' + esc(x.route_id) + '</span>') +
|
||||
'</div>' +
|
||||
'<span class="mu-chip ' + (st.hasCoord ? 'count' : 'warn') + '">' +
|
||||
esc(st.hasCoord ? (Number(st.lat).toFixed(4) + ', ' + Number(st.lng).toFixed(4)) : t('stop.noCoord')) +
|
||||
'</span>' +
|
||||
'</div>' +
|
||||
(times && times.length
|
||||
? '<div class="mu-time-grid is-est">' + times.map(function (tm) {
|
||||
return '<div class="mu-time-chip">' + esc(tm) + '</div>';
|
||||
}).join('') + '</div>' +
|
||||
(st.offsetMin !== 0 && first
|
||||
? '<p class="mu-est-note">' + esc(t('time.derived', {
|
||||
base: first.stop.name, n: Schedules.offsetLabel(st.offsetMin)
|
||||
})) + '</p>'
|
||||
: '')
|
||||
: '') +
|
||||
'</li>';
|
||||
}).join('') + '</ul>';
|
||||
}
|
||||
|
||||
/* ---------- ปุ่ม/ทางลัด ---------- */
|
||||
function renderToolbar(st, rows, preferRoute) {
|
||||
var bar = $('stop-toolbar');
|
||||
if (!bar || !rows.length) return;
|
||||
/* ถ้ามี ?route= ให้ปุ่มอ้างสายนั้นก่อน ไม่งั้นใช้สายแรก */
|
||||
var top = rows[0].route;
|
||||
if (preferRoute) {
|
||||
var hit = rows.filter(function (x) { return String(x.route.route_id) === String(preferRoute); })[0];
|
||||
if (hit) top = hit.route;
|
||||
}
|
||||
bar.innerHTML =
|
||||
'<a class="mu-btn primary" href="/check/' + encodeURIComponent(top.route_id) + '">' +
|
||||
esc(t('stop.viewScheduleN', { n: top.route_id })) + '</a>' +
|
||||
'<a class="mu-back-btn" href="/stops">' + esc(t('common.backStops')) + '</a>';
|
||||
}
|
||||
|
||||
/* ---------- สถานที่ใกล้เคียง (ต้องมีข้อมูลใน stations.json → landmarks[]) ---------- */
|
||||
function renderNearby(st) {
|
||||
var sec = $('stop-nearby');
|
||||
var grid = $('stop-nearby-grid');
|
||||
if (!sec || !grid) return;
|
||||
var marks = st.landmarks || [];
|
||||
if (!marks.length) { sec.hidden = true; return; }
|
||||
sec.hidden = false;
|
||||
var sub = $('stop-nearby-sub');
|
||||
if (sub) sub.textContent = st.landmarks_note || t('stop.nearbySub');
|
||||
grid.innerHTML = marks.map(function (m) {
|
||||
return '<div class="mu-nearby-card">' +
|
||||
'<img src="' + esc(m.img || '') + '" alt="' + esc(m.caption || '') + '" loading="lazy" decoding="async">' +
|
||||
'<p class="cap">' + esc(m.caption || '') + (m.sub ? '<small>' + esc(m.sub) + '</small>' : '') + '</p></div>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
/* ---------- ชิป: เวลาเปิด–ปิด + สิ่งอำนวยความสะดวก (ถ้ามีใน stations.json) ---------- */
|
||||
function renderChips(st, sum) {
|
||||
var box = $('stop-chips');
|
||||
if (!box) return;
|
||||
var html = '';
|
||||
if (sum.first) html += '<span class="mu-chip">' + esc(t('stop.open')) + ' ' + esc(sum.first) + '</span>';
|
||||
if (sum.last) html += '<span class="mu-chip">' + esc(t('stop.close')) + ' ' + esc(sum.last) + '</span>';
|
||||
(st.facilities || []).forEach(function (f) {
|
||||
html += '<span class="mu-chip ok">' + esc(f) + '</span>';
|
||||
});
|
||||
box.innerHTML = html;
|
||||
}
|
||||
|
||||
export default function mount(): void {
|
||||
init();
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/busStop.init.js — logic unchanged; bootstrap converted to mount(). */
|
||||
/* ============================================================
|
||||
หน้าป้ายหยุดรถ — render จาก resource/data/busstop_list.json
|
||||
------------------------------------------------------------
|
||||
ข้อมูล: busstop_list.json (shape = array ตรง ๆ ไม่มี wrapper)
|
||||
{
|
||||
"route_code": "3064", // Highway No.
|
||||
"section_code": "0100", // Control Section
|
||||
"route_name": "อ่างทอง - ปากดง", // Highway Name
|
||||
"kilometer": "3+000", // ★ รหัสป้าย (Survey point — แสดงผลคงรูปนี้)
|
||||
"position": "ขวาทาง", // Location of the pavilion
|
||||
"type": "ที่รอรถประจำทาง", // Picture / Size of the pavilion
|
||||
"latitude": 14.6016517229,
|
||||
"longitude": 100.4323316104,
|
||||
"buses-line": [15, 101] // ★ สายรถประจำทางที่ผ่านป้ายนี้ (ว่าง = [])
|
||||
}
|
||||
|
||||
กติกา:
|
||||
- รหัสป้ายบนจอ = kilometer คงรูปเดิมเสมอ ("3+000") ตาม AGENTS.md ข้อ 9
|
||||
- ชื่อไฟล์รูป = pad5(kilometer) → "3+000" = "03000" → .image/stops/03000.jpg
|
||||
(ตัด "+" ออก + เติม 0 หน้าให้ครบ 5 หลัก)
|
||||
- รูปหาย → ใช้ placeholder minibus-512x512.png
|
||||
- KPI คำนวณจากข้อมูลจริง ไม่ hardcode
|
||||
============================================================ */
|
||||
/* ---- ported module body ---- */
|
||||
'use strict';
|
||||
|
||||
var DATA_URL = '/resource/data/busstop_list.json';
|
||||
var ROUTES_URL = '/resource/data/routes.json'; /* ใช้ยืนยันว่าสายมีอยู่จริง ก่อนทำชิปเป็นลิงก์ */
|
||||
var IMG_DIR = '/image/stops/'; /* รูปป้ายริมทาง: pad5(กม.) เช่น 36020.jpg (ชุดเดิม) */
|
||||
var STATION_IMG_DIR = '/image/stations/'; /* รูปสถานี (ตัวอาคาร): <station_id>.jpg ตาม stations.json */
|
||||
var IMG_EXTS = ['jpg', 'jpeg', 'webp', 'png']; /* ไล่ลองนามสกุล (รองรับ .jpeg) */
|
||||
var PLACEHOLDER = '/image/icons/minibus-512x512.png';
|
||||
|
||||
function t(key, vars) {
|
||||
return window.I18N ? window.I18N.t(key, vars) : key;
|
||||
}
|
||||
|
||||
/* "3+000" → "03000" (ตัดเครื่องหมาย + ออก แล้วเติม 0 หน้าให้ครบ 5 หลัก) */
|
||||
function pad5(km) {
|
||||
if (!km) return '';
|
||||
return String(km)
|
||||
.split('+')
|
||||
.map(function (s) { return s.replace(/\D/g, ''); })
|
||||
.join('')
|
||||
.padStart(5, '0');
|
||||
}
|
||||
|
||||
function fetchJSON(url) {
|
||||
return fetch(url, { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.catch(function () { return null; });
|
||||
}
|
||||
|
||||
/* ---------- รูป: รูปสถานี (<station_id>.jpg) ก่อน → รูปป้ายริมทาง (pad5 กม.) → placeholder ---------- */
|
||||
function exists(url) {
|
||||
return fetch(url, { method: 'HEAD', cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? url : null; })
|
||||
.catch(function () { return null; });
|
||||
}
|
||||
/* ไล่ลองนามสกุลทีละตัว (.jpg → .jpeg → .webp → .png) — ไม่มีเลย = null */
|
||||
function firstExisting(base) {
|
||||
var i = 0;
|
||||
function next() {
|
||||
if (i >= IMG_EXTS.length) return Promise.resolve(null);
|
||||
var url = base + '.' + IMG_EXTS[i++];
|
||||
var bu = (window.ImgURL && ImgURL.of) ? ImgURL.of(url) : url; /* ?v= กัน cache-first ของ SW */
|
||||
return exists(bu).then(function (u) { return u || next(); });
|
||||
}
|
||||
return next();
|
||||
}
|
||||
function resolveImage(stop) {
|
||||
var sid = stop && stop.station_id;
|
||||
var code = pad5(stop && stop.kilometer);
|
||||
var chain = sid ? firstExisting(STATION_IMG_DIR + sid) : Promise.resolve(null);
|
||||
return chain.then(function (u) { return u ? exists(u) : null; })
|
||||
.then(function (u) {
|
||||
if (u) return u;
|
||||
return code ? firstExisting(IMG_DIR + code) : null;
|
||||
})
|
||||
.then(function (u) { return u || PLACEHOLDER; });
|
||||
}
|
||||
|
||||
/* ---------- KPI (คำนวณจากข้อมูลจริง) ---------- */
|
||||
function renderKpi(stops) {
|
||||
var host = document.getElementById('stops-kpi');
|
||||
if (!host) return;
|
||||
|
||||
var routes = {};
|
||||
var types = {};
|
||||
var busLines = {};
|
||||
stops.forEach(function (s) {
|
||||
if (s.route_code) routes[s.route_code] = true;
|
||||
if (s.type) types[s.type] = true;
|
||||
(s['buses-line'] || []).forEach(function (n) { busLines[n] = true; });
|
||||
});
|
||||
|
||||
// สายที่ผ่านป้ายเยอะที่สุด (นับจาก buses-line)
|
||||
var countByBus = {};
|
||||
stops.forEach(function (s) {
|
||||
(s['buses-line'] || []).forEach(function (n) {
|
||||
countByBus[n] = (countByBus[n] || 0) + 1;
|
||||
});
|
||||
});
|
||||
var busKeys = Object.keys(countByBus);
|
||||
var topBus = busKeys.sort(function (a, b) { return countByBus[b] - countByBus[a]; })[0];
|
||||
|
||||
var kpis = [
|
||||
{ label: t('stops.kpi.total'), value: stops.length + ' ' + t('stops.unitPoints') },
|
||||
{ label: t('stops.kpi.routes'), value: Object.keys(routes).length + ' ' + t('stops.unitRoutes') },
|
||||
{ label: t('stops.kpi.types'), value: Object.keys(types).length + ' ' + t('stops.unitTypes') },
|
||||
{ label: t('stops.kpi.buses'), value: topBus ? ('สาย ' + topBus) : '—' }
|
||||
];
|
||||
|
||||
host.innerHTML = '';
|
||||
kpis.forEach(function (k) {
|
||||
var box = document.createElement('div');
|
||||
box.className = 'mu-kpi';
|
||||
var label = document.createElement('p');
|
||||
label.className = 'label';
|
||||
label.textContent = k.label;
|
||||
var value = document.createElement('p');
|
||||
value.className = 'value';
|
||||
value.textContent = k.value;
|
||||
box.appendChild(label);
|
||||
box.appendChild(value);
|
||||
host.appendChild(box);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- การ์ดป้าย ---------- */
|
||||
function buildCard(stop, imgUrl, idx, routeIds) {
|
||||
var li = document.createElement('li');
|
||||
li.setAttribute('data-idx', String(idx));
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.className = 'mu-stop-thumb';
|
||||
img.src = imgUrl;
|
||||
img.alt = stop.route_name || '';
|
||||
img.loading = 'lazy';
|
||||
img.decoding = 'async';
|
||||
if (imgUrl === PLACEHOLDER) img.classList.add('is-placeholder');
|
||||
li.appendChild(img);
|
||||
|
||||
var card = document.createElement('div');
|
||||
card.className = 'mu-stop-card local';
|
||||
|
||||
var top = document.createElement('div');
|
||||
top.className = 'mu-stop-top';
|
||||
|
||||
var left = document.createElement('div');
|
||||
|
||||
var pill = document.createElement('span');
|
||||
pill.className = 'mu-type-pill local';
|
||||
pill.textContent = stop.type || '';
|
||||
left.appendChild(pill);
|
||||
|
||||
var title = document.createElement('h2');
|
||||
title.className = 'mu-stop-title';
|
||||
title.textContent = stop.place || stop.route_name || '—';
|
||||
left.appendChild(title);
|
||||
|
||||
var loc = document.createElement('p');
|
||||
loc.className = 'mu-loc';
|
||||
loc.textContent = t('stops.highway') + ' ' + (stop.route_code || '—') +
|
||||
' · ' + t('stops.section') + ' ' + (stop.section_code || '—');
|
||||
left.appendChild(loc);
|
||||
|
||||
top.appendChild(left);
|
||||
|
||||
var codeChip = document.createElement('span');
|
||||
codeChip.className = 'mu-chip count stop-code';
|
||||
codeChip.textContent = stop.kilometer || '—';
|
||||
top.appendChild(codeChip);
|
||||
|
||||
card.appendChild(top);
|
||||
|
||||
var row = document.createElement('div');
|
||||
row.className = 'mu-chip-row';
|
||||
|
||||
// ★ สายรถประจำทางที่ผ่านป้ายนี้ (buses-line)
|
||||
// สายที่มีใน routes.json → ทำเป็นลิงก์ไปหน้ารายละเอียดสายนั้น (#/routes/<รหัส>)
|
||||
var buses = stop['buses-line'] || [];
|
||||
if (buses.length) {
|
||||
buses.forEach(function (n) {
|
||||
var known = routeIds.indexOf(String(n)) !== -1;
|
||||
var b = document.createElement(known ? 'a' : 'span');
|
||||
b.className = 'mu-chip route';
|
||||
if (known) {
|
||||
b.href = '/routes/' + encodeURIComponent(n);
|
||||
b.title = t('stops.viewRoute', { n: n });
|
||||
}
|
||||
b.textContent = t('stops.busPrefix') + ' ' + n;
|
||||
row.appendChild(b);
|
||||
});
|
||||
} else {
|
||||
var nb = document.createElement('span');
|
||||
nb.className = 'mu-chip';
|
||||
nb.textContent = t('stops.noBusLine');
|
||||
row.appendChild(nb);
|
||||
}
|
||||
card.appendChild(row);
|
||||
|
||||
var action = document.createElement('div');
|
||||
action.className = 'mu-stop-action';
|
||||
|
||||
var note = document.createElement('p');
|
||||
note.className = 'mu-stop-note';
|
||||
note.textContent = stop.position || '';
|
||||
action.appendChild(note);
|
||||
|
||||
var coords = document.createElement('span');
|
||||
coords.className = 'mu-chip';
|
||||
coords.textContent = (stop.latitude && stop.longitude)
|
||||
? stop.latitude.toFixed(4) + ', ' + stop.longitude.toFixed(4)
|
||||
: '—';
|
||||
action.appendChild(coords);
|
||||
|
||||
card.appendChild(action);
|
||||
li.appendChild(card);
|
||||
return li;
|
||||
}
|
||||
|
||||
/* ---------- สร้างการ์ดแบบทยอย (lazy) ----------
|
||||
- สร้าง "ทุกใบ" เป็น <li> เปล่า (มี data-idx) เพื่อให้ตัวกรอง/นับผลทำงานถูกต้องทันที
|
||||
- โหลดรูป + เนื้อหา "เฉพาะใบที่มองเห็น" → เปิดหน้าเร็ว (ไม่ยิง 154 รูปพร้อมกัน)
|
||||
- ใบที่ยังไม่โหลด: ใส่ที่กันที่ว่างชั่วคราว แล้วโหลดเมื่อถูกเรียก (แสดงทั้งหมด / ค้นหาเจอ) */
|
||||
var CARD_STUB = '<div class="mu-stop-card is-stub" aria-hidden="true"></div>';
|
||||
|
||||
function renderStops(stops, host, routeIds) {
|
||||
host.innerHTML = '';
|
||||
if (!stops.length) {
|
||||
var empty = document.createElement('li');
|
||||
empty.className = 'mu-stop-empty';
|
||||
empty.textContent = t('stops.noResult');
|
||||
host.appendChild(empty);
|
||||
return Promise.resolve();
|
||||
}
|
||||
stops.forEach(function (stop, idx) {
|
||||
var li = document.createElement('li');
|
||||
li.setAttribute('data-idx', String(idx));
|
||||
li.innerHTML = CARD_STUB;
|
||||
host.appendChild(li);
|
||||
});
|
||||
if (window.StopsSearch && window.StopsSearch.apply) window.StopsSearch.apply(); /* ให้ตัวกรองนับ/แสดงผลทันที */
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/* โหลดเนื้อหาการ์ดจริงของใบนั้น (เรียกครั้งเดียวต่อใบ) */
|
||||
function hydrateCard(li, stops, routeIds) {
|
||||
if (!li || li.getAttribute('data-loaded')) return Promise.resolve();
|
||||
var idx = parseInt(li.getAttribute('data-idx'), 10);
|
||||
if (isNaN(idx) || !stops[idx]) return Promise.resolve();
|
||||
li.setAttribute('data-loaded', '1');
|
||||
return resolveImage(stops[idx]).then(function (url) {
|
||||
var built = buildCard(stops[idx], url, idx, routeIds); /* buildCard คืน <li> ของมันเอง */
|
||||
li.innerHTML = '';
|
||||
while (built.firstChild) li.appendChild(built.firstChild); /* ย้ายเนื้อหาเข้ามา — ห้ามซ้อน <li> */
|
||||
});
|
||||
}
|
||||
|
||||
var STATE = { stops: [], routeIds: [] }; /* ให้โมดูลอื่น (search) เรียก hydrateCard ได้ */
|
||||
|
||||
/* ---------- init ---------- */
|
||||
function init() {
|
||||
var host = document.getElementById('stops-list');
|
||||
if (!host) return;
|
||||
|
||||
Promise.all([fetchJSON(DATA_URL), fetchJSON(ROUTES_URL)]).then(function (res) {
|
||||
var data = res[0], routesDoc = res[1] || {};
|
||||
var stops = Array.isArray(data) ? data : (data && data.stops) || [];
|
||||
var routeIds = (routesDoc.routes || []).map(function (r) { return String(r.route_id); });
|
||||
if (!stops.length) {
|
||||
host.innerHTML = '<li class="mu-stop-empty">' + t('stops.noResult') + '</li>';
|
||||
return;
|
||||
}
|
||||
renderKpi(stops);
|
||||
STATE.stops = stops;
|
||||
STATE.routeIds = routeIds;
|
||||
// ผูก event ก่อน render การ์ด — กันเคสที่ render ค้างแล้วปุ่มไม่ตอบสนอง
|
||||
if (window.StopsSearch) window.StopsSearch.init(stops);
|
||||
renderStops(stops, host, routeIds).then(function () {
|
||||
if (window.StopsSearch) window.StopsSearch.init(stops);
|
||||
if (window.StopsSearch && window.StopsSearch.hydrateVisible) window.StopsSearch.hydrateVisible();
|
||||
});
|
||||
});
|
||||
}
|
||||
// เปิดให้ search module ใช้ helper ร่วมกัน
|
||||
window.StopsRender = {
|
||||
pad5: pad5,
|
||||
PLACEHOLDER: PLACEHOLDER,
|
||||
hydrate: function (li) { return hydrateCard(li, STATE.stops, STATE.routeIds); }
|
||||
};
|
||||
|
||||
export default function mount(): void {
|
||||
init();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from the inline <script> in web-at-transit-mock/ui/partials/busStop.html
|
||||
(ปุ่ม "ใกล้ฉัน" — ผูกกับแผนที่ Leaflet) */
|
||||
export default function mount(): void {
|
||||
var btn = document.getElementById("near-me-btn");
|
||||
var out = document.getElementById("near-me-result");
|
||||
if (!btn || !out || !window.ATMap) return;
|
||||
window.ATMap.nearMe(btn, out, { limit: 8 });
|
||||
}
|
||||
@@ -0,0 +1,499 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/partials/busStop.search.js — logic unchanged; bootstrap converted to mount(). */
|
||||
/* ============================================================
|
||||
ระบบค้นหาป้ายหยุดรถ — 2 โหมด (เลือกอย่างใดอย่างหนึ่ง)
|
||||
------------------------------------------------------------
|
||||
โหมด 1 "รหัสป้าย" : พิมพ์/กด numpad → auto-insert "+" → 00+000
|
||||
โหมด 2 "ชื่อสถานที่" : พิมพ์หา → จับคู่ place/route_name ใน JSON + suggest
|
||||
|
||||
กติกากันการชนกัน:
|
||||
- เปิดโหมดไหน ช่องของอีกโหมดถูก disable + เคลียร์ค่า + ซ่อน
|
||||
- มี activeMode ตัวเดียวเสมอ (state เดียว) → เป็นไปไม่ได้ที่จะค้น 2 ทางพร้อมกัน
|
||||
============================================================ */
|
||||
/* ---- ported module body ---- */
|
||||
'use strict';
|
||||
|
||||
var MODE_CODE = 'code';
|
||||
var MODE_PLACE = 'place';
|
||||
|
||||
var state = {
|
||||
mode: MODE_CODE,
|
||||
stops: [],
|
||||
codeValue: '',
|
||||
placeQuery: '',
|
||||
showAll: false, /* false = แสดง 6 ใบแรก · true = แสดงป้ายทั้งหมด */
|
||||
bound: false
|
||||
};
|
||||
|
||||
function t(key, vars) {
|
||||
return window.I18N ? window.I18N.t(key, vars) : key;
|
||||
}
|
||||
|
||||
/* ---------- normalize สำหรับเทียบแบบหลวม (ตัด +, -, ช่องว่าง) ---------- */
|
||||
function norm(s) {
|
||||
return String(s || '').toLowerCase().replace(/[\s+\-]/g, '');
|
||||
}
|
||||
|
||||
/* ---------- รหัสป้ายแบบ 5 ช่อง: [x][x] + [x][x][x] ----------
|
||||
ช่อง 0-1 = หลักหน้า (ก่อน +) · ช่อง 2-4 = หลักหลัง (หลัง +)
|
||||
ช่องที่ยังไม่กรอก → ถือเป็น 0 (เช่น "3" + "_" → "03+000")
|
||||
เก็บเป็น digits[] ความยาว 5 เสมอ */
|
||||
|
||||
var PREVIEW_LIMIT = 6; /* แสดง 6 ใบแรก (กดปุ่มเพื่อดูทั้งหมด) */
|
||||
var CODE_CELLS = 5; // 2 หน้า + 3 หลัง
|
||||
|
||||
/* digits[] (5 หลัก) → "03+000" */
|
||||
function digitsToCode(digits) {
|
||||
var d = digits.slice();
|
||||
for (var i = 0; i < CODE_CELLS; i++) d[i] = d[i] || '0';
|
||||
return d.slice(0, 2).join('') + '+' + d.slice(2).join('');
|
||||
}
|
||||
|
||||
/* "3+000" → digits ['0','3','0','0','0'] */
|
||||
function codeToDigits(code) {
|
||||
var parts = String(code || '').split('+');
|
||||
var head = (parts[0] || '').replace(/\D/g, '');
|
||||
var tail = (parts[1] || '').replace(/\D/g, '');
|
||||
head = head.padStart(2, '0').slice(-2);
|
||||
tail = tail.padStart(3, '0').slice(-3);
|
||||
return (head + tail).split('');
|
||||
}
|
||||
|
||||
/* เก็บของเดิมไว้ใช้กับ numpad/plantext เดิม (ถ้ามีคนเรียก) */
|
||||
/* พิมพ์ "3000" → "3+000" · "5005" → "5+005" */
|
||||
function formatCode(raw) {
|
||||
var digits = String(raw || '').replace(/\D/g, '').slice(0, 4);
|
||||
if (digits.length <= 1) return digits;
|
||||
return digits.slice(0, 1) + '+' + digits.slice(1);
|
||||
}
|
||||
|
||||
/* ---------- เทียบรหัส: "03+000" ตรงกับข้อมูล "3+000" ----------
|
||||
ข้อมูลจริงเก็บแบบไม่เติม 0 หน้า (3+000) แต่ UI เติมให้ครบ 2+3 (03+000)
|
||||
→ เทียบด้วยค่าที่ normalize แล้วเป็นตัวเลข 5 หลัก (เทียบ loosely) */
|
||||
function codeMatches(stop, query) {
|
||||
if (!query) return true;
|
||||
var q = norm(query); // "03+000" → "03000"
|
||||
var km = norm(stop.kilometer); // "3+000" → "3000"
|
||||
// เติม 0 หน้าให้เท่ากัน 5 หลักก่อนเทียบ (ตรงตัว)
|
||||
var qPad = q.padStart(5, '0');
|
||||
var kmPad = km.padStart(5, '0');
|
||||
if (qPad === kmPad) return true;
|
||||
// ผู้ใช้กรอกไม่ครบ → เทียบแบบ prefix จากซ้าย
|
||||
return qPad.indexOf(kmPad) === 0 || kmPad.indexOf(qPad) === 0;
|
||||
}
|
||||
|
||||
/* ---------- เทียบชื่อ: place (ชื่อสถานที่สำคัญ) + route_name + type ---------- */
|
||||
function placeMatches(stop, query) {
|
||||
if (!query) return true;
|
||||
var q = norm(query);
|
||||
var hay = norm([stop.place, stop.route_name, stop.route_code, stop.type, stop.position,
|
||||
(stop['buses-line'] || []).join(' ')].join(' '));
|
||||
return hay.indexOf(q) !== -1;
|
||||
}
|
||||
|
||||
function currentFilter() {
|
||||
// โหมดรหัส: ถ้ายังไม่กรอกช่องไหนเลย → ไม่กรอง (แสดงทั้งหมด)
|
||||
if (state.mode === MODE_CODE && !state.codeTouched) {
|
||||
return { fn: function () { return true; }, value: '' };
|
||||
}
|
||||
return state.mode === MODE_CODE
|
||||
? { fn: codeMatches, value: state.codeValue }
|
||||
: { fn: placeMatches, value: state.placeQuery };
|
||||
}
|
||||
|
||||
/* ---------- วาด suggestion (โหมดชื่อ) ---------- */
|
||||
function renderSuggest() {
|
||||
var box = document.getElementById('stops-suggest');
|
||||
if (!box) return;
|
||||
box.innerHTML = '';
|
||||
|
||||
if (state.mode !== MODE_PLACE) { box.hidden = true; return; }
|
||||
|
||||
var q = state.placeQuery;
|
||||
if (!q || norm(q).length < 1) { box.hidden = true; return; }
|
||||
|
||||
var hits = state.stops.filter(function (s) { return placeMatches(s, q); }).slice(0, 6);
|
||||
if (!hits.length) { box.hidden = true; return; }
|
||||
|
||||
hits.forEach(function (s) {
|
||||
var btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'mu-suggest-item';
|
||||
|
||||
var name = document.createElement('span');
|
||||
name.className = 'mu-suggest-name';
|
||||
name.textContent = s.place || s.route_name || '—';
|
||||
btn.appendChild(name);
|
||||
|
||||
var code = document.createElement('span');
|
||||
code.className = 'mu-suggest-code';
|
||||
code.textContent = s.kilometer || '';
|
||||
btn.appendChild(code);
|
||||
|
||||
btn.addEventListener('click', function () {
|
||||
state.placeQuery = s.place || s.route_name || '';
|
||||
var input = document.getElementById('stops-place-input');
|
||||
if (input) input.value = state.placeQuery;
|
||||
apply();
|
||||
box.hidden = true;
|
||||
input.focus();
|
||||
});
|
||||
|
||||
box.appendChild(btn);
|
||||
});
|
||||
box.hidden = false;
|
||||
}
|
||||
|
||||
/* ---------- กรอง + แสดงผล ---------- */
|
||||
function apply() {
|
||||
var host = document.getElementById('stops-list');
|
||||
if (!host) return;
|
||||
|
||||
var f = currentFilter();
|
||||
var filtered = state.stops.filter(function (s) { return f.fn(s, f.value); });
|
||||
|
||||
/* จำกัด 6 ใบเมื่อ "ไม่ได้กรองอะไร" (เปิดหน้าปกติ) · ค้นหา/กรอง = แสดงผลทั้งหมดที่เจอ */
|
||||
var searching = !!f.value;
|
||||
var limit = (searching || state.showAll) ? filtered.length : PREVIEW_LIMIT;
|
||||
|
||||
var cards = [].filter.call(host.children, function (el) { return el.tagName === 'LI' && el.hasAttribute('data-idx'); });
|
||||
var shown = 0;
|
||||
Array.prototype.forEach.call(cards, function (li) {
|
||||
var idx = parseInt(li.getAttribute('data-idx'), 10);
|
||||
if (isNaN(idx)) return;
|
||||
var pos = filtered.indexOf(state.stops[idx]);
|
||||
var visible = pos !== -1 && pos < limit;
|
||||
li.hidden = !visible;
|
||||
if (visible) { shown++; if (window.StopsRender) window.StopsRender.hydrate(li); } /* โหลดรูปเฉพาะใบที่แสดง */
|
||||
});
|
||||
|
||||
// empty state
|
||||
var empty = host.querySelector('.mu-stop-empty');
|
||||
if (shown === 0) {
|
||||
if (!empty) {
|
||||
empty = document.createElement('li');
|
||||
empty.className = 'mu-stop-empty';
|
||||
host.appendChild(empty);
|
||||
}
|
||||
empty.hidden = false;
|
||||
empty.textContent = t('stops.noResult') + (f.value ? ' — ' + f.value : '');
|
||||
} else if (empty) {
|
||||
empty.hidden = true;
|
||||
}
|
||||
|
||||
// จำนวนผลลัพธ์ + ปุ่ม "แสดงป้ายทั้งหมด"
|
||||
var count = document.getElementById('stops-count');
|
||||
if (count) {
|
||||
count.textContent = searching
|
||||
? t('stops.showing', { a: shown, b: filtered.length })
|
||||
: t('stops.showing', { a: shown, b: state.stops.length });
|
||||
count.hidden = false;
|
||||
}
|
||||
var more = document.getElementById('stops-show-all');
|
||||
if (more) {
|
||||
var left = filtered.length - shown;
|
||||
more.hidden = searching || state.showAll || left <= 0; /* กรองอยู่/แสดงครบแล้ว = ไม่ต้องมีปุ่ม */
|
||||
more.textContent = t('stops.showAll') + ' (' + filtered.length + ')';
|
||||
}
|
||||
}
|
||||
|
||||
/* โหลดเนื้อหาการ์ดของใบที่มองเห็น (เรียกหลัง render/กรอง) */
|
||||
function hydrateVisible() {
|
||||
var host = document.getElementById('stops-list');
|
||||
if (!host) return;
|
||||
[].forEach.call(host.children, function (li) {
|
||||
if (li.tagName === 'LI' && li.hasAttribute('data-idx') && !li.hidden && window.StopsRender) window.StopsRender.hydrate(li);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- สลับโหมด (หัวใจของการกันชน) ---------- */
|
||||
function setMode(mode) {
|
||||
if (mode !== MODE_CODE && mode !== MODE_PLACE) return;
|
||||
state.mode = mode;
|
||||
|
||||
var codeWrap = document.getElementById('stops-code-wrap');
|
||||
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;
|
||||
|
||||
// แสดง/ซ่อนช่องกรอก
|
||||
if (codeWrap) codeWrap.hidden = !isCode;
|
||||
if (placeWrap) placeWrap.hidden = isCode;
|
||||
if (pad) pad.hidden = !isCode;
|
||||
if (suggest) suggest.hidden = isCode;
|
||||
|
||||
// ปิดการใช้งานช่องของโหมดที่ไม่ได้เลือก + ล้างค่า → กันการค้น 2 ทางพร้อมกัน
|
||||
Array.prototype.forEach.call(cells, function (c) {
|
||||
c.disabled = !isCode;
|
||||
if (!isCode) c.value = '';
|
||||
});
|
||||
if (!isCode) {
|
||||
state.codeValue = '';
|
||||
state.codeDigits = [];
|
||||
state.codeTouched = false;
|
||||
updateCodeDisplay();
|
||||
}
|
||||
if (placeInput) {
|
||||
placeInput.disabled = isCode;
|
||||
if (isCode) { placeInput.value = ''; state.placeQuery = ''; }
|
||||
}
|
||||
|
||||
// ไฮไลต์ปุ่ม toggle
|
||||
document.querySelectorAll('.mu-search-tab').forEach(function (btn) {
|
||||
var on = btn.getAttribute('data-mode') === mode;
|
||||
btn.classList.toggle('active', on);
|
||||
btn.setAttribute('aria-selected', String(on));
|
||||
});
|
||||
|
||||
// โฟกัสช่องที่เพิ่งเปิด
|
||||
if (isCode) focusCell(0);
|
||||
if (!isCode && placeInput) placeInput.focus();
|
||||
|
||||
apply();
|
||||
}
|
||||
|
||||
/* ---------- 6-box code input ----------
|
||||
[x] + [x][x][x][x] ← 5 ช่อง + เครื่องหมาย + คั่นกลาง
|
||||
- พิมพ์เลข → เด้งไปช่องถัดไปอัตโนมัติ
|
||||
- Backspace บนช่องว่าง → ถอยกลับช่องก่อน
|
||||
- ช่องว่างถือเป็น 0 แต่ตัวที่โชว์คือ placeholder จาง ๆ
|
||||
- วาง (paste) "3+000" หรือ "3000" ได้ทั้งคู่ */
|
||||
|
||||
function codeCells() {
|
||||
return document.querySelectorAll('.mu-code-cell');
|
||||
}
|
||||
|
||||
/* อัปเดต state.codeValue จากช่องทั้ง 5 */
|
||||
function syncCodeFromCells() {
|
||||
var cells = codeCells();
|
||||
var digits = [];
|
||||
for (var i = 0; i < CODE_CELLS; i++) {
|
||||
var v = cells[i] ? cells[i].value.replace(/\D/g, '') : '';
|
||||
digits.push(v.charAt(0) || '');
|
||||
}
|
||||
state.codeDigits = digits;
|
||||
state.codeValue = digitsToCode(digits);
|
||||
state.codeTouched = digits.some(function (d) { return d !== ''; });
|
||||
return state.codeValue;
|
||||
}
|
||||
|
||||
/* เขียน digits[] กลับลงช่อง (ใช้ตอน paste / ล้างค่า / numpad) */
|
||||
function paintCells(digits) {
|
||||
var cells = codeCells();
|
||||
for (var i = 0; i < CODE_CELLS; i++) {
|
||||
if (cells[i]) cells[i].value = digits[i] || '';
|
||||
}
|
||||
syncCodeFromCells();
|
||||
updateCodeDisplay();
|
||||
}
|
||||
|
||||
/* โชว์รหัสเต็ม (เติม 0) ใต้ช่อง */
|
||||
function updateCodeDisplay() {
|
||||
var out = document.getElementById('stops-code-display');
|
||||
if (!out) return;
|
||||
if (!state.codeTouched) { out.textContent = ''; out.hidden = true; return; }
|
||||
out.hidden = false;
|
||||
out.textContent = t('stops.codeFull') + ' ' + state.codeValue;
|
||||
}
|
||||
|
||||
function focusCell(idx) {
|
||||
var cells = codeCells();
|
||||
if (idx < 0 || idx >= CODE_CELLS) return;
|
||||
var el = cells[idx];
|
||||
if (el) { el.focus(); el.select(); }
|
||||
}
|
||||
|
||||
function initCodeCells() {
|
||||
var cells = codeCells();
|
||||
if (!cells.length) return;
|
||||
|
||||
Array.prototype.forEach.call(cells, function (cell, idx) {
|
||||
// พิมพ์เลข → เก็บ 1 หลัก + เด้งไปช่องถัดไป
|
||||
cell.addEventListener('input', function () {
|
||||
var v = this.value.replace(/\D/g, '');
|
||||
this.value = v.charAt(v.length - 1) || ''; // เอาเฉพาะหลักสุดท้ายที่พิมพ์
|
||||
syncCodeFromCells();
|
||||
updateCodeDisplay();
|
||||
apply();
|
||||
if (this.value && idx < CODE_CELLS - 1) focusCell(idx + 1);
|
||||
});
|
||||
|
||||
// Backspace บนช่องว่าง → ถอยกลับ
|
||||
cell.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Backspace' && !this.value) {
|
||||
e.preventDefault();
|
||||
focusCell(idx - 1);
|
||||
return;
|
||||
}
|
||||
if (e.key === 'ArrowLeft') { e.preventDefault(); focusCell(idx - 1); }
|
||||
if (e.key === 'ArrowRight') { e.preventDefault(); focusCell(idx + 1); }
|
||||
});
|
||||
|
||||
// วางรหัสทั้งชุด
|
||||
cell.addEventListener('paste', function (e) {
|
||||
var txt = (e.clipboardData || window.clipboardData).getData('text') || '';
|
||||
if (!/[\d+]/.test(txt)) return;
|
||||
e.preventDefault();
|
||||
var clean = txt.replace(/[^\d+]/g, '');
|
||||
if (clean.indexOf('+') !== -1) {
|
||||
paintCells(codeToDigits(clean));
|
||||
} else {
|
||||
var d = clean.replace(/\D/g, '').slice(0, CODE_CELLS).split('');
|
||||
while (d.length < CODE_CELLS) d.push('');
|
||||
paintCells(d);
|
||||
}
|
||||
updateCodeDisplay();
|
||||
apply();
|
||||
focusCell(CODE_CELLS - 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- 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;
|
||||
|
||||
// idempotent — เรียกซ้ำได้ (ผูก event แค่ครั้งแรก)
|
||||
if (state.bound) { apply(); return; }
|
||||
state.bound = true;
|
||||
|
||||
var placeInput = document.getElementById('stops-place-input');
|
||||
var tabs = document.querySelectorAll('.mu-search-tab');
|
||||
|
||||
// toggle
|
||||
tabs.forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
setMode(btn.getAttribute('data-mode'));
|
||||
});
|
||||
});
|
||||
|
||||
// ช่องรหัส: 6-box → เด้งช่อง + เติม 0
|
||||
initCodeCells();
|
||||
|
||||
// ปุ่ม "แสดงป้ายทั้งหมด" — กดแล้วเลิกจำกัด 6 ใบ (ไม่กรองอะไรอยู่)
|
||||
var more = document.getElementById('stops-show-all');
|
||||
if (more) {
|
||||
more.addEventListener('click', function () {
|
||||
state.showAll = true;
|
||||
apply();
|
||||
hydrateVisible();
|
||||
});
|
||||
}
|
||||
|
||||
// ช่องชื่อ: debounce + suggest
|
||||
if (placeInput) {
|
||||
var timer = null;
|
||||
placeInput.addEventListener('input', function () {
|
||||
var v = this.value;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function () {
|
||||
state.placeQuery = v;
|
||||
renderSuggest();
|
||||
apply();
|
||||
hydrateVisible();
|
||||
}, 180);
|
||||
});
|
||||
placeInput.addEventListener('focus', renderSuggest);
|
||||
}
|
||||
|
||||
// ปุ่มค้นหา (โหมดรหัส: กดแล้วกรองเลย / โหมดชื่อ: ยืนยัน suggest แรก)
|
||||
var searchBtn = document.getElementById('stops-search-btn');
|
||||
if (searchBtn) {
|
||||
searchBtn.addEventListener('click', function () {
|
||||
if (state.mode === MODE_CODE) {
|
||||
syncCodeFromCells();
|
||||
updateCodeDisplay();
|
||||
} else {
|
||||
state.placeQuery = placeInput ? placeInput.value : '';
|
||||
renderSuggest();
|
||||
}
|
||||
apply();
|
||||
});
|
||||
}
|
||||
|
||||
// ปุ่มล้างค่า
|
||||
var resetBtn = document.getElementById('stops-reset-btn');
|
||||
if (resetBtn) {
|
||||
resetBtn.addEventListener('click', function () {
|
||||
state.showAll = false; /* ล้างการค้นหา → กลับไปแสดง 6 ใบแรก */
|
||||
var cells = codeCells();
|
||||
Array.prototype.forEach.call(cells, function (c) { c.value = ''; });
|
||||
if (placeInput) placeInput.value = '';
|
||||
state.codeValue = '';
|
||||
state.codeDigits = [];
|
||||
state.codeTouched = false;
|
||||
state.placeQuery = '';
|
||||
updateCodeDisplay();
|
||||
var suggest = document.getElementById('stops-suggest');
|
||||
if (suggest) suggest.hidden = true;
|
||||
apply();
|
||||
focusCell(0);
|
||||
});
|
||||
}
|
||||
|
||||
// ปิด suggest เมื่อคลิกนอก
|
||||
document.addEventListener('click', function (e) {
|
||||
var suggest = document.getElementById('stops-suggest');
|
||||
if (!suggest || suggest.hidden) return;
|
||||
if (e.target.closest('#stops-place-wrap') || e.target.closest('#stops-suggest')) return;
|
||||
suggest.hidden = true;
|
||||
});
|
||||
|
||||
initNumpad();
|
||||
setMode(MODE_CODE); // เริ่มที่โหมดรหัส
|
||||
}
|
||||
|
||||
window.StopsSearch = { init: init, setMode: setMode, formatCode: formatCode , hydrateVisible: hydrateVisible };
|
||||
|
||||
// ให้ i18n เรียก render ใหม่ได้ (ไม่บังคับ)
|
||||
window.addEventListener('langchange', function () {
|
||||
if (state.stops.length) { renderSuggest(); apply(); }
|
||||
});
|
||||
|
||||
export default function mount(): void {
|
||||
/* init is driven by stops.init.ts */
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
// @ts-nocheck
|
||||
/* Ported from web-at-transit-mock/ui/visitors.js — logic unchanged. */
|
||||
/* 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 วิต่อครั้ง */
|
||||
|
||||
/* 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">รีเซ็ตจำนวนผู้เข้าชม</h4>' +
|
||||
'<label for="vreset-pass">รหัสรีเซ็ต</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">ยกเลิก</button>' +
|
||||
'<button type="button" class="mu-vreset-ok">รีเซ็ต</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 = 'รีเซ็ตแล้ว — เริ่มนับใหม่จาก 0';
|
||||
input.value = '';
|
||||
setTimeout(close, 1200);
|
||||
} else if (why === 'unsupported') {
|
||||
msg.textContent = 'เบราว์เซอร์ไม่รองรับ — ต้องเปิดผ่าน https หรือ localhost';
|
||||
} else {
|
||||
msg.className = 'mu-vreset-msg is-bad';
|
||||
msg.textContent = 'รหัสไม่ถูกต้อง';
|
||||
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();
|
||||
})();
|
||||
export {};
|
||||
@@ -1,18 +0,0 @@
|
||||
"use client";
|
||||
import { useEffect } from "react";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { api } from "./api";
|
||||
|
||||
const KEY = "tx_visitor_id";
|
||||
|
||||
export function VisitTracker({ path }: { path: string }) {
|
||||
useEffect(() => {
|
||||
let vid = typeof window !== "undefined" ? localStorage.getItem(KEY) : null;
|
||||
if (!vid) {
|
||||
vid = uuidv4();
|
||||
try { localStorage.setItem(KEY, vid); } catch {}
|
||||
}
|
||||
api.recordVisit({ page_path: path, visitor_id: vid }).catch(() => {});
|
||||
}, [path]);
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,520 @@
|
||||
/* =========================================================
|
||||
Atroute shared polish — applied to all mockup pages
|
||||
Loaded AFTER main-theme.css, BEFORE per-page <style>.
|
||||
========================================================= */
|
||||
|
||||
/* ---------- Brand logo ---------- */
|
||||
.mu-logo-img {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 12px;
|
||||
object-fit: cover;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
|
||||
}
|
||||
|
||||
/* ---------- Universal "cover" card pattern ---------- */
|
||||
/* A card whose top region is a 16:10 image hero with a soft
|
||||
gradient overlay and a label sitting on top. Used by route
|
||||
cards (index) and stop cards (busStop) so duplicate stock
|
||||
photos no longer look bolted on. */
|
||||
.mu-cover {
|
||||
position: relative;
|
||||
aspect-ratio: 16 / 10;
|
||||
background: linear-gradient(135deg, #eef1ff 0%, #f7f0ff 100%);
|
||||
overflow: hidden;
|
||||
}
|
||||
.mu-cover > img {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform .45s ease;
|
||||
}
|
||||
.mu-card:hover .mu-cover > img,
|
||||
.mu-cover-card:hover .mu-cover > img {
|
||||
transform: scale(1.06);
|
||||
}
|
||||
.mu-cover::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(15, 23, 42, 0) 30%, rgba(15, 23, 42, .72) 100%);
|
||||
pointer-events: none;
|
||||
}
|
||||
.mu-cover-tag {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
left: 12px;
|
||||
z-index: 1;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 5px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: .72rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: .02em;
|
||||
background: rgba(255, 255, 255, .92);
|
||||
color: #1f2a44;
|
||||
backdrop-filter: blur(8px);
|
||||
box-shadow: 0 4px 10px rgba(15, 23, 42, .15);
|
||||
}
|
||||
.mu-cover-title {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
right: 14px;
|
||||
bottom: 12px;
|
||||
z-index: 1;
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
font-size: 1.05rem;
|
||||
font-weight: 800;
|
||||
line-height: 1.25;
|
||||
text-shadow: 0 2px 6px rgba(0, 0, 0, .45);
|
||||
}
|
||||
.mu-cover-title small {
|
||||
display: block;
|
||||
font-weight: 500;
|
||||
font-size: .78rem;
|
||||
opacity: .92;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.mu-cover.no-photo {
|
||||
background:
|
||||
radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .35), transparent 55%),
|
||||
linear-gradient(135deg, #7a4cc0 0%, #3071b8 100%);
|
||||
}
|
||||
.mu-cover.no-photo::after {
|
||||
background: linear-gradient(180deg, rgba(15, 23, 42, 0) 40%, rgba(15, 23, 42, .35) 100%);
|
||||
}
|
||||
.mu-cover.tone-purple { background: linear-gradient(135deg, #7a4cc0, #c084fc); }
|
||||
.mu-cover.tone-sky { background: linear-gradient(135deg, #3071b8, #60a5fa); }
|
||||
.mu-cover.tone-pink { background: linear-gradient(135deg, #bb3a78, #f472b6); }
|
||||
.mu-cover.tone-mint { background: linear-gradient(135deg, #1f8765, #34d399); }
|
||||
.mu-cover.tone-amber { background: linear-gradient(135deg, #c47b1d, #fbbf24); }
|
||||
|
||||
/* ---------- Index route cards (rebuilt) ---------- */
|
||||
.mu-card {
|
||||
overflow: hidden;
|
||||
transition: transform .18s ease, box-shadow .18s ease;
|
||||
}
|
||||
.mu-card:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 18px 36px rgba(15, 23, 42, .14);
|
||||
}
|
||||
.mu-card-head {
|
||||
position: relative;
|
||||
height: auto;
|
||||
aspect-ratio: 16 / 10;
|
||||
overflow: hidden;
|
||||
}
|
||||
.mu-card-head .mu-card-photo {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform .45s ease;
|
||||
}
|
||||
.mu-card:hover .mu-card-photo { transform: scale(1.06); }
|
||||
.mu-card-head::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(180deg, rgba(15, 23, 42, 0) 30%, rgba(15, 23, 42, .72) 100%);
|
||||
}
|
||||
.mu-card-head .mu-route-number {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
bottom: 12px;
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
font-weight: 900;
|
||||
font-size: 32px;
|
||||
letter-spacing: .02em;
|
||||
text-shadow: 0 2px 8px rgba(0, 0, 0, .45);
|
||||
z-index: 1;
|
||||
}
|
||||
.mu-card-head .mu-route-kind {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
left: 12px;
|
||||
z-index: 1;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: .7rem;
|
||||
font-weight: 700;
|
||||
background: rgba(255, 255, 255, .92);
|
||||
color: #1f2a44;
|
||||
backdrop-filter: blur(6px);
|
||||
box-shadow: 0 4px 10px rgba(15, 23, 42, .14);
|
||||
}
|
||||
.mu-card-head.no-photo {
|
||||
background:
|
||||
radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .25), transparent 55%),
|
||||
linear-gradient(135deg, #7a4cc0 0%, #3071b8 100%);
|
||||
}
|
||||
.mu-card-head.no-photo.bg-purple { background: linear-gradient(135deg, #7a4cc0, #c084fc); }
|
||||
.mu-card-head.no-photo.bg-sky { background: linear-gradient(135deg, #3071b8, #60a5fa); }
|
||||
.mu-card-head.no-photo.bg-pink { background: linear-gradient(135deg, #bb3a78, #f472b6); }
|
||||
.mu-card-head.no-photo.bg-mint { background: linear-gradient(135deg, #1f8765, #34d399); }
|
||||
|
||||
/* ---------- BusStop: integrated stop cards (no more
|
||||
disjoint thumbnails) ---------- */
|
||||
.mu-stop-grid li.mu-stop-cell {
|
||||
list-style: none;
|
||||
border-radius: 18px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 10px 24px rgba(63, 43, 94, .08);
|
||||
border: 1px solid rgba(231, 224, 246, .95);
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: transform .18s ease, box-shadow .18s ease;
|
||||
}
|
||||
.mu-stop-grid li.mu-stop-cell:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 18px 36px rgba(63, 43, 94, .14);
|
||||
}
|
||||
.mu-stop-cell .mu-stop-card {
|
||||
padding: 16px 18px 18px;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* ---------- Rich shared footer ---------- */
|
||||
.mu-site-footer {
|
||||
margin-top: 34px;
|
||||
background:
|
||||
radial-gradient(circle at 0% 0%, rgba(122, 76, 192, .35), transparent 35%),
|
||||
radial-gradient(circle at 100% 10%, rgba(48, 113, 184, .35), transparent 35%),
|
||||
linear-gradient(180deg, #1a1830 0%, #0f1126 100%);
|
||||
color: #cfd5ec;
|
||||
padding: 34px 0 0;
|
||||
}
|
||||
.mu-site-footer .mu-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 0 24px;
|
||||
}
|
||||
.mu-footer-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1.4fr 1fr 1fr 1.1fr;
|
||||
gap: 20px;
|
||||
}
|
||||
.mu-footer-brand {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.mu-footer-brand-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.mu-footer-brand-row img {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
padding: 4px;
|
||||
object-fit: contain;
|
||||
}
|
||||
.mu-footer-brand-row strong {
|
||||
display: block;
|
||||
color: #fff;
|
||||
font-size: 1.05rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: .01em;
|
||||
}
|
||||
.mu-footer-brand-row span {
|
||||
display: block;
|
||||
color: #9aa3c3;
|
||||
font-size: .82rem;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.mu-footer-brand p.about {
|
||||
margin: 0;
|
||||
color: #b6bdda;
|
||||
font-size: .88rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.mu-footer-col h4 {
|
||||
margin: 0 0 10px;
|
||||
color: #fff;
|
||||
font-size: .9rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: .03em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.mu-footer-col ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
}
|
||||
.mu-footer-col ul a {
|
||||
color: #cfd5ec;
|
||||
text-decoration: none;
|
||||
font-size: .9rem;
|
||||
line-height: 1.5;
|
||||
transition: color .15s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.mu-footer-col ul a:hover { color: #fff; }
|
||||
.mu-footer-col ul a::before {
|
||||
content: "›";
|
||||
color: #7a4cc0;
|
||||
font-weight: 800;
|
||||
}
|
||||
.mu-footer-contact a,
|
||||
.mu-footer-contact span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: #cfd5ec;
|
||||
text-decoration: none;
|
||||
font-size: .88rem;
|
||||
}
|
||||
.mu-footer-contact .row { margin-bottom: 4px; }
|
||||
|
||||
/* ---------- Sponsor strip inside footer ---------- */
|
||||
.mu-footer-sponsors {
|
||||
margin-top: 22px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid rgba(255, 255, 255, .08);
|
||||
}
|
||||
.mu-footer-sponsors h4 {
|
||||
margin: 0 0 6px;
|
||||
color: #fff;
|
||||
font-size: .95rem;
|
||||
font-weight: 800;
|
||||
}
|
||||
.mu-footer-sponsors p.lead {
|
||||
margin: 0 0 18px;
|
||||
color: #9aa3c3;
|
||||
font-size: .85rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.mu-sponsor-strip {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
.mu-sponsor-tile {
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
aspect-ratio: 5 / 3;
|
||||
transition: transform .15s ease, box-shadow .15s ease;
|
||||
border: 1px solid rgba(255, 255, 255, .04);
|
||||
}
|
||||
.mu-sponsor-tile:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 12px 24px rgba(0, 0, 0, .35);
|
||||
}
|
||||
.mu-sponsor-tile img {
|
||||
max-width: 84%;
|
||||
max-height: 70%;
|
||||
object-fit: contain;
|
||||
filter: grayscale(.1);
|
||||
transition: filter .2s ease;
|
||||
}
|
||||
.mu-sponsor-tile:hover img { filter: grayscale(0); }
|
||||
|
||||
/* ---------- Footer bottom bar ---------- */
|
||||
.mu-footer-bottom {
|
||||
margin-top: 20px;
|
||||
padding: 12px 0 14px;
|
||||
border-top: 1px solid rgba(255, 255, 255, .08);
|
||||
text-align: center;
|
||||
}
|
||||
.mu-footer-bottom p {
|
||||
margin: 0;
|
||||
color: #8d96b8;
|
||||
font-size: .82rem;
|
||||
letter-spacing: .02em;
|
||||
}
|
||||
.mu-footer-bottom .pill {
|
||||
display: inline-block;
|
||||
margin-left: 10px;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
background: rgba(122, 76, 192, .25);
|
||||
color: #d8c7ff;
|
||||
font-size: .72rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* Hide legacy thin footer when shared rich footer is present */
|
||||
body:has(.mu-site-footer) .mu-footer { display: none; }
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.mu-footer-grid { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.mu-footer-grid { grid-template-columns: 1fr; }
|
||||
.mu-site-footer { padding: 28px 0 0; }
|
||||
}
|
||||
|
||||
/* =========================================================
|
||||
Icon system — Lucide (MIT) — ใช้ <svg class="ic"><use href="#ic-NAME"/></svg>
|
||||
sprite: partials/icons-sprite.svg | credit: ui/credits.html
|
||||
========================================================= */
|
||||
.ic {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
display: inline-block;
|
||||
vertical-align: -0.125em;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.ic--lg { width: 1.4em; height: 1.4em; }
|
||||
|
||||
/* ---------- Search field (input + icon ข้างหน้า) ---------- */
|
||||
.mu-search-field {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
min-width: 220px;
|
||||
}
|
||||
.mu-search-field .ic {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
color: #6f7b95;
|
||||
pointer-events: none;
|
||||
}
|
||||
.mu-search-field input {
|
||||
width: 100%;
|
||||
padding: 10px 12px 10px 38px;
|
||||
}
|
||||
|
||||
/* ---------- ปุ่มสลับภาษา (ไทย / EN) ---------- */
|
||||
.mu-lang-switch {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
background: #f0edf7;
|
||||
border: 1px solid #e4dcf2;
|
||||
border-radius: 999px;
|
||||
padding: 3px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.mu-lang-btn {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #6d28d9;
|
||||
font-family: inherit;
|
||||
font-weight: 700;
|
||||
font-size: .72rem;
|
||||
line-height: 1;
|
||||
padding: 6px 10px;
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
transition: background .15s ease, color .15s ease;
|
||||
}
|
||||
.mu-lang-btn:hover { color: #5b21b6; }
|
||||
.mu-lang-btn.active {
|
||||
background: #fff;
|
||||
color: #7a4cc0;
|
||||
box-shadow: 0 1px 4px rgba(63, 43, 94, .18);
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
ปุ่ม + ฟอร์มคอนโทรล (shared — ทุกหน้าใช้ร่วมกัน)
|
||||
.mu-btn อยู่ที่นี่ (ไม่ใช่ใน partial) → หน้าไหนก็ได้สไตล์เดียวกัน
|
||||
============================================================ */
|
||||
.mu-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
min-height: 44px;
|
||||
padding: 10px 18px;
|
||||
border-radius: 12px;
|
||||
font-family: inherit;
|
||||
font-weight: 700;
|
||||
font-size: .85rem;
|
||||
line-height: 1;
|
||||
text-decoration: none;
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: box-shadow .15s ease, transform .1s ease, background .15s ease, border-color .15s ease;
|
||||
}
|
||||
.mu-btn:active { transform: translateY(1px); }
|
||||
.mu-btn.primary {
|
||||
background: linear-gradient(135deg, #a855f7, #7c3aed);
|
||||
color: #fff;
|
||||
box-shadow: 0 8px 18px rgba(124, 58, 237, .25);
|
||||
}
|
||||
.mu-btn.primary:hover { box-shadow: 0 10px 22px rgba(124, 58, 237, .35); }
|
||||
.mu-btn.ghost {
|
||||
background: #fff;
|
||||
border-color: #e7e2f6;
|
||||
color: #5b3b71;
|
||||
box-shadow: 0 2px 8px rgba(63, 43, 94, .05);
|
||||
}
|
||||
.mu-btn.ghost:hover { border-color: #d8c9f2; background: #faf7ff; }
|
||||
|
||||
/* select แบบโมเดิร์น — custom chevron แทนลูกศร native (prefix #view ชนะ partial style) */
|
||||
#view .mu-toolbar select {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a4cc0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"), linear-gradient(180deg, #fff, #f8fbff);
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 12px center;
|
||||
padding-right: 38px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#view .mu-toolbar select:hover { border-color: #c8b4ec; }
|
||||
#view .mu-toolbar input:hover { border-color: #c8b4ec; }
|
||||
|
||||
/* focus ring อันเดียวกันทั้งฟอร์ม — มองเห็นชัดตอน tab (a11y) */
|
||||
#view .mu-toolbar input:focus-visible,
|
||||
#view .mu-toolbar select:focus-visible,
|
||||
#view .mu-toolbar .mu-btn:focus-visible {
|
||||
outline: 2px solid #7a4cc0;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* ---------- ปุ่มติดตั้งแอป (PWA — inject จาก pwa.js) ---------- */
|
||||
.mu-install-btn {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
z-index: 100;
|
||||
display: none; /* โผล่เมื่อ beforeinstallprompt เท่านั้น */
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 48px;
|
||||
padding: 12px 20px;
|
||||
border: none;
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
font-size: .95rem;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #a855f7, #7c3aed);
|
||||
box-shadow: 0 10px 24px rgba(124, 58, 237, .35);
|
||||
transition: transform .15s ease;
|
||||
}
|
||||
.mu-install-btn:active { transform: translateY(1px); }
|
||||
.mu-install-btn svg { width: 20px; height: 20px; }
|
||||
@@ -0,0 +1,159 @@
|
||||
/* =========================================================
|
||||
Atroute — แผนที่เส้นทาง (Leaflet)
|
||||
ธีมตาม DESIGN.md §5: เส้นทาง --green-700 หนา 5px · หมุดสี่เหลี่ยมมน
|
||||
เขียว = ป้ายตามเส้นทาง · อำพัน = ต้นทาง/ปลายทาง · ไม่มี drop shadow
|
||||
========================================================= */
|
||||
|
||||
.at-map {
|
||||
position: relative;
|
||||
isolation: isolate; /* กัก z-index ของ Leaflet (400–1000) ไว้ในกรอบแผนที่ — ไม่ให้ทับ nav */
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
border: 1px solid #ddd5c0;
|
||||
border-radius: 8px;
|
||||
background: #f7f1e2; /* --paper — พื้นตอน tile ยังไม่มา/ออฟไลน์ */
|
||||
overflow: hidden;
|
||||
}
|
||||
.at-map.is-offline { background: repeating-linear-gradient(45deg, #f7f1e2 0 12px, #f2ebd8 12px 24px); }
|
||||
.at-map .leaflet-container { background: transparent; font-family: inherit; }
|
||||
|
||||
/* ปุ่ม zoom — ให้เข้าธีม (ขอบบาง ไม่มีเงา) */
|
||||
.at-map .leaflet-control-zoom a {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd5c0;
|
||||
background: #fffdf6;
|
||||
color: #14211a;
|
||||
font-weight: 700;
|
||||
box-shadow: none;
|
||||
}
|
||||
.at-map .leaflet-control-zoom a:hover { background: #e4efe4; color: #14532d; }
|
||||
.at-map .leaflet-bar { border: 0; box-shadow: none; }
|
||||
|
||||
/* attribution — เล็ก อ่านได้ ไม่ทับข้อมูล */
|
||||
.at-map .leaflet-control-attribution {
|
||||
background: rgba(255, 253, 246, .88);
|
||||
border-top-left-radius: 4px;
|
||||
font-size: .68rem;
|
||||
color: #6b7268;
|
||||
}
|
||||
|
||||
/* ---------- หมุด: สี่เหลี่ยมมน (ไม่ใช่หยดน้ำ ไม่มีเงา) ---------- */
|
||||
.at-pin-wrap { background: none; border: 0; }
|
||||
.at-pin {
|
||||
display: block;
|
||||
width: 14px; height: 14px;
|
||||
border-radius: 4px;
|
||||
border: 2px solid #fffdf6;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.at-pin.stop { background: #1f7a3d; } /* --green-500 */
|
||||
.at-pin.term { background: #f2a900; } /* --amber */
|
||||
.at-pin.mute { background: #6b7268; } /* --muted */
|
||||
/* ป้ายที่กำลังเปิดดูอยู่ — ใหญ่กว่าเพื่อให้เห็นชัด */
|
||||
.at-pin.here { background: #f2a900; width: 18px; height: 18px; border-width: 3px; }
|
||||
/* จุดย่อย (จุดขึ้นรถประจำทางอื่นๆ) — สี่เหลี่ยมม่วง ต่างจากหมุดกลม */
|
||||
.at-pin.sub { background: #7a4cc0; border-radius: 2px; }
|
||||
|
||||
.at-map .leaflet-tooltip {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd5c0;
|
||||
background: #fffdf6;
|
||||
color: #14211a;
|
||||
box-shadow: none;
|
||||
font-size: .78rem;
|
||||
padding: 5px 8px;
|
||||
}
|
||||
.at-map .leaflet-tooltip b { color: #14532d; }
|
||||
|
||||
/* ---------- legend (มุมซ้ายล่าง) ---------- */
|
||||
.at-legend {
|
||||
position: absolute;
|
||||
left: 10px; bottom: 10px;
|
||||
z-index: 500;
|
||||
background: rgba(255, 253, 246, .94);
|
||||
border: 1px solid #ddd5c0;
|
||||
border-radius: 4px;
|
||||
padding: 7px 10px;
|
||||
font-size: .74rem;
|
||||
color: #14211a;
|
||||
line-height: 1.65;
|
||||
pointer-events: none;
|
||||
}
|
||||
.at-legend i {
|
||||
display: inline-block;
|
||||
width: 14px; height: 5px;
|
||||
border-radius: 2px;
|
||||
margin-right: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.at-legend i.sq { width: 10px; height: 10px; border-radius: 3px; border: 2px solid #fffdf6; box-sizing: border-box; }
|
||||
|
||||
/* ---------- caption ใต้แผนที่ ---------- */
|
||||
.at-map-caption {
|
||||
margin: 9px 0 0;
|
||||
color: #6b7268;
|
||||
font-size: .82rem;
|
||||
}
|
||||
.at-map-caption b { color: #14211a; }
|
||||
.at-map-caption .at-offline { color: #8a6100; }
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.at-map { height: 380px; }
|
||||
}
|
||||
|
||||
/* ---------- popup บนแผนที่ (ป้าย/สถานี) ---------- */
|
||||
.at-map .leaflet-popup-content-wrapper {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd5c0;
|
||||
background: #fffdf6;
|
||||
box-shadow: none;
|
||||
color: #14211a;
|
||||
}
|
||||
.at-map .leaflet-popup-tip { background: #fffdf6; box-shadow: none; }
|
||||
.at-map .leaflet-popup-content { margin: 10px 12px; font-size: .8rem; }
|
||||
.at-pop { display: flex; flex-direction: column; gap: 3px; min-width: 150px; }
|
||||
.at-pop b { font-size: .86rem; color: #14532d; }
|
||||
.at-pop span { color: #6b7268; }
|
||||
.at-pop a { margin-top: 4px; color: #14532d; font-weight: 700; text-decoration: none; border-bottom: 1px solid #1f7a3d; align-self: flex-start; }
|
||||
.at-pop a:hover { color: #1f7a3d; }
|
||||
|
||||
/* ---------- รายการจุดจอดตามเส้นทาง + กม. จากต้นทาง ---------- */
|
||||
.at-km-wrap { margin-top: 14px; border-top: 1px solid #ddd5c0; padding-top: 12px; }
|
||||
.at-km-wrap > h3 { margin: 0 0 8px; font-size: .9rem; font-weight: 800; color: #14211a; }
|
||||
.at-km-wrap ul { list-style: none; margin: 0; padding: 0; }
|
||||
.at-km-wrap li + li { border-top: 1px dashed #ddd5c0; }
|
||||
.at-km-row { display: flex; align-items: center; gap: 9px; padding: 7px 2px; text-decoration: none; color: #14211a; font-size: .86rem; }
|
||||
.at-km-row:hover .at-km-name { color: #1f7a3d; text-decoration: underline; }
|
||||
.at-km-dot { width: 9px; height: 9px; border-radius: 3px; background: #f2a900; flex: none; }
|
||||
.at-km-name { flex: 1; font-weight: 600; }
|
||||
.at-km-val { font-variant-numeric: tabular-nums; font-weight: 700; color: #14532d; }
|
||||
/* จุดจอดที่ไม่มีหน้ารายละเอียด (มาจาก 8 other_stop.json) — ไม่ใช่ลิงก์ */
|
||||
.at-km-row.is-plain { cursor: default; }
|
||||
.at-km-row.is-plain .at-km-dot { background: #7a4cc0; }
|
||||
.at-km-row.is-sub .at-km-dot { background: #7a4cc0; } /* จุดย่อย (จุดขึ้นรถอื่นๆ) — ม่วง ให้ตรงกับหมุดบนแผนที่ */
|
||||
.at-km-row.is-plain:hover .at-km-name { color: inherit; text-decoration: none; }
|
||||
.at-km-row .at-km-val.is-off { color: #a3560f; font-weight: 600; font-size: .78rem; }
|
||||
|
||||
/* ---------- ป้ายใกล้ฉัน ---------- */
|
||||
.at-near-msg { margin: 14px 0 0; color: #6b7268; font-size: .86rem; }
|
||||
.at-near-err { color: #8a6100; }
|
||||
.at-near-list { list-style: none; margin: 12px 0 0; padding: 0; }
|
||||
.at-near-list li + li { border-top: 1px dashed #ddd5c0; }
|
||||
.at-near-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 2px; text-decoration: none; color: #14211a; align-items: center; }
|
||||
.at-near-row:hover .at-near-name { color: #1f7a3d; text-decoration: underline; }
|
||||
.at-near-name { font-weight: 700; font-size: .9rem; }
|
||||
.at-near-meta { grid-column: 1; color: #6b7268; font-size: .76rem; }
|
||||
.at-near-dist { grid-column: 2; grid-row: 1 / span 2; font-variant-numeric: tabular-nums; font-weight: 800; color: #14532d; white-space: nowrap; }
|
||||
|
||||
/* ---------- กัน CSS ภายนอกทำลายขนาด SVG ของ Leaflet ----------
|
||||
responsive.css ตั้ง `img, svg, video { max-width: 100%; height: auto; }` และบาง partial
|
||||
เคยตั้ง `.mu-map-card svg { width: 100%; height: auto; }` → ทำให้ viewport SVG ของ Leaflet
|
||||
(ซึ่งถูกวางใน pane ขนาด 0x0) ยุบเป็น 0x0 แล้ว "เส้นทางไม่แสดง" ทั้งที่ถูกวาดแล้ว
|
||||
Leaflet กำหนดขนาดเองผ่าน attribute width/height เสมอ — ห้าม CSS อื่นทับ */
|
||||
.at-map svg.leaflet-zoom-animated,
|
||||
.at-map canvas.leaflet-zoom-animated {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: none;
|
||||
max-height: none;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/* Ported from about.html <style> block */
|
||||
/* ===== หน้าเกี่ยวกับเรา — เนื้อหาจาก partials/about-data/ (textN.json + picN) ===== */
|
||||
.mu-hero-lead {
|
||||
margin: 14px auto 0;
|
||||
max-width: 640px;
|
||||
color: #5b3b71;
|
||||
font-size: .95rem;
|
||||
}
|
||||
|
||||
.mu-about-wrap { padding: 30px 0 52px; }
|
||||
#about-blocks { display: flex; flex-direction: column; gap: 26px; }
|
||||
|
||||
.mu-about-block {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border: 1px solid #ebe8f4;
|
||||
border-radius: 18px;
|
||||
padding: 16px;
|
||||
box-shadow: 0 10px 26px rgba(63, 43, 94, .07);
|
||||
}
|
||||
.mu-about-block .mu-about-media { order: 2; }
|
||||
.mu-about-block .mu-about-media img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-height: 420px;
|
||||
object-fit: cover;
|
||||
border-radius: 14px;
|
||||
display: block;
|
||||
box-shadow: 0 10px 24px rgba(63, 43, 94, .14);
|
||||
}
|
||||
.mu-about-block h2 { margin: 0 0 10px; font-size: 1.2rem; color: #1f2a44; font-weight: 800; line-height: 1.35; }
|
||||
.mu-about-block p { margin: 0 0 10px; color: #4a5568; font-size: .95rem; line-height: 1.8; }
|
||||
.mu-about-block p:last-child { margin-bottom: 0; }
|
||||
|
||||
.mu-about-skeleton { color: #6f7b95; font-size: .9rem; text-align: center; padding: 18px 0; }
|
||||
.mu-about-skel-card { height: 180px; border-radius: 18px; background: linear-gradient(90deg, #f4f2fa 25%, #ece8f6 37%, #f4f2fa 63%); background-size: 400% 100%; animation: muSkel 1.4s ease infinite; }
|
||||
@keyframes muSkel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
|
||||
|
||||
/* แท็บเล็ต/เดสก์ท็อป: 2 คอลัมน์ + สลับข้าง (คี่ = ข้อความซ้าย, คู่ = รูปซ้าย) */
|
||||
@media (min-width: 768px) {
|
||||
.mu-about-block { grid-template-columns: 1.05fr .95fr; gap: 28px; padding: 24px 26px; }
|
||||
.mu-about-block .mu-about-media { order: 0; }
|
||||
.mu-about-block:nth-child(even) .mu-about-media { order: -1; }
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
/* Ported from blog.html <style> block */
|
||||
/* ===== หน้าบทความ — ข้อมูลจาก partials/blog-data/ (ระบบเดียวกับ about) ===== */
|
||||
.mu-hero-lead {
|
||||
margin: 14px auto 0;
|
||||
max-width: 640px;
|
||||
color: #5b3b71;
|
||||
font-size: .95rem;
|
||||
}
|
||||
|
||||
.mu-blog-wrap { padding: 26px 0 52px; }
|
||||
|
||||
/* --- แถบสลับมุมมอง (ตาราง / รายการ) --- */
|
||||
.mu-blog-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.mu-blog-count { margin: 0; color: #6f7b95; font-size: .88rem; }
|
||||
.mu-view-switch {
|
||||
margin-left: auto;
|
||||
display: inline-flex;
|
||||
gap: 2px;
|
||||
background: #f0edf7;
|
||||
border: 1px solid #e4dcf2;
|
||||
border-radius: 999px;
|
||||
padding: 3px;
|
||||
}
|
||||
.mu-view-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #6d28d9;
|
||||
font-family: inherit;
|
||||
font-weight: 700;
|
||||
font-size: .8rem;
|
||||
min-height: 36px;
|
||||
padding: 6px 14px;
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
transition: background .15s ease, color .15s ease;
|
||||
}
|
||||
.mu-view-btn .ic { width: 15px; height: 15px; }
|
||||
.mu-view-btn.active { background: #fff; color: #7a4cc0; box-shadow: 0 1px 4px rgba(63, 43, 94, .18); }
|
||||
.mu-view-btn:focus-visible { outline: 2px solid #7a4cc0; outline-offset: 2px; }
|
||||
|
||||
/* --- โหมดตาราง (grid) --- */
|
||||
#blog-list.mode-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 18px;
|
||||
}
|
||||
.mu-blog-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
border: 1px solid #ebe8f4;
|
||||
border-radius: 18px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 10px 26px rgba(63, 43, 94, .07);
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: transform .18s ease, box-shadow .18s ease;
|
||||
}
|
||||
.mu-blog-card:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(63, 43, 94, .14); }
|
||||
.mu-blog-card .mu-cover { aspect-ratio: 16 / 9; }
|
||||
.mu-blog-card .mu-cover.no-img { background: linear-gradient(135deg, #7a4cc0, #3071b8); }
|
||||
.mu-blog-card .mu-cover.no-img::after { background: linear-gradient(180deg, rgba(15,23,42,0) 40%, rgba(15,23,42,.4) 100%); }
|
||||
.mu-blog-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
|
||||
.mu-blog-meta { display: flex; align-items: center; gap: 8px; color: #6f7b95; font-size: .78rem; }
|
||||
.mu-blog-meta time { font-variant-numeric: tabular-nums; }
|
||||
.mu-blog-card h2 { margin: 0; font-size: 1.02rem; color: #1f2a44; font-weight: 800; line-height: 1.4; }
|
||||
.mu-blog-excerpt { margin: 0; color: #4a5568; font-size: .88rem; line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
.mu-blog-more { margin-top: auto; padding-top: 6px; color: #7a4cc0; font-weight: 700; font-size: .85rem; }
|
||||
|
||||
/* --- โหมดรายการ (list) --- */
|
||||
#blog-list.mode-list { display: flex; flex-direction: column; gap: 14px; }
|
||||
.mu-blog-row {
|
||||
display: grid;
|
||||
grid-template-columns: 108px 1fr;
|
||||
gap: 14px;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border: 1px solid #ebe8f4;
|
||||
border-radius: 16px;
|
||||
padding: 12px;
|
||||
box-shadow: 0 8px 20px rgba(63, 43, 94, .06);
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: border-color .15s ease, box-shadow .15s ease;
|
||||
}
|
||||
.mu-blog-row:hover { border-color: #d8c9f2; box-shadow: 0 12px 26px rgba(63, 43, 94, .12); }
|
||||
.mu-blog-row .thumb {
|
||||
width: 108px; height: 84px;
|
||||
border-radius: 12px;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
background: linear-gradient(135deg, #7a4cc0, #3071b8);
|
||||
}
|
||||
.mu-blog-row h2 { margin: 4px 0 6px; font-size: .98rem; color: #1f2a44; font-weight: 800; line-height: 1.4; }
|
||||
.mu-blog-row .mu-blog-excerpt { -webkit-line-clamp: 2; }
|
||||
.mu-blog-empty { color: #6f7b95; text-align: center; padding: 34px 0; }
|
||||
.mu-blog-skel { height: 220px; border-radius: 18px; background: linear-gradient(90deg, #f4f2fa 25%, #ece8f6 37%, #f4f2fa 63%); background-size: 400% 100%; animation: muSkelB 1.4s ease infinite; }
|
||||
@keyframes muSkelB { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
|
||||
|
||||
/* --- หน้าอ่านบทความ --- */
|
||||
.mu-post { background: #fff; border: 1px solid #ebe8f4; border-radius: 20px; overflow: hidden; box-shadow: 0 12px 30px rgba(63, 43, 94, .08); }
|
||||
.mu-post .mu-cover { aspect-ratio: 16 / 8; }
|
||||
|
||||
/* --- แผนที่เส้นทางแทนรูปปก (textN.json → "map") --- */
|
||||
.mu-post .mu-cover.is-map { aspect-ratio: auto; height: 280px; position: relative; }
|
||||
.mu-post .mu-cover.is-map .at-map { height: 100%; border: 0; border-radius: 0; }
|
||||
.mu-cover.is-map .at-map.is-static { pointer-events: none; } /* ปิดซูม/ลาก */
|
||||
.mu-cover-cap {
|
||||
position: absolute; left: 0; right: 0; bottom: 0; z-index: 500;
|
||||
padding: 8px 12px; color: #fff; font-size: .8rem; line-height: 1.4;
|
||||
background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, .62));
|
||||
}
|
||||
/* --- แผนที่ "เส้นทางที่เสนอ" (ความฝัน) + รายการคลิกได้ + แผงรายละเอียด --- */
|
||||
/* isolation:isolate — กัก z-index ของ Leaflet (400–1000) ไว้ในกรอบแผนที่
|
||||
ไม่ให้ปุ่มซูม/ป๊อปอัปทะลุขึ้นไปทับ nav (z-index 1100) */
|
||||
.blog-mapx { margin: 0 0 16px; position: relative; isolation: isolate; }
|
||||
/* ป้ายหมวดบนแผนที่ (มุมขวาบน — หลบปุ่มซูมของ Leaflet ที่มุมซ้ายบน) */
|
||||
.blog-mapx-tag {
|
||||
position: absolute; top: 12px; right: 12px; z-index: 500;
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
padding: 5px 10px; border-radius: 999px;
|
||||
font-size: .72rem; font-weight: 800; letter-spacing: .02em;
|
||||
background: rgba(255, 255, 255, .92); color: #1f2a44;
|
||||
backdrop-filter: blur(8px);
|
||||
box-shadow: 0 4px 10px rgba(15, 23, 42, .15);
|
||||
pointer-events: none;
|
||||
}
|
||||
.blog-mapx-map { height: 280px; border-radius: 16px; }
|
||||
.blog-mapx-legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
|
||||
.blog-mapx-group {
|
||||
margin: 10px 0 2px; font-size: .78rem; font-weight: 700; letter-spacing: .01em;
|
||||
color: #7a4cc0; list-style: none;
|
||||
}
|
||||
.blog-mapx-group:first-child { margin-top: 0; }
|
||||
.blog-mapx-group::before { content: ''; display: inline-block; width: 14px; height: 2px;
|
||||
background: #cbb8e8; vertical-align: middle; margin-right: 8px; border-radius: 2px; }
|
||||
.blog-mapx-row {
|
||||
display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
|
||||
padding: 9px 11px; border: 1px solid #e8e4f2; border-radius: 12px;
|
||||
background: #fff; cursor: pointer; font-size: .88rem; color: #3d4a63;
|
||||
}
|
||||
.blog-mapx-row:hover { border-color: #cbb8e8; background: #faf8ff; }
|
||||
.blog-mapx-row.is-on { border-color: #7a4cc0; background: #f6f2ff; }
|
||||
.blog-mapx-row:focus-visible { outline: 2px solid #7a4cc0; outline-offset: 1px; }
|
||||
.blog-mapx-sw { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
|
||||
.blog-mapx-nm { font-weight: 700; color: #1f2a44; }
|
||||
.blog-mapx-ds { color: #6b7a94; }
|
||||
.blog-mapx-ds::before { content: '\00b7'; margin-right: 6px; color: #c9c2dc; }
|
||||
.blog-mapx-badge {
|
||||
margin-left: auto; font-size: .72rem; padding: 2px 8px; border-radius: 999px;
|
||||
background: #fdf4e3; color: #8a6100; border: 1px solid #f0dfb8;
|
||||
}
|
||||
.blog-mapx-panel { margin-top: 10px; padding: 12px 14px; border: 1px solid #e8e4f2; border-radius: 14px; background: #fbfaff; }
|
||||
.blog-mapx-panel[hidden] { display: none; }
|
||||
.blog-mapx-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
|
||||
.blog-mapx-head strong { color: #1f2a44; font-size: .95rem; }
|
||||
.blog-mapx-line { margin: 4px 0; font-size: .85rem; color: #6b7a94; }
|
||||
.blog-mapx-line span::after { content: ':'; margin-right: 6px; }
|
||||
.blog-mapx-line b { color: #1f2a44; font-weight: 600; }
|
||||
.blog-mapx-facts { margin: 8px 0 0; font-size: .82rem; color: #7a4cc0; font-weight: 700; }
|
||||
.blog-mapx-hint { margin: 8px 0 0; font-size: .8rem; color: #8b93a7; }
|
||||
.blog-mapx-src { margin: 0 0 14px; font-size: .78rem; color: #8b93a7; word-break: break-all; }
|
||||
.at-tip-org { background: #1f2a44; color: #fff; border: 0; font-weight: 700; }
|
||||
@media (min-width: 768px) { .blog-mapx-map { height: 380px; } }
|
||||
|
||||
.mu-cover-note {
|
||||
position: absolute; left: 12px; bottom: 12px; z-index: 500;
|
||||
padding: 4px 10px; border-radius: 999px; font-size: .78rem;
|
||||
background: rgba(255, 255, 255, .9); color: #8a6100; border: 1px solid #f0d9a8;
|
||||
}
|
||||
.mu-post-body { padding: 20px 18px 26px; }
|
||||
.mu-post-body h1 { margin: 6px 0 12px; font-size: 1.35rem; color: #1f2a44; font-weight: 800; line-height: 1.4; }
|
||||
/* ย่อหน้า: เว้นระยะ 20px + ย่อหน้าหน้าบรรทัด 1.5em (แบบหนังสือไทย) */
|
||||
.mu-post-body p { margin: 0 0 20px; color: #4a5568; font-size: .96rem; line-height: 1.9; text-indent: 1.5em; }
|
||||
.mu-post-body p:last-child { margin-bottom: 0; }
|
||||
/* ย่อหน้าที่เป็นรูป/บรรทัดข้อมูลไม่ต้องย่อหน้า */
|
||||
.mu-post-body p.mu-post-figure, .mu-post-figure, .mu-post-body p:empty { text-indent: 0; }
|
||||
/* มาร์กดาวน์เบา ๆ ในเนื้อหา (จาก textN.json) */
|
||||
.mu-post-body strong { color: #1f2a44; font-weight: 800; }
|
||||
.mu-post-body em { font-style: italic; }
|
||||
.mu-post-body a { color: #7a4cc0; font-weight: 700; text-decoration: none; border-bottom: 1px solid #d9cbf3; }
|
||||
.mu-post-body a:hover { border-bottom-color: #7a4cc0; }
|
||||
.mu-post-body code { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .88em;
|
||||
background: #f4f1fb; border: 1px solid #e7e0f6; border-radius: 4px; padding: 1px 5px; color: #5b4a80; }
|
||||
.mu-post-body ul { margin: 0 0 20px; padding-left: 20px; }
|
||||
.mu-post-body li { color: #4a5568; font-size: .96rem; line-height: 1.9; margin-bottom: 4px; }
|
||||
.mu-post-figure { margin: 4px 0 16px; }
|
||||
.mu-post-figure img { width: 100%; height: auto; border-radius: 10px; border: 1px solid #e7e0f6; display: block; }
|
||||
.mu-post-figure figcaption { margin-top: 6px; color: #6f7b95; font-size: .82rem; text-align: center; }
|
||||
.mu-post-back {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
margin-bottom: 16px; color: #7a4cc0; font-weight: 700;
|
||||
text-decoration: none; font-size: .9rem;
|
||||
}
|
||||
.mu-post-back:hover { text-decoration: underline; }
|
||||
|
||||
/* แท็บเล็ตขึ้นไป: การ์ด 2 คอลัมน์ → 3 คอลัมน์ */
|
||||
@media (min-width: 768px) {
|
||||
.mu-post .mu-cover.is-map { height: 380px; }
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
#blog-list.mode-grid { grid-template-columns: repeat(2, 1fr); }
|
||||
}
|
||||
@media (min-width: 1024px) {
|
||||
#blog-list.mode-grid { grid-template-columns: repeat(3, 1fr); }
|
||||
.mu-post-body { padding: 26px 30px 34px; }
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/* Ported from checkSchedule.html <style> block */
|
||||
/* ============================================================
|
||||
checkSchedule (#/check) — redesign ให้ใช้ภาษาดีไซน์เดียวกับหน้าแรก
|
||||
------------------------------------------------------------
|
||||
hero / selector / summary / zone ใช้ class จาก index.html shell
|
||||
(ประกาศใน <head> แล้ว) → ไม่ต้องนิยามใหม่
|
||||
เฉพาะส่วนเฉพาะหน้า (lead + schedule cards) ค่อยเติมตรงนี้
|
||||
============================================================ */
|
||||
|
||||
.mu-hero-lead {
|
||||
margin: 14px auto 0;
|
||||
max-width: 640px;
|
||||
color: #5b3b71;
|
||||
font-size: .95rem;
|
||||
}
|
||||
|
||||
.mu-summary-grid { gap: 14px; }
|
||||
|
||||
/* --- ตารางเวลา: การ์ดสไตล์ index (gradient header + เนื้อขาว) --- */
|
||||
.mu-schedule-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
.mu-stop-card {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 14px rgba(20, 40, 90, .06);
|
||||
transition: transform .15s ease, box-shadow .15s ease;
|
||||
}
|
||||
.mu-stop-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 10px 24px rgba(20, 40, 90, .1);
|
||||
}
|
||||
.mu-stop-card summary { list-style: none; cursor: pointer; }
|
||||
.mu-stop-card summary::-webkit-details-marker { display: none; }
|
||||
|
||||
/* header การ์ด = gradient block ตามโทนสีเดียวกับ index zone tints */
|
||||
.mu-stop-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
color: #fff;
|
||||
}
|
||||
.mu-stop-head.tone-purple { background: linear-gradient(135deg, #7a4cc0 0%, #b07ce0 100%); }
|
||||
.mu-stop-head.tone-sky { background: linear-gradient(135deg, #3071b8 0%, #6ea7e8 100%); }
|
||||
.mu-stop-head.tone-mint { background: linear-gradient(135deg, #1f8765 0%, #51c39c 100%); }
|
||||
.mu-stop-head.tone-pink { background: linear-gradient(135deg, #bb3a78 0%, #f08bb9 100%); }
|
||||
|
||||
.mu-stop-kind {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 5px 12px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, .24);
|
||||
font-size: .74rem;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.mu-stop-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
||||
.mu-stop-title strong { font-size: 1rem; font-weight: 800; }
|
||||
.mu-stop-title small { font-size: .78rem; opacity: .85; }
|
||||
.mu-stop-chevron { font-size: 1.2rem; opacity: .9; transition: transform .2s ease; }
|
||||
.mu-stop-card[open] > summary .mu-stop-chevron { transform: rotate(180deg); }
|
||||
|
||||
.mu-stop-body { padding: 16px; }
|
||||
.mu-stop-sub { font-weight: 700; color: #1f2a44; margin: 0 0 10px; font-size: .9rem; }
|
||||
.mu-direction-tag {
|
||||
background: #7a4cc0;
|
||||
color: #fff;
|
||||
border-radius: 999px;
|
||||
padding: 3px 10px;
|
||||
font-size: .72rem;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.mu-time-grid { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.mu-time-chip {
|
||||
padding: 6px 12px;
|
||||
border-radius: 10px;
|
||||
background: #f1f4fb;
|
||||
color: #2b2f42;
|
||||
font-weight: 700;
|
||||
font-size: .85rem;
|
||||
border: 1px solid #e6eaf3;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.mu-time-chip.next {
|
||||
background: linear-gradient(135deg, #a855f7, #7c3aed);
|
||||
color: #fff;
|
||||
border-color: transparent;
|
||||
box-shadow: 0 4px 10px rgba(124, 58, 237, .25);
|
||||
}
|
||||
|
||||
.mu-schedule-note {
|
||||
color: #9a3b6e;
|
||||
font-size: .82rem;
|
||||
margin: 12px 0 0;
|
||||
padding: 8px 12px;
|
||||
background: #fff5f9;
|
||||
border-left: 3px solid #bb3a78;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.mu-inline-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
|
||||
|
||||
.mu-schedule { padding: 4px 0 48px; }
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.mu-summary-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/* Ported from credits.html <style> block */
|
||||
.mu-page { background: linear-gradient(180deg, #fcfbff 0%, #f5f9ff 100%); }
|
||||
.mu-credit-wrap { max-width: 46rem; margin: 0 auto; padding: 40px 28px 56px; }
|
||||
.mu-credit-hero { margin-bottom: 28px; }
|
||||
.mu-credit-hero h1 { margin: 0 0 8px; font-size: 1.9rem; color: #1f2a44; }
|
||||
.mu-credit-hero p { margin: 0; color: #66728f; }
|
||||
.mu-credit-section {
|
||||
background: #fff; border: 1px solid #e7e0f6; border-radius: 16px;
|
||||
padding: 20px 22px; margin-bottom: 16px;
|
||||
}
|
||||
.mu-credit-section h2 { margin: 0 0 6px; font-size: 1.05rem; color: #1f2a44; }
|
||||
.mu-credit-section .src { margin: 0 0 12px; color: #6f7b95; font-size: .85rem; }
|
||||
.mu-credit-section ul { margin: 0; padding-left: 1.2rem; color: #3a4462; font-size: .92rem; line-height: 1.7; }
|
||||
.mu-credit-section code { background: #f5eeff; color: #7a4cc0; padding: 1px 6px; border-radius: 6px; font-size: .85em; }
|
||||
.mu-credit-section a { color: #7a4cc0; }
|
||||
.mu-license { margin: 14px 0 0; padding: 12px 14px; background: #f9f7ff; border-left: 3px solid #7a4cc0; border-radius: 8px; font-size: .85rem; color: #4a5573; line-height: 1.6; }
|
||||
@@ -0,0 +1,21 @@
|
||||
/* Ported from home.html <style> block */
|
||||
/* ปุ่มแชร์ลิงก์สั้น — มุมล่างขวา ต่อจากการ์ดหมวดเส้นทาง */
|
||||
.mu-share-row { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin: 22px 0 44px; }
|
||||
.mu-share-btn {
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
padding: 10px 16px; border: 1px solid #7a4cc0; border-radius: 8px;
|
||||
background: #7a4cc0; color: #fff; font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer;
|
||||
}
|
||||
.mu-share-btn:hover { background: #6a3cae; }
|
||||
.mu-share-btn:focus-visible { outline: 2px solid #2b2f42; outline-offset: 2px; }
|
||||
.mu-share-btn .ic { width: 18px; height: 18px; }
|
||||
.mu-share-status { margin: 0; font-size: .82rem; line-height: 1.7; color: #4b5570; text-align: right; }
|
||||
.mu-share-status:empty { display: none; }
|
||||
.mu-share-url { display: inline-block; padding: 2px 6px; border: 1px solid #e7e2f6; border-radius: 8px; background: #faf9ff; font-size: .8rem; }
|
||||
.mu-share-line { display: inline-block; margin-left: 6px; font-weight: 700; color: #06c755; text-decoration: none; }
|
||||
.mu-share-line:hover { text-decoration: underline; }
|
||||
@media (max-width: 560px) {
|
||||
.mu-share-row { align-items: stretch; }
|
||||
.mu-share-btn { justify-content: center; }
|
||||
.mu-share-status { text-align: left; }
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/* Ported from busDetail.html <style> block */
|
||||
/* ============================================================
|
||||
busDetail (#/routes, #/routes/:id) — หน้ารายละเอียดสายรถ
|
||||
รถประจำสาย + ติดต่อผู้ประกอบการ รวมอยู่ในการ์ดเดียว (ขึ้นก่อน)
|
||||
============================================================ */
|
||||
|
||||
.mu-page { padding: 20px 0 48px; }
|
||||
|
||||
/* --- header --- */
|
||||
.mu-breadcrumb { color: #6f7b95; font-size: .88rem; margin: 0 0 12px; }
|
||||
.mu-breadcrumb a { color: #7a4cc0; text-decoration: none; font-weight: 600; }
|
||||
.mu-page-title {
|
||||
display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
|
||||
margin: 0 0 16px; font-size: 1.6rem; color: #1f2a44; font-weight: 800; line-height: 1.25;
|
||||
}
|
||||
.mu-route-chip {
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
min-width: 54px; height: 54px; padding: 0 16px; border-radius: 14px;
|
||||
background: linear-gradient(135deg, #7a4cc0, #b07ce0); color: #fff;
|
||||
font-weight: 800; font-size: 1.35rem; flex: none;
|
||||
box-shadow: 0 6px 14px rgba(122, 76, 192, .25);
|
||||
}
|
||||
/* สีพื้นหลังของเลขสาย เปลี่ยนตามหมวดเส้นทาง (route_groups.json)
|
||||
น้ำเงิน = เข้ากรุงเทพฯ · ม่วง = ระหว่างจังหวัด · ชมพู = ภายในจังหวัด · เทา = หมวดอื่น/ไม่ระบุ */
|
||||
.mu-route-chip.grp-bangkok { background: linear-gradient(135deg, #1a53a8, #3f82d8); box-shadow: 0 6px 14px rgba(31, 95, 191, .25); }
|
||||
.mu-route-chip.grp-interprovincial { background: linear-gradient(135deg, #7a4cc0, #b07ce0); box-shadow: 0 6px 14px rgba(122, 76, 192, .25); }
|
||||
.mu-route-chip.grp-in_province { background: linear-gradient(135deg, #c02c7d, #e86aae); box-shadow: 0 6px 14px rgba(214, 56, 143, .25); }
|
||||
.mu-route-chip.grp-municipal { background: linear-gradient(135deg, #5b6560, #8b948f); box-shadow: 0 6px 14px rgba(107, 114, 104, .25); }
|
||||
.mu-toolbar {
|
||||
display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
|
||||
background: #fff; border: 1px solid #e7e2f6; border-radius: 14px;
|
||||
padding: 12px; margin-bottom: 22px;
|
||||
box-shadow: 0 8px 20px rgba(63, 43, 94, .06);
|
||||
}
|
||||
.mu-toolbar select {
|
||||
flex: 1; min-width: 180px; min-height: 46px;
|
||||
border: 1px solid #dfe6f1; background: linear-gradient(180deg, #fff, #f8fbff);
|
||||
border-radius: 10px; padding: 0 12px; font-family: inherit; font-size: .95rem; color: #1f2a44;
|
||||
}
|
||||
|
||||
/* --- รถประจำสาย + ติดต่อ (การ์ดเดียว ขึ้นก่อน) --- */
|
||||
.mu-vehicle-card {
|
||||
background: #fff;
|
||||
border: 1px solid #e7e2f6;
|
||||
border-radius: 18px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 14px rgba(20, 40, 90, .06);
|
||||
display: grid;
|
||||
grid-template-columns: 1.3fr 1fr;
|
||||
margin-bottom: 26px;
|
||||
}
|
||||
/* ไม่มีรูปรถใน .image/routes/<รหัส>/ → การ์ดไม่เว้นช่องว่าง */
|
||||
#route-vehicle-card.no-photo { grid-template-columns: 1fr; }
|
||||
#route-vehicle-card.no-photo > .meta { grid-column: 1 / -1; }
|
||||
.mu-vehicle-card > img {
|
||||
grid-column: 1; width: 100%; height: 100%; min-height: 240px;
|
||||
object-fit: cover; display: block;
|
||||
}
|
||||
.mu-vehicle-card > .meta {
|
||||
grid-column: 2; padding: 24px;
|
||||
display: flex; flex-direction: column; justify-content: center; gap: 8px;
|
||||
}
|
||||
.mu-vehicle-card .meta .label {
|
||||
margin: 0; font-size: .78rem; font-weight: 700; color: #7a4cc0;
|
||||
text-transform: uppercase; letter-spacing: .05em;
|
||||
}
|
||||
.mu-vehicle-card .meta h2 { margin: 0; font-size: 1.25rem; color: #1f2a44; }
|
||||
.mu-vehicle-card .meta p { margin: 0; color: #6f7b95; font-size: .95rem; line-height: 1.6; }
|
||||
|
||||
/* ติดต่อผู้ประกอบการ — อยู่ใน footer ของการ์ด */
|
||||
.mu-vehicle-contact {
|
||||
grid-column: 1 / -1;
|
||||
display: flex; flex-wrap: wrap; gap: 10px;
|
||||
padding: 14px 18px;
|
||||
border-top: 1px solid #f0ecf8;
|
||||
background: #faf9ff;
|
||||
}
|
||||
.mu-contact-item {
|
||||
flex: 1; min-width: 220px;
|
||||
display: flex; align-items: center; gap: 12px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 12px;
|
||||
background: #fff; border: 1px solid #eee;
|
||||
text-decoration: none; color: inherit;
|
||||
transition: transform .15s ease, box-shadow .15s ease;
|
||||
}
|
||||
a.mu-contact-item:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(20,40,90,.08); }
|
||||
.mu-contact-item .ic-wrap {
|
||||
width: 42px; height: 42px; flex: none;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, #7a4cc0, #b07ce0); color: #fff;
|
||||
}
|
||||
.mu-contact-item .ic-wrap.tone-green { background: linear-gradient(135deg, #1f8765, #51c39c); }
|
||||
.mu-contact-item .ic-wrap.tone-sky { background: linear-gradient(135deg, #1877f2, #4a9bf8); }
|
||||
.mu-contact-item .ic-wrap.tone-purple { background: linear-gradient(135deg, #7a4cc0, #a583e0); }
|
||||
.mu-contact-item .mu-link-go { flex: 0 0 auto; display: flex; align-items: center; color: #7a4cc0; opacity: .8; }
|
||||
.mu-contact-item:hover .mu-link-go { opacity: 1; transform: translateX(2px); }
|
||||
.mu-contact-item .ic-wrap svg { width: 22px; height: 22px; }
|
||||
.mu-contact-item .txt { flex: 1; min-width: 0; }
|
||||
.mu-contact-item .txt strong { display: block; color: #1f2a44; font-size: .98rem; margin-bottom: 2px; }
|
||||
.mu-contact-item .txt span { display: block; color: #6f7b95; font-size: .86rem; }
|
||||
.mu-qr-img {
|
||||
width: 72px; height: 72px; flex: none; display: block;
|
||||
object-fit: contain; background: #fff;
|
||||
border-radius: 10px; padding: 4px; border: 1px solid #eee;
|
||||
}
|
||||
/* ปุ่มครอบ QR — กดเพื่อขยาย (ไม่ให้หน้าตาเปลี่ยน) */
|
||||
.mu-qr-btn { flex: none; padding: 0; border: 0; background: none; cursor: zoom-in;
|
||||
border-radius: 10px; line-height: 0; }
|
||||
.mu-qr-btn:focus-visible { outline: 2px solid #7a4cc0; outline-offset: 2px; }
|
||||
.mu-qr-btn:hover .mu-qr-img { border-color: #c9b6ec; }
|
||||
|
||||
/* --- ขยาย QR ลอยกลางจอ --- */
|
||||
.mu-qr-modal { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; }
|
||||
.mu-qr-modal::backdrop { background: rgba(20, 28, 48, .55); }
|
||||
.mu-qr-modal-card {
|
||||
position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px;
|
||||
padding: 22px 22px 18px; border-radius: 14px; background: #fff; border: 1px solid #e7e2f6;
|
||||
max-width: min(92vw, 360px);
|
||||
}
|
||||
.mu-qr-modal-card strong { color: #1f2a44; font-size: 1.02rem; text-align: center; }
|
||||
.mu-qr-big { width: min(72vw, 260px); height: auto; border-radius: 10px; background: #fff; }
|
||||
.mu-qr-close {
|
||||
position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; padding: 0;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
border: 0; border-radius: 10px; background: #f4f1fb; color: #5b4a80; cursor: pointer;
|
||||
}
|
||||
.mu-qr-close:hover { background: #e9e2f8; }
|
||||
.mu-qr-close svg { width: 18px; height: 18px; }
|
||||
.mu-qr-modal-card .mu-btn { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.mu-qr-modal-card .mu-btn .ic { width: 16px; height: 16px; }
|
||||
/* กดรูป QR = เปิดลิงก์ (ทั้งใบ กดได้) */
|
||||
.mu-qr-link { display: block; line-height: 0; border-radius: 10px; }
|
||||
.mu-qr-link:focus-visible { outline: 2px solid #7a4cc0; outline-offset: 3px; }
|
||||
.mu-qr-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
|
||||
.mu-copy-link.is-done { border-color: #1f8765; color: #1f8765; }
|
||||
|
||||
/* --- แผนที่ --- */
|
||||
.mu-map-card {
|
||||
background: #fff;
|
||||
border: 1px solid #e7e2f6;
|
||||
border-radius: 16px;
|
||||
padding: 16px;
|
||||
box-shadow: 0 4px 14px rgba(20, 40, 90, .06);
|
||||
}
|
||||
/* (ตัดกฎ .mu-map-card svg เดิมออก — แผนที่ SVG นิ่งถูกแทนด้วย Leaflet
|
||||
และกฎนี้ทำให้ SVG ของ Leaflet ยุบเป็น 0x0 จนเส้นทางไม่แสดง) */
|
||||
|
||||
.mu-summary-grid { gap: 14px; }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.mu-page-title { font-size: 1.4rem; }
|
||||
.mu-summary-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
|
||||
.mu-vehicle-card { grid-template-columns: 1fr; }
|
||||
.mu-vehicle-card > img { grid-column: 1; min-height: 200px; }
|
||||
.mu-vehicle-card > .meta { grid-column: 1; padding: 18px; }
|
||||
.mu-vehicle-contact { grid-column: 1; flex-direction: column; }
|
||||
.mu-contact-item { min-width: 0; }
|
||||
}
|
||||
@@ -0,0 +1,413 @@
|
||||
/* Ported from stopDetail.html <style> block */
|
||||
.mu-other-stops { margin: 16px 0 6px; }
|
||||
.mu-other-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
|
||||
.mu-other-item { display: block; padding: 10px 12px; background: #fff;
|
||||
border: 1px solid #eef0f6; border-radius: 12px; min-width: 0; }
|
||||
.mu-other-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
||||
.mu-other-item .mu-time-grid { margin-top: 8px; }
|
||||
.mu-other-item .mu-est-note { margin-top: 4px; }
|
||||
.mu-other-idx { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; background: #f1e9ff;
|
||||
color: #7a4cc0; font-size: .78rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
|
||||
.mu-other-txt { flex: 1; min-width: 0; }
|
||||
.mu-other-txt strong { display: block; color: #1f2a44; font-size: .94rem; }
|
||||
.mu-other-txt span { display: block; color: #6f7b95; font-size: .8rem; }
|
||||
.mu-other-item .mu-chip { flex: 0 0 auto; font-family: ui-monospace, Consolas, monospace; font-size: .72rem; }
|
||||
.mu-other-item .mu-chip.warn { background: #fff5e6; color: #9a6b00; border-color: #f2d9a8; }
|
||||
:root {
|
||||
--mu-accent: #7a4cc0;
|
||||
--mu-accent-soft: #f3eafe;
|
||||
--mu-ink: #1f2a44;
|
||||
--mu-muted: #6f7b95;
|
||||
--mu-border: #ecd7e6;
|
||||
--mu-surface: #ffffff;
|
||||
--mu-rose: #ec4899;
|
||||
--mu-sky: #3071b8;
|
||||
--mu-mint: #1f8765;
|
||||
}
|
||||
.mu-page {
|
||||
background:
|
||||
radial-gradient(circle at 8% 10%, rgba(122, 76, 192, 0.09), transparent 30%),
|
||||
radial-gradient(circle at 100% 0%, rgba(48, 113, 184, 0.10), transparent 28%),
|
||||
linear-gradient(180deg, #fcfbff 0%, #f8f9ff 100%);
|
||||
}
|
||||
.mu-stop-hero {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(231, 224, 246, 0.95);
|
||||
border-radius: 22px;
|
||||
background: linear-gradient(135deg, #f8f4ff 0%, #f2f6ff 45%, #eefaf5 100%);
|
||||
box-shadow: 0 16px 34px rgba(122, 76, 192, 0.12);
|
||||
padding: 18px;
|
||||
margin-bottom: 14px;
|
||||
display: grid;
|
||||
grid-template-columns: 1.2fr .8fr;
|
||||
gap: 16px;
|
||||
align-items: stretch;
|
||||
}
|
||||
.mu-stop-hero::before,
|
||||
.mu-stop-hero::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
border-radius: 999px;
|
||||
pointer-events: none;
|
||||
opacity: .48;
|
||||
}
|
||||
.mu-stop-hero::before {
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
top: -120px;
|
||||
right: -70px;
|
||||
background: radial-gradient(circle, #f472b6 0%, rgba(244, 114, 182, 0) 72%);
|
||||
}
|
||||
.mu-stop-hero::after {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
left: -70px;
|
||||
bottom: -115px;
|
||||
background: radial-gradient(circle, #60a5fa 0%, rgba(96, 165, 250, 0) 72%);
|
||||
}
|
||||
.mu-stop-hero > * {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
min-width: 0; /* กัน grid track บวมตาม min-content (ไม่งั้นเนื้อหาถูก overflow:hidden ตัดที่จอแคบ) */
|
||||
}
|
||||
.mu-stop-hero-title {
|
||||
overflow-wrap: anywhere;
|
||||
margin: 0;
|
||||
font-size: 1.72rem;
|
||||
color: var(--mu-ink);
|
||||
line-height: 1.2;
|
||||
}
|
||||
.mu-stop-hero-sub {
|
||||
margin: 8px 0 0;
|
||||
color: var(--mu-muted);
|
||||
font-size: .9rem;
|
||||
}
|
||||
.mu-meta-row { display:flex; flex-wrap:wrap; gap:8px; margin: 12px 0 0; }
|
||||
.mu-meta-pill { max-width: 100%; overflow-wrap: anywhere; background:linear-gradient(135deg, #ffffff, #f7f9ff); border:1px solid rgba(231, 224, 246, 0.9); color:#5b3b71; padding:6px 14px; border-radius:999px; font-size:.85rem; font-weight:600; box-shadow: 0 4px 10px rgba(122, 76, 192, 0.08); }
|
||||
.mu-meta-pill.purple { background:linear-gradient(135deg, #f5eeff, #fce7f3); color:#7a4cc0; border-color:#e8d9f0; }
|
||||
.mu-meta-pill.sky { background:linear-gradient(135deg, #ebf5ff, #eff6ff); color:#3071b8; border-color:#d7e7fb; }
|
||||
.mu-meta-pill.mint { background:linear-gradient(135deg, #eafaf4, #ecfeff); color:#1f8765; border-color:#d1efdf; }
|
||||
.mu-direction-tag { background:#7a4cc0; color:#fff; border-radius:999px; padding:2px 10px; font-size:.78rem; margin-left:8px; }
|
||||
.mu-schedule-note { color:#9a3b6e; font-size:.8rem; margin-top:8px; padding:8px 12px; background:#fff5f9; border-left:3px solid #bb3a78; border-radius:4px; }
|
||||
.mu-hero-metric-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.mu-hero-metric {
|
||||
border: 1px solid rgba(231, 224, 246, 0.9);
|
||||
border-radius: 12px;
|
||||
padding: 10px;
|
||||
background: #fff;
|
||||
box-shadow: 0 6px 14px rgba(122, 76, 192, 0.08);
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.mu-hero-metric:nth-child(1) { background: linear-gradient(135deg, #f5efff, #fdf2f8); }
|
||||
.mu-hero-metric:nth-child(2) { background: linear-gradient(135deg, #ecfeff, #eef6ff); }
|
||||
.mu-hero-metric:nth-child(3) { background: linear-gradient(135deg, #fff1f2, #fff7ed); }
|
||||
.mu-hero-metric:nth-child(4) { background: linear-gradient(135deg, #ecfdf5, #f0fdfa); }
|
||||
.mu-hero-metric-label {
|
||||
margin: 0;
|
||||
color: var(--mu-muted);
|
||||
font-size: .76rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .03em;
|
||||
}
|
||||
.mu-hero-metric-value {
|
||||
margin: 4px 0 0;
|
||||
color: var(--mu-ink);
|
||||
font-size: 1.06rem;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.mu-stop-summary-main { order: 2; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
|
||||
.mu-stop-summary-main strong { font-size: .95rem; line-height: 1.3; }
|
||||
.mu-stop-summary-main .mu-stop-summary-meta { color: #6f7b95; font-size: .78rem; }
|
||||
.mu-route-type-badge { display: inline-flex; align-items: center; gap: 5px; order: 3; flex: none; background: linear-gradient(135deg, #f5eeff, #fce7f3); color: #7a4cc0; padding: 4px 8px; border-radius: 8px; font-size: .8rem; font-weight: 700; border: 1px solid #e8d9f0; white-space: nowrap; }
|
||||
.mu-stop-summary-rail { order: 4; flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
|
||||
.mu-route-chip { display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 38px; padding: 5px 9px; border-radius: 8px; background: linear-gradient(135deg, #7a4cc0, #b07ce0); color: #fff; font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 700; font-size: .92rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
|
||||
.mu-stop-chevron { display: inline-block; color: #7a4cc0; font-size: .9rem; line-height: 1; transition: transform .2s ease; }
|
||||
.mu-stop-expander[open] .mu-stop-chevron { transform: rotate(180deg); }
|
||||
.mu-live-clock-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
margin: 6px 0 14px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid rgba(240, 191, 224, 0.9);
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(135deg, #ffe8f4 0%, #f5f0ff 50%, #e8f7ff 100%);
|
||||
box-shadow: 0 8px 20px rgba(122, 76, 192, 0.10);
|
||||
}
|
||||
.mu-live-clock-title {
|
||||
margin: 0;
|
||||
color: #6f7b95;
|
||||
font-size: .78rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: .04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.mu-live-clock-time {
|
||||
margin: 2px 0 0;
|
||||
font-size: 1.65rem;
|
||||
line-height: 1;
|
||||
color: #1f2a44;
|
||||
font-weight: 800;
|
||||
font-family: "K2D", "Prompt", "Noto Sans Thai", sans-serif;
|
||||
}
|
||||
.mu-live-clock-note {
|
||||
margin: 0;
|
||||
padding: 6px 10px;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(135deg, #ffffff, #fff7fb);
|
||||
border: 1px solid #eec7df;
|
||||
color: #9333ea;
|
||||
font-size: .78rem;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.mu-live-dot {
|
||||
display: inline-block;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 999px;
|
||||
background: #ec4899;
|
||||
margin-right: 6px;
|
||||
animation: muPulse 1.6s infinite;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.mu-next-arrival {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: #fff;
|
||||
border: 1px solid #f0d6e6;
|
||||
color: #9a3b6e;
|
||||
border-radius: 999px;
|
||||
padding: 3px 10px;
|
||||
font-size: .76rem;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
.mu-next-arrival::before {
|
||||
content: "⏱";
|
||||
font-size: .85rem;
|
||||
line-height: 1;
|
||||
}
|
||||
.mu-time-chip.next-live {
|
||||
background: linear-gradient(135deg, #ec4899, #8b5cf6);
|
||||
border-color: transparent;
|
||||
color: #fff;
|
||||
box-shadow: 0 6px 14px rgba(139, 92, 246, 0.28);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.mu-panel {
|
||||
border: 1px solid rgba(231, 224, 246, 0.95);
|
||||
border-radius: 18px;
|
||||
background: linear-gradient(180deg, #ffffff, #fffbfe);
|
||||
box-shadow: 0 10px 24px rgba(122, 76, 192, 0.09);
|
||||
}
|
||||
|
||||
.mu-info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(140px, 1fr));
|
||||
gap: 10px;
|
||||
margin: 16px 0 18px;
|
||||
}
|
||||
.mu-info-card {
|
||||
border-radius: 14px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #e9e2fb;
|
||||
box-shadow: 0 8px 24px rgba(67, 56, 202, 0.08);
|
||||
}
|
||||
.mu-info-card .label { font-size: .78rem; color:#66728f; margin:0; font-weight:700; }
|
||||
.mu-info-card .value { margin:4px 0 0; font-size:1rem; font-weight:700; color:#2b2f42; }
|
||||
|
||||
.mu-layout-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1.35fr .9fr;
|
||||
gap: 16px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.mu-card-panel {
|
||||
background: #fff;
|
||||
border: 1px solid #ebe8f4;
|
||||
border-radius: 16px;
|
||||
padding: 18px;
|
||||
box-shadow: 0 8px 24px rgba(67, 56, 202, 0.08);
|
||||
}
|
||||
.mu-card-panel h2,
|
||||
.mu-card-panel h3 { margin-top:0; }
|
||||
|
||||
.mu-chip {
|
||||
display:inline-flex;
|
||||
align-items:center;
|
||||
gap:6px;
|
||||
padding:6px 10px;
|
||||
border-radius:999px;
|
||||
font-size:.8rem;
|
||||
font-weight:700;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.mu-info-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
|
||||
.mu-layout-grid { grid-template-columns: 1fr; }
|
||||
}
|
||||
.mu-panel h2 {
|
||||
position: relative;
|
||||
padding-left: 14px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.mu-panel h2::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 4px;
|
||||
width: 6px;
|
||||
height: 24px;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(180deg, #ec4899, #8b5cf6);
|
||||
}
|
||||
.mu-route-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.mu-route-filter {
|
||||
flex: 1;
|
||||
min-width: 240px;
|
||||
border: 1px solid rgba(214, 199, 226, 0.9);
|
||||
border-radius: 12px;
|
||||
padding: 10px 12px;
|
||||
font-size: .9rem;
|
||||
color: var(--mu-ink);
|
||||
background: linear-gradient(180deg, #ffffff, #f8fbff);
|
||||
outline: none;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,.02);
|
||||
}
|
||||
.mu-route-filter:focus {
|
||||
border-color: #c9a9eb;
|
||||
box-shadow: 0 0 0 3px rgba(122, 76, 192, 0.12);
|
||||
}
|
||||
.mu-route-count {
|
||||
border: 1px solid rgba(233, 200, 251, 0.9);
|
||||
background: linear-gradient(135deg, #faf5ff, #fdf2f8);
|
||||
color: #6b21a8;
|
||||
border-radius: 999px;
|
||||
padding: 8px 12px;
|
||||
font-size: .8rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
.mu-stop-expander {
|
||||
border: 1px solid rgba(243, 228, 238, 0.95);
|
||||
border-radius: 14px;
|
||||
margin-bottom: 8px;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(180deg, #fff, #fffafe);
|
||||
}
|
||||
.mu-stop-expander[open] {
|
||||
border-color: rgba(226, 201, 245, 0.95);
|
||||
box-shadow: 0 8px 18px rgba(122, 76, 192, 0.10);
|
||||
}
|
||||
.mu-stop-expander > summary {
|
||||
background: linear-gradient(180deg, #fff, #fff6fb);
|
||||
padding: 14px;
|
||||
/* flex + wrap: จอกว้างเรียงบรรทัดเดียว / จอแคบพับลงมา ไม่ทับกัน */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
}
|
||||
.mu-stop-expander > summary::-webkit-details-marker { display: none; }
|
||||
.mu-stop-list > li:nth-child(4n + 1) .mu-stop-expander > summary { border-left: 4px solid #8b5cf6; }
|
||||
.mu-stop-list > li:nth-child(4n + 2) .mu-stop-expander > summary { border-left: 4px solid #38bdf8; }
|
||||
.mu-stop-list > li:nth-child(4n + 3) .mu-stop-expander > summary { border-left: 4px solid #f472b6; }
|
||||
.mu-stop-list > li:nth-child(4n + 4) .mu-stop-expander > summary { border-left: 4px solid #34d399; }
|
||||
.mu-stop-expander-body {
|
||||
background: linear-gradient(180deg, #fffcff, #fffcfd);
|
||||
padding-left: 58px;
|
||||
border-top: 1px solid #f6eaf2;
|
||||
}
|
||||
.mu-toolbar {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 12px;
|
||||
background: rgba(255,255,255,.8);
|
||||
backdrop-filter: blur(8px);
|
||||
border: 1px solid rgba(231, 224, 246, 0.9);
|
||||
border-radius: 14px;
|
||||
padding: 10px;
|
||||
}
|
||||
@media (max-width: 980px) {
|
||||
.mu-stop-hero {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.mu-hero-metric-grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.mu-hero-metric-grid { grid-template-columns: 1fr; }
|
||||
.mu-hero-metric { min-width: 0; overflow-wrap: anywhere; }
|
||||
.mu-stop-summary-rail {
|
||||
gap: 6px;
|
||||
}
|
||||
/* จอแคบ: จัด summary เป็น 3 แถวอ่านง่าย — chip+badge / ชื่อสาย / รอบ+ลูกศร */
|
||||
.mu-stop-expander > summary {
|
||||
row-gap: 9px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.mu-stop-summary-main { flex: 1 1 100%; order: 5; }
|
||||
.mu-stop-summary-rail {
|
||||
flex: 1 1 100%;
|
||||
order: 6;
|
||||
margin-left: 0;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.mu-next-arrival {
|
||||
font-size: .72rem;
|
||||
}
|
||||
.mu-stop-expander-body {
|
||||
padding-left: 14px;
|
||||
}
|
||||
.mu-route-filter {
|
||||
min-width: 100%;
|
||||
}
|
||||
}
|
||||
@keyframes muPulse {
|
||||
0% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.38); }
|
||||
70% { box-shadow: 0 0 0 8px rgba(236, 72, 153, 0); }
|
||||
100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); }
|
||||
}
|
||||
|
||||
/* === Modern image polish === */
|
||||
.mu-logo-img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
|
||||
.mu-stop-hero-photo { width: 100%; height: 220px; object-fit: cover; border-radius: 16px; display: block; margin-bottom: 12px; box-shadow: 0 10px 24px rgba(63,43,94,.16); }
|
||||
/* รูปสำรอง (สถานียังไม่มีรูป) — เป็นไอคอนโปร่งใส จึงใช้ contain + พื้นอ่อน ไม่ให้ยืด/ตัด */
|
||||
.mu-stop-hero-photo.is-fallback {
|
||||
object-fit: contain; padding: 22px; box-sizing: border-box;
|
||||
background: #f7f4fd; box-shadow: none; border: 1px solid #e8e4f2;
|
||||
}
|
||||
.mu-nearby {
|
||||
background: #fff; border: 1px solid var(--mu-border); border-radius: 20px;
|
||||
padding: 18px; margin: 14px 0; box-shadow: 0 10px 24px rgba(63,43,94,.06);
|
||||
}
|
||||
.mu-nearby h2 { margin: 0 0 4px; font-size: 1.15rem; color: var(--mu-ink); }
|
||||
.mu-nearby p.sub { margin: 0 0 14px; color: var(--mu-muted); font-size: .85rem; }
|
||||
.mu-nearby-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
|
||||
.mu-nearby-card { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 4/3; box-shadow: 0 6px 14px rgba(63,43,94,.10); cursor: pointer; transition: transform .2s ease; }
|
||||
.mu-nearby-card:hover { transform: translateY(-3px); }
|
||||
.mu-nearby-card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
|
||||
.mu-nearby-card:hover img { transform: scale(1.06); }
|
||||
.mu-nearby-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15,23,42,0) 50%, rgba(15,23,42,.65) 100%); }
|
||||
.mu-nearby-card .cap { position: absolute; left: 12px; right: 12px; bottom: 10px; color: #fff; z-index: 1; font-weight: 700; font-size: .92rem; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
|
||||
.mu-nearby-card .cap small { display: block; font-weight: 500; opacity: .85; font-size: .76rem; }
|
||||
@@ -0,0 +1,366 @@
|
||||
/* Ported from busStop.html <style> block */
|
||||
.mu-page {
|
||||
background:
|
||||
linear-gradient(180deg, #ffffff 0%, #faf7ff 55%, #f4f0fd 100%);
|
||||
}
|
||||
|
||||
.mu-hero-panel {
|
||||
background: linear-gradient(135deg, #ffffff 0%, #f7f2ff 60%, #efe6ff 100%);
|
||||
border: 1px solid #e7e0f6;
|
||||
border-radius: 8px;
|
||||
padding: 18px;
|
||||
margin-bottom: 16px;
|
||||
display: grid;
|
||||
grid-template-columns: 1.1fr .9fr;
|
||||
gap: 16px;
|
||||
align-items: stretch;
|
||||
}
|
||||
.mu-hero-title { margin: 0; font-size: 1.6rem; line-height: 1.2; color: #1f2a44; }
|
||||
.mu-hero-subtitle { margin: 8px 0 0; color: #66728f; font-size: .95rem; max-width: 48rem; }
|
||||
.mu-kpi-grid { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
|
||||
.mu-kpi {
|
||||
border: 1px solid #d9c9f2;
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
background: linear-gradient(135deg, #f0e7fc, #e6d8f8);
|
||||
}
|
||||
.mu-kpi .label { margin: 0; color:#6b5b8a; font-size:.76rem; font-weight:700; letter-spacing:.03em; text-transform: uppercase; }
|
||||
.mu-kpi .value { margin:4px 0 0; color:#2b1f4d; font-size:1.03rem; font-weight:800; font-variant-numeric: tabular-nums; }
|
||||
.mu-hero-map {
|
||||
border: 1px solid #e7e0f6;
|
||||
border-radius: 8px;
|
||||
padding: 14px;
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
gap: 10px;
|
||||
justify-content:space-between;
|
||||
}
|
||||
.mu-hero-map-title { margin:0; font-size:1rem; font-weight:800; color:#2c3e50; }
|
||||
.mu-hero-map-box {
|
||||
flex:1;
|
||||
min-height: 160px;
|
||||
border-radius: 8px;
|
||||
background: linear-gradient(135deg, #faf7ff, #f2ecfd);
|
||||
border: 1px dashed #d9cdf2;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
color:#66728f;
|
||||
font-weight:700;
|
||||
text-align:center;
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
/* ===== Search toolbar: 2 โหมด ===== */
|
||||
.mu-toolbar {
|
||||
background: linear-gradient(135deg, #f0e7fc, #e6d8f8);
|
||||
border: 1px solid #d9c9f2;
|
||||
border-radius: 8px;
|
||||
padding: 14px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.mu-search-tabs {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
border: 1px solid #d5c3f0;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 12px;
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
}
|
||||
.mu-search-tab {
|
||||
font-family: inherit;
|
||||
font-size: .88rem;
|
||||
font-weight: 700;
|
||||
padding: 10px 18px;
|
||||
border: none;
|
||||
border-right: 1px solid #d5c3f0;
|
||||
background: #fff;
|
||||
color: #5b3b71;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
transition: background .15s ease, color .15s ease;
|
||||
}
|
||||
.mu-search-tab:last-child { border-right: none; }
|
||||
.mu-search-tab:hover { background: #f3ecff; }
|
||||
.mu-search-tab.active { background: linear-gradient(135deg, #7a4cc0, #b07ce0); color: #fff; }
|
||||
.mu-search-tab .ic { width: 16px; height: 16px; }
|
||||
|
||||
.mu-search-mode { display: block; }
|
||||
/* กัน .display:block ทับ attribute [hidden] — โหมดที่ไม่ได้ใช้ต้องซ่อนจริง */
|
||||
.mu-search-mode[hidden],
|
||||
.mu-numpad[hidden] { display: none; }
|
||||
|
||||
.mu-search-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
border: 1px solid #d5c3f0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
padding: 0 12px;
|
||||
min-height: 48px;
|
||||
transition: border-color .15s ease;
|
||||
}
|
||||
.mu-search-field:focus-within { border-color: #a855f7; }
|
||||
.mu-search-field .ic { position: static; width: 18px; height: 18px; color: #8b5cf6; flex: none; }
|
||||
.mu-search-field input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: #1f2a44;
|
||||
padding: 12px 0;
|
||||
}
|
||||
.mu-search-field input::placeholder { color: #6f7b95; font-weight: 500; opacity: .8; }
|
||||
|
||||
/* ===== ช่องรหัสป้าย 6 ช่อง: [x] + [x][x][x][x] ===== */
|
||||
.mu-code-boxes {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.mu-code-cell {
|
||||
width: 46px;
|
||||
height: 54px;
|
||||
text-align: center;
|
||||
font-family: "IBM Plex Mono", ui-monospace, monospace;
|
||||
font-size: 1.35rem;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: #1f2a44;
|
||||
background: #fff;
|
||||
border: 2px solid #e0d6f5;
|
||||
border-radius: 8px;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
transition: border-color .15s ease, background .15s ease;
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
.mu-code-cell::-webkit-outer-spin-button,
|
||||
.mu-code-cell::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
||||
.mu-code-cell::placeholder { color: #7a6a9e; font-weight: 600; opacity: 1; }
|
||||
.mu-code-cell:focus {
|
||||
border-color: #a855f7;
|
||||
background: #faf7ff;
|
||||
}
|
||||
.mu-code-cell:disabled { opacity: .45; }
|
||||
/* 2 หลักหน้า (ก่อน +) — เน้นให้เห็นว่าเป็นหัวของรหัส */
|
||||
.mu-code-cell:nth-of-type(1),
|
||||
.mu-code-cell:nth-of-type(2) {
|
||||
border-color: #b07ce0;
|
||||
background: linear-gradient(135deg, #7a4cc0, #b07ce0);
|
||||
color: #fff;
|
||||
}
|
||||
.mu-code-cell:nth-of-type(1)::placeholder,
|
||||
.mu-code-cell:nth-of-type(2)::placeholder { color: #fff; opacity: .8; font-weight: 600; }
|
||||
.mu-code-cell:nth-of-type(1):focus,
|
||||
.mu-code-cell:nth-of-type(2):focus { border-color: #6d28d9; }
|
||||
.mu-code-plus {
|
||||
font-family: "IBM Plex Mono", ui-monospace, monospace;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #7a4cc0;
|
||||
line-height: 1;
|
||||
padding: 0 2px;
|
||||
}
|
||||
.mu-code-display {
|
||||
margin: 10px 0 0;
|
||||
font-family: "IBM Plex Mono", ui-monospace, monospace;
|
||||
font-size: .9rem;
|
||||
font-weight: 700;
|
||||
color: #6d28d9;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.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;
|
||||
border-radius: 8px;
|
||||
margin-top: 8px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
max-height: 260px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.mu-suggest-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 11px 14px;
|
||||
border: none;
|
||||
border-bottom: 1px solid #f1edfa;
|
||||
background: #fff;
|
||||
font-family: inherit;
|
||||
font-size: .9rem;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
color: #1f2a44;
|
||||
}
|
||||
.mu-suggest-item:last-child { border-bottom: none; }
|
||||
.mu-suggest-item:hover { background: #faf7ff; }
|
||||
.mu-suggest-code {
|
||||
font-family: "IBM Plex Mono", ui-monospace, monospace;
|
||||
font-size: .85rem;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #7a4cc0, #b07ce0);
|
||||
padding: 3px 9px;
|
||||
border-radius: 4px;
|
||||
flex: none;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.mu-toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
|
||||
.mu-show-more { display: flex; justify-content: center; margin: 14px 0 4px; }
|
||||
.mu-show-more .mu-btn { min-width: 220px; }
|
||||
.mu-stop-card.is-stub { min-height: 120px; background: #faf8ff; border: 1px dashed #ddd2f2; box-shadow: none; }
|
||||
|
||||
.mu-toolbar-count { margin: 10px 0 0; font-size: .84rem; color: #6f7b95; }
|
||||
.mu-toolbar-count b { color: #7a4cc0; font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* ===== การ์ดป้าย ===== */
|
||||
.mu-stop-grid {
|
||||
display:grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
padding-left: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.mu-stop-grid li {
|
||||
margin: 0;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #e7e0f6;
|
||||
background: #fff;
|
||||
transition: border-color .15s ease, transform .15s ease;
|
||||
}
|
||||
.mu-stop-grid li:hover { border-color: #a855f7; transform: translateY(-1px); }
|
||||
.mu-stop-card {
|
||||
height: 100%;
|
||||
padding: 16px;
|
||||
background: #fff;
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.mu-stop-top { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
|
||||
.mu-type-pill {
|
||||
display:inline-block;
|
||||
border-radius: 4px;
|
||||
padding: 4px 9px;
|
||||
font-size:.74rem;
|
||||
font-weight:800;
|
||||
letter-spacing:.01em;
|
||||
}
|
||||
.mu-type-pill.local { background: #f3ecff; color: #6d28d9; }
|
||||
.mu-stop-title { margin:6px 0 0; font-size:1.05rem; line-height:1.3; color:#1f2a44; }
|
||||
.mu-loc { color:#6f7b95; font-size:.85rem; margin-top:4px; }
|
||||
.mu-chip-row { display:flex; flex-wrap:wrap; gap:8px; }
|
||||
.mu-chip {
|
||||
display:inline-flex;
|
||||
align-items:center;
|
||||
gap:6px;
|
||||
padding:5px 10px;
|
||||
border-radius: 4px;
|
||||
background: #faf7ff;
|
||||
border: 1px solid #e7e0f6;
|
||||
color:#5b3b71;
|
||||
font-size:.8rem;
|
||||
font-weight:700;
|
||||
}
|
||||
.mu-chip.route { background: #f3ecff; color:#6d28d9; border-color: #e0d6f5; }
|
||||
/* ชิปสายที่เป็นลิงก์ → ไปหน้าเช็กเวลาของสายนั้น (หน้าตาเหมือนชิปเดิม + มี hover/focus) */
|
||||
a.mu-chip.route { text-decoration: none; cursor: pointer; }
|
||||
a.mu-chip.route:hover { background:#e9dcff; border-color:#cdb5f2; }
|
||||
a.mu-chip.route:focus-visible { outline: 2px solid #7a4cc0; outline-offset: 2px; }
|
||||
/* รหัสป้าย = ม่วง-ขาว แบบเดียวกับป้ายสายรถ */
|
||||
.mu-chip.count.stop-code {
|
||||
background: linear-gradient(135deg, #7a4cc0, #b07ce0);
|
||||
color: #fff;
|
||||
border-color: transparent;
|
||||
font-family: "IBM Plex Mono", ui-monospace, monospace;
|
||||
font-size: .92rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: .05em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
flex: none;
|
||||
padding: 7px 11px;
|
||||
}
|
||||
.mu-stop-action { margin-top:auto; display:flex; justify-content:space-between; align-items:center; gap:12px; }
|
||||
.mu-stop-note { color:#6f7b95; font-size:.8rem; margin:0; }
|
||||
|
||||
.mu-stop-thumb {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 180px;
|
||||
object-fit: cover;
|
||||
background: #f7f9fd;
|
||||
border-bottom: 1px solid #e7e0f6;
|
||||
}
|
||||
/* รูป placeholder — ย่อและจัดกลาง ไม่ให้ครอปโลโก้ */
|
||||
.mu-stop-thumb.is-placeholder {
|
||||
object-fit: contain;
|
||||
padding: 34px;
|
||||
background: linear-gradient(135deg, #faf7ff, #f2ecfd);
|
||||
}
|
||||
|
||||
.mu-stop-empty {
|
||||
grid-column: 1 / -1;
|
||||
list-style: none;
|
||||
padding: 40px 16px;
|
||||
text-align: center;
|
||||
color: #6f7b95;
|
||||
border: 1px dashed #e0d6f5;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.mu-hero-panel { grid-template-columns: 1fr; }
|
||||
.mu-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.mu-stop-grid { grid-template-columns: 1fr; }
|
||||
}
|
||||
|
||||
@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; }
|
||||
/* กล่องรหัส: ย่อให้พอดีจอ 375px (5×40 + เครื่องหมาย + gap = ~244px) */
|
||||
.mu-code-boxes { gap: 5px; }
|
||||
.mu-code-cell { width: 40px; height: 48px; font-size: 1.15rem; }
|
||||
.mu-code-plus { font-size: 1.25rem; }
|
||||
}
|
||||
|
||||
.mu-hero-map-photo { width: 100%; height: 100%; min-height: 160px; object-fit: cover; border-radius: 8px; display: block; }
|
||||
@@ -0,0 +1,286 @@
|
||||
/* ============================================================
|
||||
Atroute — Mobile-first responsive layer
|
||||
------------------------------------------------------------
|
||||
base = มือถือ (จอเล็กสุด iPhone 8 = 375px, รองรับ SE 320px)
|
||||
ขยายขึ้นด้วย min-width:
|
||||
≥480px มือถือใหญ่
|
||||
≥640px มือถือใหญ่ / แท็บเล็ตเล็ก
|
||||
≥768px iPad แนวตั้ง / แท็บเล็ต
|
||||
≥1024px iPad แนวนอน / แล็ปท็อป
|
||||
≥1280px คอม 19.5"–24"
|
||||
≥1600px คอม 27" / 1440p+
|
||||
|
||||
หมายเหตุ: component ที่ router inject จาก partial (อยู่ใน #view)
|
||||
ต้องใช้ prefix `#view` — เพราะ <style> ของ partial ถูก inject
|
||||
ทีหลัง จึงต้องชนะด้วย specificity (ID > class)
|
||||
============================================================ */
|
||||
|
||||
/* ---------- base: มือถือ ---------- */
|
||||
html { -webkit-text-size-adjust: 100%; }
|
||||
body { font-size: 16px; }
|
||||
|
||||
/* --- ขยายขนาด component บนมือถือ (desktop-oriented เดิมเล็กเกิน) --- */
|
||||
/* topbar อยู่ใน section ด้านล่าง — content ใน #view ใช้ prefix ชนะ partial style */
|
||||
#view .mu-btn { font-size: .95rem; min-height: 48px; }
|
||||
#view .mu-badge { font-size: 1.05rem; }
|
||||
#view .mu-zone-tag { font-size: 1rem; }
|
||||
#view .mu-zone-desc, #view .mu-zone-sub { font-size: 1.05rem; }
|
||||
#view .mu-route-name { font-size: 1.2rem; }
|
||||
#view .mu-next-trip { font-size: .95rem; }
|
||||
#view .mu-meta-pill { font-size: .95rem; }
|
||||
#view .mu-route-type-badge { font-size: .85rem; }
|
||||
#view .mu-stop-summary-meta { font-size: .85rem; }
|
||||
#view .mu-time-chip { font-size: .95rem; min-height: 40px; }
|
||||
#view .mu-info-card .label { font-size: .85rem; }
|
||||
#view .mu-info-card .value { font-size: 1.1rem; }
|
||||
#view .mu-stat p { font-size: .9rem; }
|
||||
#view .mu-hero-lead { font-size: 1rem; }
|
||||
#view .mu-select-box select { font-size: 1rem; }
|
||||
|
||||
/* --- กัน overflow พื้นฐาน (padding/รูป/grid/ข้อความยาว ไม่ให้ล้นจอมือถือ) --- */
|
||||
*, *::before, *::after { box-sizing: border-box; }
|
||||
img, svg, video { max-width: 100%; height: auto; }
|
||||
/* grid/flex child ต้อง shrink ได้ (กัน min-width:auto ล้น container) */
|
||||
#view .mu-hero-panel > *,
|
||||
#view .mu-layout-grid > *,
|
||||
#view .mu-hero-metric-grid > *,
|
||||
#view .mu-stop-summary-main { min-width: 0; }
|
||||
/* ข้อความยาวไม่ break (เช่น mock state query string / ชื่อยาว) */
|
||||
#view .mu-inline-context strong,
|
||||
#view .mu-stop-hero-title,
|
||||
#view .mu-stop-hero-sub { overflow-wrap: anywhere; }
|
||||
|
||||
.mu-container { padding: 0 16px; }
|
||||
main.mu-container { padding-top: 24px; padding-bottom: 24px; }
|
||||
|
||||
/* --- topbar: hamburger menu บนมือถือ (brand + lang + ☰ บรรทัดเดียว) --- */
|
||||
.mu-topbar-inner { gap: 8px; padding: 10px 14px; flex-wrap: wrap; }
|
||||
.mu-logo-img { width: 36px; height: 36px; }
|
||||
.mu-brand { gap: 8px; flex-shrink: 0; }
|
||||
.mu-brand-title { font-size: 1.05rem; white-space: nowrap; }
|
||||
.mu-brand-subtitle { display: none; } /* กันล้น — โผล่กลับ ≥768px */
|
||||
.mu-nav { display: none; } /* ซ่อน nav — ใช้ hamburger แทน */
|
||||
.mu-lang-switch { order: 3; margin-left: auto; padding: 2px; }
|
||||
.mu-lang-btn { font-size: .8rem; padding: 8px 12px; min-height: 40px; min-width: 40px; } /* tap target */
|
||||
.mu-action-btn { display: none; } /* กันล้นบนจอเล็ก — โผล่กลับ ≥1024px */
|
||||
|
||||
/* hamburger menu (ขวาสุด) */
|
||||
.mu-menu { display: block; position: relative; order: 4; margin-left: 2px; }
|
||||
.mu-menu-btn {
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
width: 44px; height: 44px;
|
||||
border: none; background: transparent; cursor: pointer;
|
||||
color: #1f2a44; list-style: none;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.mu-menu-btn::-webkit-details-marker { display: none; }
|
||||
.mu-menu-btn svg { width: 26px; height: 26px; }
|
||||
.mu-menu-panel {
|
||||
position: absolute; top: calc(100% + 8px); right: 0;
|
||||
min-width: 220px;
|
||||
background: #fff; border: 1px solid #e7e2f6; border-radius: 14px;
|
||||
box-shadow: 0 12px 28px rgba(20, 40, 90, .16);
|
||||
padding: 8px;
|
||||
z-index: 60;
|
||||
display: flex; flex-direction: column; gap: 2px;
|
||||
}
|
||||
.mu-menu-panel a {
|
||||
display: flex; align-items: center;
|
||||
min-height: 48px; padding: 10px 14px;
|
||||
border-radius: 10px;
|
||||
color: #1f2a44; text-decoration: none;
|
||||
font-size: 1.05rem; font-weight: 600;
|
||||
}
|
||||
.mu-menu-panel a:hover, .mu-menu-panel a:active { background: #f5efff; }
|
||||
|
||||
/* --- hero (หน้าแรก) — ช่องว่าง + ตัวหนังสือใหญ่ขึ้น --- */
|
||||
.mu-hero { padding: 30px 0 34px; }
|
||||
.mu-hero h1 { font-size: clamp(1.9rem, 8vw, 2.9rem); margin-bottom: 14px; line-height: 1.28; }
|
||||
.mu-badge { margin-bottom: 10px; padding: 5px 14px; }
|
||||
.mu-hero-lead { margin: 0 0 8px; }
|
||||
.mu-hero-actions { flex-direction: column; align-items: stretch; padding: 0 6px; margin-top: 10px; gap: 8px; }
|
||||
.mu-pill-link { justify-content: center; padding: 11px 18px; font-size: .9rem; }
|
||||
|
||||
/* --- ตัวเลือกจังหวัด/สถานี (หน้าแรก) --- */
|
||||
#view .mu-route-selector { flex-direction: column; align-items: stretch; gap: 8px; margin-top: 12px; }
|
||||
#view .mu-route-selector select,
|
||||
#view .mu-route-selector .mu-select-arrow { width: 100%; }
|
||||
/* flex-basis 250px (จาก index.html) กลายเป็นความสูงตอน column — reset เป็น content height */
|
||||
#view .mu-route-selector .mu-select-field { width: 100%; flex: 0 0 auto; }
|
||||
#view .mu-select-arrow { transform: rotate(90deg); justify-content: center; }
|
||||
|
||||
/* --- marquee (สปอนเซอร์) — การ์ดเล็กลงบนมือถือ --- */
|
||||
.mu-marquee-track { padding: 2px 0 10px; }
|
||||
.mu-marquee-tile { width: 132px; height: 68px; margin-right: 10px; border-radius: 10px; }
|
||||
|
||||
/* --- โซนเส้นทาง + การ์ด — ระยะห่างกระชับ --- */
|
||||
main.mu-container { padding-top: 14px; padding-bottom: 14px; }
|
||||
.mu-zone { margin-bottom: 20px; }
|
||||
.mu-zone-head { margin-bottom: 10px; gap: 4px 10px; }
|
||||
|
||||
/* --- หัวโซน: ป้ายหัวข้อ + บรรทัดข้อมูล (มือถือ = เรียงลงมาเต็มความกว้าง) ---
|
||||
ใช้ #view เพื่อชนะ <style> ของ partial ที่ inject ทีหลัง */
|
||||
#view .mu-zone-head .mu-zone-desc { flex-basis: 100%; min-width: 0; line-height: 1.65; }
|
||||
#view .mu-zone-meta { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; row-gap: 2px; }
|
||||
#view .mu-zone-seg { display: inline-flex; align-items: baseline; gap: 5px; min-width: 0; }
|
||||
#view .mu-zone-seg:not(:last-child)::after { content: "\00b7"; color: #c4bcd8; margin-left: 8px; } /* คั่นท้ายชิ้น → ตัดบรรทัดแล้วจุดไม่ไปอยู่ต้นบรรทัด */
|
||||
#view .mu-zone-seg .ic { align-self: center; flex: none; }
|
||||
#view .mu-zone-now b { color: #1f2a44; font-variant-numeric: tabular-nums; }
|
||||
#view .mu-zone-at { color: #8a93a8; } /* ชื่อสถานีในวงเล็บ — จางกว่ารอบรถ */
|
||||
#view .mu-zone-updated { color: #8a7aa8; font-size: .95rem; }
|
||||
.mu-grid { gap: 12px; }
|
||||
.mu-route-info { padding: 16px 16px 18px; }
|
||||
.mu-route-name { margin-bottom: 6px; }
|
||||
.mu-route-chip-wrap { gap: 6px; }
|
||||
.mu-next-trip { padding: 3px 10px; font-size: .74rem; }
|
||||
|
||||
/* --- busStop --- */
|
||||
#view .mu-hero-panel { grid-template-columns: 1fr; padding: 14px; gap: 12px; }
|
||||
#view .mu-hero-title { font-size: 1.35rem; }
|
||||
#view .mu-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
|
||||
#view .mu-toolbar { flex-direction: column; align-items: stretch; }
|
||||
#view .mu-toolbar select,
|
||||
#view .mu-toolbar .mu-btn { width: 100%; min-height: 44px; }
|
||||
#view .mu-search-field { width: 100%; min-width: 0; }
|
||||
#view .mu-search-field input { min-height: 44px; }
|
||||
#view .mu-stop-grid { grid-template-columns: 1fr; gap: 12px; }
|
||||
#view .mu-hero-map { min-height: 200px; }
|
||||
|
||||
/* --- busDetail / expanded --- */
|
||||
#view .mu-layout-grid { grid-template-columns: 1fr; gap: 12px; }
|
||||
#view .mu-page-title { font-size: 1.45rem; }
|
||||
#view .mu-route-hero { padding: 16px; }
|
||||
#view .mu-info-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
|
||||
#view .mu-panel,
|
||||
#view .mu-card-panel { padding: 14px; }
|
||||
#view .mu-photo-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
|
||||
#view .mu-quickpick { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
#view .mu-inline-actions { flex-wrap: wrap; }
|
||||
#view .mu-back-btn { width: 100%; justify-content: center; padding: 10px; min-height: 44px; }
|
||||
#view .mu-schedule-note { font-size: .82rem; }
|
||||
|
||||
/* --- stopDetail --- */
|
||||
#view .mu-hero-metric-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
|
||||
#view .mu-live-clock-card { padding: 14px; }
|
||||
#view .mu-stop-summary-rail { flex-wrap: wrap; }
|
||||
#view .mu-time-chip { min-width: 0; }
|
||||
#view .mu-contact-row { flex-wrap: wrap; }
|
||||
|
||||
/* --- credits --- */
|
||||
#view .mu-credit-wrap { padding: 24px 16px 40px; }
|
||||
#view .mu-credit-hero h1 { font-size: 1.5rem; }
|
||||
#view .mu-credit-section { padding: 16px; }
|
||||
|
||||
/* --- footer --- */
|
||||
.mu-site-footer { margin-top: 24px; padding: 28px 0 0; }
|
||||
.mu-site-footer .mu-container { padding: 0 16px; }
|
||||
.mu-footer-grid { grid-template-columns: 1fr; gap: 16px; }
|
||||
.mu-footer-col ul a { padding: 5px 0; min-height: 34px; } /* tap target (กดได้ ≥34px) */
|
||||
.mu-footer-contact a { min-height: 34px; } /* tap target */
|
||||
.mu-sponsor-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
|
||||
|
||||
/* ============================================================
|
||||
≥480px — มือถือใหญ่
|
||||
============================================================ */
|
||||
@media (min-width: 480px) {
|
||||
.mu-topbar-inner { padding: 12px 18px; }
|
||||
.mu-hero-actions { flex-direction: row; justify-content: center; }
|
||||
.mu-pill-link { width: auto; }
|
||||
#view .mu-stop-grid { grid-template-columns: repeat(2, 1fr); }
|
||||
#view .mu-photo-strip { grid-template-columns: repeat(3, 1fr); }
|
||||
.mu-sponsor-strip { grid-template-columns: repeat(3, 1fr); }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
≥640px — มือถือใหญ่ / แท็บเล็ตเล็ก
|
||||
============================================================ */
|
||||
@media (min-width: 640px) {
|
||||
body { font-size: 16px; }
|
||||
.mu-container { padding: 0 28px; }
|
||||
.mu-brand-title { font-size: 1.05rem; }
|
||||
.mu-topbar-inner { gap: 18px; padding: 14px 28px; flex-wrap: nowrap; }
|
||||
.mu-logo-img { width: 44px; height: 44px; }
|
||||
.mu-nav { order: 0; width: auto; margin-left: auto; justify-content: flex-start; gap: 24px; display: flex; }
|
||||
.mu-nav a { font-size: .92rem; }
|
||||
.mu-menu { display: none; }
|
||||
.mu-lang-btn { font-size: .72rem; padding: 6px 10px; }
|
||||
.mu-hero { padding: 44px 0 52px; }
|
||||
.mu-hero-actions { margin-top: 14px; }
|
||||
.mu-marquee-tile { width: 170px; height: 96px; margin-right: 16px; }
|
||||
#view .mu-route-selector { flex-direction: row; align-items: flex-end; justify-content: center; }
|
||||
#view .mu-route-selector select,
|
||||
#view .mu-route-selector .mu-select-field { width: auto; }
|
||||
#view .mu-select-arrow { transform: none; }
|
||||
#view .mu-toolbar { flex-direction: row; flex-wrap: wrap; align-items: center; }
|
||||
#view .mu-toolbar select,
|
||||
#view .mu-toolbar .mu-btn { width: auto; }
|
||||
#view .mu-search-field { flex: 1; min-width: 200px; }
|
||||
#view .mu-back-btn { width: auto; }
|
||||
.mu-footer-grid { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
≥768px — iPad แนวตั้ง / แท็บเล็ต
|
||||
============================================================ */
|
||||
@media (min-width: 768px) {
|
||||
.mu-brand-subtitle { display: block; font-size: .72rem; }
|
||||
#view .mu-kpi-grid { grid-template-columns: repeat(4, 1fr); }
|
||||
#view .mu-info-grid { grid-template-columns: repeat(4, 1fr); }
|
||||
#view .mu-hero-metric-grid { grid-template-columns: repeat(4, 1fr); }
|
||||
#view .mu-photo-strip { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
|
||||
#view .mu-hero-panel { grid-template-columns: 1.1fr .9fr; padding: 18px; }
|
||||
.mu-footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1.1fr; }
|
||||
.mu-sponsor-strip { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
|
||||
|
||||
/* หัวโซนบนจอใหญ่: ป้ายหัวข้ออยู่ซ้าย · บรรทัดข้อมูลเป็นคอลัมน์ขวา
|
||||
(อ่านง่ายกว่าเดิมที่ข้อความยืดเต็มความกว้างจอ ~1144px) */
|
||||
#view .mu-zone-head { display: grid; grid-template-columns: auto minmax(0, 1fr);
|
||||
align-items: start; column-gap: 14px; row-gap: 5px; }
|
||||
#view .mu-zone-head .mu-zone-desc { grid-column: 2; max-width: 82ch; }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
≥1024px — iPad แนวนอน / แล็ปท็อป
|
||||
============================================================ */
|
||||
@media (min-width: 1024px) {
|
||||
.mu-hero { padding: 56px 0 64px; }
|
||||
.mu-action-btn { display: inline-flex; }
|
||||
.mu-hero h1 { font-size: clamp(2.2rem, 4vw, 3rem); }
|
||||
.mu-hero-actions { padding: 0; }
|
||||
#view .mu-layout-grid { grid-template-columns: 1.35fr .9fr; gap: 16px; }
|
||||
#view .mu-hero-title { font-size: 1.8rem; }
|
||||
#view .mu-hero-map { min-height: auto; }
|
||||
#view .mu-photo-strip { gap: 10px; }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
≥1280px — คอม 19.5"–24"
|
||||
============================================================ */
|
||||
@media (min-width: 1280px) {
|
||||
.mu-container { max-width: 1200px; }
|
||||
#view .mu-stop-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
|
||||
#view .mu-credit-wrap { padding: 40px 28px 56px; }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
≥1600px — คอม 27" / 1440p+
|
||||
============================================================ */
|
||||
@media (min-width: 1600px) {
|
||||
body { font-size: 17px; }
|
||||
.mu-container { max-width: 1280px; }
|
||||
#view .mu-photo-strip { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
|
||||
#view .mu-stop-grid { grid-template-columns: repeat(4, 1fr); }
|
||||
}
|
||||
|
||||
/* เวลาที่ "คำนวณจากต้นทาง" (ไม่ใช่ตารางจริงของผู้ประกอบการ) — ทำเครื่องหมายให้ผู้ใช้รู้ ไม่ให้เข้าใจผิด */
|
||||
.mu-time-grid.is-est .mu-time-chip {
|
||||
border: 1px dashed #a892d4;
|
||||
background: #faf7ff;
|
||||
color: #6b5a8e;
|
||||
font-style: italic;
|
||||
}
|
||||
.mu-est-note {
|
||||
margin: 6px 0 0;
|
||||
font-size: .78rem;
|
||||
color: #6b5a8e;
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
/* Ported from web-at-transit-mock/ui/index.html <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; }
|
||||
|
||||
/* Page-specific: hero */
|
||||
.mu-hero { position: relative; overflow: hidden; }
|
||||
.mu-hero-map { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .3; filter: saturate(1.1); z-index: 0; pointer-events: none; }
|
||||
.mu-hero-content { position: relative; z-index: 1; }
|
||||
|
||||
/* ===== maintheme-style cards: solid gradient block with big centered number ===== */
|
||||
.mu-card-head {
|
||||
aspect-ratio: auto;
|
||||
height: 130px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #8b5cf6 0%, #c084fc 100%);
|
||||
position: relative;
|
||||
}
|
||||
.mu-card-head::after { display: none; }
|
||||
.mu-card-head .mu-route-number {
|
||||
position: static;
|
||||
color: #fff;
|
||||
font-size: 56px;
|
||||
font-weight: 900;
|
||||
text-shadow: 0 4px 12px rgba(0,0,0,.25);
|
||||
letter-spacing: .02em;
|
||||
}
|
||||
/* zone tint — พื้นหลังการ์ดตามหมวดเส้นทาง (ตัวการ์ด = เฉดอ่อน / หัวการ์ด = เฉดสด) */
|
||||
.mu-zone:has(.tag-sky) { --zone-tint: #eff6ff; }
|
||||
.mu-zone:has(.tag-purple) { --zone-tint: #f5f3ff; }
|
||||
.mu-zone:has(.tag-pink) { --zone-tint: #fdf2f8; }
|
||||
.mu-zone:has(.tag-yellow) { --zone-tint: #fffbeb; }
|
||||
.mu-zone .mu-card,
|
||||
.mu-zone .mu-route-info { background: var(--zone-tint, #fff); }
|
||||
|
||||
.mu-zone:has(.tag-sky) .mu-card-head { background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%); }
|
||||
.mu-zone:has(.tag-purple) .mu-card-head { background: linear-gradient(135deg, #8b5cf6 0%, #c084fc 100%); }
|
||||
.mu-zone:has(.tag-pink) .mu-card-head { background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%); }
|
||||
.mu-zone:has(.tag-yellow) .mu-card-head { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); }
|
||||
/* การ์ดที่ยังไม่มีข้อมูล (is-empty): พื้นเทา + N/A แทนเลขสาย ไม่มีเงาตัวอักษร */
|
||||
.mu-card.is-empty,
|
||||
.mu-card.is-empty .mu-route-info { background: #f0f2f5; }
|
||||
.mu-card.is-empty .mu-card-head { background: #e4e7eb; }
|
||||
.mu-card.is-empty .mu-route-number { color: #5b636e !important; text-shadow: none !important; font-size: 42px !important; }
|
||||
.mu-card.is-empty { cursor: default; }
|
||||
.mu-card.is-empty:hover { transform: none; box-shadow: 0 4px 14px rgba(20,40,90,.06); }
|
||||
|
||||
.mu-route-info { padding: 14px 16px 16px; background: #fff; }
|
||||
.mu-route-name { margin: 0 0 10px; font-size: .95rem; color: #1f2a44; font-weight: 700; }
|
||||
|
||||
/* ===== maintheme.png look: topbar, hero, zones, grid, summary, footer ===== */
|
||||
body.main-theme-page { margin: 0; font-family: 'K2D','Noto Sans Thai','Prompt',system-ui,sans-serif; color: #1f2a44; background: #f7f9fd; }
|
||||
.mu-container { max-width: 1200px; margin: 0 auto; padding: 0 28px; }
|
||||
|
||||
/* Topbar */
|
||||
/* z-index 1100 — ต้องสูงกว่า Leaflet (pane 400 · control 800 · .leaflet-top 1000)
|
||||
ไม่งั้นแผนที่จะบัง nav ตอนเลื่อน */
|
||||
.mu-topbar { background: #ffffff; border-bottom: 1px solid #e9eef7; position: sticky; top: 0; z-index: 1100; box-shadow: 0 2px 8px rgba(20,40,90,.04); }
|
||||
.mu-topbar-inner { display: flex; align-items: center; gap: 18px; padding: 14px 28px; }
|
||||
.mu-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
|
||||
.mu-logo-img { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg,#8b5cf6,#ec4899); padding: 4px; transition: transform .15s ease; }
|
||||
.mu-brand:hover .mu-logo-img { transform: scale(1.06); }
|
||||
.mu-brand-title { display: block; margin: 0; font-weight: 800; font-size: 1.05rem; color: #1f2a44; transition: color .15s ease; }
|
||||
.mu-brand:hover .mu-brand-title { color: #7a4cc0; }
|
||||
.mu-brand-subtitle { display: block; margin: 0; font-size: .72rem; color: #6f7b95; }
|
||||
.mu-nav { margin-left: auto; display: flex; gap: 28px; }
|
||||
.mu-nav a { color: #4a5876; text-decoration: none; font-size: .92rem; font-weight: 600; padding: 6px 4px; border-bottom: 2px solid transparent; }
|
||||
.mu-nav a.active { color: #d6336c; border-bottom-color: #ec4899; }
|
||||
.mu-nav a:hover { color: #1f2a44; }
|
||||
.mu-action-btn { background: linear-gradient(135deg,#a855f7,#7c3aed); color:#fff; padding: 10px 22px; border-radius: 999px; text-decoration:none; font-weight: 700; font-size:.88rem; box-shadow: 0 6px 14px rgba(124,58,237,.3); }
|
||||
|
||||
/* Hero */
|
||||
.mu-hero { position: relative; overflow: hidden; padding: 56px 0 64px; background: linear-gradient(180deg, #f0ebff 0%, #ffe8ee 50%, #fff4d6 100%); text-align: center; }
|
||||
.mu-hero-map { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .3; filter: saturate(1.1); z-index: 0; pointer-events: none; }
|
||||
.mu-blob { position: absolute; border-radius: 50%; filter: blur(50px); opacity: .55; z-index: 0; }
|
||||
.mu-blob.one { width: 220px; height: 220px; background: #b794f4; top: -50px; left: 8%; }
|
||||
.mu-blob.two { width: 260px; height: 260px; background: #f9a8d4; top: 40%; right: 8%; }
|
||||
.mu-blob.three{ width: 180px; height: 180px; background: #fde68a; bottom: -40px; left: 38%; }
|
||||
.mu-hero-content { position: relative; z-index: 1; }
|
||||
.mu-badge { display: inline-block; background: rgba(255,255,255,.7); backdrop-filter: blur(6px); color: #6d28d9; padding: 6px 16px; border-radius: 999px; font-size: .82rem; font-weight: 700; margin-bottom: 18px; box-shadow: 0 4px 10px rgba(124,58,237,.12); }
|
||||
.mu-hero h1 { margin: 0 0 26px; font-size: 2.2rem; font-weight: 800; line-height: 1.35; color: #1f2a44; }
|
||||
.mu-gradient-text { background: linear-gradient(120deg, #d946ef 10%, #a855f7 60%, #6366f1 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
||||
/* ===== Route selector: จังหวัด → สถานีขนส่งผู้โดยสาร (cascade) ===== */
|
||||
.mu-route-selector {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
gap: 14px;
|
||||
flex-wrap: wrap;
|
||||
max-width: 780px;
|
||||
margin: 2px auto 0;
|
||||
}
|
||||
.mu-select-field { flex: 1 1 250px; min-width: 240px; text-align: left; }
|
||||
.mu-route-selector.single { max-width: 440px; }
|
||||
.mu-select-field > label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 0 0 7px 8px;
|
||||
font-size: .8rem;
|
||||
font-weight: 700;
|
||||
color: #6f7b95;
|
||||
letter-spacing: .01em;
|
||||
}
|
||||
.mu-select-field > label svg { width: 15px; height: 15px; color: #8b5cf6; flex: none; }
|
||||
.mu-select-box {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border: 1px solid #e7e2f6;
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 8px 20px rgba(63, 43, 94, .08);
|
||||
transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
|
||||
}
|
||||
.mu-select-box:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(63,43,94,.12); }
|
||||
.mu-select-box:focus-within { border-color: #c8b4ec; box-shadow: 0 0 0 4px rgba(122,76,192,.14), 0 10px 24px rgba(63,43,94,.10); }
|
||||
.mu-select-box .mu-select-icon { width: 20px; height: 20px; margin-left: 14px; color: #8b5cf6; flex: none; }
|
||||
.mu-select-box select {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: .95rem;
|
||||
font-weight: 600;
|
||||
color: #1f2a44;
|
||||
padding: 14px 12px;
|
||||
cursor: pointer;
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
.mu-select-box .mu-select-chevron { width: 18px; height: 18px; margin-right: 14px; color: #8b5cf6; flex: none; pointer-events: none; }
|
||||
.mu-select-arrow { display: none; align-self: center; color: #c4b5e6; font-weight: 700; font-size: 1.15rem; padding-bottom: 18px; }
|
||||
.mu-select-hint { margin: 12px 0 0; font-size: .84rem; color: #6f7b95; min-height: 1.25em; }
|
||||
.mu-select-hint b { color: #7a4cc0; font-weight: 700; }
|
||||
|
||||
/* ===== Hero actions ===== */
|
||||
.mu-hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 18px; }
|
||||
.mu-pill-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
padding: 11px 20px;
|
||||
border-radius: 999px;
|
||||
background: #fff;
|
||||
border: 1px solid #e7e2f6;
|
||||
color: #5b3b71;
|
||||
text-decoration: none;
|
||||
font-size: .88rem;
|
||||
font-weight: 700;
|
||||
box-shadow: 0 6px 16px rgba(63,43,94,.08);
|
||||
transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
|
||||
}
|
||||
.mu-pill-link:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(63,43,94,.14); border-color: #d8c9f2; }
|
||||
.mu-pill-link.primary { background: linear-gradient(135deg, #a855f7, #7c3aed); color: #fff; border-color: transparent; box-shadow: 0 8px 18px rgba(124,58,237,.28); }
|
||||
@media (min-width: 720px) { .mu-select-arrow { display: block; } }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.mu-select-box, .mu-pill-link { transition: none; }
|
||||
}
|
||||
|
||||
/* Zones / grid */
|
||||
main.mu-container { padding-top: 40px; padding-bottom: 40px; }
|
||||
.mu-zone { margin-bottom: 32px; }
|
||||
.mu-zone-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 14px; }
|
||||
.mu-zone-tag { padding: 5px 14px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
|
||||
.mu-zone-tag.tag-sky { background: #dbeafe; color: #1d4ed8; }
|
||||
.mu-zone-tag.tag-pink { background: #fce7f3; color: #be185d; }
|
||||
.mu-zone-tag.tag-purple { background: #ede9fe; color: #6d28d9; }
|
||||
.mu-zone-tag.tag-yellow { background: #fdf1d3; color: #8a6100; }
|
||||
|
||||
/* คำอธิบายสีการ์ดตามหมวดเส้นทาง */
|
||||
.mu-legend { background: #fff; border: 1px solid #e9eef7; border-radius: 14px; padding: 16px 18px; margin-bottom: 26px; box-shadow: 0 4px 14px rgba(20,40,90,.05); }
|
||||
.mu-legend-title { margin: 0 0 12px; font-size: .95rem; font-weight: 800; color: #1f2a44; }
|
||||
.mu-legend-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 18px; }
|
||||
.mu-legend-list li { display: flex; align-items: center; gap: 9px; font-size: .86rem; color: #3d4a63; }
|
||||
.mu-legend-list .sw { width: 26px; height: 16px; border-radius: 4px; flex: none; border: 1px solid rgba(20,40,90,.12); }
|
||||
.sw-bangkok { background: linear-gradient(135deg, #3b82f6, #60a5fa); }
|
||||
.sw-interprov { background: linear-gradient(135deg, #8b5cf6, #c084fc); }
|
||||
.sw-inprov { background: linear-gradient(135deg, #ec4899, #f472b6); }
|
||||
.sw-municipal { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
|
||||
.sw-empty { background: #e4e7eb; }
|
||||
.mu-legend-note { margin: 12px 0 0; color: #6f7b95; font-size: .82rem; }
|
||||
.mu-zone-sub, .mu-zone-desc { color: #6f7b95; font-size: .88rem; margin: 0; }
|
||||
/* ทุกบรรทัดคำอธิบายกินเต็มความกว้างของตัวเอง — ไม่ถูกบีบไปรวมแถวเดียวกับป้ายหัวข้อ
|
||||
(เดิม flex ไม่มี wrap → ทุกบรรทัดถูกย่อรวมกันหมด ข้อความไทยจึงตัดคำมั่ว) */
|
||||
.mu-zone-head .mu-zone-desc { flex-basis: 100%; min-width: 0; line-height: 1.65; }
|
||||
|
||||
/* แถวข้อมูลแบบ "ชิ้น" (segment) — กฎจริงอยู่ใน responsive.css (#view …) เพราะต้องชนะ
|
||||
<style> ของ partial ที่ถูก inject ทีหลัง · ที่นี่เก็บเฉพาะสีที่ใช้ร่วมทุกหน้า */
|
||||
.mu-zone-updated { color: #8a7aa8; }
|
||||
.mu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
|
||||
|
||||
/* Cards */
|
||||
.mu-card { display: block; text-decoration: none; color: inherit; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 14px rgba(20,40,90,.06); transition: transform .15s, box-shadow .15s; }
|
||||
.mu-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(20,40,90,.1); }
|
||||
.mu-card-head { aspect-ratio: auto !important; height: 130px !important; display: flex !important; align-items: center; justify-content: center; position: relative; }
|
||||
.mu-card-head::after { display: none !important; }
|
||||
.mu-card-head .mu-route-number { position: static !important; color: #fff !important; font-size: 52px !important; font-weight: 900; text-shadow: 0 4px 12px rgba(0,0,0,.2) !important; letter-spacing: .02em; margin: 0; }
|
||||
.mu-route-info { padding: 14px 14px 14px; }
|
||||
.mu-route-name { margin: 0 0 10px; font-size: .9rem; color: #1f2a44; font-weight: 700; }
|
||||
.mu-card .mu-badge { background: #dcfce7; color: #15803d; padding: 4px 10px; font-size: .78rem; font-weight: 700; box-shadow: none; backdrop-filter: none; }
|
||||
.mu-next-trip { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #dcfce7; color: #15803d; }
|
||||
.badge-purple { background: #ede9fe; color: #6d28d9; }
|
||||
.badge-sky { background: #dbeafe; color: #1d4ed8; }
|
||||
.badge-pink { background: #fce7f3; color: #be185d; }
|
||||
.badge-mint { background: #d1fae5; color: #047857; }
|
||||
.badge-gray { background: #e8eaed; color: #5b636e; }
|
||||
.mu-route-chip-wrap { display:flex; gap: 8px; }
|
||||
|
||||
/* Summary stats */
|
||||
.mu-summary { padding: 20px 0 40px; }
|
||||
.mu-summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
|
||||
.mu-stat { padding: 28px 18px; text-align: center; border-radius: 18px; font-weight: 700; margin: 0; }
|
||||
.mu-stat h3 { margin: 0 0 4px; font-size: 2rem; color: #1f2a44; font-weight: 800; }
|
||||
.mu-stat p { margin: 0; font-size: .82rem; color: #4a5876; font-weight: 600; }
|
||||
.mu-stat.tag-pink { background: #fce7f3; }
|
||||
.mu-stat.tag-sky { background: #dbeafe; }
|
||||
.mu-stat.tag-purple { background: #ede9fe; }
|
||||
.mu-stat.tag-mint { background: #d1fae5; }
|
||||
|
||||
/* ===== Visitor counter (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; }
|
||||
.mu-sponsor-head { text-align: center; margin-bottom: 18px; }
|
||||
.mu-sponsor-head h4 { margin: 0 0 4px; font-size: 1rem; font-weight: 800; color: #1f2a44; letter-spacing: .01em; }
|
||||
.mu-sponsor-head .lead { margin: 0; color: #6f7b95; font-size: .84rem; }
|
||||
.mu-marquee {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.mu-marquee-track {
|
||||
display: flex;
|
||||
width: max-content;
|
||||
padding: 4px 0 16px;
|
||||
animation: mu-marquee-scroll 28s linear infinite;
|
||||
}
|
||||
.mu-marquee:hover .mu-marquee-track { animation-play-state: paused; }
|
||||
@keyframes mu-marquee-scroll {
|
||||
from { transform: translateX(0); }
|
||||
to { transform: translateX(-50%); }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.mu-marquee-track { animation: none; width: auto; flex-wrap: wrap; justify-content: center; gap: 16px; }
|
||||
.mu-marquee-tile { margin-right: 0; }
|
||||
}
|
||||
.mu-marquee-tile {
|
||||
flex: 0 0 auto;
|
||||
width: 170px;
|
||||
height: 96px;
|
||||
margin-right: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #fff;
|
||||
border: 1px solid #eef0f6;
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 4px 12px rgba(63, 43, 94, .05);
|
||||
transition: transform .2s ease, box-shadow .2s ease;
|
||||
}
|
||||
.mu-marquee-tile img {
|
||||
max-width: 78%;
|
||||
max-height: 64%;
|
||||
object-fit: contain;
|
||||
filter: grayscale(.2);
|
||||
transition: filter .2s ease;
|
||||
}
|
||||
.mu-marquee-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(63, 43, 94, .12); }
|
||||
.mu-marquee-tile:hover img { filter: grayscale(0); }
|
||||
|
||||
/* ===== SPA central view ===== */
|
||||
#view { min-height: 60vh; }
|
||||
Reference in new issue
Block a user