Update app.js
This commit is contained in:
committed by
GitHub
parent
710c783e8d
commit
d3e35b4040
+13
-8
@@ -1,5 +1,5 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
Self-Organizing Static Site Framework v2.4 (Local Libs)
|
The Fold Within – Static Framework v2.4.1 (Layout fix)
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
let INDEX, CURRENT_PATH = null, PATH_TO_EL = new Map();
|
let INDEX, CURRENT_PATH = null, PATH_TO_EL = new Map();
|
||||||
@@ -24,7 +24,6 @@ overlay.addEventListener("click", () => sidebar.classList.remove("open"));
|
|||||||
|
|
||||||
/* Load index */
|
/* Load index */
|
||||||
async function loadIndex() {
|
async function loadIndex() {
|
||||||
// No CDN race now; libs are local. Still, surface diagnostics:
|
|
||||||
if (!window.marked) console.warn("⚠️ marked.js not detected.");
|
if (!window.marked) console.warn("⚠️ marked.js not detected.");
|
||||||
if (!window.DOMPurify) console.warn("⚠️ DOMPurify not detected.");
|
if (!window.DOMPurify) console.warn("⚠️ DOMPurify not detected.");
|
||||||
|
|
||||||
@@ -54,6 +53,7 @@ function populateFilters() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tree rendering */
|
||||||
function rebuildTree() {
|
function rebuildTree() {
|
||||||
treeEl.innerHTML = "";
|
treeEl.innerHTML = "";
|
||||||
PATH_TO_EL.clear();
|
PATH_TO_EL.clear();
|
||||||
@@ -147,7 +147,7 @@ async function openPath(path){
|
|||||||
if(window.innerWidth<900) sidebar.classList.remove("open");
|
if(window.innerWidth<900) sidebar.classList.remove("open");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- Markdown (robust) ---------- */
|
/* Markdown */
|
||||||
async function renderMarkdown(path){
|
async function renderMarkdown(path){
|
||||||
mdWarn.style.display = "none";
|
mdWarn.style.display = "none";
|
||||||
mdView.innerHTML="<p class='loading-note'>Loading…</p>";
|
mdView.innerHTML="<p class='loading-note'>Loading…</p>";
|
||||||
@@ -165,7 +165,6 @@ async function renderMarkdown(path){
|
|||||||
if (window.marked) {
|
if (window.marked) {
|
||||||
html = window.marked.parse(text);
|
html = window.marked.parse(text);
|
||||||
} else {
|
} else {
|
||||||
// explicit, visible signal
|
|
||||||
usedFallback = true;
|
usedFallback = true;
|
||||||
html = text.replace(/&/g,"&").replace(/</g,"<");
|
html = text.replace(/&/g,"&").replace(/</g,"<");
|
||||||
}
|
}
|
||||||
@@ -185,14 +184,14 @@ async function renderMarkdown(path){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- HTML ---------- */
|
/* HTML */
|
||||||
function renderHTML(path){
|
function renderHTML(path){
|
||||||
htmlView.src="/"+path;
|
htmlView.src="/"+path;
|
||||||
htmlView.style.display="block";
|
htmlView.style.display="block";
|
||||||
mdView.style.display="none";
|
mdView.style.display="none";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- Active + Pager ---------- */
|
/* Active + Pager */
|
||||||
function setActive(path){
|
function setActive(path){
|
||||||
document.querySelectorAll(".file.active").forEach(el=>el.classList.remove("active"));
|
document.querySelectorAll(".file.active").forEach(el=>el.classList.remove("active"));
|
||||||
const el=PATH_TO_EL.get(path);
|
const el=PATH_TO_EL.get(path);
|
||||||
@@ -231,7 +230,7 @@ searchBox.addEventListener("input",()=>{
|
|||||||
sortSel.addEventListener("change",rebuildTree);
|
sortSel.addEventListener("change",rebuildTree);
|
||||||
filterSel.addEventListener("change",rebuildTree);
|
filterSel.addEventListener("change",rebuildTree);
|
||||||
|
|
||||||
/* Internal link interception */
|
/* Internal links */
|
||||||
document.body.addEventListener("click",e=>{
|
document.body.addEventListener("click",e=>{
|
||||||
const a=e.target.closest("a[href]");
|
const a=e.target.closest("a[href]");
|
||||||
if(!a) return;
|
if(!a) return;
|
||||||
@@ -242,5 +241,11 @@ document.body.addEventListener("click",e=>{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("resize",()=>{ if(window.innerWidth<900) sidebar.classList.remove("open"); });
|
/* Resize listener (mobile full screen fix) */
|
||||||
|
window.addEventListener("resize", () => {
|
||||||
|
const vh = window.innerHeight;
|
||||||
|
const content = document.querySelector(".content");
|
||||||
|
if (content) content.style.minHeight = `${vh - 48}px`;
|
||||||
|
});
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded",loadIndex);
|
window.addEventListener("DOMContentLoaded",loadIndex);
|
||||||
Reference in New Issue
Block a user