feat: design initial ui
This commit is contained in:
commit
8e87e47017
6 files changed
+855
No files matched your search
@@ -0,0 +1,77 @@
|
||||
# AlterFlixHub — Web Mockup & Route Diagram
|
||||
|
||||
ต้นแบบเว็บไซต์ศูนย์รวมข้อมูลโรงภาพยนตร์ **AlterFlixHub** (static HTML + vanilla JS — ไม่มี backend / framework / build step)
|
||||
|
||||
ประกอบด้วย:
|
||||
- หน้าเว็บต้นแบบ (mockup) 3 หน้า
|
||||
- **Action Route Map** — diagram แสดงผังหน้าเว็บพร้อมลูกศร action route
|
||||
|
||||
## โครงสร้าง
|
||||
|
||||
```
|
||||
web-alterflixhub/
|
||||
├── resource/
|
||||
│ ├── prome.md ← สเปกงานออกแบบ (อ่านก่อนแก้ UI)
|
||||
│ ├── images/
|
||||
│ │ └── template-cinema-detail.png ← template หน้า cinema-detail (1200×778, ดำ-แดง)
|
||||
│ └── ui/ ← ★ ผลลัพธ์ (หน้า mockup + diagram)
|
||||
│ ├── home.html ← หน้าแรก: การ์ดโรงหนัง
|
||||
│ ├── cinema-detail.html ← รายละเอียดโรงภาพยนตร์
|
||||
│ └── index.html ← Action Route Map (diagram)
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## วิธีรัน (Step-by-step)
|
||||
|
||||
### 1. เปิด Terminal แล้วเข้าไปที่ root ของโปรเจกต์
|
||||
|
||||
```bash
|
||||
cd /Users/ar667100/Desktop/myworkspace/bank-project/workspace/alterflixhub/web-alterflixhub
|
||||
```
|
||||
|
||||
> ถ้าเครื่องคนอื่น path ต่างกัน ให้ `cd` ไปที่โฟลเดอร์ `web-alterflixhub` (ที่มีไฟล์ `README.md` นี้)
|
||||
|
||||
### 2. ตรวจสอบว่ามี Python 3
|
||||
|
||||
```bash
|
||||
python3 --version
|
||||
```
|
||||
|
||||
> ต้องได้เวอร์ชัน 3.x ขึ้นไป (macOS/Windows/Linux มี Python 3 ติดตั้งมาให้ หรือติดตั้งจาก python.org)
|
||||
|
||||
### 3. รัน static server
|
||||
|
||||
```bash
|
||||
python3 -m http.server 8000
|
||||
```
|
||||
|
||||
> **สำคัญ:** ต้องรันจาก root ของโปรเจกต์ (ไม่ใช่จาก `resource/ui/`)
|
||||
> เพราะหน้าเว็บอ้างไฟล์กันด้วย relative path — ต้องมี root เดียวกันครอบทั้ง tree
|
||||
|
||||
### 4. เปิดเบราว์เซอร์
|
||||
|
||||
| หน้า | URL |
|
||||
|---|---|
|
||||
| **Action Route Map (diagram)** | http://localhost:8000/resource/ui/index.html |
|
||||
| หน้าแรก (Home) | http://localhost:8000/resource/ui/home.html |
|
||||
| รายละเอียดโรงภาพยนตร์ | http://localhost:8000/resource/ui/cinema-detail.html |
|
||||
|
||||
### 5. หยุด server
|
||||
|
||||
กด `Ctrl+C` ในหน้าต่าง Terminal ที่รัน server อยู่
|
||||
|
||||
## เปลี่ยน port
|
||||
|
||||
ถ้า port `8000` ถูกใช้งานอยู่ ให้เปลี่ยนเป็นเลขอื่น (เช่น 8090):
|
||||
|
||||
```bash
|
||||
python3 -m http.server 8090
|
||||
```
|
||||
|
||||
แล้วเปิด `http://localhost:8090/resource/ui/index.html`
|
||||
|
||||
## หมายเหตุ
|
||||
|
||||
- **ห้ามเปิด `file://`** — ให้รันผ่าน static server เสมอ (ตามขั้นตอนด้านบน)
|
||||
- Diagram (`index.html`) render แต่ละหน้าแบบ **desktop 1200px + ความสูงเต็ม** แล้วย่อเป็น thumbnail 300px (`scale 0.25`) เพื่อความกระทัดรัด
|
||||
- สี theme: **ดำ-แดง** (`#0a0a0a` / `#e00000`) ตาม spec ใน `resource/prome.md` และ template `template-cinema-detail.png`
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 351 KiB |
@@ -0,0 +1,6 @@
|
||||
ให้สร้าง index.html ไฟล์สำหรับแสดง diagram prototype เพื่อแสดงหน้า web ทั้งหมดที่กำลัง design นี้ โดย diagram จะแสดงเป็นแผนผังพร้อมลูกศรแสดง action อย่างละเอียด ซึ่งแต่ละ node จะแสดงหน้าตาของ page route นั้น ๆ ซึ่งเป็น scale ของ desktop แต่จะถูก resize มาแสดงในรูปแบบ thumbnail เพื่อความกระทัดรัดและจัดลูกศรได้อย่างเป็นระเบียบ
|
||||
|
||||
เว็บไซต์นี้จะมีคุณสมบัติที่ต้องการดังต่อไปนี้
|
||||
1. หน้าแรก ทำหน้าที่แสดงโรงหนังต่าง ๆ โดยใช้รูปแบบของการ์ด โดยผู้ใช้สามารถกดคลิกเพื่อเข้าไปหน้า "cinema-detail" ได้ โดยรูปแบบของหน้าแรกนี้จะใช้ theme modern โลกอนาคต และมีความสบายตา ไม่รก ใช้ดำแดงเป็นหลัก(มีการการใช้ลูกเล่นไล่ระดับสีด้วย)
|
||||
2. หน้า cinema-detail จะใช้ templete ของ resource/images/template-cinema-detail.png เพื่อแสดงรายละเอียดของโรงหนังนั้น ๆ อย่างเหมาะสม
|
||||
3. ในส่วนของ navbar จะมีส่วน "logo"(alterflixhub) "เกี่ยวกับเรา"(เป็นปุ่มเมื่อกดแล้วจะแสดง popup กรอบสีแดง พื้นหลังสีดำ มีข้อมูลของผู้พัฒนา) "ภาษา"(รองรับไทย-อังกฤษ)
|
||||
@@ -0,0 +1,204 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="th">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AlterFlixHub — รายละเอียดโรงภาพยนตร์</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #0a0a0a;
|
||||
--surface: #141414;
|
||||
--surface-2: #1c1c1c;
|
||||
--border: rgba(255,255,255,.08);
|
||||
--red: #e00000;
|
||||
--red-2: #ff1f1f;
|
||||
--red-dark: #7a0000;
|
||||
--ink: #f5f5f5;
|
||||
--muted: #9ca3af;
|
||||
--grad-red: linear-gradient(135deg, #ff1f1f 0%, #e00000 45%, #7a0000 100%);
|
||||
--grad-bg: linear-gradient(180deg, #0a0a0a 0%, #160505 55%, #0a0a0a 100%);
|
||||
--sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
--mono: "SF Mono", ui-monospace, Menlo, monospace;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); }
|
||||
body { background: var(--grad-bg); min-height: 100vh; }
|
||||
|
||||
.nav { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 18px;
|
||||
padding: 12px 32px; background: rgba(10,10,10,.85); backdrop-filter: blur(12px);
|
||||
border-bottom: 1px solid var(--border); }
|
||||
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
|
||||
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--grad-red);
|
||||
display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff; font-size: 1rem; box-shadow: 0 4px 16px rgba(224,0,0,.4); }
|
||||
.logo-name { font-weight: 800; font-size: 1.1rem; letter-spacing: .02em; color: var(--ink); }
|
||||
.logo-name b { color: var(--red-2); }
|
||||
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
|
||||
.btn { font: inherit; font-size: .85rem; font-weight: 600; padding: 8px 16px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
|
||||
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
|
||||
.btn-ghost:hover { border-color: var(--red-2); color: var(--red-2); }
|
||||
.lang { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
|
||||
.lang button { font: inherit; font-size: .8rem; font-weight: 700; padding: 7px 12px; cursor: pointer; border: 0; background: transparent; color: var(--muted); }
|
||||
.lang button.active { background: var(--red); color: #fff; }
|
||||
|
||||
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 28px 60px; }
|
||||
.crumb { margin: 0 0 16px; color: var(--muted); font-size: .85rem; }
|
||||
.crumb a { color: var(--red-2); text-decoration: none; font-weight: 600; }
|
||||
|
||||
/* hero */
|
||||
.detail-hero { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); }
|
||||
.detail-hero .bg { height: 240px; background: linear-gradient(135deg, #2a0505 0%, #e00000 60%, #ff4d4d 100%); }
|
||||
.detail-hero .overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.1) 0%, rgba(10,10,10,.9) 100%); display: flex; align-items: flex-end; padding: 22px 24px; }
|
||||
.detail-hero h1 { margin: 0 0 4px; font-size: 1.9rem; font-weight: 900; }
|
||||
.detail-hero .tag { display: inline-block; font-size: .75rem; font-weight: 700; background: rgba(224,0,0,.9); color: #fff; padding: 4px 12px; border-radius: 999px; margin-bottom: 10px; }
|
||||
.detail-hero .sub { margin: 0; color: var(--muted); font-size: .9rem; }
|
||||
|
||||
/* stat row */
|
||||
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 20px 0; }
|
||||
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
|
||||
.stat h3 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 800; color: var(--red-2); }
|
||||
.stat p { margin: 0; color: var(--muted); font-size: .78rem; }
|
||||
|
||||
/* sections */
|
||||
.section { margin: 24px 0; }
|
||||
.section h2 { margin: 0 0 14px; font-size: 1.15rem; font-weight: 800; padding-bottom: 8px; border-bottom: 2px solid var(--red); display: inline-block; }
|
||||
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; line-height: 1.7; color: var(--muted); font-size: .9rem; }
|
||||
.info-card b { color: var(--ink); }
|
||||
|
||||
/* movie/showtime cards */
|
||||
.movies { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
|
||||
.movie { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
|
||||
.movie .poster { height: 130px; }
|
||||
.movie .p1 { background: linear-gradient(135deg,#1a0a0a,#c00000); }
|
||||
.movie .p2 { background: linear-gradient(135deg,#3a0d0d,#e00000); }
|
||||
.movie .p3 { background: linear-gradient(135deg,#0d1a1a,#c00000); }
|
||||
.movie .p4 { background: linear-gradient(135deg,#1a0a0a,#a00000); }
|
||||
.movie .p5 { background: linear-gradient(135deg,#2b0a0a,#ff1f1f); }
|
||||
.movie .p6 { background: linear-gradient(135deg,#4d0707,#e00000); }
|
||||
.movie .body { padding: 12px 14px; }
|
||||
.movie .body h4 { margin: 0 0 6px; font-size: .92rem; font-weight: 700; }
|
||||
.movie .times { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.time { font-family: var(--mono); font-size: .72rem; font-weight: 700; background: rgba(224,0,0,.15); border: 1px solid rgba(224,0,0,.4); color: var(--red-2); padding: 4px 8px; border-radius: 6px; }
|
||||
.time.hot { background: var(--grad-red); color: #fff; border-color: transparent; }
|
||||
|
||||
dialog.about { border: 2px solid var(--red-2); background: #0a0a0a; color: var(--ink); border-radius: 14px; padding: 0; width: min(92vw, 420px); }
|
||||
dialog.about::backdrop { background: rgba(0,0,0,.7); }
|
||||
.about-box { padding: 22px 24px; }
|
||||
.about-box h3 { margin: 0 0 8px; font-size: 1.15rem; color: var(--red-2); }
|
||||
.about-box p { margin: 0 0 14px; color: var(--muted); font-size: .88rem; line-height: 1.6; }
|
||||
.about-box .dev { border-top: 1px solid var(--border); padding-top: 12px; font-size: .82rem; }
|
||||
.about-box .dev b { color: var(--red-2); }
|
||||
.about-box .close { margin-top: 16px; width: 100%; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="nav">
|
||||
<a class="logo" href="home.html">
|
||||
<span class="logo-mark">A</span>
|
||||
<span class="logo-name" data-i18n="brand">Alter<b>Flix</b>Hub</span>
|
||||
</a>
|
||||
<div class="nav-right">
|
||||
<button class="btn btn-ghost" id="about-btn" data-i18n="about">เกี่ยวกับเรา</button>
|
||||
<div class="lang" role="group" aria-label="ภาษา">
|
||||
<button data-lang="th" class="active">ไทย</button>
|
||||
<button data-lang="en">EN</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="wrap">
|
||||
<p class="crumb"><a href="home.html">หน้าแรก</a> / รายละเอียดโรงภาพยนตร์</p>
|
||||
|
||||
<section class="detail-hero">
|
||||
<div class="bg"></div>
|
||||
<div class="overlay">
|
||||
<div>
|
||||
<span class="tag" data-i18n="open">เปิดบริการ</span>
|
||||
<h1 id="cinema-name">AlterFlix Major</h1>
|
||||
<p class="sub" id="cinema-loc">ชั้น 4 เซ็นทรัลเวิลด์ · กรุงเทพมหานคร</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="stats">
|
||||
<div class="stat"><h3>4.8</h3><p data-i18n="rating">คะแนน</p></div>
|
||||
<div class="stat"><h3>12</h3><p data-i18n="screens">โรงฉาย</p></div>
|
||||
<div class="stat"><h3>2,480</h3><p data-i18n="seats">ที่นั่ง</p></div>
|
||||
<div class="stat"><h3>18</h3><p data-i18n="movies">หนังรอบวันนี้</p></div>
|
||||
</div>
|
||||
|
||||
<section class="section">
|
||||
<h2 data-i18n="aboutCinema">เกี่ยวกับโรงภาพยนตร์</h2>
|
||||
<div class="info-card">
|
||||
<b data-i18n="addr">ที่อยู่:</b> ชั้น 4 ศูนย์การค้าเซ็นทรัลเวิลด์ · <b data-i18n="facilities">สิ่งอำนวยความสะดวก:</b> IMAX, Dolby Atmos, VIP Lounge, ที่จอดรถฟรี 4 ชม.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2 data-i18n="showtimes">รอบฉายวันนี้</h2>
|
||||
<div class="movies" id="movies"></div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<dialog class="about" id="about-dialog">
|
||||
<div class="about-box">
|
||||
<h3 data-i18n="about">เกี่ยวกับเรา</h3>
|
||||
<p data-i18n="aboutBody">AlterFlixHub — ศูนย์รวมข้อมูลโรงภาพยนตร์ ดูรอบฉาย เปรียบเทียบ และค้นพบประสบการณ์ชมภาพยนตร์ที่ดีที่สุด</p>
|
||||
<div class="dev"><b>ผู้พัฒนา:</b> AlterFlixHub Team · v1.0.0</div>
|
||||
<button class="btn btn-red close" id="about-close" data-i18n="close">ปิด</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
var q = new URLSearchParams(location.search);
|
||||
var name = q.get('cinema') || 'AlterFlix Major';
|
||||
document.getElementById('cinema-name').textContent = name;
|
||||
|
||||
var MOVIES = [
|
||||
{ t: 'The Red Horizon', g: 'p1' }, { t: 'Neon Runner', g: 'p2' }, { t: 'Deep Space 9', g: 'p3' },
|
||||
{ t: 'Crimson Tide', g: 'p4' }, { t: 'Midnight Drive', g: 'p5' }, { t: 'Lost Signal', g: 'p6' }
|
||||
];
|
||||
var times = ['10:30','13:00','15:30','18:00','20:30','23:00'];
|
||||
var movies = document.getElementById('movies');
|
||||
MOVIES.forEach(function (m, i) {
|
||||
var div = document.createElement('div');
|
||||
div.className = 'movie';
|
||||
var tHtml = times.slice(0, 3 + (i % 3)).map(function (t, j) {
|
||||
return '<span class="time' + (j === 0 ? ' hot' : '') + '">' + t + '</span>';
|
||||
}).join('');
|
||||
div.innerHTML = '<div class="poster ' + m.g + '"></div>' +
|
||||
'<div class="body"><h4>' + m.t + '</h4><div class="times">' + tHtml + '</div></div>';
|
||||
movies.appendChild(div);
|
||||
});
|
||||
|
||||
var dlg = document.getElementById('about-dialog');
|
||||
document.getElementById('about-btn').addEventListener('click', function () { dlg.showModal(); });
|
||||
document.getElementById('about-close').addEventListener('click', function () { dlg.close(); });
|
||||
|
||||
var LANG = {
|
||||
th: { brand: 'Alter<b>Flix</b>Hub', about: 'เกี่ยวกับเรา', open: 'เปิดบริการ', rating: 'คะแนน', screens: 'โรงฉาย',
|
||||
seats: 'ที่นั่ง', movies: 'หนังรอบวันนี้', aboutCinema: 'เกี่ยวกับโรงภาพยนตร์', showtimes: 'รอบฉายวันนี้',
|
||||
addr: 'ที่อยู่:', facilities: 'สิ่งอำนวยความสะดวก:', close: 'ปิด',
|
||||
aboutBody: 'AlterFlixHub — ศูนย์รวมข้อมูลโรงภาพยนตร์ ดูรอบฉาย เปรียบเทียบ และค้นพบประสบการณ์ชมภาพยนตร์ที่ดีที่สุด' },
|
||||
en: { brand: 'Alter<b>Flix</b>Hub', about: 'About Us', open: 'Now Open', rating: 'Rating', screens: 'Screens',
|
||||
seats: 'Seats', movies: 'Movies Today', aboutCinema: 'About Cinema', showtimes: 'Today\'s Showtimes',
|
||||
addr: 'Address:', facilities: 'Facilities:', close: 'Close',
|
||||
aboutBody: 'AlterFlixHub — your hub for cinema info, showtimes and the best movie-going experience.' }
|
||||
};
|
||||
document.querySelectorAll('.lang button').forEach(function (b) {
|
||||
b.addEventListener('click', function () {
|
||||
document.querySelectorAll('.lang button').forEach(function (x) { x.classList.remove('active'); });
|
||||
b.classList.add('active');
|
||||
var lang = b.getAttribute('data-lang');
|
||||
document.querySelectorAll('[data-i18n]').forEach(function (el) {
|
||||
var k = el.getAttribute('data-i18n');
|
||||
if (LANG[lang][k]) el.innerHTML = LANG[lang][k];
|
||||
});
|
||||
});
|
||||
});
|
||||
if (q.get('about') === '1') dlg.showModal();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,195 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="th">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AlterFlixHub — หน้าแรก</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #0a0a0a;
|
||||
--surface: #141414;
|
||||
--surface-2: #1c1c1c;
|
||||
--border: rgba(255,255,255,.08);
|
||||
--red: #e00000;
|
||||
--red-2: #ff1f1f;
|
||||
--red-dark: #7a0000;
|
||||
--ink: #f5f5f5;
|
||||
--muted: #9ca3af;
|
||||
--grad-red: linear-gradient(135deg, #ff1f1f 0%, #e00000 45%, #7a0000 100%);
|
||||
--grad-bg: linear-gradient(180deg, #0a0a0a 0%, #160505 55%, #0a0a0a 100%);
|
||||
--sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
--mono: "SF Mono", ui-monospace, Menlo, monospace;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); }
|
||||
body { background: var(--grad-bg); min-height: 100vh; }
|
||||
|
||||
/* navbar */
|
||||
.nav { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 18px;
|
||||
padding: 12px 32px; background: rgba(10,10,10,.85); backdrop-filter: blur(12px);
|
||||
border-bottom: 1px solid var(--border); }
|
||||
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
|
||||
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--grad-red);
|
||||
display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff; font-size: 1rem; box-shadow: 0 4px 16px rgba(224,0,0,.4); }
|
||||
.logo-name { font-weight: 800; font-size: 1.1rem; letter-spacing: .02em; color: var(--ink); }
|
||||
.logo-name b { color: var(--red-2); }
|
||||
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
|
||||
.btn { font: inherit; font-size: .85rem; font-weight: 600; padding: 8px 16px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
|
||||
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
|
||||
.btn-ghost:hover { border-color: var(--red-2); color: var(--red-2); }
|
||||
.btn-red { background: var(--grad-red); color: #fff; box-shadow: 0 4px 14px rgba(224,0,0,.35); }
|
||||
.lang { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
|
||||
.lang button { font: inherit; font-size: .8rem; font-weight: 700; padding: 7px 12px; cursor: pointer; border: 0; background: transparent; color: var(--muted); }
|
||||
.lang button.active { background: var(--red); color: #fff; }
|
||||
|
||||
/* hero */
|
||||
.hero { padding: 60px 32px 44px; text-align: center; }
|
||||
.hero h1 { margin: 0 0 10px; font-size: 2.4rem; font-weight: 900; letter-spacing: -.01em; }
|
||||
.hero h1 .accent { background: var(--grad-red); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
|
||||
.hero p { margin: 0 auto; max-width: 560px; color: var(--muted); font-size: .98rem; line-height: 1.6; }
|
||||
|
||||
/* cinema grid */
|
||||
.grid-wrap { max-width: 1160px; margin: 0 auto; padding: 0 28px 60px; }
|
||||
.grid-head { display: flex; align-items: baseline; gap: 12px; margin: 26px 0 16px; }
|
||||
.grid-head h2 { margin: 0; font-size: 1.25rem; font-weight: 800; }
|
||||
.grid-head span { color: var(--muted); font-size: .85rem; }
|
||||
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
|
||||
.card { display: block; text-decoration: none; color: inherit; background: var(--surface);
|
||||
border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
|
||||
transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
|
||||
.card:hover { transform: translateY(-3px); border-color: var(--red-2); box-shadow: 0 12px 30px rgba(224,0,0,.18); }
|
||||
.card-cover { height: 150px; position: relative; display: flex; align-items: flex-end; }
|
||||
.card-cover .g1 { background: linear-gradient(135deg,#7a0000,#e00000); }
|
||||
.card-cover .g2 { background: linear-gradient(135deg,#3a0d0d,#a00000); }
|
||||
.card-cover .g3 { background: linear-gradient(135deg,#1a0a0a,#c00000); }
|
||||
.card-cover .g4 { background: linear-gradient(135deg,#5c0505,#ff1f1f); }
|
||||
.card-cover .g5 { background: linear-gradient(135deg,#2b0a0a,#b00000); }
|
||||
.card-cover .g6 { background: linear-gradient(135deg,#4d0707,#e00000); }
|
||||
.card-cover .badge { position: absolute; top: 12px; left: 12px; font-size: .7rem; font-weight: 700;
|
||||
background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.2); color: #fff;
|
||||
padding: 4px 10px; border-radius: 999px; }
|
||||
.card-cover .badge.open { background: rgba(224,0,0,.85); border-color: var(--red-2); }
|
||||
.card-body { padding: 14px 16px 16px; }
|
||||
.card-body h3 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 700; }
|
||||
.card-body .loc { margin: 0 0 10px; color: var(--muted); font-size: .82rem; }
|
||||
.card-meta { display: flex; align-items: center; gap: 10px; font-size: .8rem; }
|
||||
.rating { color: var(--red-2); font-weight: 800; }
|
||||
.open-now { color: #22c55e; font-weight: 600; }
|
||||
|
||||
/* about popup */
|
||||
dialog.about { border: 2px solid var(--red-2); background: #0a0a0a; color: var(--ink);
|
||||
border-radius: 14px; padding: 0; width: min(92vw, 420px); }
|
||||
dialog.about::backdrop { background: rgba(0,0,0,.7); }
|
||||
.about-box { padding: 22px 24px; }
|
||||
.about-box h3 { margin: 0 0 8px; font-size: 1.15rem; color: var(--red-2); }
|
||||
.about-box p { margin: 0 0 14px; color: var(--muted); font-size: .88rem; line-height: 1.6; }
|
||||
.about-box .dev { border-top: 1px solid var(--border); padding-top: 12px; font-size: .82rem; color: var(--ink); }
|
||||
.about-box .dev b { color: var(--red-2); }
|
||||
.about-box .close { margin-top: 16px; width: 100%; }
|
||||
|
||||
footer { border-top: 1px solid var(--border); padding: 22px 32px; text-align: center; color: var(--muted); font-size: .8rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="nav">
|
||||
<a class="logo" href="home.html">
|
||||
<span class="logo-mark">A</span>
|
||||
<span class="logo-name" data-i18n="brand">Alter<b>Flix</b>Hub</span>
|
||||
</a>
|
||||
<div class="nav-right">
|
||||
<button class="btn btn-ghost" id="about-btn" data-i18n="about">เกี่ยวกับเรา</button>
|
||||
<div class="lang" role="group" aria-label="ภาษา">
|
||||
<button data-lang="th" class="active">ไทย</button>
|
||||
<button data-lang="en">EN</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section class="hero">
|
||||
<h1><span class="accent" data-i18n="hero1">ค้นพบโรงภาพยนตร์</span><br><span data-i18n="hero2">รอบตัวคุณ</span></h1>
|
||||
<p data-i18n="lead">เลือกโรงภาพยนตร์ที่ใช่ ดูรอบฉายและรายละเอียดได้ในที่เดียว</p>
|
||||
</section>
|
||||
|
||||
<div class="grid-wrap">
|
||||
<div class="grid-head">
|
||||
<h2 data-i18n="cinemas">โรงภาพยนตร์ทั้งหมด</h2>
|
||||
<span data-i18n="count">6 แห่ง</span>
|
||||
</div>
|
||||
<div class="grid" id="grid">
|
||||
<!-- การ์ดสร้างด้วย JS จากข้อมูล cinema -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>© 2026 AlterFlixHub</footer>
|
||||
|
||||
<dialog class="about" id="about-dialog">
|
||||
<div class="about-box">
|
||||
<h3 data-i18n="about">เกี่ยวกับเรา</h3>
|
||||
<p data-i18n="aboutBody">AlterFlixHub — ศูนย์รวมข้อมูลโรงภาพยนตร์ ดูรอบฉาย เปรียบเทียบ และค้นพบประสบการณ์ชมภาพยนตร์ที่ดีที่สุด</p>
|
||||
<div class="dev"><b>ผู้พัฒนา:</b> AlterFlixHub Team · v1.0.0</div>
|
||||
<button class="btn btn-red close" id="about-close" data-i18n="close">ปิด</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
var CINEMAS = [
|
||||
{ name: 'AlterFlix Major', loc: 'ชั้น 4 เซ็นทรัลเวิลด์', rating: 4.8, open: true, g: 'g1' },
|
||||
{ name: 'AlterFlix IMAX', loc: 'ชั้น 5 สยามพารากอน', rating: 4.9, open: true, g: 'g2' },
|
||||
{ name: 'AlterFlix Plus', loc: 'ชั้น 3 เอ็มควอเทียร์', rating: 4.7, open: true, g: 'g3' },
|
||||
{ name: 'AlterFlix Mini', loc: 'ชั้น 2 เดอะมอลล์บางกะปิ', rating: 4.5, open: false, g: 'g4' },
|
||||
{ name: 'AlterFlix VIP', loc: 'ชั้น 6 ไอคอนสยาม', rating: 4.9, open: true, g: 'g5' },
|
||||
{ name: 'AlterFlix Classic', loc: 'ชั้น 3 ฟิวเจอร์พาร์ค', rating: 4.4, open: true, g: 'g6' }
|
||||
];
|
||||
|
||||
var grid = document.getElementById('grid');
|
||||
CINEMAS.forEach(function (c) {
|
||||
var a = document.createElement('a');
|
||||
a.className = 'card';
|
||||
a.href = 'cinema-detail.html?cinema=' + encodeURIComponent(c.name);
|
||||
a.innerHTML =
|
||||
'<div class="card-cover ' + c.g + '">' +
|
||||
'<span class="badge ' + (c.open ? 'open' : '') + '">' + (c.open ? 'เปิดบริการ' : 'ปิดปรับปรุง') + '</span>' +
|
||||
'</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h3>' + c.name + '</h3>' +
|
||||
'<p class="loc">' + c.loc + '</p>' +
|
||||
'<div class="card-meta"><span class="rating">★ ' + c.rating.toFixed(1) + '</span>' +
|
||||
'<span class="open-now">' + (c.open ? 'เปิดบริการ' : 'ปิดปรับปรุง') + '</span></div>' +
|
||||
'</div>';
|
||||
grid.appendChild(a);
|
||||
});
|
||||
|
||||
/* about popup */
|
||||
var dlg = document.getElementById('about-dialog');
|
||||
document.getElementById('about-btn').addEventListener('click', function () { dlg.showModal(); });
|
||||
document.getElementById('about-close').addEventListener('click', function () { dlg.close(); });
|
||||
|
||||
/* ภาษา ไทย/EN */
|
||||
var LANG = {
|
||||
th: { brand: 'Alter<b>Flix</b>Hub', about: 'เกี่ยวกับเรา', hero1: 'ค้นพบโรงภาพยนตร์', hero2: 'รอบตัวคุณ',
|
||||
lead: 'เลือกโรงภาพยนตร์ที่ใช่ ดูรอบฉายและรายละเอียดได้ในที่เดียว', cinemas: 'โรงภาพยนตร์ทั้งหมด', count: '6 แห่ง',
|
||||
close: 'ปิด', aboutBody: 'AlterFlixHub — ศูนย์รวมข้อมูลโรงภาพยนตร์ ดูรอบฉาย เปรียบเทียบ และค้นพบประสบการณ์ชมภาพยนตร์ที่ดีที่สุด' },
|
||||
en: { brand: 'Alter<b>Flix</b>Hub', about: 'About Us', hero1: 'Discover Cinemas', hero2: 'Around You',
|
||||
lead: 'Pick the right cinema, check showtimes and details in one place.', cinemas: 'All Cinemas', count: '6 venues',
|
||||
close: 'Close', aboutBody: 'AlterFlixHub — your hub for cinema info, showtimes and the best movie-going experience.' }
|
||||
};
|
||||
document.querySelectorAll('.lang button').forEach(function (b) {
|
||||
b.addEventListener('click', function () {
|
||||
document.querySelectorAll('.lang button').forEach(function (x) { x.classList.remove('active'); });
|
||||
b.classList.add('active');
|
||||
var lang = b.getAttribute('data-lang');
|
||||
document.querySelectorAll('[data-i18n]').forEach(function (el) {
|
||||
var k = el.getAttribute('data-i18n');
|
||||
if (LANG[lang][k]) el.innerHTML = LANG[lang][k];
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* เปิด popup อัตโนมัติ เมื่อมี ?about=1 (ให้ diagram แสดง popup state ได้) */
|
||||
if (new URLSearchParams(location.search).get('about') === '1') dlg.showModal();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,373 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="th">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AlterFlixHub — Action Route Map</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg-deep: #050505;
|
||||
--surface: #141414;
|
||||
--surface-2: #1c1c1c;
|
||||
--border: rgba(255,255,255,.08);
|
||||
--ink: #F5F5F5;
|
||||
--muted: #9ca3af;
|
||||
--red: #e00000;
|
||||
--red-2: #ff1f1f;
|
||||
--mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
|
||||
--sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
--grad-bg: linear-gradient(180deg, #050505 0%, #160505 50%, #050505 100%);
|
||||
--grad-red: linear-gradient(135deg, #ff1f1f 0%, #e00000 45%, #7a0000 100%);
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; background: var(--bg-deep); color: var(--ink); font-family: var(--sans); }
|
||||
body { background: var(--grad-bg); }
|
||||
|
||||
.topbar {
|
||||
position: sticky; top: 0; z-index: 50;
|
||||
background: rgba(10,10,10,.85); backdrop-filter: blur(14px);
|
||||
border-bottom: 1px solid var(--border); padding: 12px 28px;
|
||||
}
|
||||
.topbar-inner { max-width: 1720px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
|
||||
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red-2); box-shadow: 0 0 0 0 rgba(255,31,31,.6); animation: pulse 2s infinite; flex: none; }
|
||||
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,31,31,.55);} 70% { box-shadow: 0 0 0 9px rgba(255,31,31,0);} 100% { box-shadow: 0 0 0 0 rgba(255,31,31,0);} }
|
||||
.topbar h1 { margin: 0; font-size: 1.2rem; font-weight: 800; letter-spacing: .01em; }
|
||||
.topbar h1 b { color: var(--red-2); }
|
||||
.topbar .sub { color: var(--muted); font-size: .8rem; margin: 2px 0 0; }
|
||||
.stats { margin-left: auto; display: flex; gap: 8px; }
|
||||
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 14px; font-size: .78rem; }
|
||||
.stat b { color: var(--red-2); font-family: var(--mono); }
|
||||
|
||||
.legend { max-width: 1720px; margin: 0 auto; padding: 12px 28px 2px; display: flex; flex-wrap: wrap; gap: 8px 18px; }
|
||||
.lg { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); }
|
||||
.lg .ln { display: inline-block; width: 26px; height: 0; border-top: 2px solid transparent; }
|
||||
.lg .k { color: var(--ink); font-weight: 600; }
|
||||
|
||||
.stage { position: relative; max-width: 1720px; margin: 10px auto 40px; }
|
||||
svg.edges { position: absolute; top: 0; left: 0; z-index: 0; pointer-events: none; }
|
||||
|
||||
.node { position: absolute; z-index: 1; width: 300px; background: #0b0b0b; border: 1px solid #3a0d0d; border-radius: 10px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.6); }
|
||||
.node-head {
|
||||
display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
|
||||
background: #180808; border-bottom: 1px solid var(--border); padding: 6px 9px;
|
||||
}
|
||||
.node-head .title { font-size: .8rem; font-weight: 700; }
|
||||
.chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
|
||||
.route-chip { font-family: var(--mono); font-size: .62rem; font-weight: 700; color: #fff; background: var(--grad-red); padding: 2px 6px; border-radius: 5px; white-space: nowrap; }
|
||||
.node-open { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; color: #ff8a8a; text-decoration: none; padding: 3px 8px; border: 1px solid #5c1a1a; border-radius: 7px; white-space: nowrap; }
|
||||
.node-open:hover { background: #7a0000; color: #fff; }
|
||||
.node-open svg { width: 12px; height: 12px; }
|
||||
.node-thumb { position: relative; overflow: hidden; background: #0a0a0a; }
|
||||
.node-thumb iframe { display: block; border: 0; transform-origin: top left; pointer-events: none; background: #0a0a0a; }
|
||||
|
||||
.foot { max-width: 1720px; margin: 0 auto 60px; padding: 0 28px; color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; gap: 8px 26px; }
|
||||
.foot code { font-family: var(--mono); color: #fbbf24; background: rgba(251,191,36,.1); padding: 1px 6px; border-radius: 6px; }
|
||||
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="topbar">
|
||||
<div class="topbar-inner">
|
||||
<span class="dot"></span>
|
||||
<div>
|
||||
<h1>Alter<b>Flix</b>Hub — Action Route Map</h1>
|
||||
<div class="sub">3 หน้า (route + popup state) · render desktop 1200px + ความสูงเต็ม แล้วย่อเหลือ thumbnail 300px (scale 0.25)</div>
|
||||
</div>
|
||||
<div class="stats">
|
||||
<span class="stat">pages <b id="stat-pages">–</b></span>
|
||||
<span class="stat">actions <b id="stat-actions">–</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="legend" id="legend"></div>
|
||||
|
||||
<div class="stage" id="stage">
|
||||
<svg class="edges" id="svg" xmlns="http://www.w3.org/2000/svg"></svg>
|
||||
</div>
|
||||
|
||||
<div class="foot">
|
||||
<span><b>เปิดดู</b> <code>python3 -m http.server</code> → <code>http://localhost:8000/resource/ui/index.html</code></span>
|
||||
<span><b>ที่มา</b> resource/prome.md</span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var RENDER_W = 1200; /* render desktop */
|
||||
var DISPLAY_W = 300; /* thumbnail */
|
||||
var SCALE = DISPLAY_W / RENDER_W;
|
||||
|
||||
/* ================= PAGES =================
|
||||
about = home.html?about=1 → แสดง popup เกี่ยวกับเรา (state เดียวกับหน้าแรก) */
|
||||
var PAGES = [
|
||||
{ id: 'home', title: 'หน้าแรก (Home)', routes: ['#/'], src: 'home.html' },
|
||||
{ id: 'detail', title: 'รายละเอียดโรงภาพยนตร์', routes: ['#/cinema/:id'], src: 'cinema-detail.html' },
|
||||
{ id: 'about', title: 'เกี่ยวกับเรา (popup)', routes: ['popup'], src: 'home.html?about=1' }
|
||||
];
|
||||
|
||||
/* ================= ACTIONS ================= */
|
||||
var ACTIONS = [
|
||||
{ from: 'home', to: 'detail', label: 'คลิกการ์ดโรงหนัง', color: '#e00000', back: false },
|
||||
{ from: 'detail', to: 'home', label: 'กลับหน้าแรก (logo/breadcrumb)', color: '#6b7280', back: true },
|
||||
{ from: 'home', to: 'about', label: 'เปิด popup เกี่ยวกับเรา', color: '#ff4d4d', back: false },
|
||||
{ from: 'detail', to: 'about', label: 'เปิด popup (navbar ทุกหน้า)', color: '#ff4d4d', back: false },
|
||||
{ from: 'about', to: 'home', label: 'ปิด popup', color: '#6b7280', back: true },
|
||||
{ from: 'home', to: 'home', label: 'สลับภาษา ไทย ⇄ EN', color: '#fbbf24', back: false }
|
||||
];
|
||||
|
||||
var COLUMNS = [
|
||||
{ x: 40, ids: ['home', 'about'] },
|
||||
{ x: 400, ids: ['detail'] }
|
||||
];
|
||||
var GAP = 60;
|
||||
|
||||
var stage = document.getElementById('stage');
|
||||
var svg = document.getElementById('svg');
|
||||
var byId = {};
|
||||
|
||||
PAGES.forEach(function (p) {
|
||||
var node = document.createElement('div');
|
||||
node.className = 'node';
|
||||
|
||||
var head = document.createElement('div');
|
||||
head.className = 'node-head';
|
||||
var title = document.createElement('span');
|
||||
title.className = 'title';
|
||||
title.textContent = p.title;
|
||||
head.appendChild(title);
|
||||
var chips = document.createElement('span');
|
||||
chips.className = 'chips';
|
||||
p.routes.forEach(function (r) {
|
||||
var c = document.createElement('span');
|
||||
c.className = 'route-chip';
|
||||
c.textContent = r;
|
||||
chips.appendChild(c);
|
||||
});
|
||||
head.appendChild(chips);
|
||||
var open = document.createElement('a');
|
||||
open.className = 'node-open';
|
||||
open.href = p.src;
|
||||
open.target = '_blank';
|
||||
open.rel = 'noopener';
|
||||
open.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg><span>เปิด</span>';
|
||||
head.appendChild(open);
|
||||
node.appendChild(head);
|
||||
|
||||
var thumb = document.createElement('div');
|
||||
thumb.className = 'node-thumb';
|
||||
thumb.style.width = DISPLAY_W + 'px';
|
||||
thumb.style.height = Math.round(700 * SCALE) + 'px';
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.title = p.title + ' — ' + p.routes.join(' · ');
|
||||
iframe.src = p.src;
|
||||
iframe.setAttribute('loading', 'lazy');
|
||||
iframe.setAttribute('scrolling', 'no');
|
||||
iframe.setAttribute('tabindex', '-1');
|
||||
iframe.style.width = RENDER_W + 'px';
|
||||
iframe.style.height = '700px';
|
||||
iframe.style.transform = 'scale(' + SCALE + ')';
|
||||
thumb.appendChild(iframe);
|
||||
node.appendChild(thumb);
|
||||
|
||||
stage.appendChild(node);
|
||||
p._node = node; p._thumb = thumb; p._iframe = iframe;
|
||||
byId[p.id] = p;
|
||||
});
|
||||
|
||||
function fitToContent(p) {
|
||||
var best = 0;
|
||||
function measure() {
|
||||
var doc = null;
|
||||
try { doc = p._iframe.contentDocument; } catch (e) {}
|
||||
if (!doc) return;
|
||||
var h = Math.max(
|
||||
doc.documentElement ? doc.documentElement.scrollHeight : 0,
|
||||
doc.body ? doc.body.scrollHeight : 0
|
||||
);
|
||||
h = Math.min(9000, Math.max(700, h));
|
||||
if (h > best + 24) {
|
||||
best = h;
|
||||
p._iframe.style.height = h + 'px';
|
||||
p._thumb.style.height = Math.round(h * SCALE) + 'px';
|
||||
scheduleLayout();
|
||||
}
|
||||
}
|
||||
var timers = [150, 400, 800, 1400, 2200, 3200];
|
||||
p._iframe.addEventListener('load', function () {
|
||||
timers.forEach(function (t) { setTimeout(measure, t); });
|
||||
});
|
||||
}
|
||||
PAGES.forEach(fitToContent);
|
||||
|
||||
var layoutTimer = null;
|
||||
function scheduleLayout() { clearTimeout(layoutTimer); layoutTimer = setTimeout(layout, 60); }
|
||||
|
||||
var MARKER_COLORS = {};
|
||||
ACTIONS.forEach(function (a) { MARKER_COLORS[a.color] = true; });
|
||||
var defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
|
||||
Object.keys(MARKER_COLORS).forEach(function (c, i) {
|
||||
var id = 'arr' + i;
|
||||
var m = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
|
||||
m.setAttribute('id', id);
|
||||
m.setAttribute('viewBox', '0 0 10 10');
|
||||
m.setAttribute('refX', '9'); m.setAttribute('refY', '5');
|
||||
m.setAttribute('markerWidth', '7'); m.setAttribute('markerHeight', '7');
|
||||
m.setAttribute('orient', 'auto-start-reverse');
|
||||
var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
||||
path.setAttribute('d', 'M 0 0 L 10 5 L 0 10 z');
|
||||
path.setAttribute('fill', c);
|
||||
m.appendChild(path);
|
||||
defs.appendChild(m);
|
||||
MARKER_COLORS[c] = 'url(#arr' + i + ')';
|
||||
});
|
||||
svg.appendChild(defs);
|
||||
var edgeG = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
||||
svg.appendChild(edgeG);
|
||||
|
||||
function exit(c, t, r) {
|
||||
var dx = t.x - c.x, dy = t.y - c.y;
|
||||
var tmin = Infinity, px = c.x, py = c.y;
|
||||
function tryT(tv, xx, yy) {
|
||||
if (tv > 1e-4 && tv < tmin &&
|
||||
xx >= r.x - .5 && xx <= r.x + r.w + .5 &&
|
||||
yy >= r.y - .5 && yy <= r.y + r.h + .5) { tmin = tv; px = xx; py = yy; }
|
||||
}
|
||||
if (dx !== 0) {
|
||||
var tL = (r.x - c.x) / dx; tryT(tL, r.x, c.y + tL * dy);
|
||||
var tR = (r.x + r.w - c.x) / dx; tryT(tR, r.x + r.w, c.y + tR * dy);
|
||||
}
|
||||
if (dy !== 0) {
|
||||
var tT = (r.y - c.y) / dy; tryT(tT, c.x + tT * dx, r.y);
|
||||
var tB = (r.y + r.h - c.y) / dy; tryT(tB, c.x + tB * dx, r.y + r.h);
|
||||
}
|
||||
return { x: px, y: py };
|
||||
}
|
||||
function rect(p) { return { x: p.x, y: p.y, w: DISPLAY_W, h: p.h }; }
|
||||
function center(p) { return { x: p.x + DISPLAY_W / 2, y: p.y + p.h / 2 }; }
|
||||
|
||||
function layout() {
|
||||
var colY = {};
|
||||
COLUMNS.forEach(function (c) { colY[c.x] = 0; });
|
||||
PAGES.forEach(function (p) {
|
||||
var col = COLUMNS.filter(function (c) { return c.ids.indexOf(p.id) !== -1; })[0];
|
||||
p.x = col.x;
|
||||
p.y = colY[col.x];
|
||||
p.w = DISPLAY_W;
|
||||
p.h = p._node.offsetHeight;
|
||||
p._node.style.left = p.x + 'px';
|
||||
p._node.style.top = p.y + 'px';
|
||||
colY[col.x] = p.y + p.h + GAP;
|
||||
});
|
||||
|
||||
var maxY = 0, maxX = 0;
|
||||
PAGES.forEach(function (p) {
|
||||
maxY = Math.max(maxY, p.y + p.h);
|
||||
maxX = Math.max(maxX, p.x + p.w);
|
||||
});
|
||||
var totalW = maxX + 40, totalH = maxY + 40;
|
||||
svg.setAttribute('width', totalW);
|
||||
svg.setAttribute('height', totalH);
|
||||
svg.setAttribute('viewBox', '0 0 ' + totalW + ' ' + totalH);
|
||||
edgeG.innerHTML = '';
|
||||
|
||||
var outIdx = {}, inIdx = {}, outCnt = {}, inCnt = {};
|
||||
ACTIONS.forEach(function (a) {
|
||||
outCnt[a.from] = (outCnt[a.from] || 0) + 1;
|
||||
inCnt[a.to] = (inCnt[a.to] || 0) + 1;
|
||||
});
|
||||
var pairSeen = {};
|
||||
ACTIONS.forEach(function (a) {
|
||||
var s = byId[a.from], t = byId[a.to];
|
||||
var so = outIdx[a.from] = (outIdx[a.from] || 0); outIdx[a.from]++;
|
||||
var toI = inIdx[a.to] = (inIdx[a.to] || 0); inIdx[a.to]++;
|
||||
var self = a.from === a.to;
|
||||
var pairKey = a.from + '→' + a.to;
|
||||
var pi = pairSeen[pairKey] = (pairSeen[pairKey] || 0); pairSeen[pairKey]++;
|
||||
|
||||
var srcFrac = outCnt[a.from] <= 1 ? 0.5 : 0.14 + 0.72 * (so / (outCnt[a.from] - 1));
|
||||
var tgtFrac = inCnt[a.to] <= 1 ? 0.5 : 0.14 + 0.72 * (toI / (inCnt[a.to] - 1));
|
||||
|
||||
var bend = 34 + pi * 30;
|
||||
var p1, p2, d, lx, ly;
|
||||
if (self) {
|
||||
var ly1 = s.y + s.h * 0.2 + pi * 110;
|
||||
var ly2 = ly1 + 70;
|
||||
p1 = { x: s.x + DISPLAY_W, y: ly1 };
|
||||
p2 = { x: s.x + DISPLAY_W, y: ly2 };
|
||||
var lbx = s.x + DISPLAY_W + bend;
|
||||
d = 'M ' + p1.x.toFixed(1) + ' ' + p1.y.toFixed(1) +
|
||||
' C ' + lbx + ' ' + p1.y.toFixed(1) + ', ' + lbx + ' ' + p2.y.toFixed(1) + ', ' +
|
||||
p2.x.toFixed(1) + ' ' + p2.y.toFixed(1);
|
||||
lx = lbx + 12; ly = (ly1 + ly2) / 2;
|
||||
} else {
|
||||
p1 = exit(center(s), center(t), rect(s));
|
||||
p2 = exit(center(t), center(s), rect(t));
|
||||
var mx = (p1.x + p2.x) / 2, my = (p1.y + p2.y) / 2;
|
||||
var vx = p2.x - p1.x, vy = p2.y - p1.y, len = Math.hypot(vx, vy) || 1;
|
||||
var nx = -vy / len, ny = vx / len;
|
||||
var ctrl = { x: mx + nx * bend, y: my + ny * bend };
|
||||
d = 'M ' + p1.x.toFixed(1) + ' ' + p1.y.toFixed(1) +
|
||||
' Q ' + ctrl.x.toFixed(1) + ' ' + ctrl.y.toFixed(1) +
|
||||
' ' + p2.x.toFixed(1) + ' ' + p2.y.toFixed(1);
|
||||
lx = mx + nx * (bend + 14);
|
||||
ly = my + ny * (bend + 14);
|
||||
}
|
||||
|
||||
var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
||||
path.setAttribute('d', d);
|
||||
path.setAttribute('fill', 'none');
|
||||
path.setAttribute('stroke', a.color);
|
||||
path.setAttribute('stroke-width', '1.8');
|
||||
if (a.back) path.setAttribute('stroke-dasharray', '6 5');
|
||||
path.setAttribute('marker-end', MARKER_COLORS[a.color]);
|
||||
edgeG.appendChild(path);
|
||||
|
||||
var txt = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
||||
txt.setAttribute('x', lx.toFixed(1));
|
||||
txt.setAttribute('y', ly.toFixed(1));
|
||||
txt.setAttribute('text-anchor', self ? 'start' : 'middle');
|
||||
txt.setAttribute('dominant-baseline', 'middle');
|
||||
txt.setAttribute('font-size', '11');
|
||||
txt.setAttribute('font-family', 'var(--sans)');
|
||||
txt.setAttribute('fill', a.color);
|
||||
txt.setAttribute('paint-order', 'stroke');
|
||||
txt.setAttribute('stroke', '#050505');
|
||||
txt.setAttribute('stroke-width', '4');
|
||||
txt.textContent = a.label;
|
||||
edgeG.appendChild(txt);
|
||||
});
|
||||
}
|
||||
window.addEventListener('resize', scheduleLayout);
|
||||
|
||||
var legend = document.getElementById('legend');
|
||||
var LEGEND = [
|
||||
{ c: '#e00000', k: 'ลิงก์หลัก', n: 'คลิกการ์ด → หน้า detail' },
|
||||
{ c: '#ff4d4d', k: 'popup เกี่ยวกับเรา', n: 'เปิดจาก navbar ทุกหน้า' },
|
||||
{ c: '#fbbf24', k: 'สลับภาษา', n: 'ไทย ⇄ EN (ในหน้า)' },
|
||||
{ c: '#6b7280', k: 'ย้อนกลับ / ปิด', n: 'เส้นประ กลับหน้า / ปิด popup' }
|
||||
];
|
||||
LEGEND.forEach(function (l) {
|
||||
var s = document.createElement('span');
|
||||
s.className = 'lg';
|
||||
var ln = document.createElement('span');
|
||||
ln.className = 'ln';
|
||||
ln.style.borderColor = l.c;
|
||||
if (l.k.indexOf('ย้อนกลับ') === 0) ln.style.borderTopStyle = 'dashed';
|
||||
s.appendChild(ln);
|
||||
var k = document.createElement('span');
|
||||
k.className = 'k';
|
||||
k.textContent = l.k;
|
||||
s.appendChild(k);
|
||||
s.appendChild(document.createTextNode(' ' + l.n));
|
||||
legend.appendChild(s);
|
||||
});
|
||||
|
||||
document.getElementById('stat-pages').textContent = PAGES.length;
|
||||
document.getElementById('stat-actions').textContent = ACTIONS.length;
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user