Diferencia entre revisiones de «MediaWiki:Common.js»

7724 bytes eliminados ,  hace 13 años
probando esto
(ordenando)
(probando esto)
/* Any JavaScript here will be loaded for all users on every page load. */
/** Execute function on page load *********************************************
*
* Description: Wrapper around addOnloadHook() for backwards compatibility.
* Will be removed in the near future.
* Maintainers: [[User:R. Koot]]
*/
function addLoadEvent( f ) { addOnloadHook( f ); }
 
/*
/** Import module *************************************************************
<pre>
*
*/
* Description: Includes a raw wiki page as javascript or CSS,
 
* used for including user made modules.
// The function looks for a banner like that:
* Maintainers: [[User:AzaToth]]
// <div id="RealTitleBanner">Div that is hidden
*/
// <span id="RealTitle">title</span>
// </div>
importedScripts = {}; // object keeping track of included scripts, so a script ain't included twice
// An element with id=DisableRealTitle disables the function.
function importScript( page ) {
rewritePageH1 = function() {
if( importedScripts[page] ) {
try {
return;
var realTitleBanner = document.getElementById("RealTitleBanner");
}
if (realTitleBanner) {
importedScripts[page] = true;
if (!document.getElementById("DisableRealTitle")) {
var url = wgScriptPath + '/index.php?title='
var realTitle = document.getElementById("RealTitle");
+ escape( page.replace( ' ', '_' ) )
var h1 = document.getElementsByTagName("h1")[0];
+ '&action=raw&ctype=text/javascript&dontcountme=s';
if (realTitle && h1) {
var scriptElem = document.createElement( 'script' );
h1.innerHTML = realTitle.innerHTML;
scriptElem.setAttribute( 'src' , url );
realTitleBanner.style.display = "none";
scriptElem.setAttribute( 'type' , 'text/javascript' );
document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );
}
function importStylesheet( page ) {
var sheet = '@import "'
+ wgScriptPath
+ '/index.php?title='
+ escape( page.replace( ' ', '_' ) )
+ '&action=raw&ctype=text/css";'
var styleElem = document.createElement( 'style' );
styleElem.setAttribute( 'type' , 'text/css' );
styleElem.appendChild( document.createTextNode( sheet ) );
document.getElementsByTagName( 'head' )[0].appendChild( styleElem );
}
 
/* Test if an element has a certain class **************************************
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
*/
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();
 
/** Internet Explorer bug fix **************************************************
*
* Description: UNDOCUMENTED
* Maintainers: [[User:Tom-]]?
*/
if (window.showModalDialog && document.compatMode && document.compatMode == "CSS1Compat")
{
var oldWidth;
var docEl = document.documentElement;
function fixIEScroll()
{
if (!oldWidth || docEl.clientWidth > oldWidth)
doFixIEScroll();
else
setTimeout(doFixIEScroll, 1);
oldWidth = docEl.clientWidth;
}
function doFixIEScroll() {
docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
}
document.attachEvent("onreadystatechange", fixIEScroll);
attachEvent("onresize", fixIEScroll);
}
} catch (e) {
 
/* Something went wrong. */
 
/** 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;
}
}
}
addOnloadHook(rewritePageH1);
function createCollapseButtons()
{
var tableIndex = 0;
var NavigationBoxes = new Object();
var Tables = document.getElementsByTagName( "table" );
for ( var i = 0; i < Tables.length; i++ ) {
if ( hasClass( Tables[i], "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 ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
collapseTable( i );
}
}
}
addOnloadHook( createCollapseButtons );
 
/*
//fix edit summary prompt for undo
</pre>
//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]]
addOnloadHook(function () {
if (document.location.search.indexOf("undo=") != -1
&& document.getElementsByName('wpAutoSummary')[0]) {
document.getElementsByName('wpAutoSummary')[0].value='';
}
})
 
/*
 
== Controle de imagem ofensiva ==
/* Els JavaScripts d'aquesta pàgina es carregaran per tots els usuaris independentment de la seva configuració. */
<pre>
 
/*<pre>*/
 
 
/* Funcionament de la Plantilla:Metacaixa
Implementat per: Usuari:Peleguer.
Actualitzat per Joanjoc seguint les indicacions d'en Martorell
*/
 
// Desenvolvido por Voz da Verdade 27/jan/2007
function MetaCaixaInit(){
//S'executa al carregar-se la pàgina, si hi han metacaixes,
// s'assignen els events als botons
//alert("MetaCaixaInit");
var i=0 //Inicalitzem contador 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 //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;
//alert("MetaCaixaInit, trobat botó mc"+i+"bt"+j);
vBt.onclick = MetaCaixaMostraPestanya; //A cada botó assignem l'event 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ó, 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
//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 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
}
addLoadEvent(MetaCaixaInit);
 
function AvisAdminsVandApagarAvisoImagemOfensiva(){
var aviso01=document.getElementById("imagemOfensiva01");
{
aviso01.style.display = 'none';
var url_name = 'http://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|]].--~~~~";
text_area.value = comment;
document.editform.wpSummary.value="Avís de vandalisme en curs!!!";
}
 
function criarBtnMostraImgOfensiva()
addLoadEvent(AvisAdminsVand);
{
var aviso02=document.getElementById("imagemOfensiva02");
var botaoImgOfensiva = document.createElement("a");
var pularLinha = document.createElement("br");
botaoImgOfensiva.className = 'btnMostraImagemOfensiva';
botaoImgOfensiva.setAttribute('href', 'javascript:mostrarImagemOfensiva();');
var textoMostraImgOfensiva = document.createTextNode('Mostrar imagem');
botaoImgOfensiva.appendChild(pularLinha);
botaoImgOfensiva.appendChild(textoMostraImgOfensiva);
aviso02.appendChild(botaoImgOfensiva);
var apagarEsteAviso = document.createElement("a");
apagarEsteAviso.setAttribute('href','javascript:ApagarAvisoImagemOfensiva();');
var textoApagarAvisoImgOfensiva = document.createTextNode('Ocultar');
var pularLinha2 = document.createElement("br");
apagarEsteAviso.appendChild(pularLinha2);
apagarEsteAviso.appendChild(textoApagarAvisoImgOfensiva);
aviso02.appendChild(apagarEsteAviso);
 
}
 
function mostrarImagemOfensiva(){
/*</pre>*/
var aviso01=document.getElementById("imagemOfensiva01");
 
aviso01.style.display = 'none';
/*
var aviso03=document.getElementById("imagemOfensiva03");
== Búsqueda especial extendida (specialsearch) ==
aviso03.style.display = 'block';
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]].
<pre><nowiki>*/
 
hookEvent("load", criarBtnMostraImgOfensiva);
importScript ('MediaWiki:SpecialSearch.js');
 
/* </nowikipre>< */pre>
435

ediciones