PageSourceSearch

https://pupwife.com/scripts/effects/themeBoot.js

js pupwife.com collected 2026-09-30 15:04:04 UTC 4,166 bytes, 111 lines download raw bytes

1/**
2 * First-paint theme boot — run synchronously in <head> before styles render.
3 * Default: dark mode + default palette. Respects puppywifey_settings when set.
4 */
5(function () {
6    'use strict';
7
8    document.write('<script src="/scripts/effects/siteThemePalettes.js"><\/script>');
9    (function markThemePaletteScriptLoaded() {
10        var el = document.querySelector('script[src="/scripts/effects/siteThemePalettes.js"]');
11        if (el) el.dataset.spaLoaded = '1';
12    })();
13
14    var BG_DARK = '#0a0a14';
15    var BG_LIGHT = '#e8eaf2';
16    var DAW_BG_DARK = '#0f0f1a';
17    var DAW_BG_LIGHT = '#d8d8de';
18
19    function isDawPage() {
20        var path = (window.location.pathname || '').toLowerCase();
21        return path.endsWith('daw.html') || path.endsWith('/daw') || path.endsWith('/daw/');
22    }
23
24    function isCitrusPage() {
25        var path = (window.location.pathname || '').toLowerCase();
26        return path === '/' || path === '' || path.endsWith('/index.html') || path.endsWith('index.html');
27    }
28
29    function readCssVar(name, fallback) {
30        try {
31            var val = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
32            if (val) return val;
33        } catch (e) {}
34        return fallback;
35    }
36
37    function getBootBackground(isDark) {
38        if (isCitrusPage()) {
39            if (isDark) {
40                return readCssVar('--site-boot-bg-dark', '#0a0a0c');
41            }
42            return readCssVar('--site-boot-bg', BG_LIGHT);
43        }
44        if (isDawPage()) return isDark ? DAW_BG_DARK : DAW_BG_LIGHT;
45        if (isDark) {
46            return readCssVar('--site-boot-bg-dark', BG_DARK);
47        }
48        return readCssVar('--site-boot-bg', BG_LIGHT);
49    }
50
51    function readThemeSettings() {
52        if (window.SiteThemePalettes && typeof window.SiteThemePalettes.readMergedThemeSettings === 'function') {
53            return window.SiteThemePalettes.readMergedThemeSettings();
54        }
55        return { palette: 'default', colorMode: 'dark', darkMode: true };
56    }
57
58    function applyBootThemeClasses(theme) {
59        var root = document.documentElement;
60        var isDark = theme.colorMode === 'dark';
61
62        root.setAttribute('data-site-palette', theme.palette || 'default');
63        root.setAttribute('data-color-mode', theme.colorMode || (isDark ? 'dark' : 'light'));
64        root.setAttribute('data-theme', isDark ? 'dark' : 'light');
65        root.classList.toggle('dark-mode', isDark);
66
67        function syncBody() {
68            if (!document.body) return;
69            document.body.classList.toggle('dark-mode', isDark);
70            document.body.setAttribute('data-site-palette', theme.palette || 'default');
71            document.body.setAttribute('data-color-mode', theme.colorMode || (isDark ? 'dark' : 'light'));
72        }
73
74        syncBody();
75        if (!document.body) {
76            var observer = new MutationObserver(function () {
77                if (document.body) {
78                    syncBody();
79                    observer.disconnect();
80                }
81            });
82            observer.observe(document.documentElement, { childList: true });
83        }
84    }
85
86    var theme = readThemeSettings();
87    var isDark = theme.colorMode === 'dark';
88    var bg = getBootBackground(isDark);
89    var hideBody = document.currentScript && document.currentScript.getAttribute('data-hide-body') === 'true';
90
91    var css = 'html,body{background:' + bg + ' !important;}';
92    if (hideBody) css += ' body{opacity:0}';
93    document.write('<style>' + css + '</style>');
94
95    applyBootThemeClasses(theme);
96
97    window.SiteThemeBoot = {
98        readDarkMode: function () {
99            return readThemeSettings().darkMode;
100        },
101        readThemeSettings: readThemeSettings,
102        parseDarkMode: window.SiteThemePalettes
103            ? window.SiteThemePalettes.parseDarkMode
104            : function (value, fallback) {
105                if (typeof value === 'boolean') return value;
106                if (value === 'true' || value === 1) return true;
107                if (value === 'false' || value === 0) return false;
108                return fallback;
109            }
110    };
111})();

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.