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