- move static mockups from resource/ui to mockup/ - move React app scaffold from resource/ui to app/ - move prome.md + images to docs/ - drop empty resource/jsonfile and resource/ - add root .gitignore - rewrite README for new layout - fix paths in mockup/index.html (resource/ui -> mockup, docs/prome.md)
374 lines
16 KiB
HTML
374 lines
16 KiB
HTML
<!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/mockup/index.html</code></span>
|
||
<span><b>ที่มา</b> <a href="../docs/prome.md">docs/prome.md</a></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>
|