From 3bb7d259f14c1d78bc5d92f7eb2f9e49973fcfb9 Mon Sep 17 00:00:00 2001 From: clyne Date: Wed, 8 Jan 2025 09:53:57 -0700 Subject: [PATCH 1/2] Added esgf-cookbook to the gallery (#219) --- site/cookbook_gallery.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/site/cookbook_gallery.txt b/site/cookbook_gallery.txt index c7feaf1..d402c74 100644 --- a/site/cookbook_gallery.txt +++ b/site/cookbook_gallery.txt @@ -18,3 +18,4 @@ na-cordex-viz-cookbook eofs-cookbook ocean-bgc-cookbook paleoPCA-cookbook +esgf-cookbook From a22b1e353a98e74df6dd7283c5d5b877c6087824 Mon Sep 17 00:00:00 2001 From: Julia Kent <46687291+jukent@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:48:01 -0700 Subject: [PATCH 2/2] try this again (#222) --- site/_static/custom.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/site/_static/custom.js b/site/_static/custom.js index 26420cf..b5b1328 100644 --- a/site/_static/custom.js +++ b/site/_static/custom.js @@ -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 }; @@ -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 @@ -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."); \ No newline at end of file