From 024befeb3343ed8edb8edbf91cf90214e323daf4 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Wed, 31 Aug 2022 08:06:45 +0400 Subject: [PATCH] Implemented filtering for mindflow categories. --- homepage/static/assets/js/mindflow.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 homepage/static/assets/js/mindflow.js diff --git a/homepage/static/assets/js/mindflow.js b/homepage/static/assets/js/mindflow.js new file mode 100644 index 0000000..2ece044 --- /dev/null +++ b/homepage/static/assets/js/mindflow.js @@ -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"); }); \ No newline at end of file