diff --git a/static/js/search.js b/static/js/search.js index 57b57ad..4256301 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -1,16 +1,11 @@ function filter_name(str) { if (str.length == 0) { - for (let i = 0; i < articles.length; i++) { - articles[i].style.display = "block"; - } + articles.forEach(article => article.style.display = "block"); } else { - str = str.toLowerCase(); - for (let i = 0; i < articles.length; i++) { - articles[i].style.display = !articles[i].dataset.title.includes(str) ? "none" : "block"; - } + articles.forEach(article => article.style.display = article.dataset.title.indexOf(str.toLowerCase()) === -1 ? "none" : "block"); } } -let articles = document.getElementsByTagName("article"); -let search = document.getElementById("search"); -search.style.display = "inline-block"; + +let articles = Array.from(document.getElementsByTagName("article")); +document.getElementById("search").style.display = "inline-block";