From 7ed23f232bbc1a98de0a2dbfebb605a32459940d Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Sun, 27 Apr 2025 20:58:10 +0100 Subject: [PATCH] feat: Add UI scale slider --- src/public/app.js | 44 +++++++++++++++++++++++++++++++++++++++++-- src/public/index.html | 6 ++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/public/app.js b/src/public/app.js index bc710b76e..3acb43f9d 100644 --- a/src/public/app.js +++ b/src/public/app.js @@ -456,7 +456,6 @@ document.addEventListener('DOMContentLoaded', function() { return isNaN(numericVal) ? 0 : numericVal; // Default to 0 if parsing fails unexpectedly } // --- End Special Handling --- - // Handle specific column logic if needed if (type === 'main' && col === 'id') val = parseInt(item.vmid || item.id || 0); else if (type === 'nodes' && col === 'id') val = item.node; @@ -2558,4 +2557,45 @@ document.addEventListener('DOMContentLoaded', function() { } // ---> END NEW Function <--- -}); // End DOMContentLoaded \ No newline at end of file + // --- START: UI Scale Slider Logic --- + const uiScaleSlider = document.getElementById('ui-scale-slider'); + // Target the root element for font-size adjustment + // REUSE existing variable declared earlier + + const applyRootFontSize = (sliderValue) => { + // Map slider value (0.75-1.25) to root font size (e.g., 12px-20px, centered around 16px) + const baseSize = 16; // Assuming default browser root font size is 16px + const newSizePx = baseSize * sliderValue; + + if (htmlElement) { + htmlElement.style.fontSize = `${newSizePx}px`; + } + if (uiScaleSlider) { + uiScaleSlider.value = sliderValue; + } + }; + + const loadRootFontSize = () => { + const savedMultiplier = localStorage.getItem('uiFontMultiplier'); + if (savedMultiplier) { + applyRootFontSize(parseFloat(savedMultiplier)); + } else { + applyRootFontSize(1.0); // Default multiplier (maps to 16px) + } + }; + + if (uiScaleSlider && htmlElement) { + uiScaleSlider.addEventListener('input', (event) => { + const newMultiplier = parseFloat(event.target.value); + applyRootFontSize(newMultiplier); + localStorage.setItem('uiFontMultiplier', newMultiplier.toString()); + }); + + // Load initial font size + loadRootFontSize(); + } else { + console.error('Could not find UI scale slider or HTML element.'); + } + // --- END: UI Scale Slider Logic --- + +}); // End DOMContentLoaded diff --git a/src/public/index.html b/src/public/index.html index f04562f98..a9a91107f 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -60,6 +60,12 @@ + +
+ + +
+
Disconnected