From 4f154b5e94f9f97c47a419c777e57cf1f1fa7427 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 11:57:17 -0600 Subject: [PATCH] Update app.js --- public/app.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/public/app.js b/public/app.js index 0681ff2..2cd4707 100755 --- a/public/app.js +++ b/public/app.js @@ -8,6 +8,7 @@ const filterSel = document.getElementById("filter"); const searchBox = document.getElementById("search"); const prevBtn = document.getElementById("prev"); const nextBtn = document.getElementById("next"); +const sidebar = document.querySelector(".sidebar"); async function loadIndex() { const res = await fetch("/index.json", { cache: "no-store" }); @@ -36,7 +37,7 @@ function rebuildTree() { const pruned = filterTree(root, f => (filter === "all" || f.path.split("/")[0] === filter) && (!query || (f.title || f.name).toLowerCase().includes(query))); sortDir(pruned, sort); for (const c of pruned.children) treeEl.appendChild(renderNode(c)); - treeEl.querySelectorAll(".dir").forEach(d => d.classList.add("open")); // Auto-open tops + treeEl.querySelectorAll(".dir").forEach(d => d.classList.add("open")); } function filterTree(node, keep) { if (node.type === "file") return keep(node) ? node : null; @@ -108,17 +109,17 @@ async function openPath(path) { else renderHTML(f.path); setActive(path); updatePager(); - if (window.innerWidth < 900) document.querySelector(".sidebar").classList.remove("open"); + if (window.innerWidth < 900) sidebar.classList.remove("open"); } async function renderMarkdown(path) { + mdView.style.display = "none"; const res = await fetch("/" + path); - if (!res.ok) { mdView.innerHTML = "

File not found: " + path + "

"; return; } + if (!res.ok) { mdView.innerHTML = "

File not found: " + path + "

"; requestAnimationFrame(() => mdView.style.display = "block"); return; } const text = await res.text(); const html = window.marked ? window.marked.parse(text) : text.replace(/&/g, '&').replace(/ { mdView.style.display = "block"; htmlView.style.display = "none"; }); } function renderHTML(path) { htmlView.src = "/" + path; @@ -162,4 +163,5 @@ document.body.addEventListener("click", e => { openPath(href.replace(/^\//, "")); } }); +window.addEventListener("resize", () => { if (window.innerWidth < 900) sidebar.classList.remove("open"); }); window.addEventListener("DOMContentLoaded", loadIndex); \ No newline at end of file