MediaWiki:Common.js: Difference between revisions

From the Kingdom Hearts Wiki, the Kingdom Hearts encyclopedia
Jump to navigationJump to search
No edit summary
mNo edit summary
 
(52 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on desktop */


/* Automatically add Aboutfile template to file upload description. Source: nl.wikipedia.org/wiki/MediaWiki:Common.js */
/* Alternating wiki logo */
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !document.getElementById('wpForReUpload') && !document.getElementsByClassName('mw-destfile-warning')[0] && !document.getElementsByClassName('error')[0]) {
$(function() {
function loadAutoAboutfileTemplate() {
var logos = ['b/bc/Wiki.png', 'd/d7/Wiki_2.png', '9/97/Wiki_3.png', '6/6a/Wiki_4.png', '7/79/Wiki_5.png'];
uploadDescription = document.getElementById('wpUploadDescription');
$('#p-logo a').css('background-image', 'url(https://kh.wiki.gallery/images/' + logos[Math.floor(Math.random() * logos.length)] + ')');
var doubleBracket = '{' + '{';
});
uploadDescription.value = doubleBracket + 'aboutfile\n|description=\n|purpose=\n|game=\n|source=\n}}';
 
/* Add user subpages toolbox link */
$(function() {
if (mw.config.get('wgCanonicalNamespace') === 'User' && mw.config.get('skin') !== 'timeless') {
var subpagesLink = '/Special:PrefixIndex/User:' + mw.config.get('wgTitle').split('/')[0] + '/';
mw.util.addPortletLink('p-tb', subpagesLink, 'User subpages', 't-subpages', 'Subpages for this user');
}
}
});


$(loadAutoAboutfileTemplate);
/* Hide page previews when portals are used */
}
$(function() {
 
if (document.getElementsByClassName('nav')[0] && document.getElementsByClassName('dropdown')[0])
/* Fix game icons when new user message */
$('head').append('<style type="text/css">.mwe-popups { display: none !important; }</style>');
if (document.getElementById('title-linktabs') && document.getElementsByClassName('usermessage')[0]) {
});
function fixGameIcons() {
var gameIcons = $('#title-linktabs');
gameIcons.css('top', '-48px');
}
$(fixGameIcons);
}


/* Shrinking talk bubble sprites */
/* Shrinking talk bubble sprites */
$(document).ready(function () {
$(function() {
if (document.readyState != "complete") {
if (document.readyState != "complete") {
setTimeout(arguments.callee, 100);
setTimeout(arguments.callee, 100);
return;
return;
}
}
$("table.talkbubble").each(function () {
$("table.talkbubble").each(function() {
$(this).find("td").first().width(90).css("text-align", "center").find("img").each(function () {
$(this).find("td").first().width(90).css("text-align", "center").find("img").each(function() {
if ($(this).width() > 90) $(this).css("height", "auto").width(90);
if ($(this).width() > 90) $(this).css("height", "auto").width(90);
});
});
Line 34: Line 34:
});
});


/* Username inserts for the USERNAME template */
/* Code for Template:Suite3 - Author: Soxra */
function UserNameReplace() {
$(function() {
if (typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace || mw.config.get('wgUserName') == null) return;
$(".morphMaster").each(function() {
$('span.insertusername').each(function () {
$(this).text(mw.config.get('wgUserName'));
});
}
$(UserNameReplace);
 
// ===========
// Alternating wiki logo
// Author: Porplemontage
// =============
var logos = ['/images/b/bc/Wiki.png', '/images/9/97/Wiki_3.png', '/images/d/d7/Wiki_2.png'];
$('#p-logo a').css('background-image', 'url(' + logos[Math.floor(Math.random() * logos.length)] + ')');
 
 
// ==================
// Code for Template:Suite3
// Author: Soxra
// ==================
$(document).ready(function () {
$(".morphMaster").each(function () {
var $master = $(this);
var $master = $(this);
var $tabs = $master.find(".morphTabBox");
var $tabs = $master.find(".morphTabBox");
var $container = $master.find(".morphTabContainer");
var $container = $master.find(".morphTabContainer");


$tabs.find(".morphLink").click(function () {
$tabs.find(".morphLink").click(function() {
var id = $(this).attr("id");
var id = $(this).attr("id");
id = id.substr(0, id.length - 4);
id = id.substr(0, id.length - 4);

Latest revision as of 20:17, 3 April 2024

/* Any JavaScript here will be loaded for all users on desktop */

/* Alternating wiki logo */
$(function() {
	var logos = ['b/bc/Wiki.png', 'd/d7/Wiki_2.png', '9/97/Wiki_3.png', '6/6a/Wiki_4.png', '7/79/Wiki_5.png'];
	$('#p-logo a').css('background-image', 'url(https://kh.wiki.gallery/images/' + logos[Math.floor(Math.random() * logos.length)] + ')');
});

/* Add user subpages toolbox link */
$(function() {
	if (mw.config.get('wgCanonicalNamespace') === 'User' && mw.config.get('skin') !== 'timeless') {
		var subpagesLink = '/Special:PrefixIndex/User:' + mw.config.get('wgTitle').split('/')[0] + '/';
		mw.util.addPortletLink('p-tb', subpagesLink, 'User subpages', 't-subpages', 'Subpages for this user');
	}
});

/* Hide page previews when portals are used */
$(function() {
	if (document.getElementsByClassName('nav')[0] && document.getElementsByClassName('dropdown')[0])
		$('head').append('<style type="text/css">.mwe-popups { display: none !important; }</style>');
});

/* Shrinking talk bubble sprites */
$(function() {
	if (document.readyState != "complete") {
		setTimeout(arguments.callee, 100);
		return;
	}
	$("table.talkbubble").each(function() {
		$(this).find("td").first().width(90).css("text-align", "center").find("img").each(function() {
			if ($(this).width() > 90) $(this).css("height", "auto").width(90);
		});
	});
});

/* Code for Template:Suite3 - Author: Soxra */
$(function() {
	$(".morphMaster").each(function() {
		var $master = $(this);
		var $tabs = $master.find(".morphTabBox");
		var $container = $master.find(".morphTabContainer");

		$tabs.find(".morphLink").click(function() {
			var id = $(this).attr("id");
			id = id.substr(0, id.length - 4);
			$container.find(".morphContent").hide();
			$container.find("#" + id + "Content").show();
		});
	});
});