mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-29 00:31:09 +00:00
b4488f8ddb
* refactor: Fix switching theme * ci: lint code to MediaWiki standards Check commit and GitHub actions for more details Co-authored-by: github-actions <github-actions@users.noreply.github.com>
25 lines
585 B
JavaScript
25 lines
585 B
JavaScript
/* eslint-disable */
|
|
/*
|
|
* Citizen - Inline script used in SkinCitizen.php
|
|
*
|
|
* https://starcitizen.tools
|
|
*/
|
|
window.switchTheme = () => {
|
|
try {
|
|
const cookieTheme = document.cookie.match(/skin-citizen-theme=(dark|light|auto)/);
|
|
const theme = cookieTheme !== null ? cookieTheme.pop() : null;
|
|
|
|
if (theme !== null) {
|
|
document.documentElement.classList.remove(...['auto', 'dark', 'light'].map(theme => {
|
|
return 'skin-citizen-' + theme;
|
|
}));
|
|
document.documentElement.classList.add('skin-citizen-' + theme);
|
|
}
|
|
} catch (e) {
|
|
}
|
|
}
|
|
|
|
(() => {
|
|
window.switchTheme()
|
|
})();
|