Difference between revisions of "MediaWiki:Common.js"

From SCS Modding Wiki
Jump to navigation Jump to search
Line 16: Line 16:
 
         if (elementToShow != []._) {
 
         if (elementToShow != []._) {
 
             list_item.onclick = function() {
 
             list_item.onclick = function() {
                 elementToShow.display = 'block';
+
                 elementToShow.style.display = 'block';
 
             }
 
             }
             elementToShow.display = 'none';
+
             elementToShow.style.display = 'none';
 
         }
 
         }
 
     }
 
     }
 
}
 
}

Revision as of 15:56, 2 March 2016

/* Any JavaScript here will be loaded for all users on every page load. */


var list_items = document.getElementsByTagName("li");

for (var i = 0; i < list_items.length; ++i) {
    var list_item = list_items[i];

    console.log(list_item);

    var show = list_item.getAttribute("data-show");
    console.log("show: " + show);
    if (show != []._) {
        var elementToShow = document.getElementById(show);
        console.log("elementToShow: " + elementToShow );
        if (elementToShow != []._) {
            list_item.onclick = function() {
                elementToShow.style.display = 'block';
            }
            elementToShow.style.display = 'none';
        }
    }
}