Implemented filtering for mindflow categories.
This commit is contained in:
parent
c65b92ba96
commit
024befeb33
16
homepage/static/assets/js/mindflow.js
Normal file
16
homepage/static/assets/js/mindflow.js
Normal 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"); });
|
Loading…
Reference in New Issue
Block a user