MediaWiki:Common.js

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

$(function {    /* Hide namespace prefixes for page links on category pages */    var prefix = $('#mw-cat-hide-page-ns').text.trim;

if (prefix.length > 0){ $('#mw-pages a').text(function(i, val){           return val.slice(0, prefix.length) === prefix ? val.slice(prefix.length + 1) : val;        }); }

/******************   /* CUSTOMIZATIONS * /******************/

if(wgNamespaceNumber == 0) { // Put edit links on Item tables that point to data modules var item_table_headers= { 'Base': '/Module:Items/Data', 'Crafted': '/Module:Items/Data/Crafted', 'Edible': '/Module:Items/Data/Edible', 'Category:Game mechanics': '/Module:Items/Data/Equipment', 'Category:Reagents': '/Module:Items/Data/Reagents' };

function addEditLink(url, extra_style){ if (extra_style === undefined){ extra_style = ""; }

return '[edit]'; }

$("table.game-item-table .section-header").each(function(idx){           var title = $(this).children("a").attr("title")

if (title !== undefined){ $(this).append(addEditLink(item_table_headers[title])); }       });

$("table.game-item-table img.section-header").each(function(idx){           var node = $(this).parentsUntil("div.floatnone");            var title = "Base";            node.append(addEditLink(item_table_headers[title]));        });

$("caption.game-item-table").each(function(idx){           var title = "Crafted";            var url = item_table_headers[title];            $(this).append('[edit]');        }); }

});