This commit is contained in:
Mylloon 2024-11-28 16:47:13 +01:00
parent 89ee05487c
commit ea7d962a17
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -98,7 +98,7 @@ const searchFiles = (query, parent, currentFile) => {
return; return;
} }
for (const item in children) { for (const item of children) {
if (item.innerText.toLowerCase().includes(query.toLowerCase())) { if (item.innerText.toLowerCase().includes(query.toLowerCase())) {
item.style.display = ""; item.style.display = "";
uncollapse(item); uncollapse(item);
@ -125,23 +125,24 @@ window.addEventListener("load", () => {
if (infoURL.length > 1) { if (infoURL.length > 1) {
const fullpath = infoURL[1].substring(2); const fullpath = infoURL[1].substring(2);
const path = fullpath.substring(0, fullpath.lastIndexOf("/")); const path = fullpath.substring(0, fullpath.lastIndexOf("/"));
const currently_open = deepestNodeOpened(
const currentlyOpen = deepestNodeOpened(
path.split("/"), path.split("/"),
fileTreeElement.querySelector("ul").childNodes fileTreeElement.querySelector("ul").childNodes
); );
uncollapse(currently_open); uncollapse(currentlyOpen);
// Bold opened file // Bold opened file
const opened_file = fullpath.split("/").at(-1); const openedFile = fullpath.split("/").at(-1);
currently_open.querySelector("ul").childNodes.forEach((el) => { currentlyOpen.querySelector("ul").childNodes.forEach((el) => {
if (el.innerText === opened_file) { if (el.innerText === openedFile) {
el.style.fontWeight = "bold"; el.style.fontWeight = "bold";
} }
}); });
// Search bar hook // Search bar hook
document.getElementById("searchBar").addEventListener("input", (e) => { document.getElementById("searchBar").addEventListener("input", (e) => {
searchFiles(e.target.value, fileTreeElement, currently_open); searchFiles(e.target.value, fileTreeElement, currentlyOpen);
}); });
} }