mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-18 03:41:50 +00:00
abffe590b5
Co-authored-by: H. C. Kruse <6594492+octfx@users.noreply.github.com> Co-authored-by: github-actions <github-actions@users.noreply.github.com>
37 lines
924 B
JavaScript
37 lines
924 B
JavaScript
/* eslint-disable */
|
|
/*
|
|
* Citizen - Inline script used in SkinCitizen.php
|
|
*
|
|
* https://starcitizen.tools
|
|
*
|
|
* Mangle using https://jscompress.com/
|
|
*/
|
|
window.switchTheme = () => {
|
|
// Generates an array of prefix-(auto|dark|light) strings
|
|
const classNames = (prefix) => {
|
|
return ['auto', 'dark', 'light'].map(themeType => {
|
|
return prefix + themeType;
|
|
});
|
|
}
|
|
|
|
const themeToggle = document.getElementById('theme-toggle');
|
|
|
|
try {
|
|
const theme = window.localStorage.getItem('skin-citizen-theme');
|
|
|
|
if (theme !== null) {
|
|
// First remove all theme classes
|
|
document.documentElement.classList.remove(...classNames('skin-citizen-'));
|
|
// Then add the right one
|
|
document.documentElement.classList.add('skin-citizen-' + theme);
|
|
themeToggle.classList.remove(...classNames('theme-toggle'))
|
|
themeToggle.classList.add('theme-toggle-' + theme);
|
|
}
|
|
} catch (e) {
|
|
}
|
|
}
|
|
|
|
(() => {
|
|
window.switchTheme()
|
|
})();
|