MediaWiki:Common.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */ $(document).ready(function(){ // find categories categories = []; $("#mw-normal-catlinks a").each(function(i) { // debug: // console.log($(this).html()); categories.push($.trim($(this).html())); }); //console.log(categories); // now go over all navigation links and hide all, where we don't have that category $("#p-navigation div ul li").each(function(i) { // debug: // console.log($(this).attr("class")); entry_classes = $.trim($(this).attr("class")).split(" "); //console.log(entry_classes); if(entry_classes.indexOf("nav1") != -1) { found = false; entry_classes.forEach(function(entry_class) { // ok.. we might consider hiding that.. cat_name = entry_class.substring(4); if(categories.indexOf(cat_name) != -1) { // that category we do have.. found = true; } }); if(!found) { $(this).hide(); } } }); })