26 lines
891 B
JavaScript
26 lines
891 B
JavaScript
|
|
let obj = !localStorage ? {id: 'theme-light', type: 'light'} : JSON.parse(localStorage.getItem("ui-theme"));
|
|
if ( !obj ) {
|
|
obj = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ?
|
|
{id: 'theme-dark', type: 'dark'} : {id: 'theme-light', type: 'light'};
|
|
localStorage && localStorage.setItem("ui-theme", JSON.stringify(obj));
|
|
}
|
|
|
|
document.body.classList.add(`theme-type-${obj.type}`);
|
|
|
|
const load_stylesheet = reflink => {
|
|
let link = document.createElement( "link" );
|
|
link.href = reflink;
|
|
link.type = "text/css";
|
|
link.rel = "stylesheet";
|
|
|
|
document.getElementsByTagName("head")[0].appendChild(link);
|
|
};
|
|
|
|
if ( !localStorage && localStorage.getItem('mode-direction') === 'rtl' ) {
|
|
document.body.classList.add('rtl');
|
|
load_stylesheet('./css/framework7-rtl.css')
|
|
} else {
|
|
load_stylesheet('./css/framework7.css')
|
|
}
|