The wiki is lacking in content. You can help by creating a new article. See the to do list for more ways you can help.
MediaWiki:Common.js
From Final Fantasy Wiki
Revision as of 00:08, November 23, 2020 by KeybladeSpyMaster (talk | contribs)
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. */
/***************************************
* Name: hasClass
* Description: Checks if a element has a specified class name. Uses regular expressions and caching for better performance.
* Maintainers (Wikipedia): [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
* Source: Wikipedia Common.js, imported 2/1/10
* Additional Notes: This is a utility method used in other methods.
*/
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();
/***********************************************************
* Name: createJQueryTabs
* Description: Runs at page load, inserts jQuery tabs into a page wherever a <div> with class "tabs" is found.
* Maintainers: [[User:FlyingRagnar]] (Dragon Quest Wiki - www.dragon-quest.org; taken May 18, 2020)
* Additional Notes: This function effectively replaces the Tabber extension which was
* previously used to insert tabs into a page. The template [[Template:VersionTabs]] is
* the primary method to use when inserting jQuery tabs into a page. It is tightly
* coupled to this function.
*/
mw.loader.load( 'jquery.ui.tabs' );
function createJQueryTabs()
{
var tabGroup = 0;
var Tabs = document.getElementsByTagName( "div" );
for ( var i = 0; i < Tabs.length; i++ ) {
if ( hasClass( Tabs[i], "tabs" ) ) {
Tabs[i].setAttribute("id", "tabs" + tabGroup);
var children = Tabs[i].childNodes;
var h = 0;
for( var j = 0; j < children.length; j++ ) {
if ( children[j].nodeName == "UL" ) {
var Tlinks = children[j].getElementsByTagName( "li" );
for( var k = h; k < Tlinks.length; k++ ) {
Tlinks[k].innerHTML = '<a href="#tabs' + tabGroup + '-' + (k+1) + '">' + Tlinks[k].innerHTML + '</a>';
}
} else if ( children[j].nodeName == "DIV" ) {
children[j].setAttribute("id", "tabs" + tabGroup + "-" + (h+1));
h++;
}
}
// apply the jQuery code to take effect
jQuery( "#tabs" + tabGroup ).tabs({ /*event: "mouseover"*/ });
tabGroup++;
}
}
}
// ===========
// Alternating wiki logo (Adjusted)
// Author: Porplemontage, Kingdom Hearts Wiki
// =============
$('.mw-wiki-logo').css('background-image', 'none');
var logos = ['/w/images/5/58/Logo.jpeg', '/w/images/logo2.png', '/w/images/logo3.png', '/w/images/logo4.png'];
$('#p-logo a').css('background-image', 'url(' + logos[Math.floor(Math.random() * logos.length)] + ')');