function set_style(name){
- $('link[rel~="stylesheet"]').each(function (e){
- e.disabled = true;
- });
+ $('link[title]').each(e => e.disabled = true);
$('link[title="' + name + '"]')[0].disabled = false;
localStorage.setItem("theme", name);
-}
-
-var theme_ul;
-
-function add_themelink(theme, text) {
- theme_ul.innerHTML += '<li><a role="button" data-theme="' + theme + '">' + text + '</a>'
+ $(function() {
+ if(name == 'slate' || name == 'cyborg')
+ $('.logo').each(e => e.classList.remove('logo-light'));
+ else
+ $('.logo').each(e => e.classList.add('logo-light'));
+ });
}
$(function() {
- theme_ul = document.createElement('ul');
- theme_ul.className = 'list-inline';
- theme_ul.id = 'themes';
- add_themelink('cyborg', 'Black');
- add_themelink('slate', 'Grey');
- add_themelink('readable', 'White');
+ var theme_ul = '<ul class="list-inline" id="themes">' +
+ '<li><a role="button" data-theme="cyborg">Black</a>' +
+ '<li><a role="button" data-theme="slate">Grey</a>' +
+ '<li><a role="button" data-theme="readable">White</a></ul>';
var sidebar = $('#sidebar')[0];
- sidebar.insertBefore(theme_ul, sidebar.firstChild);
- $('#themes a').on('click', function(e){
- set_style(this.dataset.theme);
- });
+ sidebar.insertBefore(m(theme_ul), sidebar.firstChild);
+ $('#themes a').on('click', e => set_style(e.target.dataset.theme));
});
-var theme = localStorage.getItem("theme");
+let theme = localStorage.getItem("theme");
if(theme) {
if(theme == "cerulean" || theme == "cosmo")
theme = "readable";