From f0571e9e380aee2646e194c232dab26833c69a10 Mon Sep 17 00:00:00 2001 From: Emil Miler Date: Fri, 10 Jan 2025 09:49:43 +0100 Subject: [PATCH] Change event listener init --- static/js/search.js | 8 ++++++-- templates/posts.html | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/static/js/search.js b/static/js/search.js index 3aa39f4..e286f82 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -1,4 +1,4 @@ -function filter_name(str) +function filter_title(str) { if (str.length == 0) { articles.forEach(article => article.style.display = "block"); @@ -7,5 +7,9 @@ function filter_name(str) } } +const search = document.querySelector("input[type='search']"); +const form = document.querySelector("form"); let articles = Array.from(document.querySelectorAll("article")); -document.querySelector("#search").style.display = "inline-block"; + +search.addEventListener("input", () => filter_title(search.value)); +window.addEventListener("load", () => search.style.display = "inline-block"); diff --git a/templates/posts.html b/templates/posts.html index d090244..e7dce29 100644 --- a/templates/posts.html +++ b/templates/posts.html @@ -6,7 +6,7 @@ {% block content %}

{{ section.title }}

- + {{ macros::list_posts() }} {% endblock content %}