diff --git a/static/js/search.js b/static/js/search.js new file mode 100644 index 0000000..c255397 --- /dev/null +++ b/static/js/search.js @@ -0,0 +1,21 @@ +function filter_name(str) +{ + str = str.toLowerCase(); + if (str.length == 0) { + for (let i = 0; i < articles.length; i++) { + articles[i].style.display = "block"; + } + } else { + for (let i = 0; i < articles.length; i++) { + let name = articles[i].getElementsByTagName("h2")[0].innerHTML.toLowerCase(); + if (!name.includes(str)) { + articles[i].style.display = "none"; + } else { + articles[i].style.display = "block"; + } + } + } +} +let articles = document.getElementsByTagName("article"); +let search = document.getElementById("search"); +search.style.display = "inline-block"; diff --git a/templates/categories/single.html b/templates/categories/single.html index a8e59de..12c40fb 100644 --- a/templates/categories/single.html +++ b/templates/categories/single.html @@ -2,5 +2,10 @@ {% block content %}