Removed unnecessary const categories array and a local const category.
This commit is contained in:
parent
6f45549b73
commit
f56ad5963a
@ -1,5 +1,3 @@
|
|||||||
const categories = ["update", "diary"];
|
|
||||||
|
|
||||||
const buttons = document.getElementsByTagName("button");
|
const buttons = document.getElementsByTagName("button");
|
||||||
const articles = document.getElementsByTagName("article");
|
const articles = document.getElementsByTagName("article");
|
||||||
|
|
||||||
@ -8,9 +6,8 @@ document.getElementById("filter").classList.remove("hidden");
|
|||||||
for (let i = 0; i < buttons.length; ++i)
|
for (let i = 0; i < buttons.length; ++i)
|
||||||
if (buttons[i].name !== "")
|
if (buttons[i].name !== "")
|
||||||
buttons[i].addEventListener("click", e => {
|
buttons[i].addEventListener("click", e => {
|
||||||
const category = e.target.name;
|
|
||||||
for (let j = 0; j < articles.length; ++j)
|
for (let j = 0; j < articles.length; ++j)
|
||||||
if (articles[j].id.startsWith(category) || category === "all")
|
if (articles[j].id.startsWith(e.target.name) || e.target.name === "all")
|
||||||
articles[j].classList.remove("hidden");
|
articles[j].classList.remove("hidden");
|
||||||
else
|
else
|
||||||
articles[j].classList.add("hidden"); });
|
articles[j].classList.add("hidden"); });
|
Loading…
Reference in New Issue
Block a user