web-apps/apps/common/mobile/utils/htmlutils.js
2022-08-18 18:20:17 +03:00

26 lines
892 B
JavaScript

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('mobile-mode-direction') === 'rtl' ) {
load_stylesheet('./css/framework7-rtl.css')
document.body.classList.add('rtl');
} else {
load_stylesheet('./css/framework7.css')
}
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}`);