PageSourceSearch

https://rathgrith.github.io/assets/js/core/publication-filter.js?v=49dbd75c781cd50d064b8c8e77d951c9988bbc75

js rathgrith.github.io collected 2026-10-03 09:49:29 UTC 2,091 bytes, 67 lines download raw bytes

1(function () {
2  function initialiseFilter(list) {
3    if (!list || list.getAttribute("data-publication-filter-bound") === "true")
4      return;
5
6    var filter = list.previousElementSibling;
7    if (!filter || !filter.classList.contains("publication-filter")) return;
8
9    var items = Array.prototype.slice.call(
10      list.querySelectorAll("[data-publication-selected]")
11    );
12    var buttons = Array.prototype.slice.call(
13      filter.querySelectorAll("[data-publication-filter]")
14    );
15    var count = filter.querySelector("[data-publication-count]");
16
17    function applyMode(mode) {
18      var showAll = mode === "all";
19      var visibleCount = 0;
20
21      items.forEach(function (item) {
22        var visible =
23          showAll || item.getAttribute("data-publication-selected") === "true";
24        item.hidden = !visible;
25        if (visible) visibleCount += 1;
26      });
27
28      buttons.forEach(function (button) {
29        var active = button.getAttribute("data-publication-filter") === mode;
30        button.classList.toggle("is-active", active);
31        button.setAttribute("aria-pressed", active ? "true" : "false");
32      });
33
34      list.setAttribute("data-publication-mode", mode);
35      if (count) count.textContent = String(visibleCount);
36    }
37
38    filter.addEventListener("click", function (event) {
39      var button = event.target.closest("[data-publication-filter]");
40      if (!button || !filter.contains(button)) return;
41      applyMode(
42        button.getAttribute("data-publication-filter") === "all"
43          ? "all"
44          : "selected"
45      );
46    });
47
48    list.setAttribute("data-publication-filter-bound", "true");
49    applyMode(
50      list.getAttribute("data-publication-mode") === "all" ? "all" : "selected"
51    );
52  }
53
54  function init() {
55    Array.prototype.forEach.call(
56      document.querySelectorAll("[data-publication-list]"),
57      initialiseFilter
58    );
59  }
60
61  document.addEventListener("site:content-updated", init);
62  if (document.readyState === "loading") {
63    document.addEventListener("DOMContentLoaded", init);
64  } else {
65    init();
66  }
67})();

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.