Add catalog search

This commit is contained in:
Dominic Ferrando
2025-04-21 00:00:50 -04:00
parent ffafc896e2
commit 65a3c155ce
2 changed files with 22 additions and 1 deletions
+18
View File
@@ -72,3 +72,21 @@ function resizeCatalogPreviewImgs() {
}
}
}
function applyCatalogSearch() {
const searchText = $("catalogSearch").value.toLowerCase();
const posts = Array.from(document.querySelectorAll(".catalog-preview"));
for (const post of posts) {
const headerContent = post.querySelector("h1 a").textContent;
const bodyContent = post.querySelector("p").textContent;
const contentToSearch = (headerContent + "\n" + bodyContent).toLowerCase();
if (contentToSearch.search(searchText) === -1) {
post.style.display = "none";
}
else {
post.style.display = "";
}
}
}