attempt to set taskbar color with JS
Hunter
Sunday, November 17th, 2024 at 1:44 PM
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <link rel="manifest" href="manifest.json">
- <meta id="themeColor" name="theme-color" content="var(--background)">
7 + <meta id="themeColor" name="theme-color" content="#ccff00">
8
9 <!-- favicon -->
10 <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🪆</text></svg>">
1006 function cycleTheme() {
1007 currentThemeIndex = (currentThemeIndex + 1) % themes.length;
1008 const newTheme = themes[currentThemeIndex];
- document.documentElement.setAttribute('data-theme', newTheme);
1009 + setTheme(newTheme);
1010 saveThemeToLocalStorage(newTheme);
1011 }
1012
1014 localStorage.setItem('currentTheme', theme);
1015 }
1016
1017 + function setTheme(theme) {
1018 + document.documentElement.setAttribute('data-theme', theme);
1019 + const backgroundColor = getComputedStyle(document.documentElement).getPropertyValue('--background').trim();
1020 + document.getElementById('themeColor').setAttribute('content', backgroundColor);
1021 + }
1022 +
1023 function setInitialTheme() {
1024 const savedTheme = localStorage.getItem('currentTheme');
1025 const defaultTheme = document.documentElement.getAttribute('data-theme');
1032 currentThemeIndex = 0;
1033 }
1034
- document.documentElement.setAttribute('data-theme', themes[currentThemeIndex]);
1035 + setTheme(themes[currentThemeIndex]);
1036 }
1037
1038 document.addEventListener('keydown', function(event) {
1050 });
1051
1052 document.addEventListener('keydown', handleSave);
- document.addEventListener('keydown', handleOpen);
1053 + document.addEventListener('keydown', handleOpen);
1054
1055 getThemesFromCSS();
1056 setInitialTheme();