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