Implemented filtering for mindflow categories.

This commit is contained in:
Alexander Andreev 2022-08-31 08:06:45 +04:00
parent c65b92ba96
commit 024befeb33
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
const categories = ["update", "diary"];
const buttons = document.getElementsByTagName("button");
const articles = document.getElementsByTagName("article");
document.getElementById("filter").classList.remove("hidden");
for (let i = 0; i < buttons.length; ++i)
if (buttons[i].hasAttribute("name"))
buttons[i].addEventListener("click", e => {
const category = e.target.name;
for (let j = 0; j < articles.length; ++j)
if (articles[j].id.startsWith(category) || category === "all")
articles[j].classList.remove("hidden");
else
articles[j].classList.add("hidden"); });