MediaWiki:Common.js
Aparença
Nota: Després de desar, heu de netejar la memòria cau del navegador per veure els canvis. En la majoria de navegadors amb Windows o Linux, premeu Ctrl+F5 o bé premeu Shift i cliqueu el botó "Actualitza" (Ctrl i "Actualitza" amb Internet Explorer). Vegeu més informació i instruccions per a cada navegador a Viquipèdia:Neteja de la memòria cau.
/**
* 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, $, importScript*/
mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'jquery.client'] ).done( function () {
/* Begin of mw.loader.using callback */
/* Redirect Sitenotice WLM 2018 */
(function(w, d) {
var el = d.querySelector(".wlm-mainlink");
if(el) {
el.addEventListener("click",function (e) {
e.preventDefault();
w.location.href = "https://ca.wikipedia.org/wiki/Viquiprojecte:Monuments/Repte_2018";
});
}
})(window,document);
/**
$(window).on( 'load', function(){
setTimeout(function (){
$("#wlm-banner a").attr("href", "http://www.wikilovesmonuments.cat");
},400);
$(document).on("click","#wlm-banner a",function () {
if($(this).attr("href") != "http://www.wikilovesmonuments.cat") {
$(this).attr("href", "http://www.wikilovesmonuments.cat");
}
});
});
*/
/*HERE STARTS THE WORKING-CODE OF "METABOXES"*/
/* Funcionament de la Plantilla:Metacaixa
Implementat per: Usuari:Peleguer.
Actualitzat per Joanjoc seguint les indicacions d'en Martorell
*/
function MetaCaixaInit(){
//S'executa al carregar-se la pàgina, si hi ha metacaixes,
// s'assignen els esdeveniments als botons
//alert("MetaCaixaInit");
var i=0; //Inicialitzem comptador de caixes
for (i=0;i<=9;i++){
var vMc = document.getElementById("mc"+i);
if (!vMc) break;
//alert("MetaCaixaInit, trobada Metacaixa mc"+i);
var j=1; //Inicialitzem comptador de botons dins de la caixa
var vPsIni = 0; //Pestanya visible inicial
for (j=1;j<=9;j++){
var vBt = document.getElementById("mc"+i+"bt"+j);
if (!vBt) break;
//alert("MetaCaixaInit, trobat botó mc"+i+"bt"+j);
vBt.onclick = MetaCaixaMostraPestanya; //A cada botó assignem l'esdeveniment onclick
//alert (vBt.className);
if (vBt.className=="mcBotoSel") vPsIni=j; //Si tenim un botó seleccionat, en guardem l'index
}
//alert ("mc="+i+", ps="+j+", psini="+vPsIni );
if (vPsIni === 0) { //Si no tenim cap botó seleccionat, n'agafem un aleatòriament
vPsIni = 1+Math.floor((j-1)*Math.random()) ;
//alert ("Activant Pestanya a l'atzar; _mc"+i+"bt"+vPsIni +"_");
document.getElementById("mc"+i+"ps"+vPsIni).style.display = "block";
document.getElementById("mc"+i+"ps"+vPsIni).style.visibility = "visible";
document.getElementById("mc"+i+"bt"+vPsIni).className="mcBotoSel";
}
}
}
function MetaCaixaMostraPestanya(){
//S'executa al clicar una pestanya,
//aquella es fa visible i les altres s'oculten
var vMcNom = this.id.substr(0,3); //A partir del nom del botó, deduïm el nom de la caixa
var vIndex = this.id.substr(5,1); //I l'index
var i=1;
for (i=1;i<=9;i++){ //busquem totes les pestanyes d'aquella caixa
//alert(vMcNom+"ps"+i);
var vPsElem = document.getElementById(vMcNom+"ps"+i);
if (!vPsElem) break;
if (vIndex==i){ //Si és la pestanya bona la mostrem i canviem la classe de botó
vPsElem.style.display = "block";
vPsElem.style.visibility = "visible";
document.getElementById(vMcNom+"bt"+i).className="mcBotoSel";
} else { //Sinó, l'ocultem i canviem la classe de botó
vPsElem.style.display = "none";
vPsElem.style.visibility = "hidden";
document.getElementById(vMcNom+"bt"+i).className="mcBoto";
}
}
return false; //evitem la recàrrega de la pàgina
}
$( MetaCaixaInit );
/*HERE FINISHES THE WORKING-CODE OF "METABOXES"*/
function AvisAdminsVand()
{
var url_name = '//ca.wikipedia.org/w/index.php?alertavandalisme=esclar';
var page_name = document.URL;
var index = page_name.indexOf(url_name);
if (index == -1)
return;
var text_area = document.editform.wpTextbox1;
var comment = "Atenció! Passa\'t per la pàgina de [[Especial:Recentchanges|canvis recents]] per a jutjar alguns canvis que poden ésser considerats com a [[Viquipèdia:vandalisme|vandalisme]].--~~"+"~~";
text_area.value = comment;
document.editform.wpSummary.value="Avís de vandalisme en curs!!!";
}
$( AvisAdminsVand );
/**
* Enllaç de càrrega per defecte a la pàgina d'ajuda
* Amb els ginys es pot eliminar i es pot afegir també un enllaç a Commons
*/
var LienUpload = function () {
var uploadLink = document.getElementById("t-upload");
if (!uploadLink) return;
var a = uploadLink.firstChild;
a.setAttribute('href', '/wiki/Ajuda:Carregar_un_fitxer');
};
$(LienUpload);
/**
* 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');
}
} );
} )();
/***** OpenStreetMap *****
* vegeu Ajuda:OpenStreetMap
*/
mw.config.set( 'osm_proj_map', 'mapa' ); //"map" in project language
mw.config.set( 'osm_proj_lang', 'ca' ); //project language
/*mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:OSM.js&action=raw&ctype=text/javascript');*/
/**
* Collapsible tables; reimplemented with mw-collapsible
* Styling is also in place to avoid FOUC
*
* Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
* @version 3.0.0 (2018-05-20)
* @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
* @author [[User:R. Koot]]
* @author [[User:Krinkle]]
* @author [[User:TheDJ]]
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
* is supported in MediaWiki core. Shimmable since MediaWiki 1.32
*/
function makeCollapsibleMwCollapsible( $content ) {
var $tables = $content
.find( 'table.collapsible:not(.mw-collapsible)' )
.addClass( 'mw-collapsible' );
$.each( $tables, function( index, table ) {
// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
if( $( table ).hasClass( 'collapsed') ) {
$( table ).addClass( 'mw-collapsed' );
// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
}
} );
if( $tables.length > 0 ) {
mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
$tables.makeCollapsible();
} );
}
}
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );
/**
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
*
* Maintainers: TheDJ
*/
function mwCollapsibleSetup( $collapsibleContent ) {
var $element,
$toggle,
autoCollapseThreshold = 2;
$.each( $collapsibleContent, function (index, element) {
$element = $( element );
if ( $element.hasClass( 'collapsible' ) ) {
$element.find('tr:first > th:first').prepend( $element.find('tr:first > * > .mw-collapsible-toggle'));
}
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
$element.data( 'mw-collapsible' ).collapse();
} else if ( $element.hasClass( 'innercollapse' ) ) {
if ( $element.parents( '.outercollapse' ).length > 0 ) {
$element.data( 'mw-collapsible' ).collapse();
}
}
// because of colored backgrounds, style the link in the text color
// to ensure accessible contrast
$toggle = $element.find( '.mw-collapsible-toggle' );
if ( $toggle.length ) {
// Make the toggle inherit text color
if( $toggle.parent()[0].style.color ) {
$toggle.find( 'a' ).css( 'color', 'inherit' );
}
}
} );
}
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
/**
* Dynamic Navigation Bars (experimental)
* https://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=554529999
* Description: See [[Wikipedia:NavFrame]].
* Maintainers: UNMAINTAINED
*/
var collapseCaption = 'amaga';
var expandCaption = 'mostra';
/* 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 );
}
}
}
$( createNavigationBarToggleButton );
/**
* Diverses fonctions manipulant les classes
* Utilise des expressions régulières et un cache pour de meilleures perfs
* isClass et whichClass depuis http://fr.wikibooks.org/w/index.php?title=MediaWiki:Common.js&oldid=140211
* hasClass, addClass, removeClass et eregReplace depuis http://drupal.org.in/doc/misc/drupal.js.source.html
* surveiller l'implémentation de .classList http://www.w3.org/TR/2008/WD-html5-diff-20080122/#htmlelement-extensions
*/
function isClass(element, classe) {
return hasClass(element, classe);
}
function whichClass(element, classes) {
var s=" "+element.className+" ";
for(var i=0;i<classes.length;i++)
if (s.indexOf(" "+classes[i]+" ")>=0) return i;
return -1;
}
function hasClass(node, className) {
if (node.className == className) {
return true;
}
var reg = new RegExp('(^| )'+ className +'($| )');
if (reg.test(node.className)) {
return true;
}
return false;
}
function addClass(node, className) {
if (hasClass(node, className)) {
return false;
}
node.className += ' '+ className;
return true;
}
function removeClass(node, className) {
if (!hasClass(node, className)) {
return false;
}
node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className);
return true;
}
function eregReplace(search, replace, subject) {
return subject.replace(new RegExp(search,'g'), replace);
}
/**
* 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' );
/**
* 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.
* Adaptat de la versió anglesa en correspondència amb Plantilla:Enllaç AD i Enllaç AB
*/
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( 'AdQ-' + className ) && InterwikiLinks[i].className.indexOf( 'badge-featuredarticle' ) === -1 ) {
InterwikiLinks[i].className += ' AdQ';
InterwikiLinks[i].title = 'Aquest és un article destacat en aquesta llengua.';
} else if ( document.getElementById( 'AB-' + className ) && InterwikiLinks[i].className.indexOf( 'badge-goodarticle' ) === -1 ) {
InterwikiLinks[i].className += ' AB';
InterwikiLinks[i].title = 'Aquest és un article bo en aquesta llengua.';
}
}
}
}
mw.hook( 'wikipage.content' ).add( LinkFA );
//###### comença codi per a plantilla de diapositives (grups d'imatges) #####
/* actualitzat 28-11-13 de [[de:MediaWiki:Common.js]] s'empra amb la plantilla:Galeria dinàmica d'imatges */
/** Skript für [[Vorlage:Galerie]] */
$(function() {
if (document.URL.match(/printable/g)) return;
function toggleImageFunction(group, remindex, shwindex) {
return function() {
document.getElementById("ImageGroupsGr" + group + "Im" + remindex).style.display = "none";
document.getElementById("ImageGroupsGr" + group + "Im" + shwindex).style.display = "block";
return false;
};
}
var divs = document.getElementsByTagName("div");
var i = 0, j = 0;
var units, search;
var currentimage;
var UnitNode;
for (i = 0; i < divs.length; i++) {
if (divs[i].className !== "ImageGroup") { continue; }
UnitNode = undefined;
search = divs[i].getElementsByTagName("div");
for (j = 0; j < search.length; j++) {
if (search[j].className !== "ImageGroupUnits") { continue; }
UnitNode=search[j];
break;
}
if (UnitNode === undefined) { continue; }
units = [];
for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
var temp = UnitNode.childNodes[j];
if (['center', 'mw-halign-center'].some(function(className) { return temp.classList.contains(className); })) {
units.push(temp);
}
}
var rightlink;
var commentText;
var wrap;
for (j = 0; j < units.length; j++) {
currentimage = units[j];
wrap = document.createElement('div');
wrap.id = "ImageGroupsGr" + i + "Im" + j;
currentimage.parentNode.insertBefore(wrap, currentimage);
wrap.appendChild(currentimage);
var leftlink = document.createElement("a");
if (commentText !== undefined) {
leftlink.setAttribute("title", commentText);
}
var comment;
if (typeof(currentimage.getAttribute("title")) !== "string") {
commentText = (j+1) + "/" + units.length;
comment = document.createElement("tt").appendChild(document.createTextNode("("+ commentText + ")"));
} else {
commentText = currentimage.getAttribute("title");
comment = document.createElement("span").appendChild(document.createTextNode(commentText));
currentimage.removeAttribute("title");
}
if(rightlink !== undefined) {
rightlink.setAttribute("title", commentText);
}
var imghead = document.createElement("div");
rightlink = document.createElement("a");
if (j !== 0) {
leftlink.href = "#";
leftlink.onclick = toggleImageFunction(i, j, j-1);
leftlink.appendChild(document.createTextNode("◀"));
}
if (j !== units.length - 1) {
rightlink.href = "#";
rightlink.onclick = toggleImageFunction(i, j, j+1);
rightlink.appendChild(document.createTextNode("▶"));
}
imghead.style.fontSize = "110%";
imghead.style.fontweight = "bold";
imghead.appendChild(leftlink);
imghead.appendChild(document.createTextNode("\xA0"));
imghead.appendChild(comment);
imghead.appendChild(document.createTextNode("\xA0"));
imghead.appendChild(rightlink);
if (units.length > 1) {
wrap.insertBefore(imghead, wrap.childNodes[0]);
}
if (j !== 0) {
wrap.style.display = "none";
}
}
}
});
//###### finalitza codi per a plantilla de diapositives #####
//================================================================================
//*** force the loading of another JavaScript file (copiat de [[Commons:Common.js]])
// Local Maintainer: [[Commons:User:Dschwen]]
mw.log.deprecate( window, 'includePage', importScript,
'Use importScript instead' );
/**
* Transformar certes pàgines en pàgines de discussió amb la plantilla:pàgina de discussió
* copiat de https://fr.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=98220897
* abans function TransformeEnDiscussion()
*/
$( function() {
if( document.getElementById('transformeEnPageDeDiscussion') ) {
removeClass(document.body, 'ns-subject');
addClass(document.body, 'ns-talk');
}
} );
/** 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() {
var classes = document.getElementsByClassName("wikidatalist");
var cats = mw.config.get('wgCategories');
if (classes.length > 0) {
addEditIntro( "Plantilla:Avís_d'edició_WDlist" );
} else if (cats) {
if ( $.inArray( 'Persones vives', cats ) !== -1 ) {
addEditIntro( "Plantilla:Avís_d'edició_BPV" );
}
}
} );
}
/**
* Inserció de nous botons en la barra d'eines d'edició
*/
var addExtraButtons = function(){
mw.toolbar.addButtons(
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/0/04/Button_array.png',
speedTip: 'Taula',
tagOpen: '{|\n|-\n|\n|\n|}',
tagClose: '',
sampleText: '',
imageId: 'mw-editbutton-array'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/8/88/Btn_toolbar_enum.png',
speedTip: 'Enumeració',
tagOpen: '\n# element 1\n# element 2\n# element 3',
tagClose: '',
sampleText: '',
imageId: 'mw-editbutton-enum'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/1/11/Btn_toolbar_liste.png',
speedTip: 'Llista',
tagOpen: '\n* element A\n* element B\n* element C',
tagClose: '',
sampleText: '',
imageId: 'mw-editbutton-liste'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/9/9e/Btn_toolbar_gallery.png',
speedTip: 'Galeria d\'imatges',
tagOpen: '\n<gallery>\nFitxer:Exemple.jpg|Descripció\nFitxer:Exemple1.jpg|Descripció 1\nFitxer:Exemple2.jpg|Descripció 2\n</gallery>\n',
tagClose: '',
sampleText: '',
imageId: 'mw-editbutton-gallery'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
speedTip: 'Comentari',
tagOpen: '<!--',
tagClose: '-->',
sampleText: '',
imageId: 'mw-editbutton-comment'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/4/47/Button_redir.png',
speedTip: 'Redirecció',
tagOpen: '#REDIRECT[[',
tagClose: ']]',
sampleText: 'pàgina destinació',
imageId: 'mw-editbutton-redir'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png',
speedTip: 'Categoria',
tagOpen: '[[Categoria:',
tagClose: ']]',
sampleText: 'nom de la categoria',
imageId: 'mw-editbutton-category'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/3/3b/Button_template_alt.png',
speedTip: 'Plantilla',
tagOpen: '{{',
tagClose: '}}',
sampleText: 'plantilla o pàgina a incloure',
imageId: 'mw-editbutton-template'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/c/c4/Button_ref.png',
speedTip: 'Referència',
tagOpen: '<ref>',
tagClose: '</ref>',
sampleText: 'referència, citació o enllaç',
imageId: 'mw-editbutton-ref'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/6/64/Buttonrefvs8.png',
speedTip: 'Índex de referències',
tagOpen: '== Referències ==\n{{referències}}',
tagClose: '',
sampleText: '',
imageId: 'mw-editbutton-references'
},
{
imageFile: '//upload.wikimedia.org/wikipedia/commons/b/bb/Seealso.png',
speedTip: 'Seccions annexes',
tagOpen: '== Referències ==\n' +
'{{referències}}\n\n' +
'== Vegeu també ==\n' +
'* [[A omplir]]\n\n' +
'== Enllaços externs ==\n' +
'*\n\n',
tagClose: '',
sampleText: '',
imageId: 'mw-editbutton-voiraussi'
}
);
};
if( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( 'user.options', function () {
if ( ! mw.user.options.get( 'usebetatoolbar' ) && mw.user.options.get( 'showtoolbar' ) ) {
$.when(
mw.loader.using( 'mediawiki.toolbar' ),
$.ready
).then( addExtraButtons );
}
} );
}
/**
* Import more specific scripts if necessary
*/
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
/* watchlist scripts */
importScript( 'MediaWiki:Common.js/watchlist.js' );
}
/**
* Redirect User:Name/skin.js and skin.css to the current skin's pages
* (unless the 'skin' page really exists).
*
* Dependencies: mediawiki.util
*
* @source www.mediawiki.org/wiki/Snippets/Redirect_skin.js
* @revision 2014-05-19
*/
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[0] + '/' + mw.config.get( 'skin' );
if ( titleParts[1] === 'skin.js' ) {
location.href = mw.util.getUrl( userSkinPage + '.js' );
} else if ( titleParts[1] === 'skin.css' ) {
location.href = mw.util.getUrl( userSkinPage + '.css' );
}
}
}
/**
* afegeix un enllaç "nova secció" en l'últim encapçalament de pàgines de discussió
* copiat de https://de.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=153954208
*/
mw.loader.using( [ 'mediawiki.util' ], function() { $( function() {
var newSectionLink = $( '#ca-addsection a' );
if( newSectionLink.length ) {
var link = newSectionLink.clone(); //create a copy
//avoid duplicate accesskey
link.removeAttr( 'accesskey' ).updateTooltipAccessKeys();
// passem "Nova secció" a minúscules per coherència
link.css( {
"text-transform" : "lowercase"
} );
//add it wihin the brackets
var lastEditsectionLink = $( 'span.mw-editsection:last a:last' );
lastEditsectionLink.after( link );
lastEditsectionLink.after( ' | ' ); //see [[MediaWiki:Pipe-separator]]
}
})});
/**
* Description: Stay on the secure server as much as possible
* Copiat de https://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=525198410
*/
if ( document.location && document.location.protocol && document.location.protocol == 'https:' ) {
/* New secure servers */
importScript( 'MediaWiki:Common.js/secure.js' );
}
/**
* Ticker: vegeu [[plantilla:ticker]]
* Adaptat de https://en.wikinews.org/w/index.php?title=MediaWiki:Ticker2.js&oldid=1384515
*/
$(function () {if ((window.disable_ticker2 !== true) && (document.getElementById("singleTickerForPage") || document.getElementById('enableTickers')))
mw.loader.load('//en.wikinews.org/w/index.php?title=MediaWiki:ticker2.js&action=raw&ctype=text/javascript');});
/**
* Simulació d'una pàgina de diferències
* Necessàri per [[VP:BUS]]. TODO: Afegir a Ajuda:Diferències
*/
if ( mw.config.get( 'wgPageName' ) === 'Viquipèdia:Bus_turístic/Earth/4/Diff' ) {
mw.loader.load( 'mediawiki.action.history.diff' );
}
/** Ajusta el ordenamiento alfabético en las tablas "sortable" */
/** https://es.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=90238839 */
(function() {
var letras = [["áàâäãāăåą", "a"], ["æ", "ae"], ["ćĉčç", "c"], ["ďḑđð", "d"], ["éèêëẽěēĕę", "e"],
["ĝḡğģǥ", "g"], ["ĥḧḩħ", "h"], ["íìÎîïĩīĭįı", "i"], ["ĵ", "j"], ["ķ", "k"],
["ĺľļł", "l"], ["ńňņ", "n"], ["ñ", "n~"], ["óòôöõōŏǫőø", "o"], ["œ", "oe"],
["ŕřŗ", "r"], ["śŝšş", "s"], ["ß", "ss"], ["ťţŧ", "t"], ["úùûüũūŭůųű", "u"], ["ṽ", "v"],
["ŵẅ", "w"], ["ẍ", "x"], ["ýŷÿỹ", "y"], ["źẑžƶ", "z"], ["·", ""], ["'", " "]];
var hash = {};
for (var i = 0; i < letras.length; i++) {
var arr = letras[i][0].split("");
var dest = letras[i][1];
for (var j = 0; j < arr.length; j++) {
hash[arr[j]] = dest;
}
}
mw.config.set('tableSorterCollation', hash);
})();
/**
* Script per alternar entre diverses imatges utilitzada a {{switcher2}}
* procedència: [[:fr:special:permalink/165756873]] el 26-07-2020
*/
function GeoBox_Init($content) {
$content.find( 'div.img_toogle' ).each( function ( i, Container ) {
Container.id = 'img_toogle_' + i;
var Boxes = $( Container ).find( '.geobox' );
if (Boxes.length < 2) {
return;
}
var ToggleLinksDiv = document.createElement('ul');
ToggleLinksDiv.id = 'geoboxToggleLinks_' + i;
Boxes.each( function ( a, ThisBox ) {
ThisBox.id = 'geobox_' + i + '_' + a;
var ThisAlt = ThisBox.getElementsByTagName('img')[0].alt;
var toggle = document.createElement('a');
toggle.id = 'geoboxToggle_' + i + '_' + a;
toggle.textContent = ThisAlt;
toggle.href = 'javascript:';
toggle.onclick = function (e) {
e.preventDefault();
GeoBox_Toggle(this);
};
var Li = document.createElement('li');
Li.appendChild(toggle);
ToggleLinksDiv.appendChild(Li);
if (a === (Boxes.length - 1)) {
toggle.style.color = '#888';
toggle.style.pointerEvents = 'none';
} else {
ThisBox.style.display = 'none';
}
} );
Container.appendChild(ToggleLinksDiv);
} );
}
function GeoBox_Toggle(link) {
var ImgToggleIndex = link.id.replace('geoboxToggle_', '').replace(/_.*/g, '');
var GeoBoxIndex = link.id.replace(/.*_/g, '');
var ImageToggle = document.getElementById('img_toogle_' + ImgToggleIndex);
var Links = document.getElementById('geoboxToggleLinks_' + ImgToggleIndex);
var Geobox = document.getElementById('geobox_' + ImgToggleIndex + '_' + GeoBoxIndex);
var Link = document.getElementById('geoboxToggle_' + ImgToggleIndex + '_' + GeoBoxIndex);
if ( !ImageToggle || !Links || !Geobox || !Link ) {
return;
}
$( ImageToggle ).find( '.geobox' ).each( function ( _, ThisgeoBox ) {
if (ThisgeoBox.id === Geobox.id) {
ThisgeoBox.style.display = '';
} else {
ThisgeoBox.style.display = 'none';
}
} );
$( Links ).find( 'a' ).each( function ( _, thisToggleLink ) {
if (thisToggleLink.id === Link.id) {
thisToggleLink.style.color = '#888';
thisToggleLink.style.pointerEvents = 'none';
} else {
thisToggleLink.style.color = '';
thisToggleLink.style.pointerEvents = '';
}
} );
}
mw.hook( 'wikipage.content' ).add( GeoBox_Init );
/* End of mw.loader.using callback */
} );
/* DO NOT ADD CODE BELOW THIS LINE */