Skip to content

Commit

Permalink
Fix weird iteration bug
Browse files Browse the repository at this point in the history
  • Loading branch information
npentrel committed Jun 15, 2024
1 parent b97ae85 commit 3ab64f5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions docs/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
showmoreBtn = document.getElementById("showmore");
if (showmoreBtn) {
collapsibleItems = document.getElementsByClassName("img-container collapsible collapsed");
collapsibleItems = document.getElementsByClassName("img-container collapsible");
showmoreBtn.textContent = "SHOW " + collapsibleItems.length + " MORE";
showmoreBtn.addEventListener('click', function () {
if (showmoreBtn.textContent.endsWith("MORE")) {
collapsibleItems = document.getElementsByClassName("img-container collapsible collapsed");
Array.prototype.forEach.call(collapsibleItems, item => {
item.classList.remove("collapsed");
showmoreBtn.textContent = "SHOW LESS";
});
collapsibleItems = document.getElementsByClassName("img-container collapsible");
for (item of collapsibleItems) {
item.classList.remove("collapsed"); showmoreBtn.textContent = "SHOW LESS";
}
} else {
collapsibleItems = document.getElementsByClassName("img-container collapsible");
Array.prototype.forEach.call(collapsibleItems, item => {
for (item of collapsibleItems) {
item.classList.add("collapsed");
showmoreBtn.textContent = "SHOW " + collapsibleItems.length + " MORE";
});
}
}
});
}

0 comments on commit 3ab64f5

Please sign in to comment.