docs: explain lightweight CatWar helpers

This commit is contained in:
nyan404 committed 2026-08-25 04:22:40 +03:00
1 parent afa56b46ee
commit 3989cdc4e3
1 file changed
+7 -1
+7 -1
View File
@@ -69,6 +69,7 @@
} }
}; };
// Applies shared stylesheet and DOM tweaks used on every supported page.
function applyCommon() { function applyCommon() {
const footer = document.getElementById('footer'); const footer = document.getElementById('footer');
if (footer) { if (footer) {
@@ -79,6 +80,7 @@
} }
} }
// Rebuilds the compact menu when the page menu appears or changes.
function enhanceMenu(forceRefresh) { function enhanceMenu(forceRefresh) {
const menu = document.querySelector('#app > span.small, .small'); const menu = document.querySelector('#app > span.small, .small');
if (!menu) return; if (!menu) return;
@@ -111,6 +113,7 @@
} }
} }
// Adds the small-screen layout classes and hides nonessential controls.
function applyCompactLayout() { function applyCompactLayout() {
toggleStyle('compact', state.compactLayout, ` toggleStyle('compact', state.compactLayout, `
body { body {
@@ -142,6 +145,7 @@
`); `);
} }
// Inserts the user-facing toggle that enables or disables compact mode.
function injectToggle() { function injectToggle() {
const menu = document.querySelector('#app > span.small, .small'); const menu = document.querySelector('#app > span.small, .small');
if (!menu || menu.querySelector('[data-cwmod-lite="toggle"]')) return; if (!menu || menu.querySelector('[data-cwmod-lite="toggle"]')) return;
@@ -169,6 +173,7 @@
menu.appendChild(toggle); menu.appendChild(toggle);
} }
// Persists one style preference and injects/removes its matching CSS rule.
function toggleStyle(key, shouldEnable, cssText) { function toggleStyle(key, shouldEnable, cssText) {
if (!shouldEnable) { if (!shouldEnable) {
if (styles[key] && styles[key].parentNode) { if (styles[key] && styles[key].parentNode) {
@@ -185,6 +190,7 @@
styles[key] = style; styles[key] = style;
} }
// Reads the saved lite-mode settings, using defaults for malformed values.
function loadSettings() { function loadSettings() {
try { try {
const raw = window.localStorage.getItem(STORAGE_KEY); const raw = window.localStorage.getItem(STORAGE_KEY);
@@ -197,6 +203,7 @@
} }
} }
// Serializes the current lite-mode settings to browser storage.
function saveSettings(settings) { function saveSettings(settings) {
try { try {
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(settings)); window.localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
@@ -205,4 +212,3 @@
} }
} }
})(window, document); })(window, document);