//Alias
(function ( $, mw ) {
/**
* 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.
*/
mw.loader.using( 'mediawiki.util', function() {
/* Begin of mw.loader.using callback */
// Funcionalidad
/**
* Redirect User:Name/skin.js and skin.css to the current skin's pages
* (unless the 'skin' page really exists)
* @source: //www.mediawiki.org/wiki/Snippets/Redirect_skin.js
* @rev: 3
*/
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' );
}
}
}
/** &withCSS= and &withJS= URL parameters *******
* Allow to try custom scripts from MediaWiki space
* without editing personal .css or .js files
*/
var extraCSS = mw.util.getParamValue('withCSS'),
extraJS = mw.util.getParamValue('withJS');
if (extraCSS) {
if (extraCSS.match(/^MediaWiki:[^&<>=%#]*\.css$/)) {
mw.loader.load('/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css');
} else {
mw.notify('Solo se pueden cargar páginas del espacio de nombres MediaWiki.', {title: 'Valor withCSS no permitido'});
}
}
if (extraJS) {
if (extraJS.match(/^MediaWiki:[^&<>=%#]*\.js$/)) {
mw.loader.load('/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript');
} else {
mw.notify('Solo se pueden cargar páginas del espacio de nombres MediaWiki.', {title: 'Valor withJS no permitido'});
}
}
// Results from Wikidata
// [[File:Wdsearch_script_screenshot.png]]
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' || ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
mw.loader.load("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
}
//Edición
if ( $.inArray(mw.config.get('wgAction'), ['edit', 'submit'] ) > -1) {
/** Fix edit summary prompt for undo ******************************************
* Fixes the fact that the undo function combined with the "no edit summary prompter"
* causes problems if leaving the edit summary unchanged.
* Added by [[User:Deskana]], code by [[User:Tra]].
* See also [[bugzilla:8912]].
*/
$(document).ready( function () {
if (location.search.indexOf("undo=") != -1 && document.getElementsByName('wpAutoSummary')[0]) {
document.getElementsByName('wpAutoSummary')[0].value = '1';
}
});
/**
* Caracteres especiales (edittools)
* Crea (y coloca) el ''combobox'' que permite seleccionar un conjunto determinado de
* caracteres especiales bajo la caja de edición.
* Funciona en conjunto con [[MediaWiki:Edittools]] y [[MediaWiki:Edittools.js]].
* Basado en [[commons:MediaWiki:Edittools.js]].
*/
mw.loader.load('/w/index.php?title=MediaWiki:Edittools.javascript&action=raw&ctype=text/javascript');
//Seguimiento
} else if (mw.config.get('wgPageName') == 'Especial:Seguimiento') {
mw.loader.load( mw.config.get('wgServer') + mw.config.get('wgScript') +
'?title=MediaWiki:Common.js/seguimiento.js&action=raw&ctype=text/javascript');
}
//Wikibugs
mw.loader.load('/w/index.php?title=MediaWiki:Gadget-Wikibugs.js&action=raw&ctype=text/javascript');
/** 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]]
*/
window.wma_settings = {
buttonImage: "//upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Erioll_world.svg/15px-Erioll_world.svg.png"
};
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript');
/* OpenStreetMap */
mw.config.set( 'osm_proj_map', 'mapa' ); //"map" in project language
mw.config.set( 'osm_proj_lang', 'es' ); //project language
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:OSM.js&action=raw&ctype=text/javascript');
/** Mejoras de diseño de la Portada
*
* Descripción: Varias mejoras de diseño para la portada, incluyendo un
* enlace adicional a la lista completa de idiomas disponibles.
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
* Adaptado de [[en:MediaWiki:Common.js]]
*/
if ($.inArray(mw.config.get('wgPageName'), ['Wikipedia:Portada']) > -1) {
$(document).ready(function () {
mw.util.addPortletLink('p-lang', '//es.wikipedia.org/wiki/Anexo:Wikipedias',
'Lista completa', 'interwiki-completelist', 'Lista completa de Wikipedias');
});
}
// Oculta los resumenes de edición para ciertas páginas
var paginasSinRE = [
"Wikipedia:Tablón_de_anuncios_de_los_bibliotecarios/Portal/Plantillas/Fusión_de_historiales/precarga",
"Wikipedia:Tablón_de_anuncios_de_los_bibliotecarios/Portal/Plantillas/Permisos/precarga",
"Wikipedia:Bot/Solicitudes/Precarga"
];
if ( $.inArray(mw.util.getParamValue('preload'), paginasSinRE ) > -1) {
$(document).ready(function () {
$('#wpSummary').hide();
$('#wpSummaryLabel').hide();
});
}
/*
* Cerrar mensajes
* Ver ejemplo en [[Usuario:Chabacano/Fírmalo]], por [[Usuario:Platonides]].
*/
if (document.getElementById("cierraPadre")) {
$(document).ready(function () {
document.getElementById("cierraPadre").childNodes[0].onclick = function () {
document.getElementById("cierraPadre").style.cursor = 'pointer';
document.getElementById("cierraPadre").parentNode.style.display = 'none';
return false; /*no seguir el href*/
};
});
}
/**
* 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
*
* @param {jQuery} $content
*/
function makeCollapsibleMwCollapsible( $content ) {
var $tables = $content
.find( 'table.collapsible:not(.mw-collapsible)' )
.addClass( 'mw-collapsible' );
$.each( $tables, function ( index, table ) {
if ( $( table ).hasClass( 'collapsed' ) ) {
$( table ).addClass( '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 (Updated for T333357 2023-04-29)
if ( $toggle.parent()[ 0 ].style.color ) {
$toggle.css( 'color', 'inherit' );
$toggle.find( '.mw-collapsible-text' ).css( 'color', 'inherit' );
}
}
} );
}
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
// == Código del plegado/desplegado de plantillas ==
var collapseCaption = 'ocultar';
var expandCaption = 'mostrar';
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';
var NavigationBarShowDefault = 0;
// 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) {
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar),
NavFrame = document.getElementById("NavFrame" + indexNavigationBar),
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;
}
};
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton() {
var indexNavigationBar = 0,
// iterate over all < div >-elements
divs = document.getElementsByTagName("div"),
NavFrame,
NavChild,
i;
for (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', 'javascript:toggleNavigationBar(' + 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),
j;
NavToggle.appendChild(NavToggleText);
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
for (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);
}
}
}
$(document).ready(createNavigationBarToggleButton);
/**
* 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.indexOf( 'badge-featuredarticle' ) === -1 ) {
InterwikiLinks[i].className += ' destacado';
InterwikiLinks[i].title = 'Éste es un artículo destacado en esta Wikipedia.';
} else if ( document.getElementById( className + '-ga' ) && InterwikiLinks[i].className.indexOf( 'badge-goodarticle' ) === -1 ) {
InterwikiLinks[i].className += ' bueno';
InterwikiLinks[i].title = 'Éste es un artículo bueno en esta Wikipedia.';
}
}
}
}
mw.hook( 'wikipage.content' ).add( LinkFA );
/**
* Enlace «sección nueva» junto a «editar» en la última sección de las páginas de discusión.
* Fuente: //de.wikipedia.org/w/index.php?oldid=133547849
*/
$( function() {
var newSectionLink = $( '#ca-addsection a' );
if( newSectionLink.length ) {
var link = newSectionLink.clone(); //create a copy
//avoid duplicate accesskey
link.removeAttr( 'accesskey' ).attr( 'title', function ( index, oldTitle ) {
return oldTitle.replace( /\s*\[.*\]\s*$/, '' );
} );
// con la skin vector se muestra como "Sección nueva", pasamos a minúsculas para integrarlo mejor
link.css( {
"text-transform" : "lowercase"
} );
//add it within the brackets
var lastEditsectionLink = $( 'span.mw-editsection:last a:last' );
lastEditsectionLink.after( link );
lastEditsectionLink.after( ' · ' ); //see [[MediaWiki:Pipe-separator]]
}
} );
/* End of mw.loader.using callback */
});
/* Ordenación de tablas:
* Desde MediaWiki 1.22wmf13 las ordenaciones numéricas funcionan correctamente con nuestros separadores de millares y decimales, sin necesidad de código adicional
* Personalización de la ordenación de fechas:
* Se ordenan según "dd de mm de yy" o "dd de mm de yyyy"
* También reconoce dd-mm-yy, dd-mm-yyyy (y otras variaciones usando / , .)
*/
mw.loader.using( 'jquery.tablesorter', function () {
var ts = $.tablesorter,
monthNames = ["","enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"],
shortMonthNames = ["","ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],
i,
j;
ts.formatDateCustom = function ( s ) {
var match;
s = $.trim( s.toLowerCase() );
s = s.replace( /( de |[\-\.\,' ])/g, '/' );
if ( ( match = s.match( ts.dateRegex[0] ) ) !== null ) {
if ( mw.config.get( 'wgDefaultDateFormat' ) === 'mdy' || mw.config.get( 'wgContentLanguage' ) === 'en' ) {
s = [ match[3], match[1], match[2] ];
} else if ( mw.config.get( 'wgDefaultDateFormat' ) === 'dmy' ) {
s = [ match[3], match[2], match[1] ];
} else {
// If we get here, we don't know which order the dd-dd-dddd
// date is in. So return something not entirely invalid.
return '99999999';
}
} else if ( ( match = s.match( ts.dateRegex[1] ) ) !== null ) {
s = [ match[3], '' + ts.monthNames[match[2]], match[1] ];
} else if ( ( match = s.match( ts.dateRegex[2] ) ) !== null ) {
s = [ match[3], '' + ts.monthNames[match[1]], match[2] ];
} else {
// Should never get here
return '99999999';
}
// Pad Month and Day
if ( s[1].length === 1 ) {
s[1] = '0' + s[1];
}
if ( s[2].length === 1 ) {
s[2] = '0' + s[2];
}
var y;
if ( ( y = parseInt( s[0], 10) ) < 100 ) {
// Guestimate years without centuries
if ( y < 30 ) {
s[0] = 2000 + y;
} else {
s[0] = 1900 + y;
}
}
while ( s[0].length < 4 ) {
s[0] = '0' + s[0];
}
return parseInt( s.join( '' ), 10 );
};
var regex = [];
ts.monthNames = {};
for ( i = 1; i < 13; i++ ) {
var name = monthNames[i].toLowerCase();
ts.monthNames[name] = i;
regex.push( mw.util.escapeRegExp( name ) );
name = shortMonthNames[i].toLowerCase().replace( '.', '' );
ts.monthNames[name] = i;
regex.push( mw.util.escapeRegExp( name ) );
}
regex = regex.join( '|' );
ts.dateRegexCustom = new RegExp( "^\\d\\d?\\sde\\s(" + regex + ")\\sde\\s\\d{2,4}$" );
ts.addParser( {
id: 'dateCustom',
is: function( s ) {
return ( $.tablesorter.dateRegexCustom.test(s) );
},
format: function( s ) {
return $.tablesorter.formatDateCustom( s );
},
type: 'numeric'
});
/* End of mw.loader.using callback */
});
/** Ajusta el ordenamiento alfabético en las tablas "sortable" */
(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);
})();
/* Fin de alias */
})( jQuery, mediaWiki );