MediaWiki:Common.js
Nota: Después de publicar, quizás necesite actualizar la caché de su navegador para ver los cambios.
- Firefox/Safari: Mantenga presionada la tecla Shift mientras pulsa el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
- Google Chrome: presione Ctrl+Shift+R (⌘+Shift+R en Mac)
- Internet Explorer/Edge: mantenga presionada Ctrl mientras pulsa Actualizar, o presione Ctrl+F5
- Opera: Presiona Ctrl+F5.
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* [[Wikipedia:NavFrame]].
* Maintainers: [[User:R. Koot]]
*/
var autoCollapse = 2;
var collapseCaption = 'ocultar';
var expandCaption = 'mostrar';
function collapseTable( tableIndex ) {
var Button = document.getElementById( 'collapseButton' + tableIndex );
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.getElementsByTagName( 'tr' );
if ( Button.firstChild.data == collapseCaption ) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = 'none';
}
Button.firstChild.data = expandCaption;
} else {
for ( var 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 = new Object();
var Tables = document.getElementsByTagName( 'table' );
for ( var i = 0; i < Tables.length; i++ ) {
if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
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.style.styleFloat = 'right';
Button.style.cssFloat = 'right';
Button.style.fontWeight = 'normal';
Button.style.textAlign = 'right';
Button.style.width = '6em';
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
ButtonLink.setAttribute( 'href', 'javascript:collapseTable(' + tableIndex + ');' );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( '[' ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( ']' ) );
var Header = Tables[i].getElementsByTagName( 'tr' )[0].getElementsByTagName( 'th' )[0];
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
for ( var i = 0; i < tableIndex; i++ ) {
if (
$( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )
)
{
collapseTable( i );
}
}
}
$( document ).ready( createCollapseButtons );
// fix edit summary prompt for undo
// this code fixes the fact that the undo function combined with the "no edit summary prompter" causes problems if leaving the
// edit summary unchanged
// this was added by [[User:Deskana]], code by [[User:Tra]]
$( document ).ready( function() {
if (
document.location.search.indexOf( 'undo=' ) != -1 &&
document.getElementsByName( 'wpAutoSummary' )[0]
)
{
document.getElementsByName( 'wpAutoSummary' )[0].value = '';
}
} );
/* 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 han metacaixes,
// s'assignen els events als botons
var i = 0; // Inicalitzem contador de caixes
for ( i = 0; i <= 9; i++ ) {
var vMc = document.getElementById( 'mc' + i );
if ( !vMc ) {
break;
}
var j = 1; //Inicalitzem contador 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;
}
vBt.onclick = MetaCaixaMostraPestanya; // A cada botó assignem l'event onclick
if ( vBt.className == 'mcBotoSel' ) {
vPsIni = j; // Si tenim un botó seleccionat, en guardem l'index
}
}
if ( vPsIni == 0 ) { // Si no tenim cap botó seleccionat, n'agafem un aleatòriament
vPsIni = 1 + Math.floor( ( j - 1 ) * Math.random() );
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ó, deduim 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
var vPsElem = document.getElementById( vMcNom + 'ps' + i );
if ( !vPsElem ) {
break;
}
if ( vIndex == i ) { // Si és la pestanya bona la mostrem i canviem la classe la boto
vPsElem.style.display = 'block';
vPsElem.style.visibility = 'visible';
document.getElementById( vMcNom + 'bt' + i ).className = 'mcBotoSel';
} else { // Sinó, la ocultem i canviem la classe la boto
vPsElem.style.display = 'none';
vPsElem.style.visibility = 'hidden';
document.getElementById( vMcNom + 'bt' + i ).className = 'mcBoto';
}
}
return false; // evitem que es recarregui la pàgina
}
$( document ).ready( MetaCaixaInit );
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]].--[[Usuario:Ruslik0|Ruslik0]] ([[Usuario discusión:Ruslik0|discusión]]) 13:12 19 oct 2014 (UTC)";
text_area.value = comment;
document.editform.wpSummary.value = 'Avís de vandalisme en curs!!!';
}
$( document ).ready( AvisAdminsVand );
/*
== Búsqueda especial extendida (specialsearch) ==
Añade a la página [[Special:Search]] enlaces a buscadores externos como Yahoo, Google, MSN Live y Exalead.
Trabaja en conjunto con el módulo [[w:es:MediaWiki:SpecialSearch.js]] y está basado en [[w:fr:MediaWiki:Monobook.js]].
*/
importScript( 'MediaWiki:SpecialSearch.js' );
/**
* @source https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
* @revision 2017-05-16
*/
mw.loader.using( ['mediawiki.util'], function () {
var extraCSS = mw.util.getParamValue( 'withCSS' ),
extraJS = mw.util.getParamValue( 'withJS' );
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' } );
}
}
});