2021-04-27 16:57:54 +00:00
|
|
|
/* eslint-disable */
|
|
|
|
/*
|
|
|
|
* Citizen - Inline script used in SkinCitizen.php
|
|
|
|
*
|
|
|
|
* https://starcitizen.tools
|
|
|
|
*
|
|
|
|
* Mangle using https://jscompress.com/
|
|
|
|
*/
|
|
|
|
window.applyPref = () => {
|
|
|
|
// Generates an array of prefix-(auto|dark|light) strings
|
|
|
|
const classNames = ( prefix ) => {
|
|
|
|
return [ 'auto', 'dark', 'light' ].map( themeType => {
|
|
|
|
return prefix + themeType;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
const htmlElement = document.documentElement,
|
|
|
|
theme = window.localStorage.getItem( 'skin-citizen-theme' ),
|
|
|
|
fontsize = window.localStorage.getItem( 'skin-citizen-fontsize' ),
|
2021-08-05 15:24:52 +00:00
|
|
|
pagewidth = window.localStorage.getItem( 'skin-citizen-pagewidth' ),
|
|
|
|
lineheight = window.localStorage.getItem( 'skin-citizen-lineheight' );
|
2021-04-27 16:57:54 +00:00
|
|
|
if ( theme !== null ) {
|
|
|
|
// First remove all theme classes
|
|
|
|
htmlElement.classList.remove(...classNames('skin-citizen-' ) );
|
|
|
|
// Then add the right one
|
|
|
|
htmlElement.classList.add( 'skin-citizen-' + theme );
|
|
|
|
}
|
|
|
|
if ( fontsize !== null ) {
|
|
|
|
htmlElement.style.setProperty( 'font-size', fontsize );
|
|
|
|
}
|
|
|
|
if( pagewidth !== null ) {
|
|
|
|
htmlElement.style.setProperty( '--width-layout', pagewidth );
|
|
|
|
}
|
2021-08-05 15:24:52 +00:00
|
|
|
if( lineheight !== null ) {
|
|
|
|
htmlElement.style.setProperty( '--line-height', lineheight );
|
|
|
|
}
|
2021-04-27 16:57:54 +00:00
|
|
|
} catch ( e ) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(() => {
|
2022-04-19 22:17:53 +00:00
|
|
|
// Set up auto theme based on prefers-color-scheme
|
|
|
|
if ( window.localStorage.getItem( 'skin-citizen-theme' ) === 'auto' ) {
|
|
|
|
const autoTheme = window.matchMedia( '(prefers-color-scheme: dark)' ) ? 'dark' : 'light';
|
|
|
|
// Set to the right theme temporarily
|
|
|
|
window.localStorage.setItem( 'skin-citizen-theme', autoTheme );
|
|
|
|
window.applyPref();
|
|
|
|
// Reset back to auto
|
|
|
|
window.localStorage.setItem( 'skin-citizen-theme', 'auto' );
|
|
|
|
} else {
|
|
|
|
window.applyPref();
|
|
|
|
}
|
2021-04-27 16:57:54 +00:00
|
|
|
})();
|