class VisualConfig { constructor(settings) { this.settings = settings; } init() { $.each(this.settings, (key, value) => { this.elector(key, value); }); } elector(key, value) { switch (key) { case 'mode': value = (value === 'light' || value === 'dark') ? value : 'default'; if(this.find_config(key, value) !== value) this.btn_click('skin-'+value); break; case 'theme': value = (value >= 1) ? value : 0; var url_theme = (value >= 1) ? window.location.origin+'/themes/default/css/themes/cust-theme-'+(value-1)+'.css' : ''; if(this.find_config(key) !== url_theme) this.btn_click('myapp-'+(value-1)); break; default: if(this.find_config(key) !== value) this.btn_click(key); } } searcher(search) { return themeSettings.themeOptions.search(search) > 0; } find_config(config, value = null) { if(config === 'mode') { if(value !== 'default') return this.searcher('mod-skin-'+value) ? value : false; return (!this.searcher('mod-skin-light') && !this.searcher('mod-skin-dark')) ? value : false; } if(config === 'theme') return themeSettings.themeURL; return this.searcher(config); } btn_click(config) { $('#'+config).click(); } }