diff --git a/web/static/index.js b/web/static/index.js index 18688ab..7cdb15a 100644 --- a/web/static/index.js +++ b/web/static/index.js @@ -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 = ""; + } + } +} diff --git a/web/views/board.templ b/web/views/board.templ index 9a9f2bc..4559b0f 100644 --- a/web/views/board.templ +++ b/web/views/board.templ @@ -75,12 +75,15 @@ templ Board(board database.Board) { +