From f5911b12a449713bb2a50ea76aea3ab716d11282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Randall=20Havens=20=E2=96=B3=20The=20Empathic=20Tec?= =?UTF-8?q?hnologist=20=E2=9F=81=20Doctor=20Who=2042?= Date: Sat, 8 Nov 2025 18:43:20 -0600 Subject: [PATCH] Update app.js --- public/app.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/public/app.js b/public/app.js index d8d4e07..09ed73b 100755 --- a/public/app.js +++ b/public/app.js @@ -15,6 +15,7 @@ const els = { let indexData = null; let sidebarOpen = false; +let currentIframe = null; async function init() { try { @@ -78,10 +79,13 @@ function wireUI() { [els.tagSelect, els.sortSelect, els.searchMode].forEach(el => el.addEventListener("change", renderList)); els.searchBox.addEventListener("input", renderList); - els.content.addEventListener("click", () => { + // Click outside to close sidebar (works on iframe too) + els.content.addEventListener("click", (e) => { if (window.innerWidth < 1024 && document.body.classList.contains("sidebar-open")) { - document.body.classList.remove("sidebar-open"); - sidebarOpen = false; + if (!e.target.closest("#sidebar")) { + document.body.classList.remove("sidebar-open"); + sidebarOpen = false; + } } }); } @@ -160,17 +164,21 @@ function renderIframe(rel) { iframe.setAttribute("sandbox", "allow-same-origin allow-scripts allow-forms"); els.viewer.appendChild(iframe); + currentIframe = iframe; + iframe.onload = () => { - if (rel.endsWith('.pdf')) return; try { const doc = iframe.contentDocument; const style = doc.createElement("style"); style.textContent = ` html,body{background:#0b0b0b;color:#e6e3d7;font-family:Inter,sans-serif;margin:0;padding:2rem;} *{max-width:720px;margin:auto;} + img, video, iframe {max-width:100%;height:auto;} `; doc.head.appendChild(style); - } catch {} + } catch (e) { + // Cross-origin: ignore + } }; }