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

Javascript for events #222

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
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
26 changes: 19 additions & 7 deletions site/_static/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ function getClassOfCheckedCheckboxes(checkboxes) {
function change() {
console.log("Change event fired.");
var domainsCbs = document.querySelectorAll(".domains input[type='checkbox']");
var eventsCbs = document.querySelectorAll(".events input[type='checkbox']");
var packagesCbs = document.querySelectorAll(".packages input[type='checkbox']");

var domainTags = getClassOfCheckedCheckboxes(domainsCbs);
var eventTags = getClassOfCheckedCheckboxes(eventsCbs);
var packageTags = getClassOfCheckedCheckboxes(packagesCbs);

var filters = {
domains: domainTags,
events: eventTags,
packages: packageTags
};

Expand All @@ -31,13 +34,22 @@ function filterResults(filters) {
rElems.forEach(function (el) {
var isVisible = true; // Assume visible by default

// Check if the element has any domain or package filter
if (filters.domains.length > 0 || filters.packages.length > 0) {
var hasMatchingDomain = filters.domains.length === 0 || filters.domains.some(domain => el.classList.contains(domain));
var hasMatchingPackage = filters.packages.length === 0 || filters.packages.some(package => el.classList.contains(package));
// Check for matching domains
if (filters.domains.length > 0) {
var hasMatchingDomain = filters.domains.some(domain => el.classList.contains(domain));
isVisible = isVisible && hasMatchingDomain;
}

// Check for matching events
if (filters.events.length > 0) {
var hasMatchingEvent = filters.events.some(event => el.classList.contains(event));
isVisible = isVisible && hasMatchingEvent;
}

// The element should be visible if it matches any filter within each category
isVisible = hasMatchingDomain && hasMatchingPackage;
// Check for matching packages
if (filters.packages.length > 0) {
var hasMatchingPackage = filters.packages.some(package => el.classList.contains(package));
isVisible = isVisible && hasMatchingPackage;
}

// Toggle visibility based on the result
Expand Down Expand Up @@ -88,4 +100,4 @@ function clearCbs() {
// Initial call to set up correct margins when the page loads
document.addEventListener('DOMContentLoaded', updateMargins);

console.log("Script loaded.");
console.log("Script loaded.");
Loading