MediaWiki:Common.js

// Add a link and notice under discussion edit boxes to automatically insert a signature. importScript('MediaWiki:AddSigLink.js');

// ReferenceTooltips: Displays references as tooltips on mouseover, built-in disable/enable function, on by default importScript('MediaWiki:Common.js/ReferenceTooltips.js');

// Select links to new tabs for Template:ilnt and Template:elnt $('.linkNewTab a').each(function{   $(this).attr('target','_blank'); });

// Add link on image pages that appends a list of uses at other language wikis importScript('MediaWiki:ImageForeignUseCheck.js');

// Disable creation of non-talk pages by anonymous IP editors and link to registration (also disabled by abuse filter but this provides warning before attempting edit) var isTalk = false, isAnon = false; if (wgPageName.indexOf('talk:') > -1 || wgPageName.indexOf('Talk:') > -1) isTalk = true; if (wgUserName === null) isAnon = true;

if (isAnon == true){ $('a.new').each(function{       var href = $(this).attr('href');        $(this).attr('href', href.replace(/&action=edit/g, '') );    }); }

if (isAnon == true && isTalk == false) { var anonWarnText = 'Page creation by anonymous editors is currently disabled. To create this page, please register an account first.'; $('body').append(' '); $('body').prepend('' + anonWarnText + ' ');

$('#ca-edit a:contains(Create), a.external.text:contains(edit this page)').attr('href', '#').click(function{       $('.anonWarnBox').show;        $('.anonWarnOverlay').show;    }); $('.anonWarnOverlay').click(function{       $('.anonWarnBox').hide;        $(this).hide;    }); }

// AJAX tables function addAjaxDisplayLink { $("table.ajax").each(function (i) {		var table = $(this).attr("id", "ajaxTable" + i);		table.find(".nojs-message").remove;		var headerLinks = $(' ').appendTo(table.find('th').first);		var cell = table.find("td").first, needLink = true;		cell.parent.show;		if (cell.hasClass("showLinkHere")) {			var old = cell.html, rep = old.replace(/\[link\](.*?)\[\/link\]/, '$1');			if (rep != old) {				cell.html(rep);				needLink = false;			}		}		if (needLink) headerLinks.html('[show data]');		table.find(".ajax-load-link").parent.andSelf.filter('a').click(function(event) { event.preventDefault; var sourceTitle = table.data('ajax-source-page'), baseLink = mw.config.get('wgScript') + '?'; cell.text('Please wait, the content is being loaded...'); $.get(baseLink + $.param({ action: 'render', title: sourceTitle }), function (data) {				if (data) {					cell.html(data);					cell.find('.ajaxHide').remove;					cell.find('.terraria').removeClass('terraria');					if (cell.find("table.sortable").length) {						mw.loader.using('jquery.tablesorter', function { cell.find("table.sortable").tablesorter; });					}					headerLinks.text('[');					headerLinks.append($('edit').attr('href', baseLink + $.param({ action: 'edit', title: sourceTitle })));					headerLinks.append(document.createTextNode(']\u00A0['));					var shown = true;					$("hide").click(function { shown = !shown; shown ? cell.show : cell.hide; $(this).text(shown ? "hide" : "show"); }).appendTo(headerLinks);					headerLinks.append(document.createTextNode(']'));				}			}).error(function {				cell.text('Unable to load table; the source article for it might not exist.');			}); });	}); }

$(addAjaxDisplayLink);