2021-01-11 18:17:20 +00:00
|
|
|
/* eslint-disable */
|
2021-01-11 17:13:59 +00:00
|
|
|
/*
|
|
|
|
* Citizen - Inline script used in SkinCitizen.php
|
|
|
|
*
|
|
|
|
* https://starcitizen.tools
|
2021-01-31 17:38:37 +00:00
|
|
|
*
|
|
|
|
* Mangle using https://jscompress.com/
|
2021-01-11 17:13:59 +00:00
|
|
|
*/
|
2021-01-11 22:13:01 +00:00
|
|
|
window.switchTheme = () => {
|
2021-01-31 17:38:37 +00:00
|
|
|
// 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');
|
|
|
|
|
2021-01-11 17:13:59 +00:00
|
|
|
try {
|
|
|
|
const cookieTheme = document.cookie.match(/skin-citizen-theme=(dark|light|auto)/);
|
|
|
|
const theme = cookieTheme !== null ? cookieTheme.pop() : null;
|
|
|
|
|
|
|
|
if (theme !== null) {
|
2021-01-31 17:38:37 +00:00
|
|
|
// First remove all theme classes
|
|
|
|
document.documentElement.classList.remove(...classNames('skin-citizen-'));
|
|
|
|
// Then add the right one
|
2021-01-11 17:13:59 +00:00
|
|
|
document.documentElement.classList.add('skin-citizen-' + theme);
|
2021-01-31 17:38:37 +00:00
|
|
|
themeToggle.classList.remove(...classNames('theme-toggle'))
|
|
|
|
themeToggle.classList.add('theme-toggle-' + theme);
|
2021-01-11 17:13:59 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
}
|
2021-01-11 22:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(() => {
|
|
|
|
window.switchTheme()
|
2021-01-11 17:13:59 +00:00
|
|
|
})();
|