deck_index.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Deck · Multi-file Slide Index</title>
  6. <!--
  7. deck_index.html — 多文件 slide deck 拼接器 · 双概览模式
  8. 概览(默认进入,两种模式按 getSeconds()%5 随机:20% 画廊 / 80% 网格):
  9. · grid 自适应网格墙:列数随页数+视口自适应,行多则倾斜变平,scale-to-fit 居中铺满(任意页数都不溢出/不失真)
  10. · gallery 无限画廊:固定卡片大小,无缝无限平铺 + 缓慢漂移 + 轻微呼吸;一个 tile 含全部页(洗牌),看完所有页才重复
  11. 演示 present:单页 fit 缩放翻页。ESC / ⊞ 回概览。
  12. 性能:manifest 每项可带 thumb(预渲染缩略图),概览即用 <img> 平铺,避免 N 个 iframe 同时加载。
  13. 用法:复制为 index.html;建 slides/ 放每页独立 HTML;编辑 MANIFEST。
  14. 可选覆盖:window.DECK_OVERVIEW = 'grid' | 'gallery'(不写则随机);URL ?ov=grid|gallery 临时强制。
  15. 键盘(演示):← / → / Space / PgUp / PgDown / Home / End / 1-9 / P 打印 / ESC 回概览
  16. -->
  17. <script>
  18. window.DECK_MANIFEST = [
  19. { file: "slides/01-cover.html", label: "Cover" /*, thumb: "thumbs/01.jpg" */ },
  20. ];
  21. window.DECK_WIDTH = 1920;
  22. window.DECK_HEIGHT = 1080;
  23. window.GALLERY_CARD_W = 300; // 画廊卡片基准宽度
  24. window.GALLERY_DRIFT_SECONDS = 80; // 画廊漂移一圈时长
  25. // window.DECK_OVERVIEW = 'grid'; // 取消注释可固定概览模式
  26. </script>
  27. <style>
  28. * { box-sizing: border-box; margin: 0; padding: 0; }
  29. html, body { height: 100%; overflow: hidden; font-family: -apple-system, "PingFang SC", sans-serif; background: #0a0a0a; }
  30. .overview { position: fixed; inset: 0; }
  31. body[data-mode="present"] .overview { display: none; }
  32. body[data-mode="present"] .start-btn { display: none; }
  33. body[data-mode="overview"] #present-ui { display: none; }
  34. body[data-ov="grid"] #ov-gallery { display: none; }
  35. body[data-ov="gallery"] #ov-grid { display: none; }
  36. body[data-ov="gallery"][data-mode="overview"] { background: #0a0805; }
  37. body[data-ov="grid"][data-mode="overview"] { background: #efece4; }
  38. /* ════════ 模式 1 · 自适应网格墙(一屏装得下→居中轻斜;装不下→舒适大小竖向滚动)════════ */
  39. #ov-grid { display: flex; justify-content: center; perspective: 2200px; perspective-origin: 50% 42%;
  40. background: radial-gradient(120% 90% at 50% 0%, #f4f1e9, #e7e3d8 75%); }
  41. body[data-grid="fit"] #ov-grid { overflow: hidden; align-items: center; }
  42. body[data-grid="scroll"] #ov-grid { overflow-y: auto; overflow-x: hidden; align-items: flex-start; padding: 74px 0 110px; }
  43. .wall-wrap { }
  44. body[data-grid="fit"] .wall-wrap { transform: translateY(-3vh); }
  45. .wall { display: grid; gap: 20px; transform-origin: center center; margin: 0 auto; } /* 不用 preserve-3d:整墙作单个倾斜平面,命中测试可靠 */
  46. #ov-grid .card {
  47. position: relative; aspect-ratio: 16/9; border-radius: 9px; overflow: hidden; background: #fff; cursor: pointer;
  48. box-shadow: 0 16px 34px rgba(40,34,24,0.20), 0 3px 10px rgba(40,34,24,0.12);
  49. transition: transform .28s cubic-bezier(.2,.7,.2,1), box-shadow .28s;
  50. }
  51. #ov-grid .card:hover {
  52. transform: scale(1.18);
  53. box-shadow: 0 48px 92px rgba(40,34,24,0.36), 0 14px 30px rgba(40,34,24,0.22); z-index: 20;
  54. }
  55. /* ════════ 模式 2 · 无限画廊 ════════ */
  56. #ov-gallery { overflow: hidden; perspective: 2200px; perspective-origin: 50% 42%;
  57. background: radial-gradient(130% 120% at 50% 38%, #1b1610, #0a0805 82%); }
  58. .stage3d { --rx: 18; --rz: 9; position: absolute; inset: 0; transform-style: preserve-3d; transform: scale(1.22) rotateX(18deg) rotateZ(-9deg); transform-origin: center center; }
  59. .breathe { position: absolute; inset: 0; animation: breathe 26s ease-in-out infinite; transform-origin: center center; transform-style: preserve-3d; }
  60. .drift-layer { position: absolute; top: 0; left: 0; will-change: transform; animation: drift var(--driftSec, 80s) linear infinite; transform-style: preserve-3d; }
  61. #ov-gallery:hover .drift-layer { animation-play-state: paused; }
  62. .gallery { display: grid; }
  63. #ov-gallery .card {
  64. position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: #fff; cursor: pointer;
  65. box-shadow: 0 14px 30px rgba(0,0,0,0.42), 0 3px 9px rgba(0,0,0,0.3);
  66. transition: transform .34s cubic-bezier(.2,.7,.2,1), box-shadow .34s; transform-style: preserve-3d; will-change: transform;
  67. }
  68. #ov-gallery .card:hover {
  69. transform: translateZ(60px) rotateX(calc(var(--rx,18)*-1deg)) rotateZ(calc(var(--rz,9)*1deg)) scale(1.06);
  70. box-shadow: 0 30px 64px rgba(0,0,0,0.55), 0 8px 20px rgba(0,0,0,0.4); z-index: 30;
  71. }
  72. .vignette { position: fixed; inset: 0; pointer-events: none; z-index: 20; box-shadow: inset 0 0 240px 70px rgba(8,6,3,0.62); }
  73. @keyframes drift { from { transform: translate3d(0,0,0); } to { transform: translate3d(calc(var(--dx)*-1), calc(var(--dy)*-1), 0); } }
  74. @keyframes breathe { 0%,100% { transform: scale(1.0); } 50% { transform: scale(1.045); } }
  75. /* 卡片通用内容 */
  76. .card .thumb { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; transform-origin: top left; pointer-events: none; }
  77. .card .thumb iframe { width: 1920px; height: 1080px; border: 0; display: block; background: #fff; pointer-events: none; }
  78. .card .thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
  79. .card .num { position: absolute; bottom: 6px; left: 7px; background: rgba(16,12,7,0.76); color: #fff; font-size: 11px; line-height: 1; padding: 4px 7px; border-radius: 5px; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; z-index: 3; pointer-events: none; max-width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  80. #ov-gallery .card .num { opacity: 0; transition: opacity .25s; }
  81. #ov-gallery .card:hover .num { opacity: 1; }
  82. .overview-title { position: fixed; top: 24px; left: 0; right: 0; text-align: center; font-size: 13px; letter-spacing: 0.22em; text-transform: uppercase; z-index: 40; pointer-events: none; }
  83. body[data-ov="grid"] .overview-title { color: #5a5346; opacity: 0.66; }
  84. body[data-ov="gallery"] .overview-title { color: rgba(244,238,224,0.7); text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
  85. .start-btn { position: fixed; bottom: 26px; right: 26px; border: 0; padding: 13px 24px; border-radius: 999px; font-size: 15px; font-family: inherit; letter-spacing: 0.04em; cursor: pointer; z-index: 200; transition: transform .18s, box-shadow .18s; }
  86. body[data-ov="grid"] .start-btn { background: #1a1712; color: #fff; box-shadow: 0 8px 28px rgba(40,34,24,0.28); }
  87. body[data-ov="gallery"] .start-btn { background: #f4eee0; color: #1a1712; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
  88. .start-btn:hover { transform: translateY(-2px); }
  89. /* ════════ 演示模式 ════════ */
  90. #stage { position: fixed; top: 50%; left: 50%; transform-origin: top left; will-change: transform; background: #fff; box-shadow: 0 10px 60px rgba(0,0,0,0.4); }
  91. #stage iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
  92. .counter { position: fixed; bottom: 20px; right: 20px; background: rgba(0,0,0,0.65); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 13px; letter-spacing: 0.05em; font-variant-numeric: tabular-nums; z-index: 100; opacity: 0.7; }
  93. .counter .label { color: rgba(255,255,255,0.7); margin-left: 8px; }
  94. .overview-btn { position: fixed; top: 20px; left: 20px; background: rgba(0,0,0,0.55); color: rgba(255,255,255,0.85); border: 0; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-family: inherit; cursor: pointer; z-index: 100; opacity: 0.6; }
  95. .overview-btn:hover { opacity: 1; }
  96. .nav-zone { position: fixed; top: 0; bottom: 0; width: 15%; cursor: pointer; z-index: 50; }
  97. .nav-zone.left { left: 0; } .nav-zone.right { right: 0; }
  98. .nav-hint { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 999px; background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.6); display: flex; align-items: center; justify-content: center; font-size: 22px; opacity: 0; transition: opacity .2s; }
  99. .nav-zone.left .nav-hint { left: 20px; } .nav-zone.right .nav-hint { right: 20px; }
  100. .nav-zone:hover .nav-hint { opacity: 1; }
  101. @media print {
  102. @page { size: 1920px 1080px; margin: 0; }
  103. html, body { background: #fff; overflow: visible; height: auto; }
  104. body[data-mode] .overview { display: none !important; }
  105. #stage { position: static; transform: none !important; box-shadow: none; }
  106. .counter, .nav-zone, .overview-btn, .start-btn { display: none !important; }
  107. .print-stack { display: block; }
  108. .print-stack iframe { width: 1920px; height: 1080px; page-break-after: always; display: block; }
  109. }
  110. </style>
  111. </head>
  112. <body data-mode="overview">
  113. <div id="ov-grid" class="overview">
  114. <div class="overview-title">Overview · 点击任意页进入演示</div>
  115. <div class="wall-wrap"><div class="wall" id="wall"></div></div>
  116. </div>
  117. <div id="ov-gallery" class="overview">
  118. <div class="stage3d"><div class="breathe"><div class="drift-layer" id="driftLayer"><div class="gallery" id="gallery"></div></div></div></div>
  119. <div class="vignette"></div>
  120. <div class="overview-title">Infinite Gallery · 悬停暂停 · 点击任意页进入演示</div>
  121. </div>
  122. <button class="start-btn" id="startBtn">▶ 开始演示</button>
  123. <div id="present-ui">
  124. <div id="stage"><iframe id="frame" src="about:blank"></iframe></div>
  125. <button class="overview-btn" id="overviewBtn">⊞ 概览</button>
  126. <div class="nav-zone left" id="navL"><div class="nav-hint">‹</div></div>
  127. <div class="nav-zone right" id="navR"><div class="nav-hint">›</div></div>
  128. <div class="counter" id="counter">1 / 1</div>
  129. </div>
  130. <div class="print-stack" id="printStack" style="display:none;"></div>
  131. <script>
  132. (function () {
  133. const W = window.DECK_WIDTH || 1920;
  134. const H = window.DECK_HEIGHT || 1080;
  135. const deck = window.DECK_MANIFEST || [];
  136. const CARD_W = window.GALLERY_CARD_W || 300;
  137. const DRIFT_SEC = window.GALLERY_DRIFT_SECONDS || 80;
  138. const stage = document.getElementById('stage');
  139. const frame = document.getElementById('frame');
  140. const counter = document.getElementById('counter');
  141. const printStack = document.getElementById('printStack');
  142. const wall = document.getElementById('wall');
  143. const gallery = document.getElementById('gallery');
  144. const driftLayer = document.getElementById('driftLayer');
  145. const storageKey = 'deck-index-' + location.pathname;
  146. let current = 0;
  147. stage.style.width = W + 'px'; stage.style.height = H + 'px';
  148. driftLayer.style.setProperty('--driftSec', DRIFT_SEC + 's');
  149. // 概览模式:URL ?ov= > window.DECK_OVERVIEW > 随机(秒%5==0 → 20% 画廊)
  150. const qp = new URLSearchParams(location.search).get('ov');
  151. // 用户未指定时按秒数随机:网格(iframe 真页面) 60% / 无限画廊(图片缩略图) 40%。可用 ?ov=grid|gallery 或 window.DECK_OVERVIEW 固定。
  152. const OVERVIEW = qp || window.DECK_OVERVIEW || ((new Date().getSeconds() % 5 < 2) ? 'gallery' : 'grid');
  153. document.body.setAttribute('data-ov', OVERVIEW === 'gallery' ? 'gallery' : 'grid');
  154. function setMode(mode) {
  155. document.body.setAttribute('data-mode', mode);
  156. if (mode === 'present') { fit(); show(current); }
  157. else { requestAnimationFrame(buildOverview); }
  158. }
  159. /* ─ 媒体(缩略图优先,否则 iframe) ─ */
  160. function makeCard(idx, useScale, useImg) {
  161. const card = document.createElement('div');
  162. card.className = 'card'; card.dataset.idx = idx;
  163. const item = deck[idx];
  164. if (useImg && item.thumb) {
  165. // 仅画廊用:预渲染缩略图,扛无限平铺的性能
  166. const im = document.createElement('img');
  167. im.className = 'thumb-img'; im.src = item.thumb; im.decoding = 'async';
  168. card.appendChild(im);
  169. } else {
  170. // 网格默认用:真实 HTML 子页面(清晰、所见即所得)
  171. const thumb = document.createElement('div');
  172. thumb.className = 'thumb';
  173. if (useScale != null) thumb.style.transform = 'scale(' + useScale + ')';
  174. const ifr = document.createElement('iframe');
  175. ifr.src = item.file; ifr.setAttribute('scrolling', 'no');
  176. thumb.appendChild(ifr); card.appendChild(thumb);
  177. }
  178. const num = document.createElement('div');
  179. num.className = 'num';
  180. num.textContent = (idx + 1) + (item.label ? ' · ' + item.label : '');
  181. card.appendChild(num);
  182. card.addEventListener('click', () => { current = idx; setMode('present'); });
  183. return card;
  184. }
  185. function buildOverview() {
  186. if (document.body.getAttribute('data-mode') !== 'overview') return;
  187. if (OVERVIEW === 'gallery') buildGallery(); else buildGrid();
  188. }
  189. /* ════════ 网格墙(自适应) ════════ */
  190. function buildGrid() {
  191. const n = deck.length; if (!n) return;
  192. wall.innerHTML = '';
  193. for (let i = 0; i < n; i++) wall.appendChild(makeCard(i, null, false)); // 网格 = iframe 真页面
  194. layoutWall();
  195. }
  196. const GRID_PAD = 74; // #ov-grid scroll 顶部 padding,算动态 transform-origin 用
  197. function layoutWall() {
  198. const n = deck.length; if (!n) return;
  199. const vw = innerWidth, vh = innerHeight, gap = 26;
  200. const availW = vw * 0.86; // 留 rotateZ 横向余量(强对角也不裁切)
  201. const target = 280;
  202. let cols = Math.max(3, Math.min(9, Math.floor((availW + gap) / (target + gap))));
  203. cols = Math.min(cols, n);
  204. const rows = Math.ceil(n / cols);
  205. const cardW = Math.min(target + 40, (availW - (cols - 1) * gap) / cols);
  206. const cardH = cardW * 9 / 16;
  207. const baseW = cols * cardW + (cols - 1) * gap;
  208. const wallH = rows * cardH + (rows - 1) * gap;
  209. wall.style.gridTemplateColumns = 'repeat(' + cols + ', 1fr)';
  210. wall.style.gap = gap + 'px';
  211. wall.style.width = baseW + 'px';
  212. // 单平面(无 preserve-3d)→任意角度都不重叠、可点;fit 与 scroll 都给强对角倾斜
  213. if (wallH <= vh * 0.80) {
  214. document.body.setAttribute('data-grid', 'fit');
  215. const rx = Math.max(11, Math.min(15, 15 - (rows - 2) * 1.1));
  216. const rz = Math.max(8, Math.min(11, 11 - (rows - 2) * 0.7));
  217. wall.style.setProperty('--rx', rx); wall.style.setProperty('--rz', rz);
  218. wall.style.transformOrigin = 'center center';
  219. const tilt = 'rotateX(' + rx + 'deg) rotateZ(-' + rz + 'deg)';
  220. wall.style.transform = tilt;
  221. const r = wall.getBoundingClientRect();
  222. let s = Math.min(vw * 0.92 / r.width, vh * 0.80 / r.height);
  223. s = Math.max(0.6, Math.min(s, 1.6));
  224. wall.style.transform = 'scale(' + s + ') ' + tilt;
  225. } else {
  226. // 多页:舒适大小竖向滚动 + 强对角倾斜;transform-origin 跟随滚动→消除高墙 rotateZ 把远端行甩出屏幕
  227. document.body.setAttribute('data-grid', 'scroll');
  228. wall.style.setProperty('--rx', 14); wall.style.setProperty('--rz', 7);
  229. wall.style.transform = 'rotateX(14deg) rotateZ(-7deg)';
  230. updateScrollOrigin();
  231. }
  232. wall.querySelectorAll('.card .thumb').forEach(t => { const c = t.parentElement; if (c.clientWidth) t.style.transform = 'scale(' + (c.clientWidth / W) + ')'; });
  233. }
  234. function updateScrollOrigin() {
  235. if (document.body.getAttribute('data-grid') !== 'scroll') return;
  236. const ovg = document.getElementById('ov-grid');
  237. wall.style.transformOrigin = '50% ' + (ovg.scrollTop + window.innerHeight / 2 - GRID_PAD) + 'px';
  238. }
  239. /* ════════ 无限画廊(洗牌不重复) ════════ */
  240. function mulberry32(a) { return function () { a |= 0; a = a + 0x6D2B79F5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a); t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296; }; }
  241. function shuffledRange(n, seed) { const rnd = mulberry32(seed); const a = Array.from({ length: n }, (_, i) => i); for (let i = n - 1; i > 0; i--) { const j = Math.floor(rnd() * (i + 1)); const tmp = a[i]; a[i] = a[j]; a[j] = tmp; } return a; }
  242. function buildGallery() {
  243. const n = deck.length; if (!n) return;
  244. const vw = innerWidth, vh = innerHeight, gap = 18;
  245. const cardW = CARD_W, cardH = cardW * 9 / 16;
  246. const cellW = cardW + gap, cellH = cardH + gap;
  247. const visCols = Math.ceil(vw / cellW), visRows = Math.ceil(vh / cellH);
  248. // tile:宽够铺满;行数取「够铺满」与「装下全部 N 页」的较大者 → 看完所有页才重复
  249. const tileCols = visCols + 1;
  250. const tileRows = Math.max(visRows + 1, Math.ceil(n / tileCols));
  251. const tileCells = tileCols * tileRows;
  252. const perm = shuffledRange(n, 0x9e3779b9); // 洗牌一次,打散规则感
  253. const tilePage = new Array(tileCells);
  254. for (let k = 0; k < tileCells; k++) tilePage[k] = perm[k % n];
  255. const cols = tileCols * 2, rows = tileRows * 2; // 2× tile 保证无缝漂移
  256. driftLayer.style.setProperty('--dx', (tileCols * cellW) + 'px');
  257. driftLayer.style.setProperty('--dy', (tileRows * cellH) + 'px');
  258. gallery.style.gridTemplateColumns = 'repeat(' + cols + ', ' + cardW + 'px)';
  259. gallery.style.gridAutoRows = cardH + 'px';
  260. gallery.style.gap = gap + 'px';
  261. gallery.innerHTML = '';
  262. const scale = cardW / W;
  263. for (let r = 0; r < rows; r++) {
  264. for (let c = 0; c < cols; c++) {
  265. const idx = tilePage[(r % tileRows) * tileCols + (c % tileCols)];
  266. gallery.appendChild(makeCard(idx, scale, true)); // 画廊 = 图片缩略图(性能)
  267. }
  268. }
  269. }
  270. /* ════════ 演示 ════════ */
  271. function fit() {
  272. const s = Math.min(innerWidth / W, innerHeight / H);
  273. stage.style.transform = 'translate(' + ((innerWidth - W * s) / 2) + 'px, ' + ((innerHeight - H * s) / 2) + 'px) scale(' + s + ')';
  274. stage.style.top = '0'; stage.style.left = '0';
  275. }
  276. function show(idx) {
  277. if (idx < 0 || idx >= deck.length) return;
  278. current = idx;
  279. if (frame.getAttribute('src') !== deck[idx].file) frame.src = deck[idx].file;
  280. counter.innerHTML = (idx + 1) + ' / ' + deck.length + ' <span class="label">' + (deck[idx].label || '') + '</span>';
  281. try { localStorage.setItem(storageKey, String(idx)); } catch (_) {}
  282. if (location.hash !== '#' + (idx + 1)) history.replaceState(null, '', '#' + (idx + 1));
  283. }
  284. function next() { show(Math.min(current + 1, deck.length - 1)); }
  285. function prev() { show(Math.max(current - 1, 0)); }
  286. document.addEventListener('keydown', (e) => {
  287. if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
  288. if (e.key === 'Escape') { if (document.body.getAttribute('data-mode') === 'present') { e.preventDefault(); setMode('overview'); } return; }
  289. if (e.key === 'p' || e.key === 'P') { window.print(); return; }
  290. if (document.body.getAttribute('data-mode') !== 'present') return;
  291. switch (e.key) {
  292. case 'ArrowRight': case ' ': case 'PageDown': e.preventDefault(); next(); break;
  293. case 'ArrowLeft': case 'PageUp': e.preventDefault(); prev(); break;
  294. case 'Home': e.preventDefault(); show(0); break;
  295. case 'End': e.preventDefault(); show(deck.length - 1); break;
  296. default: if (e.key >= '1' && e.key <= '9') { const i = parseInt(e.key, 10) - 1; if (i < deck.length) { e.preventDefault(); show(i); } }
  297. }
  298. });
  299. document.getElementById('navL').addEventListener('click', prev);
  300. document.getElementById('navR').addEventListener('click', next);
  301. document.getElementById('startBtn').addEventListener('click', () => setMode('present'));
  302. document.getElementById('overviewBtn').addEventListener('click', () => setMode('overview'));
  303. let rT;
  304. window.addEventListener('resize', () => { fit(); clearTimeout(rT); rT = setTimeout(buildOverview, 140); });
  305. document.getElementById('ov-grid').addEventListener('scroll', updateScrollOrigin, { passive: true });
  306. window.addEventListener('hashchange', () => { const m = location.hash.match(/^#(\d+)$/); if (m) { current = parseInt(m[1], 10) - 1; setMode('present'); } });
  307. const hashMatch = location.hash.match(/^#(\d+)$/);
  308. if (hashMatch) current = Math.min(parseInt(hashMatch[1], 10) - 1, deck.length - 1);
  309. else { try { const v = parseInt(localStorage.getItem(storageKey), 10); if (!isNaN(v) && v >= 0 && v < deck.length) current = v; } catch (_) {} }
  310. fit(); show(current);
  311. if (hashMatch) setMode('present'); else { setMode('overview'); buildOverview(); }
  312. window.addEventListener('beforeprint', () => { printStack.innerHTML = ''; deck.forEach(item => { const f = document.createElement('iframe'); f.src = item.file; printStack.appendChild(f); }); printStack.style.display = 'block'; stage.style.display = 'none'; });
  313. window.addEventListener('afterprint', () => { printStack.innerHTML = ''; printStack.style.display = 'none'; stage.style.display = ''; });
  314. })();
  315. </script>
  316. </body>
  317. </html>