MediaWiki:Common.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/*global mw, JSconfig, importScript */
/*jshint forin:false, strict:false, onecase:true, laxbreak:true, browser:true, jquery:true */

/**
 * JSconfig
 *
 * If you are a gadget author, you may use 
 * [[MediaWiki:Gadget-SettingsManager.js]] or jquery.jStorage or mediawiki.cookie
 * and [[MediaWiki:Gadget-SettingsUI.js]] to provide an easy interface.
 * 
 *
 * Global configuration options to enable/disable and configure
 * specific script features from [[MediaWiki:Common.js]] and [[MediaWiki:Monobook.js]]
 * <s>This framework adds config options (saved as cookies) to [[Special:Preferences]]</s>
 * (Site script does not run at [[Special:Preferences]] any more so this functionality has been removed)
 *
 * For a more permanent change you can override the default settings in your
 * [[Special:Mypage/monobook.js]]
 * for Example: JSconfig.keys[loadAutoInformationTemplate] = false;
 *
 * Maintainer: [[User:Dschwen]]
 */
window.JSconfig = {
 prefix: 'jsconfig_',
 keys: {},
 meta: {},
 // Register a new configuration item
 //  * name      : String, internal name
 //  * default_value : String or Boolean (type determines configuration widget)
 //  * description  : String, text appearing next to the widget in the preferences, or an hash-object
 //    containing translations of the description indexed by the language code
 //
 // Access keys through JSconfig.keys[name]
 registerKey: function (name, default_value, description, prefpage) {
  if (JSconfig.keys[name] === undefined) {
   JSconfig.keys[name] = default_value;
  } else {
   // all cookies are read as strings,
   // convert to the type of the default value
   switch (typeof default_value) {
   case 'boolean':
    JSconfig.keys[name] = (JSconfig.keys[name] === 'true');
    break;
   case 'number':
    JSconfig.keys[name] = JSconfig.keys[name] / 1;
    break;
   }
  }
  JSconfig.meta[name] = {
   description: description[mw.config.get( 'wgUserLanguage' )] || description.en || (typeof description === 'string' && description) || '<i>en</i> translation missing',
   page: prefpage || 0,
   default_value: default_value
  };
 },
 readCookies: function () {
  var cookies = document.cookie.split('; ');
  var p = JSconfig.prefix.length;
  var i;
  for (var key = 0; cookies && key < cookies.length; key++) {
   if (cookies[key].substring(0, p) === JSconfig.prefix) {
    i = cookies[key].indexOf('=');
    //alert( cookies[key] + ',' + key + ',' + cookies[key].substring(p,i) );
    JSconfig.keys[cookies[key].substring(p, i)] = cookies[key].substring(i + 1);
   }
  }
 },
 writeCookies: function () {
  var expdate = new Date();
  expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * 24 * 3650); // expires in 3560 days
  for (var key in JSconfig.keys) {
   document.cookie = JSconfig.prefix + key + '=' + JSconfig.keys[key] + '; path=/; expires=' + expdate.toUTCString();
  }
 }
};
JSconfig.readCookies();

mw.loader.using(['mediawiki.util']).then(function () {
/* Begin of mw.loader.using callback */

// Overwriting deprecated functions that have a follower that (also) accepts the same syntax:
window.getParamValue = mw.util.getParamValue;

/**
 * @source https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
 * @revision 2020-04-04
 */
mw.loader.using( ['mediawiki.util'], function () {
	var extraCSS = mw.util.getParamValue( 'withCSS' ),
		extraJS = mw.util.getParamValue( 'withJS' ),
		extraModule = mw.util.getParamValue( 'withModule' );

	if ( extraCSS ) {
		// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
		if ( /^MediaWiki:[^&<>=%#]*\.css$/.test( extraCSS ) ) {
			mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraCSS ) + '&action=raw&ctype=text/css', 'text/css' );
		} else {
			mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
		}
	}

	if ( extraJS ) {
		// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
		if ( /^MediaWiki:[^&<>=%#]*\.js$/.test( extraJS ) ) {
			mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraJS ) + '&action=raw&ctype=text/javascript' );
		} else {
			mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
		}
	}

	if ( extraModule ) {
		if ( /^ext\.gadget\.[^,\|]+$/.test( extraModule ) ) {
			mw.loader.load( extraModule );
		} else {
			mw.notify( 'Only gadget modules are allowed.', { title: 'Invalid withModule value' } );
		}
	}
});

/**
 * Edittools
 *
 * Formatting buttons for special characters below the edit field
 * Also enables these buttons on any textarea or input field on the page.
 *
 * Maintainer: [[User:Lupo]], [[User:DieBuche]]
 */
if ( [ 'edit' , 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1
	|| mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload'
) {
 mw.loader.load( '/w/index.php?title=MediaWiki:Edittools.js&action=raw&ctype=text/javascript' ); // Backlink: [[MediaWiki:Edittools.js]]
}

/**
 * ImageAnnotator
 * Globally enabled per
 * http://commons.wikimedia.org/?title=Commons:Village_pump&oldid=26818359#New_interface_feature
 * Maintainer: [[User:Lupo]]
 */
// Not on Special pages, and only if viewing the page
if (mw.config.get( 'wgNamespaceNumber' ) !== -1 && ['view', 'submit'].indexOf(mw.config.get('wgAction') ) !== -1 ) {
 if (typeof ImageAnnotator_disable === 'undefined' || !ImageAnnotator_disable) {
  // Don't even import it if it's disabled.
  mw.loader.load( '/w/index.php?title=MediaWiki:Gadget-ImageAnnotator.js&action=raw&ctype=text/javascript' ); // Backlink: [[MediaWiki:Gadget-ImageAnnotator.js]]
 }
}

/**
 * QICSigs
 *
 * Fix for the broken signatures in gallery tags
 * Helper script to make voting on QIC easier
 * needed for [[COM:QIC]]
 *
 * Maintainers: [[User:Dschwen]]
 */
if (mw.config.get( 'wgPageName' ) === 'Commons:Quality_images_candidates/candidate_list' && mw.config.get( 'wgAction' ) === 'edit') {
 // Does QIvoter.js expect QICSigs.js to have run first? If not, replace this importScript with mw.loader.load
 importScript('MediaWiki:QICSigs.js');
 mw.loader.load( '/w/index.php?title=MediaWiki:QIvoter.js&action=raw&ctype=text/javascript' ); // Backlink: [[MediaWiki:QIvoter.js]]
}


/**
 * VICValidate
 *
 * Some basic form validation for creating new Valued image nominations
 * needed for [[COM:VIC]]
 *
 * Maintainers: [[User:Dschwen]]
 */
if (mw.config.get( 'wgPageName' ) === 'Commons:Valued_image_candidates' && mw.config.get( 'wgAction' ) === 'view') {
 mw.loader.load( '/w/index.php?title=MediaWiki:VICValidate.js&action=raw&ctype=text/javascript' ); // Backlink: [[MediaWiki:VICValidate.js]]
}


/**
 * subPagesLink
 *
 * Adds a link to subpages of current page
 *
 * Maintainers: [[:he:משתמש:ערן]], [[User:Dschwen]]
 *
 * JSconfig items: bool JSconfig.subPagesLink(true=enabled (default), false=disabled)
 */
var subPagesLink = {
 // Translations of the menu item
 i18n: {
  'be-tarask': 'Падстаронкі',
  'be-x-old': 'Падстаронкі',
  ar: 'صفحات فرعية',
  bg: 'Подстраници',
  bn: 'উপপাতাসমূহ',
  ca: 'Subpàgines',
  cs: 'Podstránky',
  cy: 'Isdudalennau',
  de: 'Unterseiten',
  en: 'Subpages', // default
  et: 'Alamlehed',
  eo: 'Subpaĝoj',
  eu: 'Azpiorrialdeak',
  es: 'Subpáginas',
  fa: 'زیرصفحه\u200cها',
  fi: 'Alasivut',
  fr: 'Sous-pages',
  gl: 'Subpáxinas',
  he: 'דפי משנה',
  hr: 'Podstranice',
  hy: 'Ենթաէջեր',
  id: 'Sub halaman',
  it: 'Sottopagine',
  is: 'Undirsíður',
  ja: '下位ページ',
  ko: '하위 문서 목록',
  min: 'Sublaman',
  mk: 'Потстраници',
  ml: 'ഉപതാളുകൾ',
  nl: "Subpagina's",
  no: 'Undersider',
  pl: 'Podstrony',
  pt: 'Subpáginas',
  'pt-br': 'Subpáginas',
  ru: 'Подстраницы',
  sl: 'Podstrani',
  sr: 'Подстранице',
  sv: 'Undersidor',
  tr: 'Altsayfalar',
  tyv: 'Адакы арыннар',
  uk: 'Підсторінки',
  vi: 'Trang con',
  'zh-hans': '子页面',
  'zh-hant': '子頁面'
 },
 install: function () {
  // honor user configuration
  if (!JSconfig.keys.subPagesLink) {
   return;
  }
  if (document.getElementById('t-whatlinkshere')
  && ['Special', 'File', 'Category'].indexOf(mw.config.get('wgCanonicalNamespace')) === -1
  ) {
   var subpagesText = subPagesLink.i18n[mw.config.get( 'wgUserLanguage' )] || subPagesLink.i18n.en;
   var subpagesLink = mw.util.getUrl('Special:Prefixindex/' + mw.config.get( 'wgPageName' ) + '/');
   mw.util.addPortletLink('p-tb', subpagesLink, subpagesText, 't-subpages');
  }
 }
};
JSconfig.registerKey('subPagesLink', true, {
 'be-tarask': 'Паказваць спасылку на падстаронкі ў панэлі інструмэнтаў',
 'be-x-old': 'Паказваць спасылку на падстаронкі ў панэлі інструмэнтаў',
 ar: 'اعرض وصلة الصفحات الفرعية في صندوق الأدوات',
 bg: 'Показване на връзката Подстраници в менюто с инструменти',
 bn: 'সরঞ্জাম-এ উপপাতাসমূহের লিঙ্ক দেখাও',
 cs: 'Zobrazovat v panelu nástrojů odkaz Podstránky',
 cy: 'Dangos cyswllt i Isdudalennau yn y blwch offer',
 en: 'Show a Subpages link in the toolbox', // default
 eo: 'Montri subpaĝan ligilon en la ilaro',
 fa: 'نمایش زیرصفجه\u200cها در جعبه ابزار',
 fr: 'affiche un lien Sous-pages dans la boîte à outils',
 hr: 'Prikaži poveznicu na podstranice u pomagalima',
 hy: 'Ցույց տալ «Ենթաէջեր» հղումը գործիքների տուփում',
 id: 'Tampilkan Sub halaman di kotak perkakas',
 ja: 'ツールボックスに「下位ページ」リンクを表示',
 min: 'Tunjuakan Sublaman pado kotak pakakeh',
 mk: 'Покажи врска до потстраниците во алатникот',
 ml: 'പണിസഞ്ചിയിൽ ഉപതാളുകൾക്കുള്ള കണ്ണി പ്രദർശിപ്പിക്കുക',
 nl: "Een link Subpagina's weergeven bij de hulpmiddelen",
 pl: 'Pokaż w panelu bocznym link do podstron',
 pt: 'Exibir um link para as subpáginas no menu de ferramentas',
 'pt-br': 'Exibir um link para as subpáginas no menu de ferramentas',
 ru: 'Показывать ссылку на подстраницы в меню инструментов',
 sl: 'Med pripomočki prikaži povezavo na podstrani',
 sv: 'Visa en länk för undersidor i verktygslådan',
 tr: 'Araç kutusunda alt sayfalara bir bağlantı gösterir',
 vi: 'Hiển thị liên kết Trang con ở hộp Công cụ',
 'zh-hans': '在工具箱显示一个子页面的链接',
 'zh-hant': '在工具箱顯示壹個子頁面的鏈接'
}, 7);
$(subPagesLink.install);

/**
 * dshuf: Shuffle media items within galleries that are within `<div class="dshuf">`.
 *
 * Example: <https://commons.wikimedia.org/wiki/Commons:Picture_of_the_Year/2009/Galleries/Artworks/1>
 *
 * Maintainers: [[User:Dschwen]], [[User:Krinkle]]
 */
function gallery_dshuf($c) {
    $c.find('div.dshuf > ul.gallery').each( function (i, listParent) {
        /** @type {Array<HTMLElement>} */
        var items = $(listParent).children('li.gallerybox').get();
        // sort at random
        items.sort(function () {
            return 0.5 - Math.random();
        });
        // re-append to the parent in the new random order
        items.forEach(function (item) { 
        	listParent.appendChild(item);
        });
    });
}
mw.hook( 'wikipage.content' ).add( gallery_dshuf );

/**
 * dshufset: Shuffle DIV elements across a page from a set of elements with the same set number.
 *
 * Example: <https://commons.wikimedia.org/wiki/Commons:Picture_of_the_Year/2010/Results/R1/Category_winners> 
 * 
 * Each DIV element needs to have a class of "dshuf" and a class of "dshufsetX" where X is a number identifying
 * a particular set of DIV elements that should be shuffled amongst each other. 
 *
 *
 * Maintainers: [[User:Gmaxwell]], [[User:Dschwen]], [[User:Krinkle]]
 */
function dshufset($c) {
 var shufsets = {};
 var rx = /(?:^|\s+)dshufset(\d+)(?:\s+|$)/;
 var $divs = $('div.dshuf[class*="dshufset"]');

 function sortFunction() {
   return 0.5 - Math.random();
 }

 $divs.each(function (i, div) {
   var m = rx.exec(div.className);
   if (!m || !m[1]) {
     return; // Ignore, this one is missing a number
   }
   if (!shufsets[m[1]]) {
     shufsets[m[1]] = []; // First item in a set
   }
   shufsets[m[1]].push(div);
 });

 var original, shuffled, item;
 for (var shufset in shufsets) {
   original = shufsets[shufset].slice();
   shuffled = shufsets[shufset].sort(sortFunction);
   // Insert placeholders
   for (var i = 0; i < original.length; i++) {
     item = original[i];
     original[i] = document.createComment('tmp');
     item.parentNode.replaceChild(original[i], item);
   }
   // Replace placeholders
   for (var j = 0; j < original.length; j++) {
     original[j].parentNode.replaceChild(shuffled[j], original[j]);
   }
 }
}
mw.hook( 'wikipage.content' ).add( dshufset );


/**
 * localizeSignature: localizes the signature on Commons with the string in the user's preferred language
 *
 * Maintainer: [[User:Slomox]]
 */
function localizeSignature($c) {
 var talkTextLocalization = {
  'be-tarask': 'Абмеркаваньне',
  'be-x-old': 'Абмеркаваньне',
  ar: 'نقاش',
  bn: 'আলোচনা',
  ca: 'Discussió',
  cs: 'diskuse',
  cy: 'Sgwrs',
  de: 'Diskussion',
  fa: 'بحث',
  fr: 'd',
  hy: 'Քննարկում',
  id: 'bicara',
  ko: '토론',
  min: 'maota',
  mk: 'Разговор',
  ml: 'സംവാദം',
  nl: 'Overleg',
  pt: 'Discussão',
  'pt-br': 'Discussão',
  nds: 'Diskuschoon',
  sl: 'Pogovor',
  sv: 'Diskussion',
  tr: 'Tartışma',
  'zh-hans': '留言',
  'zh-hant': '留言'
 };
 var talkText = talkTextLocalization[mw.config.get( 'wgUserLanguage' )];
 if (!talkText) {
  return;
 }
 $c.find('.signature-talk').text(talkText);
}
mw.hook( 'wikipage.content' ).add( localizeSignature );


/**
 * Ajax Translation of /lang links, see [[MediaWiki:AjaxTranslation.js]]
 * Maintainer: [[User:ערן]], [[User:DieBuche]]
 */
if (!window.disableAjaxTranslation) {
    mw.loader.load( '/w/index.php?title=MediaWiki:AjaxTranslation.js&action=raw&ctype=text/javascript' ); // Backlink: [[MediaWiki:AjaxTranslation.js]]
}

// RTL site-side scripts
if ([
	'ar',
	'arc',
	'arz',
	'bcc',
	'bqi',
	'dv',
	'fa',
	'fa-af',
	'glk',
	'ha',
	'he',
	'kk-arab',
	'kk-cn',
	'ks',
	'ku-arab',
	'mzn',
	'prd',
	'ps',
	'sd',
	'ur',
	'ydd',
	'yi'
].indexOf(mw.config.get('wgUserLanguage')) !== -1) {
  mw.loader.load('ext.gadget.BiDiEditing');
}

// Language-specific site-wide scripts
if ([
	'ku',
	'nds'
].indexOf(mw.config.get('wgUserLanguage')) !== -1) {
  mw.loader.load('/w/?title=MediaWiki:Common.js/' + mw.config.get( 'wgUserLanguage' ) + '.js&action=raw&ctype=text/javascript');
}

/**
 * Sitenotice translation for all skins
 * Maintainer: Krinkle
 */
$(function () {
 if (mw.config.get( 'wgUserLanguage' ) !== 'en') {
  $('#siteNotice').find('#localNotice p').load(
    mw.util.getUrl( 'MediaWiki:Sitenotice-translation' ) + '?action=render&uselang=' + mw.config.get( 'wgUserLanguage' ) + ' p'
  );
 }
});


/**
 * Main page tab all main pages and instead of the 'Gallery' tab
 */
if ([ 0 , 1 ].indexOf( mw.config.get( 'wgNamespaceNumber' )) !== -1) {
 mw.loader.load( '/w/index.php?title=MediaWiki:MainPages.js&action=raw&ctype=text/javascript' ); // Backlink: [[MediaWiki:MainPages.js]]
}

/**
 * Add links to GlobalUsage and the CommonsDelinker log to file deletion log entries.
 *
 * Maintainer: [[User:Ilmari Karonen]]
 */
mw.hook( 'wikipage.content' ).add(function($content) {
 var $deletions = $content.find('li.mw-logline-delete');
 if (!$deletions.length) {
   return;
 }
 
 // create the links in advance so we can cloneNode() them quickly in the loop
 var guLink = $('<a>', {
   'class' : 'delinker-log-globalusage'
 }).append('global usage');
 var cdLink = $('<a>', {
   'class' : 'delinker-log-link extiw'
 }).append('delinker log');
 
 var span = $('<span>', {
    'class' : 'delinker-log-links'
 }).append(' (').append(guLink).append('; ')
   .append(cdLink).append(')');
 
 $deletions.each (function() {
   var $match = $( this ).find('a[title^="File:"]').first();
   if ( $match.length ) {
     var filename = $match.text().substring(5).replace(/ /g,'_');
     guLink.attr('href', mw.util.getUrl( 'Special:GlobalUsage' ) + '?target=' + encodeURIComponent(filename) );
     guLink.attr('title', 'Current usage of ' + filename + ' on all Wikimedia projects');
     cdLink.attr('href', 'https://commons-delinquent.toolforge.org/index.php?image=' + encodeURIComponent(filename));
     cdLink.attr('title', 'CommonsDelinker log for ' + filename);
     $( this ).append( span.clone() );
   }
 });
});

// Workaround for [[bugzilla:708]] via [[Template:InterProject]]
// Only load if page contains template
mw.hook( 'wikipage.content' ).add( function ( $content ) {
	if ( $content.find( '#interProject' ).length ) {
		mw.loader.load( '/w/index.php?title=MediaWiki:InterProject.js&action=raw&ctype=text/javascript' ); // Backlink: [[MediaWiki:InterProject.js]]
	}
});

/**
 * {{tl|LargeImage}} linkswap
 *
 * Swaps the 'full resolution' link with the 'interactive zoomviewer' links for large images.
 * Avoids people crashing their browser by accidentally attempting to view a 200MP image
 *
 * Maintainer: [[User:Dschwen]]
 */
if (mw.config.get( 'wgAction' ) === 'view' && mw.config.get( 'wgNamespaceNumber' ) === 6) {
 $(function () {
  var $viewerLinks = $('#LargeImage_viewer_links'),
      $fullResLink = $('.fullMedia>a[href^="//upload.wikimedia.org/wikipedia/commons/"].internal'),
      $copy_to = $fullResLink.clone(true),
      $copy_from = $viewerLinks.clone(true);
  if ($viewerLinks.length === 1 && $fullResLink.length === 1) {
   $fullResLink.replaceWith($copy_from);
   $viewerLinks.replaceWith($copy_to);
  }
 });
}

// Update from https://intuition.toolforge.org/wpAvailableLanguages.js.php - Last update: Wed, 08 Jul 2020 19:32:59 +0000
window.wpAvailableLanguages={"aa":"Qafár af","ab":"Аҧсшәа","abs":"bahasa ambon","ace":"Acèh","ady":"адыгабзэ","ady-cyrl":"адыгабзэ","aeb":"تونسي\/Tûnsî","aeb-arab":"تونسي","aeb-latn":"Tûnsî","af":"Afrikaans","ak":"Akan","aln":"Gegë","als":"Alemannisch","alt":"тÿштÿк алтай тил","am":"አማርኛ","ami":"Pangcah","an":"aragonés","ang":"Ænglisc","anp":"अङ्गिका","ar":"العربية","arc":"ܐܪܡܝܐ","arn":"mapudungun","arq":"جازايرية","ary":"الدارجة","arz":"مصرى","as":"অসমীয়া","ase":"American sign language","ast":"asturianu","atj":"Atikamekw","av":"авар","avk":"Kotava","awa":"अवधी","ay":"Aymar aru","az":"azərbaycanca","azb":"تۆرکجه","ba":"башҡортса","ban":"Bali","bar":"Boarisch","bat-smg":"žemaitėška","bbc":"Batak Toba","bbc-latn":"Batak Toba","bcc":"جهلسری بلوچی","bcl":"Bikol Central","be":"беларуская","be-tarask":"беларуская (тарашкевіца)‎","be-x-old":"беларуская (тарашкевіца)‎","bg":"български","bgn":"روچ کپتین بلوچی","bh":"भोजपुरी","bho":"भोजपुरी","bi":"Bislama","bjn":"Banjar","bm":"bamanankan","bn":"বাংলা","bo":"བོད་ཡིག","bpy":"বিষ্ণুপ্রিয়া মণিপুরী","bqi":"بختیاری","br":"brezhoneg","brh":"Bráhuí","bs":"bosanski","btm":"Batak Mandailing","bto":"Iriga Bicolano","bug":"ᨅᨔ ᨕᨘᨁᨗ","bxr":"буряад","ca":"català","cbk-zam":"Chavacano de Zamboanga","cdo":"Mìng-dĕ̤ng-ngṳ̄","ce":"нохчийн","ceb":"Cebuano","ch":"Chamoru","cho":"Choctaw","chr":"ᏣᎳᎩ","chy":"Tsetsêhestâhese","ckb":"کوردی","co":"corsu","cps":"Capiceño","cr":"Nēhiyawēwin \/ ᓀᐦᐃᔭᐍᐏᐣ","crh":"qırımtatarca","crh-cyrl":"къырымтатарджа (Кирилл)‎","crh-latn":"qırımtatarca (Latin)‎","cs":"čeština","csb":"kaszëbsczi","cu":"словѣньскъ \/ ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ","cv":"Чӑвашла","cy":"Cymraeg","da":"dansk","de":"Deutsch","de-at":"Österreichisches Deutsch","de-ch":"Schweizer Hochdeutsch","de-formal":"Deutsch (Sie-Form)‎","din":"Thuɔŋjäŋ","diq":"Zazaki","dsb":"dolnoserbski","dtp":"Dusun Bundu-liwan","dty":"डोटेली","dv":"ދިވެހިބަސް","dz":"ཇོང་ཁ","ee":"eʋegbe","egl":"Emiliàn","el":"Ελληνικά","eml":"emiliàn e rumagnòl","en":"English","en-ca":"Canadian English","en-gb":"British English","eo":"Esperanto","es":"español","es-419":"español de América Latina","es-formal":"español (formal)‎","et":"eesti","eu":"euskara","ext":"estremeñu","fa":"فارسی","ff":"Fulfulde","fi":"suomi","fit":"meänkieli","fiu-vro":"Võro","fj":"Na Vosa Vakaviti","fkv":"kvääni","fo":"føroyskt","fr":"français","frc":"français cadien","frp":"arpetan","frr":"Nordfriisk","fur":"furlan","fy":"Frysk","ga":"Gaeilge","gag":"Gagauz","gan":"贛語","gan-hans":"赣语(简体)‎","gan-hant":"贛語(繁體)‎","gcr":"kriyòl gwiyannen","gd":"Gàidhlig","gl":"galego","glk":"گیلکی","gn":"Avañe'ẽ","gom":"गोंयची कोंकणी \/ Gõychi Konknni","gom-deva":"गोंयची कोंकणी","gom-latn":"Gõychi Konknni","gor":"Bahasa Hulontalo","got":"\ud800\udf32\ud800\udf3f\ud800\udf44\ud800\udf39\ud800\udf43\ud800\udf3a","grc":"Ἀρχαία ἑλληνικὴ","gsw":"Alemannisch","gu":"ગુજરાતી","gv":"Gaelg","ha":"Hausa","hak":"客家語\/Hak-kâ-ngî","haw":"Hawaiʻi","he":"עברית","hi":"हिन्दी","hif":"Fiji Hindi","hif-latn":"Fiji Hindi","hil":"Ilonggo","ho":"Hiri Motu","hr":"hrvatski","hrx":"Hunsrik","hsb":"hornjoserbsce","ht":"Kreyòl ayisyen","hu":"magyar","hu-formal":"magyar (formal)‎","hy":"հայերեն","hyw":"Արեւմտահայերէն","hz":"Otsiherero","ia":"interlingua","id":"Bahasa Indonesia","ie":"Interlingue","ig":"Igbo","ii":"ꆇꉙ","ik":"Iñupiak","ike-cans":"ᐃᓄᒃᑎᑐᑦ","ike-latn":"inuktitut","ilo":"Ilokano","inh":"ГӀалгӀай","io":"Ido","is":"íslenska","it":"italiano","iu":"ᐃᓄᒃᑎᑐᑦ\/inuktitut","ja":"日本語","jam":"Patois","jbo":"la .lojban.","jut":"jysk","jv":"Jawa","ka":"ქართული","kaa":"Qaraqalpaqsha","kab":"Taqbaylit","kbd":"Адыгэбзэ","kbd-cyrl":"Адыгэбзэ","kbp":"Kabɩyɛ","kea":"Kabuverdianu","kg":"Kongo","khw":"کھوار","ki":"Gĩkũyũ","kiu":"Kırmancki","kj":"Kwanyama","kjp":"ဖၠုံလိက်","kk":"қазақша","kk-arab":"قازاقشا (تٴوتە)‏","kk-cn":"قازاقشا (جۇنگو)‏","kk-cyrl":"қазақша (кирил)‎","kk-kz":"қазақша (Қазақстан)‎","kk-latn":"qazaqşa (latın)‎","kk-tr":"qazaqşa (Türkïya)‎","kl":"kalaallisut","km":"ភាសាខ្មែរ","kn":"ಕನ್ನಡ","ko":"한국어","ko-kp":"조선말","koi":"Перем Коми","kr":"Kanuri","krc":"къарачай-малкъар","kri":"Krio","krj":"Kinaray-a","krl":"karjal","ks":"कॉशुर \/ کٲشُر","ks-arab":"کٲشُر","ks-deva":"कॉशुर","ksh":"Ripoarisch","ku":"kurdî","ku-arab":"كوردي (عەرەبی)‏","ku-latn":"kurdî (latînî)‎","kum":"къумукъ","kv":"коми","kw":"kernowek","ky":"Кыргызча","la":"Latina","lad":"Ladino","lb":"Lëtzebuergesch","lbe":"лакку","lez":"лезги","lfn":"Lingua Franca Nova","lg":"Luganda","li":"Limburgs","lij":"Ligure","liv":"Līvõ kēļ","lki":"لەکی","lld":"Ladin","lmo":"lumbaart","ln":"lingála","lo":"ລາວ","loz":"Silozi","lrc":"لۊری شومالی","lt":"lietuvių","ltg":"latgaļu","lus":"Mizo ţawng","luz":"لئری دوٙمینی","lv":"latviešu","lzh":"文言","lzz":"Lazuri","mai":"मैथिली","map-bms":"Basa Banyumasan","mdf":"мокшень","mg":"Malagasy","mh":"Ebon","mhr":"олык марий","mi":"Māori","min":"Minangkabau","mk":"македонски","ml":"മലയാളം","mn":"монгол","mni":"ꯃꯤꯇꯩ ꯂꯣꯟ","mnw":"ဘာသာ မန်","mo":"молдовеняскэ","mr":"मराठी","mrj":"кырык мары","ms":"Bahasa Melayu","mt":"Malti","mus":"Mvskoke","mwl":"Mirandés","my":"မြန်မာဘာသာ","myv":"эрзянь","mzn":"مازِرونی","na":"Dorerin Naoero","nah":"Nāhuatl","nan":"Bân-lâm-gú","nap":"Napulitano","nb":"norsk bokmål","nds":"Plattdüütsch","nds-nl":"Nedersaksies","ne":"नेपाली","new":"नेपाल भाषा","ng":"Oshiwambo","niu":"Niuē","nl":"Nederlands","nl-informal":"Nederlands (informeel)‎","nn":"norsk nynorsk","no":"norsk","nod":"ᨣᩴᩤᨾᩮᩥᩬᨦ","nov":"Novial","nqo":"ߒߞߏ","nrm":"Nouormand","nso":"Sesotho sa Leboa","nv":"Diné bizaad","ny":"Chi-Chewa","nys":"Nyunga","oc":"occitan","olo":"Livvinkarjala","om":"Oromoo","or":"ଓଡ଼ିଆ","os":"Ирон","ota":"لسان توركى","pa":"ਪੰਜਾਬੀ","pag":"Pangasinan","pam":"Kapampangan","pap":"Papiamentu","pcd":"Picard","pdc":"Deitsch","pdt":"Plautdietsch","pfl":"Pälzisch","pi":"पालि","pih":"Norfuk \/ Pitkern","pl":"polski","pms":"Piemontèis","pnb":"پنجابی","pnt":"Ποντιακά","prg":"Prūsiskan","ps":"پښتو","pt":"português","pt-br":"português do Brasil","qu":"Runa Simi","qug":"Runa shimi","rgn":"Rumagnôl","rif":"Tarifit","rm":"rumantsch","rmf":"kaalengo tšimb","rmy":"romani čhib","rn":"Kirundi","ro":"română","roa-rup":"armãneashti","roa-tara":"tarandíne","ru":"русский","rue":"русиньскый","rup":"armãneashti","ruq":"Vlăheşte","ruq-cyrl":"Влахесте","ruq-latn":"Vlăheşte","rw":"Kinyarwanda","rwr":"मारवाड़ी","sa":"संस्कृतम्","sah":"саха тыла","sat":"ᱥᱟᱱᱛᱟᱲᱤ","sc":"sardu","scn":"sicilianu","sco":"Scots","sd":"سنڌي","sdc":"Sassaresu","sdh":"کوردی خوارگ","se":"davvisámegiella","sei":"Cmique Itom","ses":"Koyraboro Senni","sg":"Sängö","sgs":"žemaitėška","sh":"srpskohrvatski \/ српскохрватски","shi":"Tašlḥiyt\/ⵜⴰⵛⵍⵃⵉⵜ","shi-latn":"Tašlḥiyt","shi-tfng":"ⵜⴰⵛⵍⵃⵉⵜ","shn":"ၽႃႇသႃႇတႆး ","shy-latn":"tacawit","si":"සිංහල","simple":"Simple English","sjd":"Кӣллт са̄мь кӣлл","sje":"bidumsámegiella","sju":"ubmejesámiengiälla","sk":"slovenčina","skr":"سرائیکی","skr-arab":"سرائیکی","sl":"slovenščina","sli":"Schläsch","sm":"Gagana Samoa","sma":"åarjelsaemien","smj":"julevsámegiella","smn":"anarâškielâ","sms":"sääʹmǩiõll","sn":"chiShona","so":"Soomaaliga","sq":"shqip","sr":"српски \/ srpski","sr-ec":"српски (ћирилица)‎","sr-el":"srpski (latinica)‎","srn":"Sranantongo","srq":"mbia cheë","ss":"SiSwati","st":"Sesotho","stq":"Seeltersk","sty":"себертатар","su":"Sunda","sv":"svenska","sw":"Kiswahili","szl":"ślůnski","szy":"Sakizaya","ta":"தமிழ்","tay":"Tayal","tcy":"ತುಳು","te":"తెలుగు","tet":"tetun","tg":"тоҷикӣ","tg-cyrl":"тоҷикӣ","tg-latn":"tojikī","th":"ไทย","ti":"ትግርኛ","tk":"Türkmençe","tl":"Tagalog","tly":"толышә зывон","tn":"Setswana","to":"lea faka-Tonga","tpi":"Tok Pisin","tr":"Türkçe","tru":"Ṫuroyo","trv":"Seediq","ts":"Xitsonga","tt":"татарча\/tatarça","tt-cyrl":"татарча","tt-latn":"tatarça","tum":"chiTumbuka","tw":"Twi","ty":"reo tahiti","tyv":"тыва дыл","tzm":"ⵜⴰⵎⴰⵣⵉⵖⵜ","udm":"удмурт","ug":"ئۇيغۇرچە \/ Uyghurche","ug-arab":"ئۇيغۇرچە","ug-latn":"Uyghurche","uk":"українська","ur":"اردو","uz":"oʻzbekcha\/ўзбекча","uz-cyrl":"ўзбекча","uz-latn":"oʻzbekcha","ve":"Tshivenda","vec":"vèneto","vep":"vepsän kel’","vi":"Tiếng Việt","vls":"West-Vlams","vmf":"Mainfränkisch","vo":"Volapük","vot":"Vaďďa","vro":"Võro","wa":"walon","war":"Winaray","wo":"Wolof","wuu":"吴语","xal":"хальмг","xh":"isiXhosa","xmf":"მარგალური","xsy":"saisiyat","yi":"ייִדיש","yo":"Yorùbá","yue":"粵語","za":"Vahcuengh","zea":"Zeêuws","zgh":"ⵜⴰⵎⴰⵣⵉⵖⵜ ⵜⴰⵏⴰⵡⴰⵢⵜ","zh":"中文","zh-classical":"文言","zh-cn":"中文(中国大陆)‎","zh-hans":"中文(简体)‎","zh-hant":"中文(繁體)‎","zh-hk":"中文(香港)‎","zh-min-nan":"Bân-lâm-gú","zh-mo":"中文(澳門)‎","zh-my":"中文(马来西亚)‎","zh-sg":"中文(新加坡)‎","zh-tw":"中文(台灣)‎","zh-yue":"粵語","zu":"isiZulu"};

/**
 * AnonymousI18N
 *
 * Internationalisation for anonymous users.
 *
 * @author [[User:Krinkle]]
 * @stats [[File:Krinkle_AnonymousI18N.js]]
 */
if (mw.config.get('wgUserName') === null) {
  mw.loader.load( 'ext.gadget.AnonymousI18N' );
  // ULS disabled until functional - T58464
  $('#pt-uls').hide();
}

/**
 * Special:Upload enhancements
 *
 * Moved to [[MediaWiki:Upload.js]], [[MediaWiki:Gadget-ImprovedUploadForm.js]]
 *
 * Maintainer: [[User:Lupo]]
 */
if (mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload') {
 mw.loader.load( '/w/index.php?title=MediaWiki:Upload.js&action=raw&ctype=text/javascript' ); // Backlink: [[MediaWiki:Upload.js]]
}

/**
 * ImageStacks
 * Maintainer: [[User:Hellerhoff]], [[User:DieBuche]]
 */
// Only load if page contains template
mw.hook( 'wikipage.content' ).add( function ( $content ) {
    if ( $content.find( 'div.ImageStack' ).length ) mw.loader.load( 'ext.gadget.ImageStack' );
} );

/**
 * Infobox image switcher
 * Maintainer: [[User:Mike Peel]]
 */
// Only load if page contains template
mw.hook( 'wikipage.content' ).add( function ( $content ) {
    if ( $content.find( 'table#wdinfobox' ).length ) mw.loader.load( 'ext.gadget.Infobox' );
} );

// Catfood - tweaked version of [[MediaWiki:Catfood.js]]
// Add a link to a RSS feed for each category page, in the toolbox.
// If i18n is required, create a gadget, please and use MW-messages
if (mw.config.get('wgNamespaceNumber') === 14) $(function () {
   var p = mw.util.addPortletLink('p-tb', 'https://catfood.toolforge.org/catfood.php?category=' + encodeURIComponent(mw.config.get('wgTitle').split(' ').join('_')), 'RSS feed', 't-catfood', 'Category feed: The images are ordered based on the time of the addition of the image to the category, latest additions first');
   if (!p) return;
   var $p = $(p);
   var $a = $p.find('a');
   if ($a.length) {
      $a.addClass('feedlink');
   } else {
      $p.addClass('feedlink');
   }
});

/**
 * Commons Dashboard
 * a collection of widgets containing real time status displays
 * and ways to achieve common tasks with less work
 * that seamless integrate into the Wikimedia Commons user interface
 * @maintainer [[User:Rillke]]
 */
mw.hook( 'wikipage.content' ).add( function($content) {
 if ($content.find('.commonsdashboard').length) mw.loader.load('ext.gadget.CommonsDashboard');
} );

/**
 * jQuery UI loader
 * Loads jQuery UI modules on demand and allows users making use of
 * (some) of the awesome jQuery UI widgets.
 * 
 * @maintainer [[User:Rillke]]
 */
mw.hook( 'wikipage.content' ).add( function ( $content ) {
	var $accordion = $content.find( '.accordion' ),
		$button = $content.find( '.ui-button' );

	if ($accordion.length) {
		mw.loader.using( 'jquery.ui', function () {
			$accordion.accordion( { autoHeight: false } );
		} );
	}
	if ($button.length) {
		mw.loader.load( 'jquery.ui' );
	}
} );

// Fix for https://bugzilla.wikimedia.org/show_bug.cgi?id=51038
mw.hook( 'wikipage.content' ).add( function($content) {
	if ($content.find('.mw-babel-wrapper').length) mw.loader.load('ext.babel');
});

/* End of mw.loader.using callback */
});

/**
 * MediaSearch link
 * 
 * Add a link to Special:MediaSearch from Special:Search
 * 
 * @maintainer [[User:AntiCompositeNumber]]
 */
if (mw.config.get( 'wgPageName' ) === "Special:Search") {
	mw.loader.load('https://commons.wikimedia.org/w/index.php?title=MediaWiki:Mediasearchlink.js&action=raw&ctype=text/javascript');
}

/**
 * POTY gallery script
 * Displays galleries for Picture of the Year contests, and allows users to vote.
 * 
 * @maintainer [[User:Ingenuity]]
 */
// Note Firefox 66 does not have support for replaceAll so this is wrapped in a try/catch.
let matchPoty = null;
try {
	matchPoty = mw.config.get("wgPageName")
		.replaceAll("_", " ")
		.match(/Picture of the Year\/(\d{4})/);
} catch ( e ) {
    // pass.
}
if (matchPoty && Number(matchPoty[1]) >= 2023) {
    mw.loader.load("/w/index.php?title=MediaWiki:POTY-gallery.js&action=raw&ctype=text/javascript");
}