MediaWiki:Common.js: Difference between revisions

From wiki.jriver.com
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
/**
/* Any JavaScript here will be loaded for all users on every page load. */
* Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
* loaded for all users on every wiki page. If possible create a gadget that is
* enabled by default instead of adding it here (since gadgets are fully
* optimized ResourceLoader modules with possibility to add dependencies etc.)
*
* Since Common.js isn't a gadget, there is no place to declare its
* dependencies, so we have to lazy load them with mw.loader.using on demand and
* then execute the rest in the callback. In most cases these dependencies will
* be loaded (or loading) already and the callback will not be delayed. In case a
* dependency hasn't arrived yet it'll make sure those are loaded before this.
*/
/*global mw, $, importStylesheet, importScript */
/*jshint curly:false eqnull:true, strict:false, browser:true, */


mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
// add &__vanilla=1 to URL to disable all scripts except gadgets (as enabled in [[Special:Preferences]])
/* Begin of mw.loader.using callback */
if (mw.util.getParamValue('__vanilla'))
throw void 0; // return is invalid here. oh well.
/*
== [[WT:PREFS]] v2.0 ==
*/


/**
try { (function () {
* Main Page layout fixes
"use strict";
*

* Description: Adds an additional link to the complete list of languages available.
var prefs;
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
try {
*/
prefs = window.localStorage.getItem('AGprefs');
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
} catch (e) {
$( function () {
prefs = jQuery.cookie('AGprefs');
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
} );
}
}
prefs = prefs && (window.JSON ? window.JSON.parse(prefs) : eval('(' + prefs + ')'));


/**
if (wgUserGroups.indexOf('autoconfirmed') !== -1)
* Redirect User:Name/skin.js and skin.css to the current skin's pages
return;
* (unless the 'skin' page really exists)

* @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
if (wgUserGroups.indexOf('user') === -1)
* @rev: 2
if ((wgAction === 'view') && (wgPageName === 'Wiktionary:Preferences/V2')) {
*/
mw.loader.load('ext.gadget.AGprefs');
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
}
var titleParts = mw.config.get( 'wgPageName' ).split( '/' );

/* Make sure there was a part before and after the slash
if (!prefs)
and that the latter is 'skin.js' or 'skin.css' */
return;
if ( titleParts.length == 2 ) {

var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
mw.loader.state('the_pope_is_an_atheist_woman_alien', 'missing');
if ( titleParts.slice( -1 ) == 'skin.js' ) {
for (var key in prefs.modules) {
window.location.href = mw.util.getUrl( userSkinPage + '.js' );
if (prefs.modules[key]) {
} else if ( titleParts.slice( -1 ) == 'skin.css' ) {
mw.loader.load(key);
window.location.href = mw.util.getUrl( userSkinPage + '.css' );
} else {
}
// unavoidable race condition. to prevent it, every enabled-by-default gadget should have "site" as a dependency
}
if (mw.loader.getState(key) !== 'ready') {
mw.loader.moduleRegistry[key].dependencies.push('the_pope_is_an_atheist_woman_alien');
mw.loader.state(key, 'missing');
} else {
// XXX
mw.log.warn(key + ": the milk has been spilt.");
}
}
}
}


/**
for (var key in prefs.sheets) {
* Map addPortletLink to mw.util
importStylesheet('MediaWiki:Gadget-' + key);
*
}
* @deprecated: Use mw.util.addPortletLink instead.

*/
for (var key in prefs.scripts) {
mw.log.deprecate( window, 'addPortletLink', function () {
importScript('MediaWiki:Gadget-' + key);
return mw.util.addPortletLink.apply( mw.util, arguments );
}
}, 'Use mw.util.addPortletLink() instead' );

if (wgUserGroups.indexOf('user') !== -1) {
var changes = [];
for (var key in prefs.gadgets)
changes.push('gadget-' + key + '=' + (prefs.gadgets[key] ? '1' : '0'));

(new mw.Api()).postWithToken('options', {
action: 'options',
change: changes.join('|')
}).fail(function () {
jQuery.cookie('AGprefs', null);
try { window.localStorage.removeItem('AGprefs'); } catch (e) { /* */ }
mw.util.jsMessage(
'<b>Your <a href="/wiki/Wiktionary:Preferences/V2">per-browser preferences</a> have been migrated</b><br/><br/>' +
'From now on, you should use your <a href="/wiki/Special:Preferenced">user preferences page</a>. ' +
'Preferences will no longer apply after you log out.'
);
});
}

})(); } catch (e) { mw.log.warn(e); }

/*</pre>
===importScript===
<pre>*/


/**
/**
* Extract a URL parameter from the current URL
* importScript inserts a javascript page either
* from Wiktionary: importScript('User:Connel MacKensie/yetanother.js');
* from another Wikimedia wiki: importScript('User:Lupin/insane.js','en.wikipedia.org');
*
*
* @deprecated: Use mw.util.getParamValue with proper escaping
* by specifying the third argument, an oldid can be passed to ensure that updates to the script are not included.
*/
* by specifying the fourth argument, a specific version of JavaScript can be declared.
mw.log.deprecate( window, 'getURLParamValue', function () {
return mw.util.getParamValue.apply( mw.util, arguments );
}, 'Use mw.util.getParamValue() instead' );

/**
* Test if an element has a certain class
*
*
* @deprecated: Use $(element).hasClass() instead.
* based on [[w:MediaWiki:Common.js]] 2007-11-29
**/
*/
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
function importScript(page, wiki, oldid, jsver) {
return $( element ).hasClass( className );
if (wiki || oldid || jsver) {
}, 'Use jQuery.hasClass() instead' );
mw.log.warn("importScript called with more than one argument. This may be unreliable.");
}


/**
// Default to local
* @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
if (!wiki) {
* @rev 5
wiki=wgScript;
*/
// CSS
var extraCSS = mw.util.getParamValue( 'withCSS' );
if ( extraCSS ) {
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
importStylesheet( extraCSS );
} else {
} else {
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
wiki='//'+escape(wiki)+'/w/index.php';
}
}

var url = wiki + '?title='
+ mw.util.wikiUrlencode(page)
+ (oldid ? '&oldid=' + encodeURIComponent(oldid) : '')
+ '&action=raw&ctype=text/javascript';

//Only include scripts once
if (loadedScripts[url]) {
return false;
}
loadedScripts[url] = true;

var scriptElem = document.createElement("script");
scriptElem.setAttribute("src",url);
scriptElem.setAttribute("type", jsver ? "application/javascript;version=" + jsver : "text/javascript");
document.getElementsByTagName("head")[0].appendChild(scriptElem);
return true;
}
}


/*</pre>
// JS
var extraJS = mw.util.getParamValue( 'withJS' );
=== DOM creation ===
if ( extraJS ) {
<pre>*/
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
/**
importScript( extraJS );
* Create a new DOM node for the current document.
} else {
* Basic usage: var mySpan = newNode('span', "Hello World!")
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
* Supports attributes and event handlers*: var mySpan = newNode('span', {style:"color: red", focus: function(){alert(this)}, id:"hello"}, "World, Hello!")
* Also allows nesting to create trees: var myPar = newNode('p', newNode('b',{style:"color: blue"},"Hello"), mySpan)
*
* *event handlers, there are some issues with IE6 not registering event handlers on some nodes that are not yet attached to the DOM,
* it may be safer to add event handlers later manually.
**/
function newNode(tagname){
var node = document.createElement(tagname);

for (var i = 1; i < arguments.length; ++i){
if (typeof arguments[i] == 'string') { // text
node.appendChild(document.createTextNode(arguments[i]));
} else if (typeof arguments[i] == 'object') {
if (arguments[i].nodeName) { //If it is a DOM Node
node.appendChild(arguments[i]);
} else { // Attributes (hopefully)
for (var j in arguments[i]){
if (j == 'class') { //Classname different because...
node.className = arguments[i][j];
} else if (j == 'style') { //Style is special
node.style.cssText = arguments[i][j];
} else if (typeof arguments[i][j] == 'function') { //Basic event handlers
newNode.addEventHandler(node, j, arguments[i][j]);
} else {
node.setAttribute(j, arguments[i][j]); //Normal attributes
}
}
}
}
}
}

node.addEventHandler = function(eventName, handler) {
newNode.addEventHandler(this, eventName, handler);
};

return node;
}
}

newNode.addEventHandler = function(node, eventName, handler)
{
try{ node.addEventListener(eventName,handler,false); //W3C
}catch(e){try{ node.attachEvent('on'+eventName,handler,"Language"); //MSIE
}catch(e){ node['on'+eventName]=handler; }} //Legacy
};
/*</pre>

=== CSS ===
<pre>*/


/**
/**
* Import more specific scripts if necessary
* Cross browser CSS - yurk
* @deprecated: Use mw.util.addCSS() instead
*/
*/
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) {
var p_styleSheet=false;
/* scripts specific to editing pages */
importScript( 'MediaWiki:Common.js/edit.js' );
window.addCSSRule = function (selector,cssText) {
} else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
mw.log.warn("deprecated function addCSSRule called; use mw.util.addCSS(css) instead");
/* watchlist scripts */
mw.util.addCSS( selector+'{' + cssText + '}' );
importScript( 'MediaWiki:Common.js/watchlist.js' );
}
}
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {

/* file description page scripts */
/*</pre>
importScript( 'MediaWiki:Common.js/file.js' );

===Cookies===
<pre>
*/

/* @deprecated: Use $.cookie instead */
function setCookie(cookieName, cookieValue) {
mw.log.warn("deprecated function setCookie called; use jQuery.cookie instead");
var today = new Date();
var expire = new Date();
var nDays = 30;
expire.setTime( today.getTime() + (3600000 * 24 * nDays) );
document.cookie = cookieName + "=" + escape(cookieValue)
+ ";path=/"
+ ";expires="+expire.toGMTString();
}
}


/**
function getCookie(cookieName) {
* Load scripts specific to Internet Explorer
mw.log.warn("deprecated function getCookie called; use jQuery.cookie instead");
*/
var start = document.cookie.indexOf( cookieName + "=" );
if ( start == -1 ) return "";
if ( $.client.profile().name === 'msie' ) {
importScript( 'MediaWiki:Common.js/IEFixes.js' );
var len = start + cookieName.length + 1;
if ( ( !start ) &&
( cookieName != document.cookie.substring( 0, cookieName.length ) ) )
{
return "";
}
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
}


/**
function deleteCookie(cookieName) {
* Fix for Windows XP Unicode font rendering
mw.log.warn("deprecated function deleteCookie called; use jQuery.cookie instead");
*/
if (getCookie(cookieName)) {
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
document.cookie = cookieName + "=" + ";path=/" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' +
}
'.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
}
}


/*</pre>
/**
* WikiMiniAtlas
*
* Description: WikiMiniAtlas is a popup click and drag world map.
* This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
* The script itself is located on meta because it is used by many projects.
* See [[Meta:WikiMiniAtlas]] for more information.
* Maintainers: [[User:Dschwen]]
*/
( function () {
var require_wikiminiatlas = false;
var coord_filter = /geohack/;
$( function () {
$( 'a.external.text' ).each( function( key, link ) {
if ( link.href && coord_filter.exec( link.href ) ) {
require_wikiminiatlas = true;
// break from loop
return false;
}
} );
if ( $( 'div.kmldata' ).length ) {
require_wikiminiatlas = true;
}
if ( require_wikiminiatlas ) {
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
}
} );
} )();


/**
==Wiktionary Customisation==
* Interwiki links to featured articles ***************************************
<pre>*/
*
* Description: Highlights interwiki links to featured articles (or
* equivalents) by changing the bullet before the interwiki link
* into a star.
* Maintainers: [[User:R. Koot]]
*/
function LinkFA() {
if ( document.getElementById( 'p-lang' ) ) {
var InterwikiLinks = document.getElementById( 'p-lang' ).getElementsByTagName( 'li' );


for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById('footer') ) {
var className = InterwikiLinks[i].className.match(/interwiki-[-\w]+/);
jQuery.ready()
if ( document.getElementById( className + '-fa' ) ) {
InterwikiLinks[i].className += ' FA';
InterwikiLinks[i].title = 'This is a featured article in this language.';
} else if ( document.getElementById( className + '-ga' ) ) {
InterwikiLinks[i].className += ' GA';
InterwikiLinks[i].title = 'This is a good article in this language.';
}
}
}
}
}


mw.hook( 'wikipage.content' ).add( LinkFA );
//initialize the storage for script options. Gadgets that set script
//options should also include this line as they are loaded before us.
if ( typeof WiktScriptPrefs == 'undefined') {
WiktScriptPrefs = {};
}


/*</pre>
/**
* Collapsible tables
===[[MediaWiki:Youhavenewmessages]] to display differently for non-newbies with JS than for others===
*
<pre>*/
* Allows tables to be collapsed, showing only the header. See [[Wikipedia:NavFrame]].
/* Suspected unresponsive page culprit: see the GP (Nov. 2010, "Blocking script execution on each page") */
*
/* if (wgUserGroups && wgUserGroups.join("").indexOf("autoconfirmed") > -1)
* @version 2.0.3 (2014-03-14)
{
* @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
addCSSRule(".msgfornewbies", "display: none");
* @author [[User:R. Koot]]
}else{
* @author [[User:Krinkle]]
addCSSRule(".msgfornonnewbies", "display: none");
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
} */
* is supported in MediaWiki core.
/*</pre>
*/


var autoCollapse = 2;
===[[WT:FEED]]===
var collapseCaption = 'hide';
<pre>*/
var expandCaption = 'show';
if ( !wgUserName ) {
importScript('User:Conrad.Irwin/feedback.js');
}
/*</pre>
===WT:PREFS===
<pre>*/


function collapseTable( tableIndex ) {
if ( jQuery.cookie('WiktPrefs') || mw.config.get('wgPageName') == "Wiktionary:Per-browser_preferences") {
var Button = document.getElementById( 'collapseButton' + tableIndex );
//importScript('User:Connel_MacKenzie/custom.js');
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
importScript('User:Hippietrail/custom.js');
}


if ( !Table || !Button ) {
/*</pre>
return false;
}


var Rows = Table.rows;
===Edit page javascript===
var i;
<pre>*/
$(document).ready( function() {
if ( wgAction == 'edit' || wgAction == 'submit' || document.getElementById('editpage-specialchars') ) {
importScript('MediaWiki:Edit.js');
}
});
/*</pre>


if ( Button.firstChild.data === collapseCaption ) {
===Page specific extensions===
for ( i = 1; i < Rows.length; i++ ) {
<pre>*/
Rows[i].style.display = 'none';

}
/*</pre>
Button.firstChild.data = expandCaption;
====Wiktionary:Main Page====
} else {
<pre>*/
for ( i = 1; i < Rows.length; i++ ) {
// Hide the title and "Redirected from" (maybe we should keep the redirected from so's people update their bookmarks ;)
Rows[i].style.display = Rows[0].style.display;
// Broken in IE!
}
if ( wgPageName == 'Wiktionary:Main_Page' && !( wgAction == 'view' || wgAction == 'submit' ) ){
Button.firstChild.data = collapseCaption;
mw.util.addCSS( '.firstHeading { display: block !important; }' );
}
mw.util.addCSS( '#contentSub { display: inline !important; }' );
}
}

function createClickHandler( tableIndex ) {
if (wgPageName == 'Wiktionary:Main_Page') {
$(function () {
return function ( e ) {
e.preventDefault();
mw.util.addPortletLink('p-lang', '//meta.wikimedia.org/wiki/Wiktionary#List_of_Wiktionaries',
collapseTable( tableIndex );
'Complete list', 'interwiki-completelist', 'Complete list of Wiktionaries');
});
};
}
}


function createCollapseButtons() {
/*</pre>
var tableIndex = 0;
====Special:Search====
var NavigationBoxes = {};
<pre>*/
var Tables = document.getElementsByTagName( 'table' );
var i;


for ( i = 0; i < Tables.length; i++ ) {
if ( wgPageName == 'Special:Search') {
if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
importScript('MediaWiki:SpecialSearch.js');
importScript('User:Yair rand/FindTrans.js');
}
jQuery(document).ready(function () { if(document.getElementById('preloadGuide')) {
importScript('MediaWiki:SpecialSearch.js');
}});


/* only add button and increment count if there is a header row to work with */
/*</pre>
var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
====Unsupported titles====
if ( !HeaderRow ) {
<pre>*/
continue;
}
var Header = HeaderRow.getElementsByTagName( 'th' )[0];
if ( !Header ) {
continue;
}


NavigationBoxes[ tableIndex ] = Tables[i];
if (wgTitle.indexOf('Unsupported titles/') === 0)
Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
$(document).ready(function () {
//if (wgCanonicalNamespace != 'Appendix') return;
//pages have been moved to mainspace, so commenting out this line
var newTitle;
if (document.getElementById('unsupportedpage')) {
newTitle = document.getElementById('unsupportedpage').title;
} else {
newTitle = "[" + wgTitle.slice(19) + "]";
}
document.getElementById('firstHeading').innerHTML = newTitle;
});


var Button = document.createElement( 'span' );
/*</pre>
var ButtonLink = document.createElement( 'a' );
var ButtonText = document.createTextNode( collapseCaption );
// Styles are declared in [[MediaWiki:Common.css]]
Button.className = 'collapseButton';


ButtonLink.style.color = Header.style.color;
====Custom search engines====
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
<pre>*/
ButtonLink.setAttribute( 'href', '#' );
$( ButtonLink ).on( 'click', createClickHandler( tableIndex ) );
ButtonLink.appendChild( ButtonText );


Button.appendChild( document.createTextNode( '[' ) );
if( wgPageName=='Help:Tips_and_tricks' ){
Button.appendChild( ButtonLink );
importScript('MediaWiki:CustomSearch.js');
Button.appendChild( document.createTextNode( ']' ) );
}


Header.insertBefore( Button, Header.firstChild );
/*</pre>
tableIndex++;
}
}


for ( i = 0; i < tableIndex; i++ ) {
====Turn headings in comments into real headings on JavaScript source pages====
if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
<pre>*/
( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )

) {
else if ((wgNamespaceNumber == 2 || wgNamespaceNumber == 8) && wgTitle.lastIndexOf('.js') != -1 && wgAction == 'view') {
collapseTable( i );
importScript('MediaWiki:JavascriptHeadings.js');
}
else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
var element = NavigationBoxes[i];
while ((element = element.parentNode)) {
if ( $( element ).hasClass( 'outercollapse' ) ) {
collapseTable ( i );
break;
}
}
}
}
}
}


mw.hook( 'wikipage.content' ).add( createCollapseButtons );
/*</pre>
====Geonotice====
<pre>*/
/*Ended December 2009
else if (wgPageName == "Special:Watchlist") //watchlist scripts
{
importScriptURI('http://toolserver.org/~para/geoip.fcgi');
addOnloadHook(function() { importScriptURI('http://en.wiktionary.org/w/index.php?title=MediaWiki:Geonotice.js&action=raw&ctype=text/javascript&maxage=3600'); });
}
*/
/*</pre>
====New-section redirects====
<pre>*/
// This allows the new-section link (the "+" tab) to point to a different
// URL, as specified by the page (so that, for example, the new-section link
// for the Grease pit will add a new section to the appropriate monthly
// subpage):
importScript('MediaWiki:NewSectionRedirects.js');
/*</pre>


/**
===Add editor.js for editing translations===
* Dynamic Navigation Bars (experimental)
<pre>*/
*

* Description: See [[Wikipedia:NavFrame]].
importScript('User:Conrad.Irwin/editor.js');
* Maintainers: UNMAINTAINED

/*</pre>
*/

===Import newentrywiz.js===
<pre>*/
jQuery(document).ready(function(){
if(document.getElementById('necblah')){
importScript('User:Yair rand/newentrywiz.js');
}
});


/*</pre>
===Import adddefinition.js===
<pre>*/
importScript('User:Yair rand/adddefinition.js');
/*</pre>
===Import rhymesedit.js===
<pre>*/
wgNamespaceNumber == 106 && importScript("User:Yair rand/rhymesedit.js");
/*</pre>
===Import Targeted Translations===
<pre>*/
importScript("User:Yair rand/TargetedTranslations.js");
/*</pre>


/* set up the words in your language */
==URL Fixes==
var NavigationBarHide = '[' + collapseCaption + ']';
<pre>*/
var NavigationBarShow = '[' + expandCaption + ']';


/**
/**
* Shows and hides content and picture (if available) of navigation bars
* doRedirect will redirect if a did you mean box is found, and create a
* Parameters:
* "redirected from X" if a rdfrom is passed in the get parameters
* indexNavigationBar: the index of navigation bar to be toggled
* The first half is an ugly workaround for Bugzilla:3339, :(
**/
* The second half is an ugly workaround for not having serverware support :(
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
**/
var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
var NavChild;


if ( !NavFrame || !NavToggle ) {
/*</pre>
return false;
===Did you mean ____ redirects===
}
<pre>*/


/* if shown now */
jQuery(document).ready(function () {
if ( NavToggle.firstChild.data === NavigationBarHide ) {
// REDIRECTED FROM
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if( window.location.href.indexOf('rdfrom=') != -1 ) {
if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
var wiktDYMfrom = decodeURIComponent(window.location.href.replace(/^(.+[&\?]rdfrom=([^&]+).*|.*)?$/,"$2"));
NavChild.style.display = 'none';
}
}
NavToggle.firstChild.data = NavigationBarShow;


/* if hidden now */
jQuery('#siteSub').after(
} else if ( NavToggle.firstChild.data === NavigationBarShow ) {
newNode('div', {id: 'contentSub'}, '(Auto-redirected from ',
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
newNode('a', {href: mw.util.getUrl(wiktDYMfrom) + '?redirect=no', 'class': 'new'}, wiktDYMfrom),
if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
')'));
NavChild.style.display = 'block';
}
}
NavToggle.firstChild.data = NavigationBarHide;
}


event.preventDefault();
} else {
};
// DID YOU MEAN
var target = jQuery('#did-you-mean a').html(),
pagetitle = jQuery('h1').first().text().replace(/^\s+|\s+$/g, '');


/* adds show/hide-button to navigation bars */
if (target && target != pagetitle
function createNavigationBarToggleButton() {
&& !window.location.href.match(/[&\?]redirect=no|[&\?]action=(?!view)/)
var indexNavigationBar = 0;
&& (jQuery.cookie('WiktionaryDisableAutoRedirect') != 'true')
var NavFrame;
&& wgArticleId === 0
var NavChild;
&& !/Redirected from/.test(jQuery('#contentSub').html())
/* iterate over all < div >-elements */
) {
var divs = document.getElementsByTagName( 'div' );
document.location = mw.util.getUrl( target, { "rdfrom": pagetitle } );
for ( var i = 0; (NavFrame = divs[i]); i++ ) {
}
/* if found a navigation bar */
}
if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {


indexNavigationBar++;
// Random page in a given language
var NavToggle = document.createElement( 'a' );
document.location.toString().replace(/[?&]rndlang=([^&#]+)[^#]*(?:#(.+))?/, function (m, lang, headlang) {
NavToggle.className = 'NavToggle';
var script = 'http://toolserver.org/~hippietrail/randompage.fcgi';
NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
NavToggle.setAttribute( 'href', '#' );
$( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );


var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
var insert = document.getElementById('contentSub');
/**
if (headlang) {
* Check if any children are already hidden. This loop is here for backwards compatibility:
var heading = document.getElementById(headlang);
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
if (heading) heading = heading.parentNode;
* to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make
if (heading) {
* the content visible without JavaScript support), the new recommended way is to add the class
insert = newNode('div', {style: 'font-size: 84%; line-height: 1.2em;'});
* "collapsed" to the NavFrame itself, just like with collapsible tables.
heading.parentNode.insertBefore(insert, heading.nextSibling)
*/
}
for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
}
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
if ( NavChild.style.display === 'none' ) {
isCollapsed = true;
}
}
}
if ( isCollapsed ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
NavChild.style.display = 'none';
}
}
}
var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
NavToggle.appendChild( NavToggleText );


/* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
if (!insert || insert.innerHTML != "") return;
for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
NavToggle.style.color = NavFrame.childNodes[j].style.color;
NavFrame.childNodes[j].appendChild( NavToggle );
}
}
NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
}
}
}


mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
insert.appendChild(newNode('span', {style: 'color: #888;'}, "Another ",
newNode('a', {href: script + '?langs=1'}, "Random"), " word in ",
newNode('a', {href: script + '?langname=' + lang}, decodeURIComponent(lang))
));
});
})


/*</pre>
/**
* Uploadwizard_newusers

* Switches in a message for non-autoconfirmed users at [[Wikipedia:Upload]]
===Fix Wikified section titles===
*
<pre>*/
* Maintainers: [[User:Krimpet]]
jQuery(document).ready(function () {
*/
// {temp|template}
function uploadwizard_newusers() {
if (/\.7B\.7Btemp\.7C(.*?)\.7D\.7D/.test(window.location.href)) {
if ( mw.config.get( 'wgNamespaceNumber' ) === 4 && mw.config.get( 'wgTitle' ) === 'Upload' && mw.config.get( 'wgAction' ) === 'view' ) {
var url=window.location.href.replace(/\.7B\.7Btemp.7C/g, ".7B.7B");
var oldDiv = document.getElementById( 'autoconfirmedusers' ),
window.location = url;
newDiv = document.getElementById( 'newusers' );
}
if ( oldDiv && newDiv ) {
});
var userGroups = mw.config.get( 'wgUserGroups' );

if ( userGroups ) {
jQuery(document).ready(function () {
for ( var i = 0; i < userGroups.length; i++ ) {
if(wgAction != 'edit')
if ( userGroups[i] === 'autoconfirmed' ) {
return;
oldDiv.style.display = 'block';
if(! /[?&]section=\d/.test(window.location.href))
newDiv.style.display = 'none';
return;
return;
var wpSummary = document.getElementById('wpSummary');
}
if(! wpSummary)
}
return;
}
if(wpSummary.value.substr(0, 3) != '/* ')
oldDiv.style.display = 'none';
return;
newDiv.style.display = 'block';
if(wpSummary.value.substr(wpSummary.value.length - 4) != ' */ ')
return;
return;
}
wpSummary.value = wpSummary.value.replace(/\{\{temp(late)?\|/g, '{{');
}
});

/*</pre>
== Visibility toggling ==
<pre>*/
var VisibilityToggles = {
// toggles[category] = [[show, hide],...]; statuses[category] = [true, false,...]; buttons = <li>
toggles: {}, statuses: {}, buttons: null,

// Add a new toggle, adds a Show/Hide category button in the toolbar,
// and will call show_function and hide_function once on register, and every alternate click.
register: function (category, show_function, hide_function) {

var id = 0;
if (!this.toggles[category]) {
this.toggles[category] = [];
this.statuses[category] = [];
} else {
id = this.toggles[category].length;
}
this.toggles[category].push([show_function, hide_function]);
this.statuses[category].push(this.currentStatus(category));
this.addGlobalToggle(category);

(this.statuses[category][id] ? show_function : hide_function)();

return function () {
var statuses = VisibilityToggles.statuses[category];
statuses[id] = !statuses[id]
VisibilityToggles.checkGlobalToggle(category);
return (statuses[id] ? show_function : hide_function)();
}

},

// Add a new global toggle to the side bar
addGlobalToggle: function(category) {
if (document.getElementById('p-visibility-'+category))
return;
if (!this.buttons) {
this.buttons = newNode('ul');
var collapsed = $.cookie("vector-nav-p-visibility") == "false", toolbox = newNode('div', {'class': "portal portlet "+(collapsed?"collapsed":"expanded"), 'id': 'p-visibility'},
newNode('h3', 'Visibility'),
newNode('div', {'class': "pBody body"}, collapsed?undefined:{'style':'display:block;'}, this.buttons)
);
var sidebar = document.getElementById('mw-panel') || document.getElementById('column-one');
var insert = null;
if (insert = (document.getElementById('p-lang') || document.getElementById('p-feedback')))
sidebar.insertBefore(toolbox, insert);
else
sidebar.appendChild(toolbox);

}
var status = this.currentStatus(category);
var newToggle = newNode('li', newNode('a', {
id: 'p-visibility-' + category,
style: 'cursor: pointer',
href: '#visibility-' + category,
click: function(e)
{
VisibilityToggles.toggleGlobal(category);
if (e && e.preventDefault)
e.preventDefault();
else
window.event.returnValue = false;
return false;
}},
(status ? 'Hide ' : 'Show ') + category));
for (var i=0; i < this.buttons.childNodes.length; i++) {
if (this.buttons.childNodes[i].id < newToggle.id) {
this.buttons.insertBefore(newToggle, this.buttons.childNodes[i]);
return;
}
}
this.buttons.appendChild(newToggle);
},

// Update the toggle-all buttons when all things are toggled one way
checkGlobalToggle: function(category) {
var statuses = this.statuses[category];
var status = statuses[0];
for (var i = 1; i < statuses.length; i++) {
if (status != statuses[i])
return;
}
document.getElementById('p-visibility-' + category).innerHTML = (status ? 'Hide ' : 'Show ') + category;
},

// Toggle all un-toggled elements when the global button is clicked
toggleGlobal: function(category) {
var status = document.getElementById('p-visibility-' + category).innerHTML.indexOf('Show ') == 0;
for (var i = 0; i < this.toggles[category].length; i++ ) {
if (this.statuses[category][i] != status) {
this.toggles[category][i][status ? 0 : 1]();
this.statuses[category][i] = status;
}
}
document.getElementById('p-visibility-' + category).innerHTML = (status ? 'Hide ' : 'Show ') + category;
var current = jQuery.cookie('Visibility');
if (!current)
current = ";";
current = current.replace(';' + category + ';', ';');
if (status)
current = current + category + ";";
setCookie('Visibility', current);
},

currentStatus: function(category) {
if (window.location.hash.toLowerCase().split('_')[0] == '#' + category.toLowerCase())
return true;
if (window.location.href.search(/[?](.*&)?hidecats=/) > 0)
{
var hidecats = window.location.href;
hidecats = hidecats.replace(/^[^?]+[?]((?!hidecats=)[^&]*&)*hidecats=/, '');
hidecats = hidecats.replace(/&.*/, '');
hidecats = hidecats.split(',');
for (var i = 0; i < hidecats.length; ++i)
if (hidecats[i] == category || hidecats[i] == 'all')
return false;
else if (hidecats[i] == '!' + category || hidecats[i] == 'none')
return true;
}
if (jQuery.cookie('WiktionaryPreferencesShowNav') == 'true')
return true;
if ((jQuery.cookie('Visibility') || "").indexOf(';' + category + ';') >= 0)
return true;
// TODO check category-specific cookies
return false;
}
}
}


$(uploadwizard_newusers);
/*</pre>
=== NavBars ===
<pre>*/
var NavigationBarHide = 'hide ▲';
var NavigationBarShow = 'show ▼';


/**
function NavToggleCategory(navFrame)
* Magic editintros ****************************************************
{
*
var table = navFrame.getElementsByTagName('table')[0];
* Description: Adds editintros on disambiguation pages and BLP pages.
if (table && table.className == "translations")
* Maintainers: [[User:RockMFR]]
return "translations";
*/

function addEditIntro( name ) {
var heading = navFrame.previousSibling;
$( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
while (heading) {
el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
if (/[hH][4-6]/.test(heading.nodeName)) {
} );
if (heading.getElementsByTagName('span')[1])
heading = heading.getElementsByTagName('span')[0];
return $(heading).text().toLowerCase()
// jQuery's .text() is inconsistent about whitespace:
.replace(/^\s+|\s+$/g, '').replace(/\s+/g, ' ')
// remove numbers added by the "Auto-number headings" pref:
.replace(/^[1-9][0-9.]+ ?/, '');
}
else if (/[hH][1-3]/.test(heading.nodeName))
break;
heading = heading.previousSibling;
}
return "other boxes";
}
}


if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
function createNavToggle(navFrame){
$( function () {
var navHead, navToggle, navContent;
if ( document.getElementById( 'disambigbox' ) ) {
for (var j=0; j < navFrame.childNodes.length; j++) {
addEditIntro( 'Template:Disambig_editintro' );
var div = navFrame.childNodes[j];
}
switch (div.className) {
} );
case 'NavHead':
navHead = div;
break;
case 'NavContent':
navContent = div;
break;
}
}
if (!navHead || !navContent)
return;
// Step 1, don't react when a subitem is clicked.
for (var i=0; i<navHead.childNodes.length; i++) {
var child = navHead.childNodes[i];
if (child.nodeName == "A") {
child.onclick = function (e)
{
if (e && e.stopPropagation)
e.stopPropagation();
else
window.event.cancelBubble = true;
}
}
}
// Step 2, toggle visibility when bar is clicked.
// NOTE This function was chosen due to some funny behaviour in Safari.
navToggle = newNode('a', {href: 'javascript:(function(){})()'}, '');
navHead.insertBefore(newNode('span', {'class': 'NavToggle'}, '[', navToggle, ']'), navHead.firstChild);


$( function () {
navHead.style.cursor = "pointer";
var cats = document.getElementById( 'mw-normal-catlinks' );
navHead.onclick = VisibilityToggles.register(NavToggleCategory(navFrame),
if ( !cats ) {
function show() {
return;
navToggle.innerHTML = NavigationBarHide;
}
if (navContent)
cats = cats.getElementsByTagName( 'a' );
navContent.style.display = "block";
for ( var i = 0; i < cats.length; i++ ) {
},
if ( cats[i].title === 'Category:Living people' || cats[i].title === 'Category:Possibly living people' ) {
function hide() {
addEditIntro( 'Template:BLP_editintro' );
navToggle.innerHTML = NavigationBarShow;
break;
if (navContent)
}
navContent.style.display = "none";
}
});
};
} );

jQuery(document).ready( function ()
{
var divs = $(".NavFrame");
for (var i=0; i<divs.length; i++) {
// NOTE: some templates use a class of NavFrame for the style, but for legacy reasons, are not NavFrames
if (divs[i].className == "NavFrame") {
createNavToggle(divs[i]);
}
}

});

/*</pre>

===Hidden Quotes===
<pre>*/

function setupHiddenQuotes(li) {
var HQToggle, liComp, dl;
var HQShow = 'quotations ▼';
var HQHide = 'quotations ▲';
for (var k = 0; k < li.childNodes.length; k++) {
// Look at each component of the definition.
liComp = li.childNodes[k];
if ( liComp.nodeName.toLowerCase() === "dl" && !dl ) {
dl = liComp;
}
// If we find a ul or dl, we have quotes or example sentences, and thus need a button.
if (/^(ul|UL)$/.test(liComp.nodeName)) {
HQToggle = newNode('a', {href: 'javascript:(function(){})()'}, '');
li.insertBefore(newNode('span', {'class': 'HQToggle'}, ' [', HQToggle, ']'), dl || liComp);
HQToggle.onclick = VisibilityToggles.register('quotations',
function show() {
HQToggle.innerHTML = HQHide;
for (var child = li.firstChild; child != null; child = child.nextSibling) {
if (/^(ul|UL)$/.test(child.nodeName)) {
child.style.display = 'block';
}
}
},
function hide() {
HQToggle.innerHTML = HQShow;
for (var child = li.firstChild; child != null; child = child.nextSibling) {
if (/^(ul|UL)$/.test(child.nodeName)) {
child.style.display = 'none';
}
}
});

break;
}
}
}
}
jQuery(document).ready(function () {
if (wgNamespaceNumber == 0) {
var ols, lis, li;
// First, find all the ordered lists, i.e. all the series of definitions.
var ols = document.getElementsByTagName('ol');
for(var i = 0; i < ols.length; i++) {
// Then, for every set, find all the individual definitions.
for (var j = 0; j < ols[i].childNodes.length; j++) {
li = ols[i].childNodes[j];
if (li.nodeName.toUpperCase() == 'LI') {
setupHiddenQuotes(li);
}
}
}
}
});


/*</pre>
/**
* Description: Stay on the secure server as much as possible

* Maintainers: [[User:TheDJ]]
== Interproject links ==
<pre>*/
*/
if ( document.location && document.location.protocol === 'https:' ) {

/* New secure servers */
/*
importScript( 'MediaWiki:Common.js/secure new.js' );
#########
### ProjectLinks
### by [[user:Pathoschild]] (idea from an older, uncredited script)
### * generates a sidebar list of links to other projects from {{projectlinks}}
#########
*/
jQuery(document).ready(function () {
var elements = new Array();
var spans = document.getElementsByTagName('span');

// filter for projectlinks
for (var i=0, j=0; i<spans.length; i++) {
if (spans[i].className == 'interProject') {
elements[j] = spans[i].getElementsByTagName('a')[0];
j++;
}
}

if (j == 0)
return;

// sort alphabetically
function sortbylabel(a,b) {
// get labels
a = a.innerHTML.replace(/^.*<a[^>]*>(.*)<\/a>.*$/i,'$1');
b = b.innerHTML.replace(/^.*<a[^>]*>(.*)<\/a>.*$/i,'$1');

// return sort order
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
elements.sort(sortbylabel);

// Create the list of project links
var pllist = newNode('ul');
for (var i=0; i<elements.length; i++) {
pllist.appendChild(newNode('li', elements[i]));
}
var collapsed = $.cookie("vector-nav-p-projects") == "false";
var projectBox = newNode('div', {'class': 'portlet portal '+(collapsed?"collapsed":"expanded"), id: 'p-projects'},
newNode('h3', 'In other projects'),
newNode('div', {'class': 'pBody body'}, collapsed?undefined:{'style':'display:block;'}, pllist)
);

var insert = document.getElementById('p-tb');
if (!insert)
return;

if (insert.nextSibling)
insert.parentNode.insertBefore(projectBox, insert.nextSibling);
else
insert.parentNode.appendChild(projectBox);
});

/*</pre>
===Scripts specific to Internet Explorer===
<pre>*/
if (navigator.appName == "Microsoft Internet Explorer") {
/** Internet Explorer bug fix **************************************************
*
* Description: Fixes IE horizontal scrollbar bug
* Maintainers: [[User:Tom-]]?
*/

var oldWidth;
var docEl = document.documentElement;

function fixIEScroll()
{
if (!oldWidth || docEl.clientWidth > oldWidth)
doFixIEScroll();
else
setTimeout(doFixIEScroll, 1);

oldWidth = docEl.clientWidth;
}

function doFixIEScroll() {
docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
}
document.attachEvent("onreadystatechange", fixIEScroll);
document.attachEvent("onresize", fixIEScroll);

// In print IE (7?) does not like line-height
mw.util.addCSS( '@media print { sup, sub, p, .documentDescription { line-height: normal; }}');

// IE overflow bug
mw.util.addCSS('div.overflowbugx { overflow-x: scroll !important; overflow-y: hidden !important; } div.overflowbugy { overflow-y: scroll !important; overflow-x: hidden !important; }');

// IE zoomfix
// Use to fix right floating div/table inside tables
mw.util.addCSS('.iezoomfix div, .iezoomfix table { zoom: 1;}');

// Import scripts specific to Internet Explorer 6
if (navigator.appVersion.substr(22, 1) == "6") {
importScript("MediaWiki:Common.js/IE60Fixes.js")
}
}
}


/*</pre>
/**
* Description: Removes ArticleFeedback related cookies from clients.
===Category page fixes===
* Can be removed in a couple of weeks to a month or so.
<pre>*/
* Maintainers: [[User:Reedy]]

*/
$(document).ready(function($){
var s, c = "", lang;
var match, re = /[\S]*articleFeedback[^=]*/g;
while ( ( match = re.exec( document.cookie ) ) !== null ) {
if( wgNamespaceNumber === 14 && ( s = document.getElementById("catfix") ) ) {
document.cookie = match + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/;';
lang = s.className.split("CATFIX-")[1]
if (lang.length > 0)
{
c = "#" + lang;
}

s = s.getElementsByTagName("*")[0] || document.createElement("span");
$("#mw-pages>.mw-content-ltr").find("li>a").each(function(){
var li = this.parentNode, clone = s.cloneNode( false );
li.removeChild( this );
this.setAttribute("href", this.getAttribute("href", 2) + c );
clone.appendChild( this );
li.appendChild( clone );
})
}
})

/*</pre>
===Temporary button for enabling two proposed scripts===
<pre>*/

if ( $.cookie("YRNewStuff") || location.search.indexOf("tabbedlanguages=on") != -1 )
{
importScript("User:Yair rand/editor2.js")
importScript("User:Yair rand/TabbedLanguages2.js")
}
}


/* End of mw.loader.using callback */
jQuery(document).ready(function () {
} );
if(document.getElementById('YRNewStuff-enable-button'))
/* DO NOT ADD CODE BELOW THIS LINE */
{
document.getElementById('YRNewStuff-enable-button').innerHTML = ""
var toggle = newNode('span', {click: function ()
{
if( $.cookie("YRNewStuff") ){
$.cookie("YRNewStuff", null,{path:"/"})
toggle.innerHTML = "Enable tabbed languages and definition editing options."
}
else{
$.cookie("YRNewStuff",1,{expires:30,path:"/"})
toggle.innerHTML = "Disable tabbed languages and definition editing options."
}
} }, ($.cookie("YRNewStuff")?"Disable":"Enable")+" tabbed languages and definition editing options.")
document.getElementById('YRNewStuff-enable-button').appendChild(toggle);
}
})

/*</pre>
===WT:ES Discussion tool===
<pre>*/

wgPageName == "Wiktionary:Etymology_scriptorium" && importScript("User:Yair rand/DiscussionSandbox.js");

$(document).ready(function() {
$("table.unit-tests th.unit-tests-img-corner").bind("click", function () {
var table = this;
while (table.tagName !== "TABLE")
table = table.parentNode;
table.classList.toggle("unit-tests-hide-passing");
})
});

Revision as of 18:42, 9 April 2014

/**
 * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
 * loaded for all users on every wiki page. If possible create a gadget that is
 * enabled by default instead of adding it here (since gadgets are fully
 * optimized ResourceLoader modules with possibility to add dependencies etc.)
 *
 * Since Common.js isn't a gadget, there is no place to declare its
 * dependencies, so we have to lazy load them with mw.loader.using on demand and
 * then execute the rest in the callback. In most cases these dependencies will
 * be loaded (or loading) already and the callback will not be delayed. In case a
 * dependency hasn't arrived yet it'll make sure those are loaded before this.
 */
/*global mw, $, importStylesheet, importScript */
/*jshint curly:false eqnull:true, strict:false, browser:true, */

mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
/* Begin of mw.loader.using callback */

/**
 * Main Page layout fixes
 *
 * Description: Adds an additional link to the complete list of languages available.
 * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
 */
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
    $( function () {
        mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
            'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
    } );
}

/**
 * Redirect User:Name/skin.js and skin.css to the current skin's pages
 * (unless the 'skin' page really exists)
 * @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 * @rev: 2
 */
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
    var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
    /* Make sure there was a part before and after the slash
       and that the latter is 'skin.js' or 'skin.css' */
    if ( titleParts.length == 2 ) {
        var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
        if ( titleParts.slice( -1 ) == 'skin.js' ) {
            window.location.href = mw.util.getUrl( userSkinPage + '.js' );
        } else if ( titleParts.slice( -1 ) == 'skin.css' ) {
            window.location.href = mw.util.getUrl( userSkinPage + '.css' );
        }
    }
}

/**
 * Map addPortletLink to mw.util 
 *
 * @deprecated: Use mw.util.addPortletLink instead.
 */
mw.log.deprecate( window, 'addPortletLink', function () {
    return mw.util.addPortletLink.apply( mw.util, arguments );
}, 'Use mw.util.addPortletLink() instead' );

/**
 * Extract a URL parameter from the current URL
 *
 * @deprecated: Use mw.util.getParamValue with proper escaping
 */
mw.log.deprecate( window, 'getURLParamValue', function () {
    return mw.util.getParamValue.apply( mw.util, arguments );
}, 'Use mw.util.getParamValue() instead' );

/** 
 * Test if an element has a certain class
 *
 * @deprecated:  Use $(element).hasClass() instead.
 */
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
    return $( element ).hasClass( className );
}, 'Use jQuery.hasClass() instead' );

/**
 * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
 * @rev 5
 */
// CSS
var extraCSS = mw.util.getParamValue( 'withCSS' );
if ( extraCSS ) {
	if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
		importStylesheet( extraCSS );
	} else {
		mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
	}
}

// JS
var extraJS = mw.util.getParamValue( 'withJS' );
if ( extraJS ) {
	if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
		importScript( extraJS );
	} else {
		mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
	}
}

/**
 * Import more specific scripts if necessary
 */
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) {
    /* scripts specific to editing pages */
    importScript( 'MediaWiki:Common.js/edit.js' );
} else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
    /* watchlist scripts */
    importScript( 'MediaWiki:Common.js/watchlist.js' );
}
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
    /* file description page scripts */
    importScript( 'MediaWiki:Common.js/file.js' );
}

/**
 * Load scripts specific to Internet Explorer
 */
if ( $.client.profile().name === 'msie' ) {
    importScript( 'MediaWiki:Common.js/IEFixes.js' );
}

/**
 * Fix for Windows XP Unicode font rendering
 */
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
    mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' + 
                '.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
}

/**
 * WikiMiniAtlas
 *
 * Description: WikiMiniAtlas is a popup click and drag world map.
 *              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
 *              The script itself is located on meta because it is used by many projects.
 *              See [[Meta:WikiMiniAtlas]] for more information. 
 * Maintainers: [[User:Dschwen]]
 */
( function () {
    var require_wikiminiatlas = false;
    var coord_filter = /geohack/;
    $( function () {
        $( 'a.external.text' ).each( function( key, link ) {
            if ( link.href && coord_filter.exec( link.href ) ) {
                require_wikiminiatlas = true;
                // break from loop
                return false;
            }
        } );
        if ( $( 'div.kmldata' ).length ) {
            require_wikiminiatlas = true;
        }
        if ( require_wikiminiatlas ) {
            mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
        }
    } );
} )();

/**
 * Interwiki links to featured articles ***************************************
 *
 * Description: Highlights interwiki links to featured articles (or
 *              equivalents) by changing the bullet before the interwiki link
 *              into a star.
 * Maintainers: [[User:R. Koot]]
 */
function LinkFA() {
    if ( document.getElementById( 'p-lang' ) ) {
        var InterwikiLinks = document.getElementById( 'p-lang' ).getElementsByTagName( 'li' );

        for ( var i = 0; i < InterwikiLinks.length; i++ ) {
            var className = InterwikiLinks[i].className.match(/interwiki-[-\w]+/);
            if ( document.getElementById( className + '-fa' ) ) {
                InterwikiLinks[i].className += ' FA';
                InterwikiLinks[i].title = 'This is a featured article in this language.';
            } else if ( document.getElementById( className + '-ga' ) ) {
                InterwikiLinks[i].className += ' GA';
                InterwikiLinks[i].title = 'This is a good article in this language.';
            }
        }
    }
}

mw.hook( 'wikipage.content' ).add( LinkFA );

/**
 * Collapsible tables
 *
 * Allows tables to be collapsed, showing only the header. See  [[Wikipedia:NavFrame]].
 *
 * @version 2.0.3 (2014-03-14)
 * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 * @author [[User:R. Koot]]
 * @author [[User:Krinkle]]
 * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 * is supported in MediaWiki core.
 */

var autoCollapse = 2;
var collapseCaption = 'hide';
var expandCaption = 'show';

function collapseTable( tableIndex ) {
    var Button = document.getElementById( 'collapseButton' + tableIndex );
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );

    if ( !Table || !Button ) {
        return false;
    }

    var Rows = Table.rows;
    var i;

    if ( Button.firstChild.data === collapseCaption ) {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = 'none';
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
}
 
function createClickHandler( tableIndex ) {
    return function ( e ) {
        e.preventDefault();
        collapseTable( tableIndex );
    };
}

function createCollapseButtons() {
    var tableIndex = 0;
    var NavigationBoxes = {};
    var Tables = document.getElementsByTagName( 'table' );
    var i;

    for ( i = 0; i < Tables.length; i++ ) {
        if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {

            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
            if ( !HeaderRow ) {
                continue;
            }
            var Header = HeaderRow.getElementsByTagName( 'th' )[0];
            if ( !Header ) {
                continue;
            }

            NavigationBoxes[ tableIndex ] = Tables[i];
            Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );

            var Button     = document.createElement( 'span' );
            var ButtonLink = document.createElement( 'a' );
            var ButtonText = document.createTextNode( collapseCaption );
            // Styles are declared in [[MediaWiki:Common.css]]
            Button.className = 'collapseButton';

            ButtonLink.style.color = Header.style.color;
            ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
            ButtonLink.setAttribute( 'href', '#' );
            $( ButtonLink ).on( 'click', createClickHandler( tableIndex ) );
            ButtonLink.appendChild( ButtonText );

            Button.appendChild( document.createTextNode( '[' ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( ']' ) );

            Header.insertBefore( Button, Header.firstChild );
            tableIndex++;
        }
    }

    for ( i = 0;  i < tableIndex; i++ ) {
        if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
            ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )
        ) {
            collapseTable( i );
        } 
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
            var element = NavigationBoxes[i];
            while ((element = element.parentNode)) {
                if ( $( element ).hasClass( 'outercollapse' ) ) {
                    collapseTable ( i );
                    break;
                }
            }
        }
    }
}

mw.hook( 'wikipage.content' ).add( createCollapseButtons );

/**
 * Dynamic Navigation Bars (experimental)
 *
 * Description: See [[Wikipedia:NavFrame]].
 * Maintainers: UNMAINTAINED
 */

/* set up the words in your language */
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';

/**
 * Shows and hides content and picture (if available) of navigation bars
 * Parameters:
 *     indexNavigationBar: the index of navigation bar to be toggled
 **/
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
    var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
    var NavChild;

    if ( !NavFrame || !NavToggle ) {
        return false;
    }

    /* if shown now */
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;

    /* if hidden now */
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'block';
            }
        }
        NavToggle.firstChild.data = NavigationBarHide;
    }

    event.preventDefault();
};

/* adds show/hide-button to navigation bars */
function createNavigationBarToggleButton() {
    var indexNavigationBar = 0;
    var NavFrame;
    var NavChild;
    /* iterate over all < div >-elements */
    var divs = document.getElementsByTagName( 'div' );
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
        /* if found a navigation bar */
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {

            indexNavigationBar++;
            var NavToggle = document.createElement( 'a' );
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
            NavToggle.setAttribute( 'href', '#' );
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );

            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
            /**
             * Check if any children are already hidden.  This loop is here for backwards compatibility:
             * the old way of making NavFrames start out collapsed was to manually add style="display:none"
             * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
             * the content visible without JavaScript support), the new recommended way is to add the class
             * "collapsed" to the NavFrame itself, just like with collapsible tables.
             */
            for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
                if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                    if ( NavChild.style.display === 'none' ) {
                        isCollapsed = true;
                    }
                }
            }
            if ( isCollapsed ) {
                for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
                    if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                        NavChild.style.display = 'none';
                    }
                }
            }
            var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
            NavToggle.appendChild( NavToggleText );

            /* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
            for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
                if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
                    NavFrame.childNodes[j].appendChild( NavToggle );
                }
            }
            NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
        }
    }
}

mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );

/**
 * Uploadwizard_newusers
 * Switches in a message for non-autoconfirmed users at [[Wikipedia:Upload]]
 *
 * Maintainers: [[User:Krimpet]]
 */
function uploadwizard_newusers() {
    if ( mw.config.get( 'wgNamespaceNumber' ) === 4 && mw.config.get( 'wgTitle' ) === 'Upload' && mw.config.get( 'wgAction' ) === 'view' ) {
        var oldDiv = document.getElementById( 'autoconfirmedusers' ),
            newDiv = document.getElementById( 'newusers' );
        if ( oldDiv && newDiv ) {
            var userGroups = mw.config.get( 'wgUserGroups' );
            if ( userGroups ) {
                for ( var i = 0; i < userGroups.length; i++ ) {
                    if ( userGroups[i] === 'autoconfirmed' ) {
                        oldDiv.style.display = 'block';
                        newDiv.style.display = 'none';
                        return;
                    }
                }
            }
            oldDiv.style.display = 'none';
            newDiv.style.display = 'block';
            return;
        }
    }
}

$(uploadwizard_newusers);

/**
 * Magic editintros ****************************************************
 *
 * Description: Adds editintros on disambiguation pages and BLP pages.
 * Maintainers: [[User:RockMFR]]
 */
function addEditIntro( name ) {
    $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
    } );
}

if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
    $( function () {
        if ( document.getElementById( 'disambigbox' ) ) {
            addEditIntro( 'Template:Disambig_editintro' );
        }
    } );

    $( function () {
        var cats = document.getElementById( 'mw-normal-catlinks' );
        if ( !cats ) {
            return;
        }
        cats = cats.getElementsByTagName( 'a' );
        for ( var i = 0; i < cats.length; i++ ) {
            if ( cats[i].title === 'Category:Living people' || cats[i].title === 'Category:Possibly living people' ) {
                addEditIntro( 'Template:BLP_editintro' );
                break;
            }
        }
    } );
}

/**
 * Description: Stay on the secure server as much as possible
 * Maintainers: [[User:TheDJ]]
 */
if ( document.location && document.location.protocol === 'https:' ) {
    /* New secure servers */
    importScript( 'MediaWiki:Common.js/secure new.js' );
}

/**
 * Description: Removes ArticleFeedback related cookies from clients.
 * Can be removed in a couple of weeks to a month or so.
 * Maintainers: [[User:Reedy]]
 */
var match, re = /[\S]*articleFeedback[^=]*/g;
while ( ( match = re.exec( document.cookie ) ) !== null ) {
    document.cookie = match + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/;';
}

/* End of mw.loader.using callback */
} );
/* DO NOT ADD CODE BELOW THIS LINE */