Difference between revisions of "MediaWiki:Common.js"

From SCS Modding Wiki
Jump to navigation Jump to search
Line 10: Line 10:
  
 
     var show = list_item.getAttribute("show");
 
     var show = list_item.getAttribute("show");
 +
    console.log("show: " + show);
 
     if (show != []._) {
 
     if (show != []._) {
 
         var elementToShow = document.getElementById(show);
 
         var elementToShow = document.getElementById(show);

Revision as of 15:54, 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("show");
    console.log("show: " + show);
    if (show != []._) {
        var elementToShow = document.getElementById(show);
        console.log("elementToShow: " + elementToShow );
        if (elementToShow != []._) {
            list_item.onclick = function() {
                elementToShow.display = 'block';
            }
            elementToShow.display = 'none';
        }
    }
}