bugs in index (fix #90)

This commit is contained in:
Mylloon 2024-12-13 15:16:07 +01:00
parent d14c3a8781
commit ef40ea96d7
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -137,29 +137,27 @@ window.addEventListener("load", () => {
// Open nested openeded directories
const infoURL = window.location.href.split("?");
if (infoURL.length > 1) {
const fullpath = infoURL[1].substring(2);
const path = fullpath.substring(0, fullpath.lastIndexOf("/"));
const fullpath = infoURL.length > 1 ? infoURL[1].substring(2) : "index.md";
const path = fullpath.substring(0, fullpath.lastIndexOf("/"));
const currentlyOpen = deepestNodeOpened(
path.split("/"),
fileTreeElement.querySelector("ul").childNodes
);
uncollapse(currentlyOpen);
const currentlyOpen = deepestNodeOpened(
path.split("/"),
fileTreeElement.querySelector("ul").childNodes
);
uncollapse(currentlyOpen);
// Bold opened file
const openedFile = decodeURI(fullpath.split("/").at(-1));
currentlyOpen.querySelector("ul").childNodes.forEach((el) => {
if (el.innerText === openedFile) {
el.style.fontWeight = "bold";
}
});
// Bold opened file
const openedFile = decodeURI(fullpath.split("/").at(-1));
currentlyOpen.querySelector("ul").childNodes.forEach((el) => {
if (el.innerText === openedFile) {
el.style.fontWeight = "bold";
}
});
// Search bar hook
document.getElementById("searchBar").addEventListener("input", (e) => {
searchFiles(e.target.value, fileTreeElement, currentlyOpen);
});
}
// Search bar hook
document.getElementById("searchBar").addEventListener("input", (e) => {
searchFiles(e.target.value, fileTreeElement, currentlyOpen);
});
// Responsive menu
let menuOpen = false;