Add a function for making a DOM element from HTML
[plack-app-gruntmaster.git] / js / 90-themes.js
index a61b4c0c0089983ff69f06341667ceb9f6d57e15..c280266f466e6ac7506ce355df3d4c8767bcdceb 100644 (file)
@@ -6,21 +6,13 @@ function set_style(name){
        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() {
-       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);
+       sidebar.insertBefore(m(theme_ul), sidebar.firstChild);
        $('#themes a').on('click', function(e){
                set_style(this.dataset.theme);
        });
This page took 0.010152 seconds and 4 git commands to generate.