2025-01-10 09:49:43 +01:00
|
|
|
function filter_title(str)
|
2021-12-04 22:10:40 +01:00
|
|
|
{
|
|
|
|
if (str.length == 0) {
|
2022-12-09 13:17:29 +01:00
|
|
|
articles.forEach(article => article.style.display = "block");
|
2021-12-04 22:10:40 +01:00
|
|
|
} else {
|
2022-12-09 13:17:29 +01:00
|
|
|
articles.forEach(article => article.style.display = article.dataset.title.indexOf(str.toLowerCase()) === -1 ? "none" : "block");
|
2021-12-04 22:10:40 +01:00
|
|
|
}
|
|
|
|
}
|
2022-12-09 13:17:29 +01:00
|
|
|
|
2025-01-10 09:49:43 +01:00
|
|
|
const search = document.querySelector("input[type='search']");
|
|
|
|
const form = document.querySelector("form");
|
2024-05-06 12:45:39 +02:00
|
|
|
let articles = Array.from(document.querySelectorAll("article"));
|
2025-01-10 09:49:43 +01:00
|
|
|
|
|
|
|
search.addEventListener("input", () => filter_title(search.value));
|
|
|
|
window.addEventListener("load", () => search.style.display = "inline-block");
|