PageSourceSearch

https://pupwife.com/scripts/desktop/citrusRouteScope.js

js pupwife.com collected 2026-09-30 15:04:17 UTC 3,011 bytes, 84 lines download raw bytes

1/**
2 * CitrusOS route state belongs on the window container, not document.body.
3 * Tools use this instead of document.body.classList when isCitrusHost().
4 */
5(function (global) {
6    'use strict';
7
8    function isCitrusHost() {
9        return !!(document.body && document.body.classList.contains('page-citrusos'));
10    }
11
12    function getScopeEl(preferred) {
13        if (!isCitrusHost()) return document.body;
14        if (preferred) {
15            if (preferred.classList &&
16                (preferred.classList.contains('citrus-window__content') ||
17                    preferred.classList.contains('citrus-fullscreen__content'))) {
18                return preferred;
19            }
20            if (preferred.closest) {
21                var nested = preferred.closest('.citrus-window__content, .citrus-fullscreen__content');
22                if (nested) return nested;
23            }
24        }
25        if (global.__citrusRouteScopeEl) return global.__citrusRouteScopeEl;
26        if (global.CitrusWindowLoader && typeof global.CitrusWindowLoader.getFocusedContainer === 'function') {
27            var focused = global.CitrusWindowLoader.getFocusedContainer();
28            if (focused) return focused;
29        }
30        return document.body;
31    }
32
33    function getClassTarget(preferred) {
34        return isCitrusHost() ? getScopeEl(preferred) : document.body;
35    }
36
37    function hasClass(className, preferred) {
38        if (!className) return false;
39        if (isCitrusHost()) {
40            if (preferred && getScopeEl(preferred).classList.contains(className)) return true;
41            if (global.__citrusRouteScopeEl && global.__citrusRouteScopeEl.classList.contains(className)) {
42                return true;
43            }
44            return !!document.querySelector(
45                '.citrus-window__content.' + className + ', .citrus-fullscreen__content.' + className
46            );
47        }
48        return document.body.classList.contains(className);
49    }
50
51    function toggleClass(className, on, preferred) {
52        getClassTarget(preferred).classList.toggle(className, !!on);
53    }
54
55    function addClass(className, preferred) {
56        getClassTarget(preferred).classList.add(className);
57    }
58
59    function removeClass(className, preferred) {
60        getClassTarget(preferred).classList.remove(className);
61    }
62
63    function removeClasses(classNames, preferred) {
64        var el = getClassTarget(preferred);
65        var i;
66        for (i = 0; i < classNames.length; i++) el.classList.remove(classNames[i]);
67    }
68
69    function setActiveScope(el) {
70        global.__citrusRouteScopeEl = el || null;
71    }
72
73    global.CitrusRouteScope = {
74        isCitrusHost: isCitrusHost,
75        getScopeEl: getScopeEl,
76        getClassTarget: getClassTarget,
77        hasClass: hasClass,
78        toggleClass: toggleClass,
79        addClass: addClass,
80        removeClass: removeClass,
81        removeClasses: removeClasses,
82        setActiveScope: setActiveScope
83    };
84})(typeof window !== 'undefined' ? window : this);

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.