Difference between revisions of "MediaWiki:Common.js"

From SCS Modding Wiki
Jump to navigation Jump to search
Line 4: Line 4:
 
var list_items = document.getElementsByTagName("li");
 
var list_items = document.getElementsByTagName("li");
  
    for (var i = 0; i < list_items.length; ++i) {
+
for (var i = 0; i < list_items.length; ++i) {
        var list_item = list_items[i];
+
    var list_item = list_items[i];
  
        console.log(list_item);
+
    console.log(list_item);
  
        var show = list_item.getAttribute("show");
+
    var show = list_item.getAttribute("show");
        if (show != []._) {
+
    if (show != []._) {
            var elementToShow = document.getElementById(show);
+
        var elementToShow = document.getElementById(show);
            if (elementToShow != []._) {
+
        console.log("elementToShow: " + elementToShow );
                list_item.onclick = function() {
+
        if (elementToShow != []._) {
                    elementToShow.display = 'block';
+
            list_item.onclick = function() {
                }
+
                elementToShow.display = 'block';
                elementToShow.display = 'none';
 
 
             }
 
             }
 +
            elementToShow.display = 'none';
 
         }
 
         }
 
     }
 
     }
 
+
}
    console.log("Common.js (" + list_items.length + ")");
 

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