web-apps/apps/common/mobile/utils/htmlutils.js

26 lines
892 B
JavaScript
Raw Normal View History

2021-11-24 12:19:07 +00:00
2022-07-12 07:41:09 +00:00
const load_stylesheet = reflink => {
let link = document.createElement( "link" );
link.href = reflink;
2022-08-12 11:55:09 +00:00
// link.type = "text/css";
2022-07-12 07:41:09 +00:00
link.rel = "stylesheet";
document.getElementsByTagName("head")[0].appendChild(link);
};
2022-08-18 15:20:17 +00:00
if ( localStorage && localStorage.getItem('mobile-mode-direction') === 'rtl' ) {
2022-07-12 07:41:09 +00:00
load_stylesheet('./css/framework7-rtl.css')
2022-08-12 11:55:09 +00:00
document.body.classList.add('rtl');
2022-07-12 07:41:09 +00:00
} else {
load_stylesheet('./css/framework7.css')
}
2022-08-12 11:55:09 +00:00
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}`);