Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learning filter #1210

Merged
merged 7 commits into from
Nov 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
formatter
  • Loading branch information
thisisjofrank committed Nov 28, 2024
commit 8cbfa9e137e893fec6be9c27b91620a95f7989a4
24 changes: 24 additions & 0 deletions learn_filter.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
document.addEventListener("DOMContentLoaded", () => {
const tutorial = document.getElementById("tutorial")! as HTMLInputElement;
const example = document.getElementById("example")! as HTMLInputElement;
const video = document.getElementById("video")! as HTMLInputElement;
const listItems = document.getElementsByClassName("learning-list-item");

const filterItems = () => {
const shown = [tutorial, example, video].filter((item) => item.checked);
const shownType = shown.map((item) => item.id);

for (const item of listItems) {
const htmlItem = item as HTMLElement;
const category = htmlItem.getAttribute("data-category");
const enabled = shownType.includes(category!);
htmlItem.style.display = enabled ? "" : "none";
}
};

tutorial.addEventListener("change", () => filterItems());
example.addEventListener("change", () => filterItems());
video.addEventListener("change", () => filterItems());

filterItems();
});