mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-17 19:32:00 +00:00
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()
|
|
})();
|