PageSourceSearch

https://kaaitheater.be/modules/_custom/dark_mode_switch/js/dark_mode_switch.js?tl5c85

js kaaitheater.be collected 2026-09-24 19:28:04 UTC 1,367 bytes, 34 lines download raw bytes

1(function (Drupal, drupalSettings, once) {
2  const dataAttr = '[data-dark-mode-switch]';
3  const darkClass = drupalSettings.dark_mode_switch.dark_class;
4  const parentElement = drupalSettings.dark_mode_switch.parent_element;
5  const defaultMode = drupalSettings.dark_mode_switch.default_mode;
6
7  Drupal.behaviors.dark_mode_switch = {
8    attach: function (context) {
9      // be sure this is executed only once, on page load
10      if (context === document) {
11        // Check Dark Mode Switch Cookie.
12        const elements = once('dark_mode_switch', dataAttr, context);
13        elements.forEach(processingCallback);
14        // Toggle Dark Mode Switch.
15        document.querySelector(dataAttr).onchange = (event) => {
16          document.querySelector(parentElement).classList.toggle(darkClass);
17          localStorage.theme = event.target.checked
18        };
19      }
20    }
21  };
22
23  function processingCallback() {
24    let darkmodestate = defaultMode === 'dark';
25    if (defaultMode === 'browser') {
26      darkmodestate = window.matchMedia('(prefers-color-scheme: dark)').matches;
27    }
28    if ('theme' in localStorage) {
29      darkmodestate = (localStorage.theme !== 'false');
30    }
31    document.querySelector(parentElement).classList.toggle(darkClass, darkmodestate);
32    document.querySelector(dataAttr).checked = darkmodestate;
33  }
34})(Drupal, drupalSettings, once);

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.