Vés al contingut

MediaWiki:Common.js

De Viccionari

Nota: Després de publicar, possiblement necessitareu refrescar la memòria cau del vostre navegador per a veure'n els canvis.

  • Firefox / Safari: Premeu Majús i alhora cliqueu el botó Actualitzar, o pressioneu Ctrl+F5 o Ctrl+R (⌘+R en un Mac)
  • Google Chrome: Premeu Ctrl+Majús+R (⌘+Shift+R en un Mac)
  • Internet Explorer / Edge: Premeu Ctrl i alhora cliqueu a Actualitza o pressioneu Ctrl+F5
  • Opera: Premeu Ctrl-F5.
/**
 * 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.
 */
'use strict';
/*jshint shadow:true, undef:true, latedef:true, unused:true, es3:true */
/*global jQuery, mw, importScript, importStylesheet, $ */


// &preloadtext= (usat a Usuari:Vriullop/creation.js)
// portat de https://en.wiktionary.org/w/index.php?title=MediaWiki:Common.js&oldid=37119665
mw.loader.using('mediawiki.util').done(function(){
	if (mw.config.get('wgAction') === 'edit')
		jQuery(document).ready(function () {
			var wpTextbox1 = document.getElementById('wpTextbox1');
			if (!wpTextbox1)
				return;
			
			var preloadtext = mw.util.getParamValue('preloadtext');
			
			if (preloadtext && !wpTextbox1.value)
				wpTextbox1.value = preloadtext;
		});
});

// categories amb direcció rtl, adaptat de de.wikt
// s'activa amb class="catrtl"
jQuery(window).ready(function(){
	var ns=mw.config.get("wgNamespaceNumber");
	if((ns==14) && mw.config.get("wgAction")=="view")
	{
		var elements = document.getElementsByClassName("catrtl");
		if (elements.length > 0)
		{
			$("#mw-pages h3").attr("dir", "rtl").attr("style", "margin-right: 1em").wrapInner("<span dir='ltr'></span>");
			$("#mw-pages ul").attr("dir", "rtl").attr("style", "margin-right: 2em");
			$("#mw-pages li").wrapInner("<span dir='ltr'></span>");
		}
	}
});

// The rest of the scripts are at [[MediaWiki:Gadget-legacy.js]].
// Most of them should be converted into gadgets as time and resources allow.
OSZAR »