Skip to content

Commit 8d800c8

Browse files
committed
- program hide and show all buttons
1 parent ee4cea5 commit 8d800c8

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

js/categoryFilter.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,18 @@ function categoryFilter(show_on_start) {
9797
}
9898
post_list.appendChild(frag);
9999
parent_node.insertBefore(post_list, next_sibling);
100-
return post_list;
101100
}
102101

103102
// initialize
104103

104+
if (show_on_start == 'all') {
105+
show_on_start = [];
106+
107+
category_buttons.forEach((cat) => {
108+
show_on_start.push(cat.innerHTML);
109+
});
110+
}
111+
105112
for (var i=0; i<show_on_start.length; i++) {
106113
if (show_on_start[i] == 'reverse') {
107114
reversePosts();
@@ -123,4 +130,28 @@ function categoryFilter(show_on_start) {
123130
reversePosts();
124131
});
125132

133+
document.getElementById('hide-all').addEventListener('click', function() {
134+
135+
category_buttons.forEach((but) => {
136+
137+
if (but.classList[0]!=='disabled') {
138+
but.classList.add('disabled');
139+
}
140+
141+
applySelection();
142+
});
143+
});
144+
145+
document.getElementById('show-all').addEventListener('click', function() {
146+
147+
category_buttons.forEach((but) => {
148+
149+
if (but.classList[0]==='disabled') {
150+
but.classList.remove('disabled');
151+
}
152+
153+
applySelection();
154+
});
155+
});
156+
126157
}

0 commit comments

Comments
 (0)