mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 00:36:16 -04:00
fix invalid theme error
This commit is contained in:
parent
d3357d2acd
commit
9f30dd0e7a
1 changed files with 18 additions and 3 deletions
|
@ -160,18 +160,33 @@ class OptionsWaiter {
|
|||
|
||||
// Update theme selection
|
||||
const themeSelect = document.getElementById("theme");
|
||||
themeSelect.selectedIndex = themeSelect.querySelector(`option[value="${theme}"`).index;
|
||||
let themeOption = themeSelect.querySelector(`option[value="${theme}"]`);
|
||||
|
||||
if (!themeOption) {
|
||||
const preferredColorScheme = this.getPreferredColorScheme();
|
||||
document.querySelector(":root").className = preferredColorScheme;
|
||||
themeOption = themeSelect.querySelector(`option[value="${preferredColorScheme}"]`);
|
||||
}
|
||||
|
||||
themeSelect.selectedIndex = themeOption.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the user's preferred color scheme using the `prefers-color-scheme` media query.
|
||||
*/
|
||||
applyPreferredColorScheme() {
|
||||
const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
const theme = prefersDarkScheme ? "dark" : "classic";
|
||||
const theme = this.getPreferredColorScheme();
|
||||
this.changeTheme(theme);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's preferred color scheme using the `prefers-color-scheme` media query.
|
||||
*/
|
||||
getPreferredColorScheme() {
|
||||
const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
return prefersDarkScheme ? "dark" : "classic";
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the console logging level.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue