28 lines
963 B
JavaScript
28 lines
963 B
JavaScript
|
|
||
|
+function init_themes() {
|
||
|
var objtheme = localStorage.getItem("ui-theme");
|
||
|
if ( typeof(objtheme) == 'string' &&
|
||
|
objtheme.startsWith("{") && objtheme.endsWith("}") )
|
||
|
{
|
||
|
objtheme = JSON.parse(objtheme);
|
||
|
}
|
||
|
|
||
|
var ui_theme_name = objtheme && typeof(objtheme) == 'object' ? objtheme.id :
|
||
|
typeof(objtheme) == 'string' ? objtheme : localStorage.getItem("ui-theme-id");
|
||
|
|
||
|
if ( !!ui_theme_name ) {
|
||
|
if ( !!objtheme && !!objtheme.colors ) {
|
||
|
var colors = [];
|
||
|
for ( var c in objtheme.colors ) {
|
||
|
colors.push('--' + c + ':' + objtheme.colors[c]);
|
||
|
}
|
||
|
|
||
|
var style = document.createElement('style');
|
||
|
style.type = 'text/css';
|
||
|
style.innerHTML = '.' + ui_theme_name + '{'+ colors.join(';') +';}';
|
||
|
document.getElementsByTagName('head')[0].appendChild(style);
|
||
|
|
||
|
window.currentLoaderTheme = objtheme;
|
||
|
}
|
||
|
}
|
||
|
}();
|