/* Calquera JavaScript que haxa aquí será cargado para todos os usuarios en cada páxina que vexan. */
// import scripts for Interwiki Transclusion from http://wikisource.org/wiki/Wikisource:Shared_Scripts
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:InterWikiTransclusion.js&action=raw&ctype=text/javascript');
/* O seguinte código foi importado dende a wikipedia - 15/01/2016 */
/**
* 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', 'jquery.client'], function () {
/* Inicio da chamada de retorno ao mw.loader.using */
/**
* Arranxos na Portada
*
* Descrición: Engade unha ligazón adicional cara á lista completa de linguas dispoñibles.
* Traído de [[en:MediaWiki:Common.js]]. Mantido por [[en:User:AzaToth]], [[en:User:R. Koot]] e [[en:User:Alex Smotrov]]
*/
if ( mw.config.get( 'wgPageName' ) === 'Portada' || mw.config.get( 'wgPageName' ) === 'Conversa:Portada' ) {
$( document ).ready( function () {
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/Wikiquote',
'Lista completa', 'interwiki-completelist', 'Lista completa de Wikisources' );
} );
}
/**
* Caixa de Descrición en páxina de carga de ficheiros
*
* Descrición: Chama a [[Mediawiki:Upload.js]] para engadir o texto predefinido
* para o [[Modelo:Information]] na caixa de texto de "Descrición" na
* páxina de carga de ficheiros [[Especial:Subir]]
*
* Traído de [[nl:MediaWiki:Common.js]].
*/
if (mw.config.get('wgPageName') === 'Especial:Subir') {
importScript('MediaWiki:Upload.js');
}
/**
* Redirixir Usuario:Nome/skin.js e skin.css ás páxinas de aparencia actuais
* (agás que a subpáxina "skin" exista)
* @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' );
}
}
}
/**
* @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( 'Só están permitidas as páxinas do espazo de nomes MediaWiki.', { title: 'Valor withCSS non válido' } );
}
}
// JS
var extraJS = mw.util.getParamValue( 'withJS' );
if ( extraJS ) {
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
importScript( extraJS );
} else {
mw.notify( 'Só están permitidas as páxinas do espazo de nomes MediaWiki.', { title: 'Valor withJS non válido' } );
}
}
/**
* Arranxo para a renderización de fontes Unicode en Windows XP
*/
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
*
* Descrición: WikiMiniAtlas é un mapa mundial nunha ventá emerxente.
* Este script provoca que todas as ligazóns de coordenadas mostren o botón de WikiMiniAtlas.
* O script en si está localizado en Meta-Wiki porque moitos proxectos fan uso del.
* Véxase [[meta:WikiMiniAtlas]] para obter máis información.
* Traído de [[en:MediaWiki:Common.js]]. Mantido por [[en:User:Dschwen]]
*/
( function () {
var require_wikiminiatlas = false;
var coord_filter = /geohack/;
$( document ).ready( 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' );
}
} );
} )();
/**
* Táboas contraíbles
*
* Descrición: Permite que as táboas se poidan contraer, mostrando só a cabeceira.
* Véxase [[en:Wikipedia:NavFrame]].
* Traído de [[en:MediaWiki:Common.js]]. Mantido por [[en:User:R. Koot]]
*/
var autoCollapse = 2;
var collapseCaption = 'agochar';
var expandCaption = 'amosar';
window.collapseTable = function ( 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 createCollapseButtons() {
var tableIndex = 0;
var NavigationBoxes = {};
var Tables = document.getElementsByTagName( 'table' );
var i;
function handleButtonLink( index, e ) {
window.collapseTable( index );
e.preventDefault();
}
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 );
Button.className = 'collapseButton'; /* Os estilos están declarados en [[MediaWiki:Common.css]] */
ButtonLink.style.color = Header.style.color;
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
ButtonLink.setAttribute( 'href', '#' );
$( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, 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' ) ) ) {
window.collapseTable( i );
}
else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
var element = NavigationBoxes[i];
while ((element = element.parentNode)) {
if ( $( element ).hasClass( 'outercollapse' ) ) {
window.collapseTable ( i );
break;
}
}
}
}
}
$( createCollapseButtons );
/**
* Barras de navegación dinámicas (experimental)
*
* Descrición: Véxase [[en:Wikipedia:NavFrame]].
* Traído de [[en:MediaWiki:Common.js]]. Mantido por NINGUÉN
*/
/* Definir as parabras na lingua do usuario */
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';
/**
* Mostra e agocha o contido e imaxes (se están dispoñibles) das barras de navegación
* Parámetros:
* indexNavigationBar: O índice da barra de navegación a alternar
**/
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
var NavChild;
if ( !NavFrame || !NavToggle ) {
return false;
}
/* Se se mostra agora */
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;
/* Se está agochado agora */
} 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();
};
/* Engade un botón "amosar"/"agochar" ás barras de navegación */
function createNavigationBarToggleButton() {
var indexNavigationBar = 0;
var NavFrame;
var NavChild;
/* Iterar sobre todos os elementos < div > */
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 );
/**
* Descrición: Desactivar o botón "Gardar a páxina" aos usuarios anónimos
* que non usen antes o botón "Mostrar a vista previa".
* Véxase [[mw:Manual:Force preview]].
* Traído de [[fr:MediaWiki:Common.js/edit.js]]. Author: Marc Mongenet, 2006 (fr.wikipedia.org)
*/
function forcePreview() {
if (mw.config.get('wgUserName') != null || mw.config.get('wgAction') != "edit") return;
var saveButton = document.getElementById("wpSave");
if (!saveButton) return;
saveButton.disabled = true;
saveButton.value = "Gardar (use antes a vista previa!)";
saveButton.style.fontWeight = "normal";
document.getElementById("wpPreview").style.fontWeight = "bold";
}
$(forcePreview);
function eregReplace(search, replace, subject) {
return subject.replace(new RegExp(search,'g'), replace);
}
/**
* Descrición: Mostra as categorías ocultas aos usuarios rexistrados,
* engadindo a función "[amosar]".
* Traído de [[fr:MediaWiki:Common.js]].
*/
function hiddencat(){
if(typeof(DesactiveHiddenCat)!="undefined" && DesactiveHiddenCat) return;
if(document.URL.indexOf("printable=yes")!=-1) return;
var cl = document.getElementById('catlinks'); if(!cl) return;
if( !(hc = document.getElementById('mw-hidden-catlinks')) ) return;
if( $(hc).hasClass('mw-hidden-cats-user-shown') ) return;
if( $(hc).hasClass('mw-hidden-cats-ns-shown') ) $(hc).addClass('mw-hidden-cats-hidden');
var nc = document.getElementById('mw-normal-catlinks');
if( !nc ) {
var catline = document.createElement('div');
catline.id = 'mw-normal-catlinks';
var a = document.createElement('a');
a.href = '/wiki/Categoría:Índice';
a.title = 'Categoría:Índice';
a.appendChild(document.createTextNode('Categorías'));
catline.appendChild(a);
catline.appendChild(document.createTextNode(' : '));
nc = cl.insertBefore(catline, cl.firstChild);
}
else nc.appendChild(document.createTextNode(' | '));
var lnk = document.createElement('a');
lnk.id = 'mw-hidden-cats-link';
lnk.title = 'Este artigo contén categorías ocultas';
lnk.style.cursor = 'pointer';
lnk.style.color = 'black';
lnk.onclick = toggleHiddenCats;
lnk.appendChild(document.createTextNode('[amosar]'));
hclink = nc.appendChild(lnk);
}
function toggleHiddenCats(){
if( $(hc).hasClass('mw-hidden-cats-hidden') ) {
$(hc).removeClass('mw-hidden-cats-hidden');
$(hc).addClass('mw-hidden-cat-user-shown');
$(hclink).text('[agochar]');
} else {
$(hc).removeClass('mw-hidden-cat-user-shown');
$(hc).addClass('mw-hidden-cats-hidden');
$(hclink).text('[amosar]');
}
}
$(hiddencat);
/**
* Ticker: ver [[Modelo:ticker]]
* Adaptado 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');});
/* Fin da chamada de retorno ao mw.loader.using */
} );
/* NON ENGADAS NINGÚN CÓDIGO POR DEBAIXO DESTA LIÑA */