PageSourceSearch

https://justiceconnect.org.au/wp-content/themes/2025-website/jc-scripts/overrides.js?ver=0.1

js justiceconnect.org.au collected 2026-10-02 03:34:05 UTC 4,139 bytes, 94 lines download raw bytes

1(function () {
2  var parentCategory = "program",
3    parentTitle = "Program",
4    urlParams = new URLSearchParams(window.location.search),
5    categories = urlParams.get("categories")?.split(",") ?? [];
6  document
7    .querySelectorAll(".wp-block-categories-dropdown.posts-filter-categories")
8    .forEach(function (dropdown) {
9      var section = dropdown.parentElement.parentElement.parentElement, // dropdown.parents(".jc-posts-filter-section"),
10        hidden = document.createElement("input"),
11        options = [],
12        harvest = false;
13      hidden.setAttribute("name", "categories");
14      hidden.setAttribute("type", "hidden");
15      dropdown.querySelectorAll("select option").forEach(function (option) {
16        if (option.classList.contains("level-0")) {
17          if (harvest) {
18            harvest = false;
19          }
20          if (option.getAttribute("value") === parentCategory) {
21            harvest = true;
22            parentTitle = option.textContent.trim();
23          }
24        }
25        if (option.classList.contains("level-1") && harvest) {
26          options.push({
27            value: option.getAttribute("value"),
28            title: option.textContent.trim(),
29          });
30        }
31      });
32      var checkboxContainer = document.createElement("div"),
33        button = document.createElement("button"),
34        checkboxes = document.createElement("div");
35      checkboxContainer.setAttribute("class", "posts-filter-checkboxes");
36      button.setAttribute("type", "button");
37      checkboxes.setAttribute("class", "posts-filter-checkboxes-list");
38      var toggleCheckboxes = function () {
39        var checkedCategories = [];
40        section
41          .querySelectorAll(".posts-filter-checkboxes-item.is-checked")
42          .forEach(function (checkboxItem) {
43            checkedCategories.push(checkboxItem.getAttribute("data-value"));
44          });
45        hidden.value = checkedCategories.join(",");
46      };
47      var buttonText = document.createElement("span");
48      buttonText.innerHTML = parentTitle;
49      button.innerHTML =
50        '<svg width="18" height="10" viewBox="0 0 18 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.654328 0.0143692C0.897469 -0.0259618 1.14266 0.0150646 1.3339 0.182647L8.98261 7.96166L16.7229 0.134667C17.4284 -0.294371 18.2336 0.37109 17.9365 1.16241C15.2107 4.11144 12.3046 6.91792 9.51329 9.8155C9.28108 10.013 8.95598 10.0519 8.67937 9.93301C5.77465 7.14809 3.00788 4.18237 0.155751 1.3293C-0.195985 0.856453 0.0813054 0.108938 0.654328 0.0143692Z" fill="black"/></svg>';
51      button.prepend(buttonText);
52      button.addEventListener("click", function () {
53        if (checkboxContainer.classList.contains("is-open")) {
54          checkboxContainer.classList.remove("is-open");
55        } else {
56          checkboxContainer.classList.add("is-open");
57        }
58      });
59      options.forEach(function (option) {
60        var item = document.createElement("button"),
61          itemText = document.createElement("span");
62        itemText.innerHTML = option.title;
63        item.setAttribute("type", "button");
64        item.setAttribute("class", "posts-filter-checkboxes-item");
65        item.setAttribute("data-value", option.value);
66        item.append(itemText);
67        if (categories.includes(option.value)) {
68          item.classList.add("is-checked");
69        }
70        item.addEventListener("click", function () {
71          if (item.classList.contains("is-checked")) {
72            item.classList.remove("is-checked");
73          } else {
74            item.classList.add("is-checked");
75          }
76          toggleCheckboxes();
77        });
78        checkboxes.append(item);
79      });
80      checkboxContainer.append(button);
81      checkboxContainer.append(checkboxes);
82      dropdown.append(checkboxContainer);
83      section.querySelector("form")?.append(hidden);
84      toggleCheckboxes();
85      document.addEventListener("mousedown", function (event) {
86        if (
87          !button.contains(event.target) &&
88          !checkboxes.contains(event.target)
89        ) {
90          checkboxContainer.classList.remove("is-open");
91        }
92      });
93    });
94})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.