User:Madminecrafter12/common.js

// Initialises stripes on all zebra tables after page load $(document).ready(function {	$('table.zebra tbody tr:nth-child(even)').addClass('even');	$('table.zebra tbody tr:nth-child(odd)').addClass('odd'); });

// Re do stripes on a table after sort finishes $(document).on('sortEnd.tablesorter', function(event) {	var table = $(event.target);	if(table.hasClass('zebra')) {		$('tbody tr:nth-child(even)',table).addClass('even').removeClass('odd');		$('tbody tr:nth-child(odd)',table).addClass('odd').removeClass('even');	} });

function getImageThumbnailURL(name, store, size) { var encodedName = encodeURIComponent(name.replace(/ /g, "_")); return "https://minecraft.gamepedia.com/media/minecraft.gamepedia.com/thumb/" + store + "/"		+ encodedName + "/"		+ size + "px-" + encodedName; }

function mimicIndicator(id, link, imgName, imgStore, title) { var encodedLink = encodeURIComponent(link.replace(/ /g, "_")); return $(" ") .attr("id", "mw-indicator-" + id) .addClass("mw-indicator") .append($("")			.attr({ "href": "/" + encodedLink, "title": title }).append($(" ") .attr({				"alt": title,				"src": getImageThumbnailURL(imgName, imgStore, 25),				"srcset": getImageThumbnailURL(imgName, imgStore, 38)					+ " 1.5x, "					+ getImageThumbnailURL(imgName, imgStore, 50)					+ " 2x",				"width": "25",				"height": "25"				}) )		); }

// JavaScript code $(function {	var blockedDiv = $(".blocked");	if (blockedDiv.length > 0) {		var usernameSpan;		var username;		var targetBlock = $(".userinfo");		if ($("#mw-mf-viewport").length > 0) { // Detect mobile mode			usernameSpan = $("#section_0");			username = usernameSpan.html.match(/UserProfile:(.*)/)[1];		} else {			usernameSpan = $("h1 .mw-headline");			username = usernameSpan.attr("id");		}

$(' ').append(			$(' ')			.append("This user is currently blocked! ")			.append($("") .attr("href", "https://minecraft.gamepedia.com/index.php?title=Special:Log/block&page=User%3A" + username) .attr("title", "Block log") .text("Check the block log") ).append(" • ")			.append($("") .attr("href", "https://minecraft.gamepedia.com/Special:GlobalBlockList?wpTarget=" + username) .attr("title", "Global block log") .text("List global blocks") ).append("")		).appendTo(targetBlock); } });

// https://terraria.gamepedia.com/MediaWiki:Gadget-ImageForeignUseCheck.js - should list file usage from other wikis

var wgNamespaceNumber = mw.config.get( 'wgNamespaceNumber' ); var wgPageName = mw.config.get( 'wgPageName' ); var wgTitle = mw.config.get( 'wgTitle' );

if (wgNamespaceNumber == 6) { $('#filetoc').append(		$('').append( $('', {'class':'foreignLink', 'href':'#foreign', 'text':'List foreign uses'}) )	);	$('#mw-imagepage-nolinkstoimage').append(		$('', {'class':'foreignLink', 'href':'#foreign', 'text':' (List foreign uses)'})	); $('.foreignLink').click(function{		$('.interUses').remove;		$('div[id$="linkstoimage"]').append($('', {'class':'interUses'}));		var $interUses = $('.interUses');		var URLprefix = 'https://', 			URLsuffix = '.gamepedia.com/api.php?format=json&callback=?';		var msgForeignUses = 'Foreign uses',			msgImageLink = 'file page',			msgNoUses = 'No foreign uses of this file were detected.';		$interUses.append( $(' ', {'text':msgForeignUses, 'style':'margin-left:-22px;'}) );		var langs = {			"Russian":"minecraft-ru",			"French":"minecraft-fr",			"Polish":"minecraft-pl",			"Chinese":"minecraft-zh",			"Dutch":"minecraft-nl",			"German":"minecraft-de",			"Japanese":"minecraft-ja",			"Ukrainian":"minecraft-uk",			"Czech":"minecraft-cs",			"Hungarian":"minecraft-hu",			"Portuguese":"minecraft-pt",			"Greek":"minecraft-el",			"Italian":"minecraft-it",			"Korean":"minecraft-ko",			"Spanish":"minecraft-es", "Thai":"minecraft-th", "Turkish":"minecraft-tr" };		$interUses.append( $(' ', {'text': msgNoUses, 'class':'no_foreign_uses'}) ); $.each(langs, function(key, value) {			var currentLangCode = value;			var request2 = { action:'query', list:'allimages', ailimit:'1',	aifrom:wgTitle }			$.getJSON(URLprefix + currentLangCode + URLsuffix, request2, function(response2) { $.each(response2.query.allimages, function(index, value){					if (value.name != wgTitle.replace(/ /g,'_')){						var request1 = { action:'query', list:'imageusage', iutitle:wgPageName };						$.getJSON(URLprefix + currentLangCode + URLsuffix, request1, function(response1) { var currentLangName = key; if (response1.query.imageusage.length > 0) { var urlImage = URLprefix + currentLangCode + '.gamepedia.com/' + wgPageName; $('.no_foreign_uses').remove; $interUses.append(									$(' ', {'style':'margin-left:-20px;', 'text':currentLangName}).append( $(' ', {'style':'font-size:85%;'}).append(											' (', $('', {'href':urlImage, 'text':msgImageLink}), ')'										) )								);								$.each(response1.query.imageusage, function(index, value) {									var urlUse = URLprefix + currentLangCode + '.gamepedia.com/' + value.title;									$interUses.append( $('').append(											$('</a>', {'href': urlUse, 'text':value.title})										) );								});							}						});					}				});			});		});	setTimeout(function{$interUses[0].scrollIntoView(true)}, 1000); }); }

// Tools/Navigation popups mw.loader.load('https://en.wikipedia.org/w/load.php?modules=ext.gadget.Navigation_popups');

// JWB mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript');