Cimitero:MediaWiki:Common.js: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Contenuto aggiunto Contenuto cancellato
m (Annullata la modifica 1599428 di Sanjilops (discussione)) |
(ma funziona o no??? cazzo!!!!) |
||
Riga 1 686: | Riga 1 686: | ||
addOnloadHook(facebooklikeboxTEST); |
addOnloadHook(facebooklikeboxTEST); |
||
} |
|||
/************************** MONOBOOK.JS *******************************/ |
|||
/************ SPOSTATO QUI FINO A RISOLUZIONE DEL PROBLEMA ************/ |
|||
/************************ OnloadHooks ************/ |
|||
/* Funzioni generali */ |
|||
function hooks_monobook () { |
|||
addeditintro(); |
|||
hooks_monobook_render (); |
|||
communitya (); |
|||
sharelinks(); |
|||
search_thumb(); |
|||
ShoutBox_load(); |
|||
return; |
|||
} |
|||
addOnloadHook(hooks_monobook); |
|||
/* Funzioni del rendering - separate per richiamarle in anteprima rapida */ |
|||
function hooks_monobook_render () { |
|||
addCss(); |
|||
hideEdit(); |
|||
rewriteTitle(); |
|||
change_subtitle(); |
|||
moveeditsection(); |
|||
sectionzero_editlink(); |
|||
jsLoading(); // dev'essere sempre l'ultima!! |
|||
return; |
|||
} |
|||
/* Funzioni dell'editor */ |
|||
function hooks_monobook_edit () { |
|||
if (wgAction != 'edit' && wgAction != 'submit') return; |
|||
Quick_Editor(); |
|||
// vandal_block_load(); |
|||
return; |
|||
} |
|||
addOnloadHook(hooks_monobook_edit); |
|||
/* Codice per far scomparire tasto modifica in articoli da cancellare */ |
|||
/* Per disabilitarlo: aggiungere nel proprio monobook.js la riga */ |
|||
/* disablehideEdit = 1; */ |
|||
var disablehideEdit = 0; |
|||
function hideEdit () { |
|||
if(disablehideEdit) return; |
|||
if (!document.getElementById('ca-edit') || !document.getElementById('hide-edit')) return; |
|||
editLink = document.getElementById('ca-edit').firstChild; |
|||
editLink.removeAttribute('href', 0); |
|||
editLink.style.color = 'gray'; |
|||
editLink.innerHTML = 'X'; |
|||
return; |
|||
} |
|||
/* Reskin parser */ |
|||
/* Permette di personalizzare il foglio di stile di una pagina */ |
|||
/* Utilizzato da Template:Css */ |
|||
var disableaddCss = 0; |
|||
function addCss () { |
|||
if(disableaddCss) return; |
|||
var Css = document.getElementById('add-css'); |
|||
if (!Css) return; |
|||
// aggiungo l'eventuale stile esterno (linked): |
|||
var linkElem = document.createElement( 'link' ); |
|||
linkElem.type = 'text/css'; |
|||
linkElem.rel = 'stylesheet'; |
|||
linkElem.href = '/index.php?title=Nonciclopedia:Skin/' + Css.innerHTML + '.css&action=raw&ctype=text/css&smaxage=120'; |
|||
linkElem.id = "add-css-link"; |
|||
document.getElementsByTagName( 'head' )[0].appendChild( linkElem ); |
|||
return; |
|||
} |
|||
/* Funzioni per impedire svuotamenti di massa da parte dei vandali */ |
|||
var VB_code = false; |
|||
function vandal_block_load () { |
|||
if ((wgAction != 'edit' && wgAction != 'submit') || wgArticleId == 0 || wgPageName == "Nonciclopedia:Sandbox" || wgPageName == "Template:Prova" || ((wgNamespaceNumber == 2 || wgNamespaceNumber == 3) && RegExp("^" + wgUserName + "/?").test(wgTitle))) return false; /* non si attiva su pagine inesistenti, sandbox e sulle proprie pagine utenti e discussioni */ |
|||
if (wgUserGroups) { |
|||
if(wgUserGroups.join().indexOf("emailconfirmed") != -1 && wgUserGroups.join().indexOf("autoconfirmed") != -1) return false; |
|||
} |
|||
VB_code = document.getElementById('wpTextbox1').value; |
|||
if (VB_code.length == 0) return false; |
|||
var button = document.getElementById('wpSave'); |
|||
button.onclick = vandal_block; |
|||
return; |
|||
} |
|||
function vandal_block () { |
|||
var textbox = document.getElementById('wpTextbox1'); |
|||
if (/\{\{\s*(cancellazione|scadenza|accusa).*\}\}\n/i.test(VB_code)) { |
|||
var template = /\{\{\s*(cancellazione|scadenza|accusa).*\}\}\n/i.exec(VB_code); |
|||
if (template != null && textbox.value.indexOf(template) == -1) textbox.value = template + '\n' + textbox.value; /* rimette i template quando vengono rimossi */ |
|||
} |
|||
var is_section = /§ion=\d/.test(location.search); |
|||
if (textbox.value.length/VB_code.length > 0.5 || (!is_section && /^#\s?REDIRECT/i.test(textbox.value))) return; /* il blocco scatta per riduzioni del testo superiori al 50%; eccezione per i redirect */ |
|||
if (textbox.value.length/VB_code.length < 0.2 && !is_section) { |
|||
alert("Questo potrebbe essere un vandalismo. Il salvataggio verrà annullato"); |
|||
textbox.value = VB_code; |
|||
return; |
|||
} |
|||
var n1 = Math.round(Math.random() * 9000) + 1000; |
|||
var n2 = Math.round(Math.random() * 9000) + 1000; |
|||
var answer = prompt("Attenzione: questo potrebbe essere un vandalismo. Rispondi correttamente alla domanda per continuare. Per evitare questo passaggio, registrati e conferma la registrazione via mail.\n\nQuanto fa " + n1 + " + " + n2 + " ?", ''); |
|||
if (answer == null || answer.match(/\d+/) != n1 + n2) { |
|||
alert("Risposta non corretta. Il salvataggio verrà annullato"); |
|||
textbox.value = VB_code; |
|||
return; |
|||
} |
|||
alert("Se sei un vandalo, sappi che la tua modifica verrà annullata entro un minuto. Lascia perdere e trovati un altro passatempo. Se invece non sei un vandalo, registrati, o conferma la registrazione con la mail."); |
|||
return; |
|||
} |
|||
/** Extra toolbar options ****************************************************** |
|||
* |
|||
* Description: UNDOCUMENTED |
|||
* Maintainers: [[User:MarkS]]?, [[User:Voice of All]], [[User:R. Koot]] |
|||
*/ |
|||
//This is a modified copy of a script by User:MarkS for extra features added by User:Voice of All. |
|||
// This is based on the original code on Wikipedia:Tools/Editing tools |
|||
// To disable this script, add <code>mwCustomEditButtons = [];<code> to [[Special:Mypage/monobook.js]] |
|||
if (mwCustomEditButtons) { |
|||
mwCustomEditButtons[mwCustomEditButtons.length] = { |
|||
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/0/0c/Button_P_template.png", |
|||
"speedTip": "Template", |
|||
"tagOpen": "{{", |
|||
"tagClose": "}" + "}", |
|||
"sampleText": "Template"}; |
|||
mwCustomEditButtons[mwCustomEditButtons.length] = { |
|||
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/0/05/Button_Anf%C3%BChrung.png", |
|||
"speedTip": "Citazione", |
|||
"tagOpen": "{{Cit|", |
|||
"tagClose": "|Testo sotto}" + "}", |
|||
"sampleText": "Testo citazione"}; |
|||
} |
|||
/*************** INIZIO CATEGORYTREE *****************/ |
|||
/* Messaggi in italiano */ |
|||
var categoryTreeCollapseMsg = "comprimi"; |
|||
var categoryTreeExpandMsg = "espandi"; |
|||
var categoryTreeCollapseBulletMsg = "[\x3cb\x3e−\x3c/b\x3e]"; |
|||
var categoryTreeExpandBulletMsg = "[\x3cb\x3e+\x3c/b\x3e]"; |
|||
var categoryTreeLoadMsg = "carica"; |
|||
var categoryTreeLoadingMsg = "caricamento in corso"; |
|||
var categoryTreeNothingFoundMsg = "nessun risultato"; |
|||
var categoryTreeNoSubcategoriesMsg = "nessuna sottocategoria."; |
|||
var categoryTreeNoParentCategoriesMsg = "nessuna categoria superiore"; |
|||
var categoryTreeNoPagesMsg = "nessuna voce né sottocategoria."; |
|||
var categoryTreeErrorMsg = "Problema nel caricamento dei dati."; |
|||
var categoryTreeRetryMsg = "Attendere un momento e riprovare."; |
|||
/* Codice */ |
|||
function categoryTreeNextDiv(e) { |
|||
var n= e.nextSibling; |
|||
while ( n && ( n.nodeType != 1 || n.nodeName != 'DIV') ) { |
|||
//alert('nodeType: ' + n.nodeType + '; nodeName: ' + n.nodeName); |
|||
n= n.nextSibling; |
|||
} |
|||
return n; |
|||
} |
|||
function categoryTreeExpandNode(cat, options, lnk) { |
|||
var div= categoryTreeNextDiv( lnk.parentNode.parentNode ); |
|||
div.style.display= 'block'; |
|||
lnk.innerHTML= categoryTreeCollapseBulletMsg; |
|||
lnk.title= categoryTreeCollapseMsg; |
|||
lnk.onclick= function() { categoryTreeCollapseNode(cat, options, lnk) } |
|||
if (!lnk.className.match(/(^| )CategoryTreeLoaded($| )/)) { |
|||
categoryTreeLoadNode(cat, options, lnk, div); |
|||
} |
|||
} |
|||
function categoryTreeCollapseNode(cat, options, lnk) { |
|||
var div= categoryTreeNextDiv( lnk.parentNode.parentNode ); |
|||
div.style.display= 'none'; |
|||
lnk.innerHTML= categoryTreeExpandBulletMsg; |
|||
lnk.title= categoryTreeExpandMsg; |
|||
lnk.onclick= function() { categoryTreeExpandNode(cat, options, lnk) } |
|||
} |
|||
function categoryTreeLoadNode(cat, options, lnk, div) { |
|||
div.style.display= 'block'; |
|||
lnk.className= 'CategoryTreeLoaded'; |
|||
lnk.innerHTML= categoryTreeCollapseBulletMsg; |
|||
lnk.title= categoryTreeCollapseMsg; |
|||
lnk.onclick= function() { categoryTreeCollapseNode(cat, options, lnk) } |
|||
categoryTreeLoadChildren(cat, options, div) |
|||
} |
|||
function categoryTreeEncodeValue(value) { |
|||
switch (typeof value) { |
|||
case 'function': |
|||
throw new Error("categoryTreeEncodeValue encountered a function"); |
|||
break; |
|||
case 'string': |
|||
s = '"' + value.replace(/([\\"'])/g, "\\$1") + '"'; |
|||
break; |
|||
case 'number': |
|||
case 'boolean': |
|||
case 'null': |
|||
s = String(value); |
|||
break; |
|||
case 'object': |
|||
if ( !value ) { |
|||
s = 'null'; |
|||
} |
|||
else if (typeof value.length === 'number' && !(value.propertyIsEnumerable('length'))) { |
|||
s = ''; |
|||
for (i = 0; i<value.length; i++) { |
|||
v = value[i]; |
|||
if ( s!='' ) s += ', '; |
|||
s += categoryTreeEncodeValue( v ); |
|||
} |
|||
s = '[' + s + ']'; |
|||
} |
|||
else { |
|||
s = ''; |
|||
for (k in value) { |
|||
v = value[k]; |
|||
if ( s!='' ) s += ', '; |
|||
s += categoryTreeEncodeValue( k ); |
|||
s += ': '; |
|||
s += categoryTreeEncodeValue( v ); |
|||
} |
|||
s = '{' + s + '}'; |
|||
} |
|||
break; |
|||
default: |
|||
throw new Error("categoryTreeEncodeValue encountered strange variable type " + (typeof value)); |
|||
} |
|||
return s; |
|||
} |
|||
function categoryTreeLoadChildren(cat, options, div) { |
|||
div.innerHTML= '<i class="CategoryTreeNotice">' + categoryTreeLoadingMsg + '</i>'; |
|||
if ( typeof options == "string" ) { //hack for backward compatibility |
|||
options = { mode : options }; |
|||
} |
|||
function f( request ) { |
|||
if (request.status != 200) { |
|||
div.innerHTML = '<i class="CategoryTreeNotice">' + categoryTreeErrorMsg + ' </i>'; |
|||
var retryLink = document.createElement('a'); |
|||
retryLink.innerHTML = categoryTreeRetryMsg; |
|||
retryLink.onclick = function() { |
|||
categoryTreeLoadChildren(cat, options, div, enc); |
|||
} |
|||
div.appendChild(retryLink); |
|||
return; |
|||
} |
|||
result= request.responseText; |
|||
result= result.replace(/^\s+|\s+$/, ''); |
|||
if ( result == '' ) { |
|||
result= '<i class="CategoryTreeNotice">'; |
|||
if ( options.mode == 0 ) result= categoryTreeNoSubcategoriesMsg; |
|||
else if ( options.mode == 10 ) result= categoryTreeNoPagesMsg; |
|||
else if ( options.mode == 100 ) result= categoryTreeNoParentCategoriesMsg; |
|||
else result= categoryTreeNothingFoundMsg; |
|||
result+= '</i>'; |
|||
} |
|||
result = result.replace(/##LOAD##/g, categoryTreeExpandMsg); |
|||
div.innerHTML= result; |
|||
if(wgAction == 'edit' || wgAction == 'submit') { |
|||
var links = div.getElementsByTagName('a'); |
|||
var l, i=0; |
|||
for (i in links) { |
|||
l = links[i]; |
|||
if (!(/CategoryTreeLabelCategory/.test(l.className))) continue; |
|||
l.setAttribute('onclick', "this.href='javascript:void(0)'; insertTags('[[Categoria:" + l.innerHTML + "]]', '', '');"); |
|||
l.title = "Clicca per inserire"; |
|||
} |
|||
} |
|||
} |
|||
var opt = categoryTreeEncodeValue(options); |
|||
sajax_do_call( "efCategoryTreeAjaxWrapper", [cat, opt, 'json'] , f ); |
|||
} |
|||
/************ FINE CATEGORYTREE ****************/ |
|||
/* |
|||
== Tooltips and access keys == |
|||
*/ |
|||
ta = new Object(); |
|||
ta['pt-userpage'] = new Array('.','La tua pagina utente'); |
|||
ta['pt-anonuserpage'] = new Array('.','La pagina utente di questo indirizzo IP'); |
|||
ta['pt-mytalk'] = new Array('n','La tua pagina di discussione'); |
|||
ta['pt-anontalk'] = new Array('n','Discussioni sulle modifiche fatte da questo indirizzo IP'); |
|||
ta['pt-preferences'] = new Array('','Le tue preferenze'); |
|||
ta['pt-watchlist'] = new Array('l','La lista delle pagine che stai tenendo sotto osservazione'); |
|||
ta['pt-mycontris'] = new Array('y','L\'elenco dei tuoi contributi'); |
|||
ta['pt-login'] = new Array('o','La registrazione è consigliata, anche se non obbligatoria'); |
|||
ta['pt-anonlogin'] = new Array('o','La registrazione è consigliata, anche se non obbligatoria'); |
|||
ta['pt-logout'] = new Array('o','Uscita (logout)'); |
|||
ta['ca-talk'] = new Array('t','Vedi le discussioni relative a questa pagina'); |
|||
ta['ca-edit'] = new Array('e','Puoi modificare questa pagina. Per favore usa il pulsante di anteprima prima di salvare'); |
|||
ta['ca-addsection'] = new Array('+','Aggiungi un commento a questa discussione'); |
|||
ta['ca-viewsource'] = new Array('e','Questa pagina è protetta, ma puoi vedere il suo codice sorgente'); |
|||
ta['ca-history'] = new Array('h','Versioni precedenti di questa pagina'); |
|||
ta['ca-protect'] = new Array('=','Proteggi questa pagina'); |
|||
ta['ca-unprotect'] = new Array('=','Sblocca questa pagina'); |
|||
ta['ca-delete'] = new Array('d','Cancella questa pagina'); |
|||
ta['ca-undelete'] = new Array('d','Ripristina la pagina com\'era prima della cancellazione'); |
|||
ta['ca-move'] = new Array('m','Sposta questa pagina (cambia titolo)'); |
|||
ta['ca-watch'] = new Array('w','Aggiungi questa pagina alla tua lista di osservati speciali'); |
|||
ta['ca-unwatch'] = new Array('w','Elimina questa pagina dalla tua lista di osservati speciali'); |
|||
ta['search'] = new Array('f','Cerca all\'interno del sito'); |
|||
ta['p-logo'] = new Array('','Pagina principale'); |
|||
ta['n-mainpage'] = new Array('z','Visita la pagina principale'); |
|||
ta['n-portal'] = new Array('','Descrizione del progetto, cosa puoi fare, dove trovare le cose'); |
|||
ta['n-currentevents'] = new Array('','Informazioni sugli eventi di attualità'); |
|||
ta['n-recentchanges'] = new Array('r','Elenco delle ultime modifiche del sito'); |
|||
ta['n-randompage'] = new Array('x','Mostra una pagina a caso'); |
|||
ta['n-help'] = new Array('a','Pagine di aiuto'); |
|||
ta['n-sitesupport'] = new Array('','Aiutaci'); |
|||
ta['t-whatlinkshere'] = new Array('j','Elenco di tutte le pagine che sono collegate a questa'); |
|||
ta['t-recentchangeslinked'] = new Array('k','Elenco delle ultime modifiche alle pagine collegate a questa'); |
|||
ta['feed-rss'] = new Array('','Feed RSS per questa pagina'); |
|||
ta['feed-atom'] = new Array('','Feed Atom per questa pagina'); |
|||
ta['t-contributions'] = new Array('','Lista dei contributi di questo utente'); |
|||
ta['t-emailuser'] = new Array('','Invia un messaggio e-mail a questo utente'); |
|||
ta['t-upload'] = new Array('u','Carica immagini o file multimediali'); |
|||
ta['t-specialpages'] = new Array('q','Lista di tutte le pagine speciali'); |
|||
ta['ca-nstab-main'] = new Array('c','Vedi la voce'); |
|||
ta['ca-nstab-user'] = new Array('c','Vedi la pagina utente'); |
|||
ta['ca-nstab-media'] = new Array('c','Vedi la pagina del file multimediale'); |
|||
ta['ca-nstab-special'] = new Array('','Questa è una pagina speciale, non può essere modificata'); |
|||
ta['ca-nstab-wp'] = new Array('c','Vedi la pagina di servizio'); |
|||
ta['ca-nstab-image'] = new Array('c','Vedi la pagina dell\'immagine'); |
|||
ta['ca-nstab-mediawiki'] = new Array('c','Vedi il messaggio di sistema'); |
|||
ta['ca-nstab-template'] = new Array('c','Vedi il template'); |
|||
ta['ca-nstab-help'] = new Array('c','Vedi la pagina di aiuto'); |
|||
ta['ca-nstab-category'] = new Array('c','Vedi la pagina della categoria'); |
|||
/* |
|||
==Routine per il cambio del titolo e del sottotitolo== |
|||
*/ |
|||
/* "Technical restrictions" title fix ***************************************** |
|||
* |
|||
* copiato da :it:MediaWiki:Common.js, a sua volta copiato da :en:MediaWiki:Common.js |
|||
*/ |
|||
// The function looks for span like this: |
|||
// <span id="TitleText">title</span> |
|||
// |
|||
var disableAssignTitle = 0; // un utente può disabilitare l'assegnazione del titolo dal suo monobook.js |
|||
var disableAssignSubTitle = 0; // un utente può disabilitare l'assegnazione del sottotitolo dal suo monobook.js |
|||
function rewriteTitle() { |
|||
try { |
|||
if (!disableAssignTitle) { |
|||
var titleTextElement = document.getElementById("TitleText"); |
|||
if (titleTextElement) { |
|||
var titleTextHTML = titleTextElement.innerHTML; |
|||
titleText = pickUpText(titleTextElement); |
|||
// assegno il testo completo di HTML come titolo della pagina: |
|||
var h1 = document.getElementsByTagName("h1")[0]; |
|||
if (h1) { |
|||
h1.innerHTML = titleTextHTML; |
|||
} |
|||
// assegno il testo senza HTML come titolo della finestra del browser: |
|||
if (titleText == "") { |
|||
document.title = "Nonciclopedia"; |
|||
} |
|||
else { |
|||
document.title = titleText + " - Nonciclopedia"; |
|||
} |
|||
// nascondo l'elemento "TitleText" perché serve solo per il javascript: |
|||
titleTextElement.style.display = "none"; |
|||
// se è presente la specifica del colore, lo assegno al titolo della pagina: |
|||
var titleColorElement = document.getElementById("TitleColor"); |
|||
if (titleColorElement) { |
|||
titleColorText = pickUpText(titleColorElement); |
|||
if (h1) { |
|||
h1.style.color = titleColorText; |
|||
} |
|||
// nascondo l'elemento "TitleColor" perché serve solo per il javascript: |
|||
titleColorElement.style.display = "none"; |
|||
} |
|||
// se è presente la specifica dello stile del bordo inferiore, lo assegno al titolo della pagina: |
|||
var titleBorderBottomElement = document.getElementById("TitleBorderBottom"); |
|||
if (titleBorderBottomElement) { |
|||
titleBorderBottomText = pickUpText(titleBorderBottomElement); |
|||
if (h1) { |
|||
h1.style.borderBottom = titleBorderBottomText; |
|||
} |
|||
// nascondo l'elemento "TitleBorderBottom" perché serve solo per il javascript: |
|||
titleBorderBottomElement.style.display = "none"; |
|||
} |
|||
// se è presente la specifica del font-family, lo assegno al titolo della pagina: |
|||
var titleFontFamilyElement = document.getElementById("TitleFontFamily"); |
|||
if (titleFontFamilyElement) { |
|||
titleFontFamilyText = pickUpText(titleFontFamilyElement); |
|||
if (h1) { |
|||
h1.style.fontFamily = titleFontFamilyText; |
|||
} |
|||
// nascondo l'elemento "TitleFontFamily" perché serve solo per il javascript: |
|||
titleFontFamilyElement.style.display = "none"; |
|||
} |
|||
} |
|||
} |
|||
} catch (e) { |
|||
/* Something went wrong. */ |
|||
} |
|||
} |
|||
// similar to innerHTML, but only returns the text portions of the insides, excludes HTML |
|||
function pickUpText(aParentElement) { |
|||
var str = ""; |
|||
function pickUpTextInternal(aElement) { |
|||
var child = aElement.firstChild; |
|||
while (child) { |
|||
if (child.nodeType == 1) // ELEMENT_NODE |
|||
pickUpTextInternal(child); |
|||
else if (child.nodeType == 3) // TEXT_NODE |
|||
str += child.nodeValue; |
|||
child = child.nextSibling; |
|||
} |
|||
} |
|||
pickUpTextInternal(aParentElement); |
|||
return str; |
|||
} |
|||
var disableRandomSubTitle = 0; |
|||
// routine per l'eventuale assegnazione del sottotitolo (default: random): |
|||
function change_subtitle() { |
|||
var subTitleTextElement = document.getElementById("SubTitleText"); |
|||
if ((subTitleTextElement) && (!disableAssignSubTitle)) { |
|||
var subTitleTextHTML = subTitleTextElement.innerHTML; |
|||
subTitleText = pickUpText(subTitleTextElement); |
|||
// assegno il testo completo di HTML come sottotitolo della pagina: |
|||
var h3 = document.getElementsByTagName("h3")[0]; |
|||
if (h3) { |
|||
h3.innerHTML = subTitleTextHTML; |
|||
} |
|||
// nascondo l'elemento "SubTitleText" perché serve solo per il javascript: |
|||
subTitleTextElement.style.display = "none"; |
|||
} else { |
|||
sottotitoloRandom(); |
|||
} |
|||
} |
|||
function sottotitoloRandom() { |
|||
if (disableRandomSubTitle) return; |
|||
var sottotitoli = new Array(); |
|||
//attenzione, il testo non può contenere nessun tag o collegamento |
|||
sottotitoli[0] = "Da Nonciclopedia, l'enciclopedia libera su cauzione"; |
|||
sottotitoli[1] = "Da Nonciclopedia, l'enciclopedia libera con l'indulto"; |
|||
sottotitoli[2] = "Da Nonciclopedia, l'enciclopedia libera dagli inestetismi"; |
|||
sottotitoli[3] = "Dà Noncicloppedia, lenciclopedia l'ibbera dal'orttografia"; |
|||
sottotitoli[4] = "Da Nonciclopedia, l'enciclopedia che libera la gola e calma la tosse"; |
|||
sottotitoli[5] = "Da Nonciclopedia, l'enciclopedia libera... finché non ci beccano!"; |
|||
sottotitoli[6] = "Da Nonciclopedia, l'enciclopedia in libertà vigilata"; |
|||
sottotitoli[7] = "Da Nonciclopedia, l'enciclopedia libera da qualsivoglia contenuto"; |
|||
sottotitoli[8] = "Da Nonciclopedia, l'enciclopedia libidinosa"; |
|||
sottotitoli[9] = "Da Nonciclopedia, l'enciclopedia libertina"; |
|||
sottotitoli[10] = "Da Nonciclopedia, l'enciclopedia liberatoria"; |
|||
sottotitoli[11] = "Da Nonciclopedia, l'enciclopedia libera dal pudore. 8====D"; |
|||
sottotitoli[12] = "Da Nonciclopedia, l'enciclopedia liberalizzata (ma solo in Olanda)"; |
|||
sottotitoli[13] = "Da Nonciclopedia, l'enciclopedia liberamente ispirata all'Osservatore Romano"; |
|||
sottotitoli[14] = "Da Nonciclopedia, l'enciclopedia VM 18 e libera dai bambini"; |
|||
var n = Math.round(Math.random() * (sottotitoli.length - 1)); //scelta random |
|||
// assegno il testo come sottotitolo della pagina: |
|||
subtitle = document.getElementById("siteSub"); |
|||
subtitle.innerHTML = sottotitoli[n]; |
|||
} |
|||
/* Apre la shoutbox */ |
|||
function ShoutBox_load() { |
|||
if(wgPageName != "Nonciclopedia:ShoutBox" || wgAction !="view") return false; |
|||
window.open('http://nonciclopedia.wikia.com/index.php?title=Speciale:WidgetDashboard&action=render&useskin=monaco', '_blank','directories=no, location=no, menubar=no, toolbar=no, titlebar=no, width=250, height=300', false); |
|||
return; |
|||
} |
|||
/******************* QUICK EDITOR ********************/ |
|||
/* Functions for rapid saving and previewing without need of reloading the page: basically a hack on api.php */ |
|||
/* Created and mantained by Sanjilops (http://nonciclopedia.wikia.com/wiki/Utente:Sanjilops) */ |
|||
/* Feel free to copy and adapt it on your wiki. Check also MediaWiki:Monobook.css */ |
|||
/** |
|||
* |
|||
* MD5 (Message-Digest Algorithm) |
|||
* http://www.webtoolkit.info/ |
|||
* |
|||
**/ |
|||
var MD5 = function (string) { |
|||
function RotateLeft(lValue, iShiftBits) { |
|||
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits)); |
|||
} |
|||
function AddUnsigned(lX,lY) { |
|||
var lX4,lY4,lX8,lY8,lResult; |
|||
lX8 = (lX & 0x80000000); |
|||
lY8 = (lY & 0x80000000); |
|||
lX4 = (lX & 0x40000000); |
|||
lY4 = (lY & 0x40000000); |
|||
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF); |
|||
if (lX4 & lY4) { |
|||
return (lResult ^ 0x80000000 ^ lX8 ^ lY8); |
|||
} |
|||
if (lX4 | lY4) { |
|||
if (lResult & 0x40000000) { |
|||
return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); |
|||
} else { |
|||
return (lResult ^ 0x40000000 ^ lX8 ^ lY8); |
|||
} |
|||
} else { |
|||
return (lResult ^ lX8 ^ lY8); |
|||
} |
|||
} |
|||
function F(x,y,z) { return (x & y) | ((~x) & z); } |
|||
function G(x,y,z) { return (x & z) | (y & (~z)); } |
|||
function H(x,y,z) { return (x ^ y ^ z); } |
|||
function I(x,y,z) { return (y ^ (x | (~z))); } |
|||
function FF(a,b,c,d,x,s,ac) { |
|||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); |
|||
return AddUnsigned(RotateLeft(a, s), b); |
|||
}; |
|||
function GG(a,b,c,d,x,s,ac) { |
|||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); |
|||
return AddUnsigned(RotateLeft(a, s), b); |
|||
}; |
|||
function HH(a,b,c,d,x,s,ac) { |
|||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); |
|||
return AddUnsigned(RotateLeft(a, s), b); |
|||
}; |
|||
function II(a,b,c,d,x,s,ac) { |
|||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); |
|||
return AddUnsigned(RotateLeft(a, s), b); |
|||
}; |
|||
function ConvertToWordArray(string) { |
|||
var lWordCount; |
|||
var lMessageLength = string.length; |
|||
var lNumberOfWords_temp1=lMessageLength + 8; |
|||
var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64; |
|||
var lNumberOfWords = (lNumberOfWords_temp2+1)*16; |
|||
var lWordArray=Array(lNumberOfWords-1); |
|||
var lBytePosition = 0; |
|||
var lByteCount = 0; |
|||
while ( lByteCount < lMessageLength ) { |
|||
lWordCount = (lByteCount-(lByteCount % 4))/4; |
|||
lBytePosition = (lByteCount % 4)*8; |
|||
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition)); |
|||
lByteCount++; |
|||
} |
|||
lWordCount = (lByteCount-(lByteCount % 4))/4; |
|||
lBytePosition = (lByteCount % 4)*8; |
|||
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition); |
|||
lWordArray[lNumberOfWords-2] = lMessageLength<<3; |
|||
lWordArray[lNumberOfWords-1] = lMessageLength>>>29; |
|||
return lWordArray; |
|||
}; |
|||
function WordToHex(lValue) { |
|||
var WordToHexValue="",WordToHexValue_temp="",lByte,lCount; |
|||
for (lCount = 0;lCount<=3;lCount++) { |
|||
lByte = (lValue>>>(lCount*8)) & 255; |
|||
WordToHexValue_temp = "0" + lByte.toString(16); |
|||
WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2); |
|||
} |
|||
return WordToHexValue; |
|||
}; |
|||
function Utf8Encode(string) { |
|||
string = string.replace(/\r\n/g,"\n"); |
|||
var utftext = ""; |
|||
for (var n = 0; n < string.length; n++) { |
|||
var c = string.charCodeAt(n); |
|||
if (c < 128) { |
|||
utftext += String.fromCharCode(c); |
|||
} |
|||
else if((c > 127) && (c < 2048)) { |
|||
utftext += String.fromCharCode((c >> 6) | 192); |
|||
utftext += String.fromCharCode((c & 63) | 128); |
|||
} |
|||
else { |
|||
utftext += String.fromCharCode((c >> 12) | 224); |
|||
utftext += String.fromCharCode(((c >> 6) & 63) | 128); |
|||
utftext += String.fromCharCode((c & 63) | 128); |
|||
} |
|||
} |
|||
return utftext; |
|||
}; |
|||
var x=Array(); |
|||
var k,AA,BB,CC,DD,a,b,c,d; |
|||
var S11=7, S12=12, S13=17, S14=22; |
|||
var S21=5, S22=9 , S23=14, S24=20; |
|||
var S31=4, S32=11, S33=16, S34=23; |
|||
var S41=6, S42=10, S43=15, S44=21; |
|||
string = Utf8Encode(string); |
|||
x = ConvertToWordArray(string); |
|||
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; |
|||
for (k=0;k<x.length;k+=16) { |
|||
AA=a; BB=b; CC=c; DD=d; |
|||
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478); |
|||
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756); |
|||
c=FF(c,d,a,b,x[k+2], S13,0x242070DB); |
|||
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE); |
|||
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF); |
|||
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A); |
|||
c=FF(c,d,a,b,x[k+6], S13,0xA8304613); |
|||
b=FF(b,c,d,a,x[k+7], S14,0xFD469501); |
|||
a=FF(a,b,c,d,x[k+8], S11,0x698098D8); |
|||
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF); |
|||
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1); |
|||
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE); |
|||
a=FF(a,b,c,d,x[k+12],S11,0x6B901122); |
|||
d=FF(d,a,b,c,x[k+13],S12,0xFD987193); |
|||
c=FF(c,d,a,b,x[k+14],S13,0xA679438E); |
|||
b=FF(b,c,d,a,x[k+15],S14,0x49B40821); |
|||
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562); |
|||
d=GG(d,a,b,c,x[k+6], S22,0xC040B340); |
|||
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51); |
|||
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA); |
|||
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D); |
|||
d=GG(d,a,b,c,x[k+10],S22,0x2441453); |
|||
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681); |
|||
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8); |
|||
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6); |
|||
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6); |
|||
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87); |
|||
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED); |
|||
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905); |
|||
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8); |
|||
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9); |
|||
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A); |
|||
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942); |
|||
d=HH(d,a,b,c,x[k+8], S32,0x8771F681); |
|||
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122); |
|||
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C); |
|||
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44); |
|||
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9); |
|||
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60); |
|||
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70); |
|||
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6); |
|||
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA); |
|||
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085); |
|||
b=HH(b,c,d,a,x[k+6], S34,0x4881D05); |
|||
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039); |
|||
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5); |
|||
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8); |
|||
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665); |
|||
a=II(a,b,c,d,x[k+0], S41,0xF4292244); |
|||
d=II(d,a,b,c,x[k+7], S42,0x432AFF97); |
|||
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7); |
|||
b=II(b,c,d,a,x[k+5], S44,0xFC93A039); |
|||
a=II(a,b,c,d,x[k+12],S41,0x655B59C3); |
|||
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92); |
|||
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D); |
|||
b=II(b,c,d,a,x[k+1], S44,0x85845DD1); |
|||
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F); |
|||
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0); |
|||
c=II(c,d,a,b,x[k+6], S43,0xA3014314); |
|||
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1); |
|||
a=II(a,b,c,d,x[k+4], S41,0xF7537E82); |
|||
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235); |
|||
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB); |
|||
b=II(b,c,d,a,x[k+9], S44,0xEB86D391); |
|||
a=AddUnsigned(a,AA); |
|||
b=AddUnsigned(b,BB); |
|||
c=AddUnsigned(c,CC); |
|||
d=AddUnsigned(d,DD); |
|||
} |
|||
var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d); |
|||
return temp.toLowerCase(); |
|||
} |
|||
function Quick_Editor() { |
|||
var sect = document.getElementsByName("wpSection"); |
|||
if (!/&?undo=\d+/.test(location.search) && ((sect.length && !sect[0].value) || !sect.length)) quicksave_load(); |
|||
if (!(/\.(j|cs)s$/.test(wgTitle) && wgNamespaceNumber % 2 == 0)) quickpreview_load(); |
|||
var t = document.getElementById("wpTextbox1"); |
|||
if (!t) return; |
|||
if (t.addEventListener) { |
|||
t.addEventListener('mouseup', quickedit_switch, false); |
|||
t.addEventListener('keyup', quickedit_switch, false); |
|||
} |
|||
else if (t.attachEvent) { |
|||
t.attachEvent('onmouseup', quickedit_switch); |
|||
t.attachEvent('onmouseup', quickedit_switch); |
|||
} |
|||
return; |
|||
} |
|||
var quicksave_checktext = ''; |
|||
function quicksave_load() { |
|||
var buttons = getElementsByClass(document, "editButtons", 'div')[0]; |
|||
var b = document.createElement('input'); |
|||
b.type = 'button'; |
|||
b.value = "Salva"; |
|||
b.id = "quicksaveButton"; |
|||
if (b.addEventListener) b.addEventListener('click', quicksave, false); |
|||
else if (b.attachEvent) b.attachEvent('onclick', quicksave); |
|||
b.accessKey = '1'; |
|||
b.title = "Salva e resta nell'editor [alt-shift-1]"; |
|||
buttons.insertBefore(b, document.getElementById("wpPreview")); |
|||
quicksave_checktext = document.getElementById("wpTextbox1").value; |
|||
return; |
|||
} |
|||
function quicksave () { |
|||
var textbox = document.getElementById("wpTextbox1"); |
|||
textbox.disabled = true; |
|||
document.getElementById("wpSave").disabled = true; |
|||
document.getElementById("quicksaveButton").disabled = true; |
|||
var temp = null; |
|||
temp = document.getElementById("quickpreviewButton"); |
|||
if (temp) temp.disabled = true; |
|||
var Source = encodeURIComponent(textbox.value); |
|||
var msg_box = document.getElementById("quicksave_msgbox"); |
|||
if (msg_box == null) { |
|||
msg_box = document.createElement('div'); |
|||
msg_box.id = "quicksave_msgbox"; |
|||
document.getElementById('content').insertBefore(msg_box, document.getElementById('firstHeading')); |
|||
} |
|||
else msg_box.innerHTML = ''; |
|||
var httpRequest = createRequest(); |
|||
var id = setTimeout(function() { httpRequest.abort(); msg_box.innerHTML = "Salvataggio fallito: il server non risponde.".fontcolor('Red'); Finish(false); }, 30000); |
|||
httpRequest.onreadystatechange = function () { Response(httpRequest, id); return;}; |
|||
var url = wgServer + wgScriptPath + "/api.php"; |
|||
var param = "action=edit&format=xml&title=" + encodeURIComponent(wgPageName); |
|||
param += "&token=" + document.getElementsByName("wpEditToken")[0].value.replace(/\+\\/, '%2' + "B%5" + 'C'); |
|||
temp = document.getElementById("wpSummary"); |
|||
if (temp) param += "&summary=" + encodeURIComponent(temp.value); |
|||
temp = document.getElementById("wpCaptchaId"); |
|||
if (temp) { |
|||
param += "&captchaid=" + temp.value + "&captchaword=" + encodeURIComponent(document.getElementById("wpCaptchaWord").value); |
|||
document.getElementById('editform').removeChild(document.getElementById("captcha_box")); |
|||
} |
|||
temp = document.getElementById("wpMinoredit"); |
|||
if (temp && temp.checked) param += "&minor="; |
|||
temp = document.getElementById("wpWatchthis"); |
|||
if (temp) { |
|||
var Watched = temp.checked; |
|||
if (document.getElementById('ca-watch') && Watched) param += "&watch="; |
|||
if (document.getElementById('ca-unwatch') && !Watched) param += "&unwatch="; |
|||
} |
|||
param += "&basetimestamp=" + document.getElementsByName("wpEdittime")[0].value; |
|||
param += "&starttimestamp=" + document.getElementsByName("wpStarttime")[0].value; |
|||
param += "&text=" + Source; |
|||
param += "&md5=" + MD5(textbox.value); |
|||
httpRequest.open('POST', url, true); |
|||
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
|||
httpRequest.setRequestHeader('Content-Length', param.length); |
|||
document.getElementsByTagName('body')[0].style.cursor = 'progress'; |
|||
httpRequest.send(param); |
|||
return; |
|||
function Response (o, id) { |
|||
if (o.readyState != 4) return; |
|||
clearTimeout(id); |
|||
msg_box.scrollIntoView(); |
|||
if (o.status != 200) { |
|||
if (o.status && (o.status < 199 || o.status > 300)) { |
|||
msg_box.innerHTML = "Salvataggio fallito. Risposta del server: ".fontcolor('Red') + o.status.fontcolor('Red'); |
|||
Finish(false); |
|||
} |
|||
return; |
|||
} |
|||
if (o.responseXML == null) { |
|||
msg_box.innerHTML = "Errore nella risposta del server. Controlla nella cronologia se il salvataggio è avvenuto".fontcolor('Red'); |
|||
Finish(false); |
|||
return; |
|||
} |
|||
if (o.responseXML.normalize) o.responseXML.normalize(); |
|||
var result = o.responseXML.getElementsByTagName('edit'); |
|||
if (result && result[0] != undefined) { |
|||
if (result[0].getAttribute('result') == "Success") { |
|||
msg_box.innerHTML = "Salvataggio completato."; |
|||
wgCurRevisionId = result[0].getAttribute('newrevid'); |
|||
var request_ts = createRequest(); |
|||
var ts_id = setTimeout(function() { request_ts.abort(); appendText(msg_box, " Impossibile procedere ad ulteriori salvataggi."); return; }, 30000); |
|||
request_ts.onreadystatechange = function () { Get_Timestamp(request_ts, ts_id); return; } |
|||
var param = "action=query&format=xml&" + "prop=revisions&meta=userinfo&uiprop=hasmsg&rvprop=timestamp%" + "7Cuser&rvlimit=1&rvdir=older&titles=" + encodeURIComponent(wgPageName); |
|||
request_ts.open('POST', url, true); |
|||
request_ts.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
|||
request_ts.setRequestHeader('Content-Length', param.length); |
|||
request_ts.send(param); |
|||
Finish(true); |
|||
return; |
|||
} |
|||
if (result[0].getAttribute('result') == "Failure") { |
|||
var captcha = result[0].getElementsByTagName('captcha')[0]; |
|||
if (captcha == null) { |
|||
msg_box.innerHTML = "Salvataggio fallito: errore ignoto".fontcolor('Red'); |
|||
Finish(false); |
|||
return; |
|||
} |
|||
var captcha_id = document.createElement('input'); |
|||
captcha_id.type = 'hidden'; |
|||
captcha_id.id = "wpCaptchaId"; |
|||
captcha_id.value = captcha.getAttribute('id'); |
|||
var captcha_word = document.createElement('input'); |
|||
captcha_word.id = "wpCaptchaWord"; |
|||
captcha_word.style.marginBottom = "10px"; |
|||
var captcha_img = document.createElement('img'); |
|||
captcha_img.src = wgServer + wgScriptPath + "/index.php?title=Special:Captcha/image&wpCaptchaId=" + captcha_id.value; |
|||
var captcha_msg = document.createElement('p'); |
|||
captcha_msg.innerHTML = 'La modifica richiesta aggiunge dei collegamenti esterni alla pagina; come misura precauzionale contro l\'inserimento automatico di spam, si prega di inserire nella casella sottostante la parola che compare distorta in questa immagine (<' + 'a href="/wiki/Speciale:Captcha/help" title="Speciale:Captcha/help">come funziona?</' + 'a>)'; |
|||
var captcha_box = document.createElement('div'); |
|||
captcha_box.id = "captcha_box"; |
|||
document.getElementById('editform').insertBefore(captcha_box, document.getElementById('toolbar')); |
|||
captcha_box.appendChild(captcha_msg); |
|||
captcha_box.appendChild(captcha_img); |
|||
captcha_box.appendChild(captcha_word); |
|||
captcha_box.appendChild(captcha_id); |
|||
Finish(false); |
|||
return; |
|||
} |
|||
} |
|||
var error = o.responseXML.getElementsByTagName('error'); |
|||
if (error == null) { |
|||
msg_box.innerHTML = "Errore nella risposta del server. Controlla nella cronologia se il salvataggio è avvenuto".fontcolor('Red'); |
|||
Finish(false); |
|||
return; |
|||
} |
|||
switch (error[0].getAttribute('code')) { |
|||
case 'editconflict': |
|||
document.getElementById("wpSave").disabled = false; |
|||
setTimeout(function () {document.getElementById('wpSave').click(); return;}, 1000); |
|||
return; |
|||
case 'noedit': |
|||
case 'noedit-anon': |
|||
msg_box.innerHTML = "Non sei autorizzato a modificare questa pagina.".fontcolor('Red'); |
|||
Finish(false); |
|||
return; |
|||
default: |
|||
msg_box.innerHTML = "Salvataggio fallito: ".fontcolor('Red') + error[0].getAttribute('info').fontcolor('Red'); |
|||
Finish(false); |
|||
return; |
|||
} |
|||
} |
|||
function Get_Timestamp (o, id) { |
|||
if (o.readyState != 4) return; |
|||
clearTimeout(id); |
|||
if (o.status != 200) { |
|||
if (o.status && (o.status < 199 || o.status > 300)) { |
|||
appendText(msg_box, " Impossibile procedere ad ulteriori salvataggi."); |
|||
} |
|||
return; |
|||
} |
|||
if (o.responseXML == null) { |
|||
appendText(msg_box, " Impossibile procedere ad ulteriori salvataggi."); |
|||
return; |
|||
} |
|||
if (o.responseXML.normalize) o.responseXML.normalize(); |
|||
var rev = o.responseXML.getElementsByTagName('rev'); |
|||
if (!rev || rev[0] == undefined) { |
|||
appendText(msg_box, " Impossibile procedere ad ulteriori salvataggi."); |
|||
return; |
|||
} |
|||
var t = rev[0].getAttribute('timestamp'); |
|||
document.getElementsByName("wpEdittime")[0].value = t.replace(/\D/g, ''); |
|||
var d = new Date(t.replace(/(\d\d\d\d)-(\d\d)-(\d\d)T(.+)Z/, "$1/$2/$3 $4")); |
|||
d.setHours(d.getHours() - d.getTimezoneOffset()/60); |
|||
appendText(msg_box, " Ultima modifica: " + rev[0].getAttribute('user') + ' ' + d.toLocaleString()); |
|||
d = new Date(); |
|||
document.getElementsByName("wpStarttime")[0].value = d.getUTCFullYear().toString() + addzero(d.getUTCMonth()) + addzero(d.getUTCDate()) + addzero(d.getUTCHours()) + addzero(d.getUTCMinutes())+ addzero(d.getUTCSeconds() + 1); |
|||
document.getElementById("wpSave").disabled = false; |
|||
temp = o.responseXML.getElementsByTagName('userinfo'); |
|||
if (!temp || temp[0] == undefined) return; |
|||
var orange = getElementsByClass(document.getElementById('bodyContent'), 'usermessage', 'div'); |
|||
if (orange) orange = orange[0]; |
|||
if (!temp[0].hasAttribute('messages')) { |
|||
if (orange) orange.style.display = 'none'; |
|||
return; |
|||
} |
|||
var name = (wgUserName)? wgUserName : temp[0].getAttribute('name'); |
|||
if (!orange) { |
|||
orange = document.createElement('div'); |
|||
orange.className = 'usermessage'; |
|||
document.getElementById('bodyContent').insertBefore(orange, document.getElementById('wikiPreview')); |
|||
} |
|||
else orange.style.display = 'block'; |
|||
orange.innerHTML = 'Hai <a title="Discussioni utente:' + name + '" href="/index.php?title=Discussioni_utente:' + encodeURI(name) + '&redirect=no">nuovi messaggi</a' + '> (<a title="Discussioni utente:' + name + '" href="/index.php?title=Discussioni_utente:' + encodeURI(name) + '&diff=cur">differenza con la revisione precedente</a' + '>).'; |
|||
return; |
|||
} |
|||
function Finish(success) { |
|||
if (success) { |
|||
document.getElementById("wpSummary").value = ''; |
|||
quicksave_checktext = textbox.value; |
|||
if (!(/\.(j|cs)s$/.test(wgTitle) && wgNamespaceNumber % 2 == 0)) { |
|||
textbox.selectionStart = 0; |
|||
textbox.selectionEnd = 0; |
|||
quickpreview(true); |
|||
} |
|||
else { |
|||
document.getElementsByTagName('body')[0].style.cursor = 'auto'; |
|||
} |
|||
if (wgUserName) { |
|||
if (Watched) { |
|||
temp = document.getElementById('ca-watch'); |
|||
if (temp) { |
|||
temp.id = 'ca-unwatch'; |
|||
temp = temp.firstChild; |
|||
temp.href = temp.href.replace(/=watch$/, "=unwatch"); |
|||
setText(temp, "non seguire"); |
|||
temp.title = temp.title.replace(/^Aggiungi/, "Rimuovi"); |
|||
appendText(msg_box, " Pagina aggiunta agli osservati speciali.") |
|||
} |
|||
} |
|||
else { |
|||
temp = document.getElementById('ca-unwatch'); |
|||
if (temp) { |
|||
temp.id = 'ca-watch'; |
|||
temp = temp.firstChild; |
|||
temp.href = temp.href.replace(/=unwatch$/, "=watch"); |
|||
setText(temp, "segui"); |
|||
temp.title = temp.title.replace(/^Rimuovi/, "Aggiungi"); |
|||
appendText(msg_box, " Pagina rimossa dagli osservati speciali.") |
|||
} |
|||
} |
|||
} |
|||
} |
|||
else { |
|||
document.getElementById("wpSave").disabled = false; |
|||
document.getElementById("quicksaveButton").disabled = false; |
|||
temp = document.getElementById("quickpreviewButton"); |
|||
if (temp) temp.disabled = false; |
|||
document.getElementById("wikiPreview").innerHTML = ''; |
|||
document.getElementsByTagName('body')[0].style.cursor = 'auto'; |
|||
} |
|||
textbox.disabled = false; |
|||
return; |
|||
} |
|||
} // <-quicksave() |
|||
var quickpreview_firstLoad = true; |
|||
var QP_hiddencatlist; |
|||
var QP_cat_ns = "Categoria:"; |
|||
var QP_hiddencats_cat = "Categorie nascoste"; |
|||
function quickpreview_load() { |
|||
if (/\.(j|cs)s$/.test(wgTitle)) return; |
|||
var buttons = getElementsByClass(document, "editButtons", 'div')[0]; |
|||
if (buttons == null) return; |
|||
var b = document.createElement('input'); |
|||
b.type = 'button'; |
|||
b.value = "Visualizza anteprima"; |
|||
b.id = "quickpreviewButton"; |
|||
if (b.addEventListener) b.addEventListener('click', quickpreview1, false); |
|||
else if (b.attachEvent) b.attachEvent('onclick', quickpreview1); |
|||
b.accessKey = '2'; |
|||
b.title = "Anteprima delle modifiche (consigliata prima di salvare) [alt-shift-2]"; |
|||
var wpButton = document.getElementById('wpPreview'); |
|||
wpButton.style.margin = '0px'; |
|||
wpButton.style.padding = '0px'; |
|||
wpButton.style.fontSize = '0'; |
|||
wpButton.style.width = '0px'; |
|||
wpButton.style.borderWidth = '0pt'; |
|||
buttons.insertBefore(b, wpButton); |
|||
var hotkey = document.getElementById("quickpreview-hotkeysuggest"); |
|||
hotkey.style.left = (b.offsetLeft - 15) + 'px'; |
|||
hotkey.style.visibility = 'visible'; |
|||
QP_hiddencatlist = getCookie("QPhc"); |
|||
if (QP_hiddencatlist == null) { |
|||
var request_hc = createRequest(); |
|||
request_hc.onreadystatechange = function () { set_hc_cookie(request_hc); return;}; |
|||
request_hc.open('GET', wgServer + wgScriptPath + "/api.php?action=query&list=categorymembers&cmtitle=Category:" + encodeURI(QP_hiddencats_cat) + "&cmlimit=500&format=xml", true); |
|||
request_hc.send(null); |
|||
} |
|||
return; |
|||
function set_hc_cookie (o) { |
|||
if (o.readyState != 4) return false; |
|||
if (o.status != 200) return false; |
|||
if (o.responseXML == null) return false; |
|||
if(o.responseXML.normalize) o.responseXML.normalize(); |
|||
var cm = o.responseXML.getElementsByTagName('categorymembers')[0].getElementsByTagName('cm'); |
|||
var tmp = new Array(); |
|||
var i = 0; |
|||
for (i; i < cm.length; i++) tmp.push(cm[i].getAttribute('title')); |
|||
QP_hiddencatlist = tmp.join('|'); |
|||
document.cookie = "QPhc=" + escape(QP_hiddencatlist); |
|||
return true; |
|||
} |
|||
} |
|||
function quickpreview1() { quickpreview(false); return; } |
|||
function quickpreview (after_save) { |
|||
/* Pulizia dell'area di anteprima */ |
|||
var previewArea = document.getElementById("wikiPreview"); |
|||
if (previewArea == null) return false; |
|||
previewArea.innerHTML = ''; |
|||
var temp; |
|||
if (quickpreview_firstLoad) { |
|||
previewArea.style.display = 'block'; |
|||
temp = document.getElementById("editintro"); |
|||
if (temp) temp.style.display = 'none'; |
|||
temp = getElementsByClass(document, "mw-newarticletext")[0]; |
|||
if (temp) temp.style.display = 'none'; |
|||
temp = getElementsByClass(document, "mw-newarticletextanon")[0]; |
|||
if (temp) temp.style.display = 'none'; |
|||
temp = document.getElementById(document, "mw-anon-edit-warning"); |
|||
if (temp) temp.style.display = 'none'; |
|||
temp = getElementsByClass(document, "mw-warning-with-logexcerpt")[0]; |
|||
if (temp) temp.style.display = 'none'; |
|||
temp = document.getElementById("contentSub2"); |
|||
if (temp) temp.style.display = 'none'; |
|||
temp = document.getElementById("wpTalkPageText"); |
|||
if (temp) temp.style.display = 'none'; |
|||
temp = document.getElementById("explainconflict"); |
|||
if (temp) temp.style.display = 'none'; |
|||
quickpreview_firstLoad = false; |
|||
} |
|||
else { |
|||
/* Rimuove eventuali css importati precedentemente; */ |
|||
temp = document.getElementById("add-css-link"); |
|||
if (temp) document.getElementsByTagName('head')[0].removeChild(temp); |
|||
} |
|||
/* Imposta il titolo */ |
|||
document.getElementById("firstHeading").innerHTML = wgPageName.replace(/_/g, ' '); |
|||
document.getElementById("quickpreviewButton").disabled = true; |
|||
document.getElementsByTagName('body')[0].style.cursor = 'progress'; |
|||
var httpRequest = createRequest(); |
|||
var id = setTimeout(function() { httpRequest.abort(); alert("Errore: il server non risponde"); Finish(false); }, 30000); |
|||
httpRequest.onreadystatechange = function () { Write(httpRequest, id); return;}; |
|||
var url = wgServer + wgScriptPath + "/api.php"; |
|||
var param = "action=parse&format=xml&" + "prop=text%7" + "Ccategories"; |
|||
if (after_save) { |
|||
param += "&page=" + encodeURIComponent(wgPageName); |
|||
} |
|||
else { |
|||
var textbox = document.getElementById("wpTextbox1"); |
|||
var Source; |
|||
var start = textbox.selectionStart, end = textbox.selectionEnd; |
|||
if (start < end) Source = textbox.value.slice(start, end); |
|||
else { |
|||
Source = textbox.value + '\n'; |
|||
if (document.getElementsByName("wpSection")[0].value == 'new') Source = "== " + document.getElementById('wpSummary').value + " ==\n" + Source; |
|||
} |
|||
Source = encodeURIComponent(Source); |
|||
param += "&pst=&title=" + encodeURIComponent(wgPageName) + "&text=" + Source; |
|||
} |
|||
httpRequest.open('POST', url, true); |
|||
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
|||
httpRequest.setRequestHeader('Content-Length', param.length); |
|||
httpRequest.send(param); |
|||
return; /* fine quickpreview */ |
|||
function Write(o, id) { |
|||
if (o.readyState != 4) return; |
|||
clearTimeout(id); |
|||
if (o.status != 200) { |
|||
if (o.status && (o.status < 199 || o.status > 300)) { |
|||
alert("Anteprima non riuscita. Risposta del server: " + o.status); |
|||
Finish(false); |
|||
} |
|||
return; |
|||
} |
|||
if (o.responseXML == null) { |
|||
alert("Anteprima non riuscita (errore del parser?)"); |
|||
Finish(false); |
|||
return; |
|||
} |
|||
if(o.responseXML.normalize) o.responseXML.normalize(); |
|||
var R = o.responseXML.getElementsByTagName('text')[0].firstChild; |
|||
var code = R.data; |
|||
previewArea.innerHTML += code; |
|||
/* aggiungi categorie */ |
|||
var show_cat = false; |
|||
var catlinksBox = document.getElementById("catlinks"); |
|||
R = o.responseXML.getElementsByTagName('categories')[0].getElementsByTagName('cl'); |
|||
if (R.length > 0) { |
|||
if (catlinksBox != null) catlinksBox.innerHTML = ''; |
|||
else { |
|||
catlinksBox = document.createElement('div'); |
|||
catlinksBox.id = "catlinks"; |
|||
catlinksBox.className = "catlinks"; |
|||
document.getElementById("bodyContent").insertBefore(catlinksBox, getElementsByClass(document.getElementById("bodyContent"), "visualClear", 'div')[0]); |
|||
} |
|||
var catname; |
|||
var normalcatlinks = new Array(); |
|||
var hiddencatlinks = new Array(); |
|||
for (i=0; i<R.length; i++) { |
|||
catname = R.item(i).firstChild.nodeValue; |
|||
if (RegExp(catname.replace(/_/g, ' ')).test(QP_hiddencatlist)) hiddencatlinks.push('<span dir="ltr"><a href="/wiki/' + QP_cat_ns + encodeURI(catname) + '" title="' + QP_cat_ns + catname.replace(/_/g, ' ') + '">' + catname.replace(/_/g, ' ') + '</a></span>'); |
|||
else normalcatlinks.push('[[:' + QP_cat_ns + catname + '|' + catname.replace(/_/g, ' ') + ']]'); |
|||
} |
|||
var tmp = ''; |
|||
if (hiddencatlinks.length > 0) { |
|||
var hiddencatlinksBox = document.createElement('div'); |
|||
hiddencatlinksBox.id = "mw-hidden-catlinks"; |
|||
hiddencatlinksBox.className = "mw-hidden-cats-hidden"; |
|||
if (normalcatlinks.length == 0) catlinksBox.className += " catlinks-allhidden"; |
|||
catlinksBox.appendChild(hiddencatlinksBox); |
|||
tmp = "Categori" + ((hiddencatlinks.length > 1)? "e nascoste: " + hiddencatlinks.join(" | ") : "a nascosta: " + hiddencatlinks[0]); |
|||
hiddencatlinksBox.innerHTML = tmp; |
|||
} |
|||
if (normalcatlinks.length > 0) { |
|||
show_cat = true; |
|||
var normalcatscode = '<div id="mw-normal-catlinks">[[Speciale:Categorie|Categori' + ((normalcatlinks.length > 1)? 'e]]: ' + normalcatlinks.join(' | ') : 'a]]: ' + normalcatlinks[0]) + '</div>'; |
|||
var request_cat = createRequest(); |
|||
var cat_id = setTimeout(function() { request_cat.abort(); alert("Errore del server. Impossibile visualizzare le categorie"); Finish(true); }, 30000); |
|||
normalcatscode = normalcatscode.replace(/&/g, "%2" + "6"); |
|||
normalcatscode = normalcatscode.replace(/\+/g, "%2" + "B"); |
|||
normalcatscode = "action=parse&format=xml&" + "prop=text&text=" + normalcatscode; |
|||
request_cat.onreadystatechange = function () { Show_Cat(request_cat, cat_id, catlinksBox); return;}; |
|||
request_cat.open('POST', wgServer + wgScriptPath + "/api.php", true); |
|||
request_cat.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
|||
request_cat.setRequestHeader('Content-Length', normalcatscode.length); |
|||
request_cat.send(normalcatscode); |
|||
} |
|||
} |
|||
else { |
|||
if (catlinksBox != null) document.getElementById("bodyContent").removeChild(catlinksBox); |
|||
} |
|||
if (!show_cat) Finish(true) // caricamento terminato |
|||
return; |
|||
} /* <- Write */ |
|||
function Show_Cat (o, id, box) { |
|||
if (o.readyState != 4) return; |
|||
clearTimeout(id); |
|||
if (o.status != 200) { |
|||
if (o.status && (o.status < 199 || o.status > 300)) { |
|||
alert("Impossibile visualizzare le categorie: errore del server " + o.status); |
|||
} |
|||
Finish(true); |
|||
return; |
|||
} |
|||
if (o.responseXML == null) { |
|||
alert("Impossibile visualizzare le categorie: errore del parser?"); |
|||
} |
|||
if (o.responseXML.normalize) o.responseXML.normalize(); |
|||
box.innerHTML = o.responseXML.getElementsByTagName('text')[0].firstChild.data + box.innerHTML; |
|||
Finish(true); |
|||
return; |
|||
} |
|||
function Finish(success) { |
|||
document.getElementById("quickpreviewButton").disabled = false; |
|||
if (success) { |
|||
document.getElementById('p-logo').scrollIntoView(); |
|||
// mostra il toggle dell'indice |
|||
if (window.showTocToggle) { window.tocShowText = "mostra"; window.tocHideText = "nascondi"; showTocToggle();} |
|||
// carica onloadhooks |
|||
hooks_common_render(); |
|||
hooks_monobook_render(); |
|||
var i = 0; |
|||
for (i; i < hooks_custom.length; i++) hooks_custom[i](); |
|||
} |
|||
document.getElementsByTagName('body')[0].style.cursor = 'auto'; |
|||
return; |
|||
} |
|||
} // <- quickpreview(); |
|||
function quickedit_switch() { |
|||
var bs = document.getElementById("quicksaveButton"); |
|||
if (bs) { |
|||
if (this.value == quicksave_checktext) bs.disabled = true; |
|||
else bs.disabled = false; |
|||
} |
|||
var bp = document.getElementById("quickpreviewButton"); |
|||
if (bp) { |
|||
if (this.selectionStart < this.selectionEnd) bp.value = "Anteprima selezione"; |
|||
else bp.value = "Visualizza anteprima"; |
|||
} |
|||
return; |
|||
} |
|||
/* Aggiunge link di modifica per la sezione 0 */ |
|||
var nosectionzeroedit = false; |
|||
function sectionzero_editlink() { |
|||
if (wgNamespaceNumber == -1) return; |
|||
if (nosectionzeroedit) return; |
|||
if (getElementsByClass(document.getElementById('bodyContent'), 'editsection', 'span').length == 0) return; |
|||
if (document.getElementById('no-sec0-edit')) return; |
|||
// var title = document.getElementById('firstHeading'); |
|||
var subtitle = document.getElementById('siteSub'); |
|||
var link = document.createElement('a'); |
|||
link.rel = 'nofollow'; |
|||
link.title = "Modifica la sezione introduttiva"; |
|||
link.href = wgServer + wgScriptPath + '/index.php?title=' + encodeURI(wgPageName) + '&action=edit§ion=0&editintro=MediaWiki:Editintro'; |
|||
link.innerHTML = "modifica"; |
|||
var span = document.createElement('span'); |
|||
span.className = "editsection"; |
|||
subtitle.insertBefore(span,subtitle.firstChild); |
|||
span.appendChild(link); |
|||
span.innerHTML = '[' + span.innerHTML + ']'; |
|||
return; |
|||
} |
|||
/* Perfeziona i link di condivisione nella sidebar */ |
|||
function sharelinks() { |
|||
var box = document.getElementById("p-condividi"); |
|||
if (box == null) return false; |
|||
var links = box.getElementsByTagName('a'); |
|||
for (var i=0; i < links.length; i++) links[i].target = '_blank'; |
|||
return; |
|||
} |
|||
/* Mostra thumbnail delle immagini nella ricerca */ |
|||
function search_thumb() { |
|||
if (wgPageName != "Speciale:Ricerca") return false; |
|||
var ul = getElementsByClass(document, 'mw-search-results', 'ul'); |
|||
if (ul == null || ul[0] == undefined) return false; |
|||
var li = ul[0].getElementsByTagName('li'); |
|||
if (li.length == 0) return false; |
|||
var a, title, i; |
|||
for (i = 0; i < li.length; i++) { |
|||
a = li[i].getElementsByTagName('a')[0]; |
|||
if (/^File:/i.test(a.title) && !/\.ogg$/i.test(a.title)) addThumb(a, a.title); |
|||
} |
|||
return; |
|||
function addThumb (link, file) { |
|||
var httpRequest = createRequest(); |
|||
var id = setTimeout(function() { httpRequest.abort();}, 30000); |
|||
httpRequest.onreadystatechange = function () { Do(httpRequest, id, link, file); return; } |
|||
httpRequest.open('GET', wgServer + wgScriptPath + "/api.php?action=imagethumb&format=xml&tiwidth=50&tiimage=" + encodeURIComponent(file.replace(/^File:/i, '')), true); |
|||
httpRequest.send(''); |
|||
return; |
|||
} |
|||
function Do(o, id, link, file) { |
|||
if (o.readyState != 4) return; |
|||
clearTimeout(id); |
|||
if (o.status != 200) return; |
|||
if (o.responseXML == null) return; |
|||
if (o.responseXML.normalize) o.responseXML.normalize(); |
|||
if (o.responseXML.getElementsByTagName('thumb')[0] == undefined) return false; |
|||
var url = o.responseXML.getElementsByTagName('thumb')[0].getAttribute("url"); |
|||
if (url == null) return false; |
|||
var img = document.createElement('img'); |
|||
img.src = url; |
|||
img.alt = file; |
|||
img.width = o.responseXML.getElementsByTagName('thumb')[0].getAttribute("width"); |
|||
img.height = o.responseXML.getElementsByTagName('thumb')[0].getAttribute("height"); |
|||
img.style.marginRight = "3px"; |
|||
link.insertBefore(img, link.firstChild); |
|||
return; |
|||
} |
|||
} |
|||
/* Aggiunge l'editintro nei link di modifica anche per gli utenti registrati */ |
|||
function addeditintro() |
|||
{ |
|||
if (wgUserName == null) return false; |
|||
if (document.getElementById('ca-talk')) { |
|||
if (document.getElementById('ca-talk').getAttribute('class')=='new') |
|||
{ |
|||
document.getElementById('ca-talk').getElementsByTagName('a')[0].href = document.getElementById('ca-talk').getElementsByTagName('a')[0].href.concat('&editintro=MediaWiki:Editintro'); |
|||
} |
|||
} |
|||
if (document.getElementById('ca-edit')) |
|||
{ |
|||
var link = document.getElementById('ca-edit').getElementsByTagName('a')[0]; |
|||
if(link==null) return false; /*non sono sicuro che serva, ma nel dubbio lo lascio*/ |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
if (wgCurRevisionId) |
|||
{ |
|||
if(link==null) return false; |
|||
link.href = link.href.concat('&editintro=MediaWiki:Editintro'); |
|||
} |
|||
function sections () { |
|||
var spans = document.getElementsByTagName('span'); |
|||
var i = 0, l; |
|||
for (i in spans) { |
|||
if (/editsection/.test(spans[i].className)) { |
|||
l = spans[i].getElementsByTagName('a')[0]; |
|||
if (l == null) continue; |
|||
l.href = l.href.concat('&editintro=MediaWiki:Editintro'); |
|||
} |
|||
} |
|||
return; |
|||
} |
|||
sections(); |
|||
} |
|||
function communitya () { |
|||
setText(document.getElementById('p-community').getElementsByTagName('h5')[0], "comunità"); |
|||
return; |
|||
} |
|||
/* Template:Caricamento */ |
|||
function jsLoading () { |
|||
var i = 0, array1 = document.getElementsByClass('jsloading-pre'), array2 = document.getElementsByClass('jsloading-post'); |
|||
for (i; i < array1.length; i++) |
|||
array1[i].style.display = 'none'; |
|||
for (i=0; i < array1.length; i++) |
|||
array2[i].style.display = ''; |
|||
return; |
|||
} |
|||
/* Rende il link di modifica sezione identico a quello di wikipedia italiana */ |
|||
function moveeditsection () { |
|||
var el = getElementsByClass(document, 'editsection', 'span'); |
|||
if (el.length == 0) return; |
|||
var tmp, parent; |
|||
for (var i=0; i < el.length; i++) { |
|||
el[i].className += " editsection-it_wiki"; |
|||
parent = el[i].parentNode; |
|||
tmp = parent.removeChild(el[i]); |
|||
parent.appendChild(tmp); |
|||
} |
|||
return; |
|||
} |
} |
Versione delle 16:54, 26 nov 2010
/* Funzione per cambiare il logo per il Nonciversario */
function RandomLogo() {
var logoArray = new Array();
logoArray[0] = 'http://images.wikia.com/nonciclopedia/images/b/bc/Wiki.png';
logoArray[1] = 'http://images1.wikia.nocookie.net/nonciclopedia/images/e/ec/Logo-5-anni_Nonci.png';
logoArray[2] = 'http://images3.wikia.nocookie.net/nonciclopedia/images/a/ae/Logo-5-anni-Nonci-3.png';
var chosenLogo = Math.round(Math.random() * (logoArray.length - 1));
document.getElementById('p-logo').innerHTML = '<a accesskey="z" title="Pagina principale [alt-shift-z]" href="/wiki/Pagina_principale" style="background-image: url(' + logoArray[chosenLogo] + ');"/>';
}
addOnloadHook(RandomLogo);
/********************** OnloadHooks **********************/
var hooks_custom = new Array();
/* Funzioni generali */
function hooks_common () {
Script_Import();
hooks_common_render();
createPurgeButton();
return;
}
addOnloadHook(hooks_common);
/* Funzioni del rendering - separate per richiamarle in anteprima rapida */
var __test_js__ = false;
function hooks_common_render () {
randomlist();
createCollapseButtons();
createNavigationBarToggleButton();
createToggleLinks();
createMorphLinks();
multislide_startup();
multifade_startup();
UserNameReplace();
ref_tooltip();
alertLink();
setTimeout(alertLoad, 1);
alertUnload();
import_script((/\<\;((test)|(abc))(.*)\>\;/.test(document.getElementById('bodyContent').innerHTML) && !__test_js__), "Nonciclopedia:Script/Test.js");
target_blank();
hiddencats_IE();
return;
}
/* Funzioni dell'editor */
function hooks_common_edit () {
if (wgAction != 'edit' && wgAction != 'submit') return;
charinsert_anon_hack();
return;
}
addOnloadHook(hooks_common_edit);
/* Importazione script */
function Script_Import () {
/*
Sintassi: import_script(CONDIZIONE, SCRIPT);
Es.: import_script((wgPageName == "Esempio"), "Esempio.js");
*/
import_script((wgPageName == "Speciale:WidgetDashboard"), "Nonciclopedia:Script/Shoutbox.js");
import_script((wgPageName == "Giochi:CasiNonci/Slot_machine"), "Nonciclopedia:Script/SlotMachine.js");
import_script((wgPageName == "Nonciclopedia:Storia/Pagine commemorative/Pesci d'aprile/4"), "Nonciclopedia:Script/Pesce aprile 2010.js");
import_script((wgPageName == "Utente:Zaza/Sandbox/Monabooktor"), "Nonciclopedia:Script/Monabooktor.js");
return;
}
function import_script (condition, script) {
if(!condition) return;
var scriptElem = document.createElement( 'script' );
scriptElem.type = 'text/javascript';
scriptElem.language = 'javascript';
scriptElem.src = '/index.php?title=' + script + '&action=raw&ctype=text/javascript&smaxage=8400';
document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );
return;
}
/************* Funzioni di utilità generale *************/
/* 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);
};
})();
function getElementsByClass (node, className, tagName) {
if (node.getElementsByClassName && (tagName == undefined || tagName == null || tagName == '*')) return node.getElementsByClassName(className);
var list = node.getElementsByTagName(tagName?tagName:'*');
var array = new Array();
var i = 0;
for (i in list) {
if (hasClass(list[i], className))
array.push(list[i]);
}
return array;
}
/* Creates the method getElementsByClass, if unsupported from the browser */
if(!document.getElementsByClass) document.getElementsByClass = function(className) {
return getElementsByClass(document, className, '*');
};
function getElementsByName (name, root) {
if (root == undefined) root = document;
var e = root.getElementsByTagName('*');
var r = new Array();
for (var i = 0; i < e.length; i++) {
if (e[i].getAttribute('name') == name) r[r.length] = e[i];
}
return r;
}
function getText (e) {
if (e.textContent) return e.textContent;
else if (e.innerText) return e.innerText;
else return null;
}
function setText (e, t) {
if (e.textContent) e.textContent = t;
else if (e.innerText) e.innerText = t;
else { e.textContent = t; e.innerText = t; } // entrambi nulli, non si può discriminare
return;
}
function appendText (e, t) {
if (e.textContent) e.textContent += t;
else if (e.innerText) e.innerText += t;
else { e.textContent = t; e.innerText = t; }
return;
}
/* Crea una request Ajax */
function createRequest () {
if (window.XMLHttpRequest) { // Mozilla, Safari...
return new XMLHttpRequest();
}
else if (window.ActiveXObject) { // IEmmerda
return new ActiveXObject("Microsoft.XMLHTTP");
}
return
}
/* Restituisce il valore di un cookie */
function getCookie(name) {
if (document.cookie.length == 0) return null;
var start = document.cookie.indexOf(name);
if (start == -1) return null;
start += name.length + 1;
var end = document.cookie.indexOf(';', start);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(start,end));
}
/* Aggiunge uno zero alle cifre minori di 10 nella rappresentazione testuale */
function addzero(n) {
if (n<10) return '0' + n.toString();
else return n.toString();
}
function addEvent(el, ev, f, capt) {
if (capt == undefined) capt = false;
if (el.addEventListener) el.addEventListener(ev, f, capt);
else if (el.attachEvent) el.attachEvent('on' + ev, f);
return;
}
function removeEvent(el, ev, f, capt) {
if (capt == undefined) capt = false;
if (el.removeEventListener) el.removeEventListener(ev, f, capt);
else if (el.detachEvent) el.detachEvent('on' + ev, f);
return;
}
var noFade = false;
function Fade (element, delay, i, rev, ratio) {
if (noFade) return;
/* rev = sparizione; se !rev, ratio = opacità finale; se rev, ratio = opacità iniziale*/
var start_time = new Date().getTime();
var start_value = rev? ratio : 0;
element.style.filter = "alpha(opacity=" + start_value * 100 + ")";
element.style.opacity = start_value;
if (!parseInt(element.style.width) && navigator.appName == "Microsoft Internet Explorer") element.style.width = element.offsetWidth + 'px';
setTimeout(function() { Do()} , i);
return;
function Do() {
var cur_time = new Date().getTime();
var past_time = cur_time - start_time;
if (past_time >= delay) { /* ultima chiamata */
var final_value = rev? 0 : ratio;
element.style.filter = "alpha(opacity=" + final_value * 100 + ")";
element.style.opacity = final_value;
return;
}
var progress = past_time/delay;
var new_value = rev? ratio * (1 - progress) : ratio * progress;
element.style.filter = "alpha(opacity=" + new_value * 100 + ")";
element.style.opacity = new_value;
setTimeout(function() { Do(); } , i);
return;
}
}
var noSlide = false;
function Slide(element, param, final_value, final_size, delay, i) {
if (noSlide) return;
/* NB: Il valore finale deve avere la stessa unità di misura di quello iniziale! */
var start_time = new Date().getTime();
var unit = 'px';
if (typeof(final_value) == 'string') {
final_value = final_value.split(/\D/);
if (final_value.length > 1) unit = final_value[1];
final_value = parseFloat(final_value[0]);
}
var start_value = Get();
var sub = (start_value > final_value)? true : false;
var diff = Math.abs(start_value - final_value);
var start_size;
if (param == 'top' || param == 'bottom') start_size = element.parentNode.offsetHeight;
else if (param == 'left' || param == 'right') start_size = element.parentNode.offsetWidth;
var diff_size = Math.abs(start_size - final_size);
setTimeout( function() {Do(); } , i);
return;
function Do() {
var cur_time = new Date().getTime();
var past_time = cur_time - start_time;
if (past_time >= delay) { /* ultima chiamata */
Set(final_value);
if (param == 'top' || param == 'bottom') element.parentNode.style.height = final_size + unit;
else if (param == 'left' || param == 'right') element.parentNode.style.width = final_size + unit;
return;
}
var progress = diff * past_time/delay;
new_value = (sub)? start_value - progress : start_value + progress;
Set(new_value);
new_size = (sub)? start_size - diff_size * past_time/delay: start_size + diff_size * past_time/delay;
if (param == 'top' || param == 'bottom') element.parentNode.style.height = new_size + unit;
else if (param == 'left' || param == 'right') element.parentNode.style.width = new_size + unit;
setTimeout(function() { Do(); } , i);
return;
}
function Get() {
var ret;
switch (param) {
case 'top':
ret = element.style.top;
break;
case 'bottom':
ret = element.style.bottom;
break;
case 'left':
ret = element.style.left;
break;
case 'right':
ret = element.style.right;
break;
default:
return false;
}
if (/em/i.test(ret)) return parseFloat(ret);
return (/\d+/.test(ret))? parseInt(ret) : 0;
}
function Set(v) {
switch (param) {
case 'top':
element.style.top = v + unit;
return;
case 'bottom':
element.style.bottom = v + unit;
return;
case 'left':
element.style.left = v + unit;
return;
case 'right':
element.style.right = v + unit;
return;
default:
return false;
}
}
}
/************* Funzioni applicative ***************/
// ============================================================
// BEGIN Dynamic Navigation Bars (experimantal)
// This script is from Wikipedia. For author attribution, please see http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&action=history
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* [[Wikipedia:NavFrame]].
* Maintainers: [[User:R. Koot]]
*/
var autoCollapse = 0; // numero massimo di barre visibili
// per default al caricamento di una pagina
var collapseCaption = "nascondi";
var expandCaption = "vedi";
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 ( hasClass( Tables[i], "collapsible" ) && !Tables[i].id) {
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].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];
/* only add button and increment count if there is a header row to work with */
if (Header) {
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 );
}
}
}
/** Dynamic Navigation Bars (experimental) *************************************
*
* Description: See [[Wikipedia:NavFrame]].
* Maintainers: UNMAINTAINED
*/
// set up the words in your language
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';
// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = autoCollapse;
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
var noNavSlide = true;
function toggleNavigationBar(indexNavigationBar) {
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {
return false;
}
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
if (!hasClass(NavFrame, 'no-slide') && !noNavSlide) NavSlide(NavFrame, true);
else {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if ( hasClass( NavChild, 'NavPic' ) ) {
NavChild.style.display = 'none';
}
if ( hasClass( NavChild, 'NavContent') ) {
NavChild.style.display = 'none';
}
}
}
NavToggle.firstChild.data = NavigationBarShow;
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (hasClass(NavChild, 'NavPic')) {
NavChild.style.display = 'block';
}
if (hasClass(NavChild, 'NavContent')) {
NavChild.style.display = 'block';
}
}
if (!hasClass(NavFrame, 'no-slide') && !noNavSlide) NavSlide(NavFrame, false);
NavToggle.firstChild.data = NavigationBarHide;
}
}
var NavigationBarSlideDelay = 600;
var NavigationBarSlideInterval = 70;
var NavigationBarFadeDelay = 400;
var NavigationBarFadeInterval = 70;
function NavSlide (NavFrame, close) {
/* close = chiusura */
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent') ) Slide(NavChild);
}
return;
function Slide (element) {
if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.userAgent[navigator.userAgent.indexOf("MSIE") + 5]) >= 8) return;
var fade = !hasClass(NavFrame, 'no-fade');
var start_time = new Date().getTime() + NavigationBarFadeDelay * ((close && fade)? 1.1 : 0);
var size = element.offsetHeight;
var start_value = close? 0: 0 - size;
var final_value = close? 0 - size : 0;
element.style.marginTop = start_value + 'px';
element.style.width = 'auto';
if (fade) {
if (close) Fade(element, NavigationBarFadeDelay, NavigationBarFadeInterval, true, 0.7);
else {
element.style.filter = "alpha(opacity=0)";
element.style.opacity = 0;
}
}
setTimeout(function() { Do(); } , NavigationBarSlideInterval + NavigationBarFadeDelay * ((close && fade)? 1.1 : 0));
return;
function Do() {
var cur_time = new Date().getTime();
var past_time = cur_time - start_time;
if (past_time >= NavigationBarSlideDelay) {
element.style.marginTop = final_value + 'px';
if (!close && fade) Fade(element, NavigationBarFadeDelay, NavigationBarFadeInterval, false, 1);
if (close) element.style.display = 'none';
return;
}
var progress = past_time/NavigationBarSlideDelay;
var new_value = close? final_value * progress : start_value * (1 - progress);
element.style.marginTop = new_value + 'px';
setTimeout(function() { Do(); } , NavigationBarSlideInterval);
return;
}
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
var indexNavigationBar = 0;
// iterate over all < div >-elements
var divs = document.getElementsByTagName("div");
for(
var i=0;
NavFrame = divs[i];
i++
) {
// if found a navigation bar
if (hasClass(NavFrame, "NavFrame")) {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var NavToggleText = document.createTextNode(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 (hasClass(NavFrame.childNodes[j], "NavHead")) {
NavFrame.childNodes[j].appendChild(NavToggle);
}
}
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
// if more Navigation Bars found than Default: hide all
if (NavigationBarShowDefault < indexNavigationBar) {
for(
var i=1;
i<=indexNavigationBar;
i++
) {
toggleNavigationBar(i);
}
}
}
/** Codice sostituzione Username ([[template:USERNAME]]) *******************************
* Inserts user name into <span id="insertusername"></span>
* By [[wikia:User:Splarka|Splarka]]
*/
var disableUsernameReplace = false;
function UserNameReplace() {
if (disableUsernameReplace) return;
var list = getElementsByClass(document.getElementsByTagName('body')[0], "insertusername", 'span');
if (list.length < 1) return;
if (wgUserName) {
for (var i=0; UserName = list[i]; i++) {
setText(UserName, wgUserName);
}
return;
}
var defaultText = "<tuo nome>";
var userpage = document.getElementById("pt-anonuserpage");
if (userpage != null) {
var IP = getText(userpage.getElementsByTagName('a')[0]);
if (IP == null) return;
for (var i=0; UserName = list[i]; i++) {
if (getText(UserName) == defaultText)
setText(UserName, IP);
}
return;
}
var httpRequest;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
var id = setTimeout(function() { httpRequest.abort();}, 30000);
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState != 4) return;
clearTimeout(id);
if (httpRequest.status != 200) return;
if (httpRequest.responseXML == null) return;
var IP = httpRequest.responseXML.getElementsByTagName('userinfo')[0].getAttribute("name");
if (IP == null) return;
for (var i=0; UserName = list[i]; i++) {
if (getText(UserName) == defaultText)
setText(UserName, IP);
}
return;
}
httpRequest.open('GET', wgServer + wgScriptPath + "/api.php?action=query&meta=userinfo&format=xml", true);
httpRequest.send('');
return;
}
/* Generatori di alert */
/* Carica un alert su un link prima di caricare la nuova pagina, oppure su un link "fasullo", senza caricare nessuna nuova pagina*/
function alertLink() {
for(var i=0; Elem = document.getElementsByTagName("span")[i]; i++) {
if((Elem.getAttribute('id') == "alert-link") || (Elem.getAttribute('id') == "alert-nolink")) {
var Link = Elem.firstChild;
var Testo = Elem.title;
Link.setAttribute('onclick', 'alert("' + Testo + '");');
if(Elem.getAttribute('id') == "alert-nolink") {
Link.removeAttribute('href',0);
}
}
}
}
/* Carica uno o più alert al caricamento della pagina */
var disablealertLoad = 0;
function alertLoad() {
if (disablealertLoad) return;
for(var i=0; Elem = document.getElementsByTagName("span")[i]; i++) {
if(Elem.getAttribute('id') == "alert-load") {
var Testo = Elem.innerText || Elem.textContent;
alert(Testo);
}
}
}
/* Carica uno o più alert all'uscita dalla pagina */
function alertUnload() {
if (disablealertLoad) return;
for(var i=0; Elem = document.getElementsByTagName("span")[i]; i++) {
if(Elem.getAttribute('id') == "alert-unload") {
var Testo = Elem.innerText || Elem.textContent;
var temp = document.getElementsByTagName("body")[0].getAttribute('onUnload');
if (temp) document.getElementsByTagName("body")[0].setAttribute('onUnload', temp + 'alert("' + Testo + '");');
else document.getElementsByTagName("body")[0].setAttribute('onUnload', 'alert("' + Testo + '");');
}
}
}
/* Elenchi random */
function randomlist() {
if (document.getElementsByClass('randomlist') &&
document.getElementsByClass('randomcontent') &&
document.getElementsByClass('randomtext')) {
var listNumber = document.getElementsByClass('randomlist').length;
for (var k = 0; k < listNumber; k++) {
var max = parseInt(document.getElementsByClass('randomlist')[k].title);
var List = document.getElementsByClass('randomcontent')[k].getElementsByTagName('li');
var Text = document.getElementsByClass('randomtext')[k];
var N = new Array();
if (max == 1) var dot = '';
else var dot = '• ';
Text.innerHTML = '';
for (var i = 0; i < max; i++) {
do {
n = Math.round(Math.random() * (List.length - 1));
for (var j = 0; j < i && n != -1; j++) {
if (N[j] == n) n = -1;
}
} while (n == -1)
N[i] = n;
var Item = document.createElement('div');
Item.innerHTML = dot + List[n].innerHTML;
Text.appendChild(Item);
}
}
}
}
/* Hook that enables collapsing objects.
* Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com)
* on Encyclopedia Dramatica, stolen by Zaza
* Improved with multiMorph and galleryMorph by MFH
* Enhanced with fading effect by Sanjilops
* Uses publicly available code in one function, where noted. */
var noMorphSFX = true;
/* Function that toggles collapsing objects.
* Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com)
* on Encyclopedia Dramatica, stolen by Zaza
* Uses publicly available code in one function, where noted. */
function tableOrNot(objId) {
if (document.getElementById(objId).tagName == "TABLE") return "table";
else return "block";
}
var toggleLinkDelay = 700;
var toggleLinkInterval = 10;
function toggleCollapse(objToToggle) {
var objToToggle = this.parentNode.id.replace(/Link$/, '');
var linkText = "";
var targetObject = returnObjById(objToToggle);
if (!targetObject) return;
var collapseText = returnObjById(objToToggle + "CollapseText").innerHTML;
var expandText = returnObjById(objToToggle + "ExpandText").innerHTML;
var slide = !hasClass(returnObjById(objToToggle + "Link"), "no-slide") && !noMorphSFX;
var fade = !hasClass(returnObjById(objToToggle + "Link"), 'no-fade') && !noMorphSFX;
if ( targetObject.style.display == "none" ) {
targetObject.style.display = tableOrNot(objToToggle);
linkText = collapseText;
if (slide) Slide(targetObject, false);
if (fade) {
if (!parseInt(targetObject.style.width) && navigator.appName == "Microsoft Internet Explorer") targetObject.style.width = targetObject.offsetWidth + 'px';
targetObject.style.filter = "alpha(opacity=0)";
targetObject.style.opacity = 0;
setTimeout(function () {Fade(targetObject, toggleLinkDelay, toggleLinkInterval, false, 1);}, 1);
}
}
else {
if (slide) {
Slide(targetObject, true);
setTimeout(function() { targetObject.style.display = "none"; }, toggleLinkDelay + toggleLinkInterval);
if (fade) setTimeout(function () {Fade(targetObject, toggleLinkDelay, toggleLinkInterval, true, 0.8);}, 1);
}
else {
if (fade) {
setTimeout(function () {Fade(targetObject, toggleLinkDelay, toggleLinkInterval, true, 0.8);}, 1);
setTimeout(function () {targetObject.style.display = "none"; }, toggleLinkDelay + toggleLinkInterval);
}
else targetObject.style.display = "none";
}
linkText = expandText;
}
var toggleLink = returnObjById(objToToggle + "Link-");
toggleLink.innerHTML = linkText;
function Slide (element, close) {
if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.userAgent[navigator.userAgent.indexOf("MSIE") + 5]) >= 8) return;
var start_time = new Date().getTime();
var size = element.offsetHeight;
var start_value = close? 0: 0 - size;
var final_value = close? 0 - size : 0;
element.style.marginTop = start_value + 'px';
element.style.width = 'auto';
setTimeout(function() { Do(); } , toggleLinkInterval);
return;
function Do() {
var cur_time = new Date().getTime();
var past_time = cur_time - start_time;
if (past_time >= NavigationBarSlideDelay) {
element.style.marginTop = final_value + 'px';
return;
}
var progress = past_time/toggleLinkDelay;
var new_value = close? final_value * progress : start_value * (1 - progress);
element.style.marginTop = new_value + 'px';
setTimeout(function() { Do(); } , toggleLinkInterval);
return;
}
}
}
function createToggleLinks() {
var toggleLinkCollection = document.getElementsByClass("toggleLink");
for (var i = 0; i < toggleLinkCollection.length; i++) {
var spanID = toggleLinkCollection[i].getAttribute("id");
var targetID = spanID.substr(0, spanID.length - 4);
var collapseText = returnObjById(targetID + "CollapseText").innerHTML;
var expandText = returnObjById(targetID + "ExpandText").innerHTML;
var initialState = returnObjById(targetID + "InitialState").innerHTML;
var toggleLink = document.createElement("a");
toggleLinkCollection[i].appendChild(toggleLink);
if (initialState == "0") {
returnObjById(targetID).style.display = "none";
toggleLink.innerHTML = expandText;
}
else {
returnObjById(targetID).style.display = tableOrNot(targetID);
toggleLink.innerHTML = collapseText;
}
toggleLink.onclick = toggleCollapse;
//toggleLink.className = "morphLink";
toggleLink.id = targetID + "Link-";
}
}
/* Functions that performs the morph operation.
* Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com)
* on Encyclopedia Dramatica, stolen by Zaza
* Uses publicly available code in one function, where noted. */
var MorphFadeDelay = 800;
var MorphFadeInterval = 50;
function performMorph(targetID, targetNumber) {
var counter = 1;
while ( returnObjById(targetID + "Content" + counter) ) {
if ( counter == targetNumber ) {
returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter);
if (!hasClass(returnObjById(targetID + "Master"), 'no-fade') && !noMorphSFX) Fade(returnObjById(targetID + "Content" + counter), MorphFadeDelay, MorphFadeInterval, false, 1);
}
else
returnObjById(targetID + "Content" + counter).style.display = "none";
counter++;
}
returnObjById(targetID + "Master").innerHTML = targetNumber;
}
function morphForward() {
var targetID = this.getAttribute('name').replace(/LinkNext$/, '');
var nextPane = parseInt(returnObjById(targetID + "Master").innerHTML) + 1;
if ( returnObjById(targetID + "Content" + nextPane) )
performMorph(targetID, nextPane);
else
performMorph(targetID, "1");
}
function morphBackward() {
var targetID = this.getAttribute('name').replace(/LinkPrev$/, '');
var prevPane = parseInt(returnObjById(targetID + "Master").innerHTML) - 1;
if ( prevPane > 0 )
performMorph(targetID, prevPane);
else {
var maxIndex = 1;
while ( returnObjById(targetID + "Content" + maxIndex) )
maxIndex++;
performMorph(targetID, maxIndex - 1);
}
}
/* Special functions for the galleryMorph,
* created by MFH */
function performGalleryMorph(targetID, targetNumber) {
var counter = 1;
while ( returnObjById(targetID + "Content" + counter) ) {
if ( counter == targetNumber ) {
returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter);
if (!hasClass(returnObjById(targetID + "Master"), 'no-fade') && !noMorphSFX) Fade(returnObjById(targetID + "Content" + counter), MorphFadeDelay, MorphFadeInterval, false, 1);
}
else
returnObjById(targetID + "Content" + counter).style.display = "none";
counter++;
}
if (targetNumber == 1) {
returnObjById(targetID + "LinkPrev").style.display = "none";
}
else {
returnObjById(targetID + "LinkPrev").style.display = tableOrNot(targetID + "LinkPrev");
}
if (targetNumber == counter - 1) {
returnObjById(targetID + "LinkNext").style.display = "none";
}
else {
returnObjById(targetID + "LinkNext").style.display = tableOrNot(targetID + "LinkNext");
}
galleryCounter = returnObjById(targetID + "Master").getAttribute("counter");
returnObjById(targetID + "Counter").innerHTML = "(" + targetNumber + "/" + galleryCounter + ")";
returnObjById(targetID + "Master").innerHTML = targetNumber;
}
function galleryMorphForward() {
var targetID = this.getAttribute('name').replace(/LinkNext$/, '');
var nextPane = parseInt(returnObjById(targetID + "Master").innerHTML) + 1;
if ( returnObjById(targetID + "Content" + nextPane) )
performGalleryMorph(targetID, nextPane);
else
performGalleryMorph(targetID, "1");
}
function galleryMorphBackward() {
var targetID = this.getAttribute('name').replace(/LinkPrev$/, '');
var prevPane = parseInt(returnObjById(targetID + "Master").innerHTML) - 1;
if ( prevPane > 0 )
performGalleryMorph(targetID, prevPane);
else {
var maxIndex = 1;
while ( returnObjById(targetID + "Content" + maxIndex) )
maxIndex++;
performGalleryMorph(targetID, maxIndex - 1);
}
}
/* Function that creates ED's collapsing objects and toggle links.
* Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com)
* on Encyclopedia Dramatica, stolen by Zaza
* Uses publicly available code in one function, where noted.
*
* Updated: 1/11/2008 by WhiteMystery to add new Morphing Objects
* functionality.
* Updated: 23/5/2009 by MFH to add 2 new kinds of morph:
* multiMorph and galleryMorph */
function createMorphLinks () {
var morphMasterCollection = document.getElementsByClass("morphMaster");
var multiMorphMasterCollection = document.getElementsByClass("multiMorphMaster");
var galleryMorphMasterCollection = document.getElementsByClass("galleryMorphMaster");
for (var i = 0; i < morphMasterCollection.length; i++) {
var spanID = morphMasterCollection[i].getAttribute("id");
var targetID = spanID.substr(0, spanID.length - 6);
var counter = 1;
// Create forward and backward paging if the paging elements exist
if ( returnObjById(targetID + "LinkNext") && returnObjById(targetID + "LinkPrev") && returnObjById(targetID + "Content1") ) {
// Create the forward link
var nextLink = document.createElement("div");
nextLink.innerHTML = returnObjById(targetID + "LinkNext").innerHTML;
nextLink.setAttribute('name', targetID + "LinkNext");
nextLink.onclick = morphForward;
nextLink.className = "morphLink";
returnObjById(targetID + "LinkNext").innerHTML = "";
returnObjById(targetID + "LinkNext").appendChild(nextLink, 0);
// Create the backward link
var prevLink = document.createElement("div");
prevLink.innerHTML = returnObjById(targetID + "LinkPrev").innerHTML;
prevLink.setAttribute('name', targetID + "LinkPrev");
prevLink.onclick = morphBackward;
prevLink.className = "morphLink";
returnObjById(targetID + "LinkPrev").innerHTML = "";
returnObjById(targetID + "LinkPrev").appendChild(prevLink, 0);
// Initialize content panes
while ( returnObjById(targetID + "Content" + counter) ) {
if ( counter == 1 )
returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter);
else
returnObjById(targetID + "Content" + counter).style.display = "none";
counter++;
}
}
counter = 1;
// Whether or not there is paging, generate normal links
while (returnObjById(targetID + "Link" + counter) && returnObjById(targetID + "Content" + counter)) {
var morphLink = document.createElement("div");
morphLink.innerHTML = returnObjById(targetID + "Link" + counter).innerHTML;
returnObjById(targetID + "Link" + counter).innerHTML = "";
returnObjById(targetID + "Link" + counter).appendChild(morphLink);
morphLink.className = "morphLink";
morphLink.setAttribute('name', targetID + "Link" + counter);
morphLink.onclick = function () {
var targetID = this.getAttribute('name').replace(/Link\d+$/, '');
var targetNumber = this.parentNode.id.replace(/.+Link/, '');
performMorph(targetID, targetNumber);
return
};
// Initialize content panes
if (counter == 1)
returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter);
else
returnObjById(targetID + "Content" + counter).style.display = "none";
counter++;
}
morphMasterCollection[i].innerHTML = "1";
morphMasterCollection[i].style.display = "none";
}
for (var i = 0; i < multiMorphMasterCollection.length; i++) {
var spanID = multiMorphMasterCollection[i].getAttribute("id");
var targetID = spanID.substr(0, spanID.length - 6);
var counter = 1;
// Create forward and backward paging if the paging elements exist
if (document.getElementsByClass(targetID + "LinkNext") && document.getElementsByClass(targetID + "LinkPrev") && document.getElementsByClass(targetID + "Content1")) {
// Create the forward link
var nextLinkCollection = document.getElementsByClass(targetID + "LinkNext");
for (j = 0; j < nextLinkCollection.length; j++) {
var nextLink = document.createElement("div");
nextLink.innerHTML = nextLinkCollection[j].innerHTML;
nextLink.setAttribute('name', targetID + "LinkNext");
nextLink.onclick = morphForward;
nextLink.className = "morphLink";
nextLinkCollection[j].innerHTML = "";
nextLinkCollection[j].appendChild(nextLink, 0);
}
// Create the backward link
var prevLinkCollection = document.getElementsByClass(targetID + "LinkPrev");
for (j = 0; j < prevLinkCollection.length; j++) {
var prevLink = document.createElement("div");
prevLink.innerHTML = prevLinkCollection[j].innerHTML;
prevLink.setAttribute('name', targetID + "LinkPrev");
prevLink.onclick = morphBackward;
prevLink.className = "morphLink";
prevLinkCollection[j].innerHTML = "";
prevLinkCollection[j].appendChild(prevLink, 0);
}
// Initialize content panes
while (returnObjById(targetID + "Content" + counter)) {
if (counter == 1)
returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter);
else
returnObjById(targetID + "Content" + counter).style.display = "none";
counter++;
}
}
counter = 1;
// Whether or not there is paging, generate normal links
while ( document.getElementsByClass(targetID + "Link" + counter) && returnObjById(targetID + "Content" + counter) ) {
var morphLinkCollection = document.getElementsByClass(targetID + "Link" + counter);
for (j = 0; j < morphLinkCollection.length; j++) {
var morphLink = document.createElement("div");
morphLink.innerHTML = morphLinkCollection[j].innerHTML;
morphLinkCollection[j].innerHTML = "";
morphLink.setAttribute('name', targetID + "Link" + counter);
morphLinkCollection[j].appendChild(morphLink, 0);
morphLink.onclick = function () {
var targetID = this.getAttribute('name').replace(/Link\d+$/, '');
var targetNumber = this.getAttribute('name').replace(/.+Link/, '');
performMorph(targetID, targetNumber);
return
};
morphLink.className = "morphLink";
}
// Initialize content panes
if (counter == 1)
returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter);
else
returnObjById(targetID + "Content" + counter).style.display = "none";
counter++;
}
multiMorphMasterCollection[i].innerHTML = "1";
multiMorphMasterCollection[i].style.display = "none";
}
for (var i = 0; i < galleryMorphMasterCollection.length; i++) {
var spanID = galleryMorphMasterCollection[i].getAttribute("id");
var targetID = spanID.substr(0, spanID.length - 6);
var counter = 1;
// Create forward and backward paging if the paging elements exist
if ( returnObjById(targetID + "LinkNext") && returnObjById(targetID + "LinkPrev") && returnObjById(targetID + "Content1") ) {
// Create the forward link
var nextLink = document.createElement("div");
nextLink.innerHTML = returnObjById(targetID + "LinkNext").innerHTML;
nextLink.setAttribute('name', targetID + "LinkNext");
nextLink.onclick = galleryMorphForward;
nextLink.className = "morphLink";
returnObjById(targetID + "LinkNext").innerHTML = "";
returnObjById(targetID + "LinkNext").appendChild(nextLink, 0);
// Create the backward link
var prevLink = document.createElement("div");
prevLink.innerHTML = returnObjById(targetID + "LinkPrev").innerHTML;
prevLink.setAttribute('name', targetID + "LinkPrev");
prevLink.onclick = galleryMorphBackward;
prevLink.className = "morphLink";
returnObjById(targetID + "LinkPrev").innerHTML = "";
returnObjById(targetID + "LinkPrev").appendChild(prevLink, 0);
// Initialize content panes
while ( returnObjById(targetID + "Content" + counter) ) {
if (counter == 1)
returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter);
else
returnObjById(targetID + "Content" + counter).style.display = "none";
counter++;
}
if (counter == 2) {
returnObjById(targetID + "LinkNext").style.display = "none";
}
galleryCounter = counter - 1;
returnObjById(targetID + "Master").setAttribute("counter", galleryCounter);
if (returnObjById(targetID + "Counter")) {
returnObjById(targetID + "Counter").innerHTML = "(1/" + galleryCounter + ")";
}
}
galleryMorphMasterCollection[i].innerHTML = "1";
galleryMorphMasterCollection[i].style.display = "none";
}
}
/* Function that toggles ED's collapsing objects.
* Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com)
* on Encyclopedia Dramatica, stolen by Zaza
* Taken from http://www.netlobo.com/javascript_get_element_id.html */
function returnObjById(id) {
if (document.getElementById)
var returnVar = document.getElementById(id);
else if (document.all)
var returnVar = document.all[id];
else if (document.layers)
var returnVar = document.layers[id];
return returnVar;
}
/* Attiva il charinsert per gli anonimi nel box "newarticleintro" */
function charinsert_anon_hack () {
if(!(wgAction == "edit" && wgArticleId == 0 && wgUserName == null)) return;
var box = getElementsByClass(document.getElementById("bodyContent"), "mw-newarticletextanon", 'div')[0];
if (!box) return;
var link = '<' + 'a href="#" onclick="insertTags('$1','','');return false">$1<' + '/a>';
box.innerHTML = box.innerHTML.replace(/<charinsert>(.+?)<\/charinsert>/, link);
return;
}
/* Function to add a "purge" button at the top of the page,
* usefull for dpl, random and similar things that need the
* cache of the server.
*
* Created by MFH */
var buttonPurge = 0;
function createPurgeButton() {
if (buttonPurge == 0 || wgCanonicalNamespace == 'Special') return;
if (document.getElementById('ca-report-problem')) { /* Modifies the "report a problem" button, that is already invisible */
document.getElementById('ca-report-problem').getElementsByTagName('a')[0].innerHTML = 'Purge';
document.getElementById('ca-report-problem').getElementsByTagName('a')[0].href = wgServer + wgScriptPath + '/index.php?title=' + wgPageName + '&action=purge';
document.getElementById('ca-report-problem').setAttribute('id', 'ca-purge');
}
else {
var menuList = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
var newLi = document.createElement('li');
newLi.setAttribute('id', 'ca-purge');
newLi.innerHTML = '<a href="' + wgServer + wgScriptPath + '/index.php?title=' + wgPageName + '&action=purge">Purge</a>';
menuList.appendChild(newLi);
}
}
/* Visualizza correttamente categorie nascoste in IE */
function hiddencats_IE () {
if (navigator.appName != "Microsoft Internet Explorer") return;
var div = document.getElementById("mw-hidden-catlinks");
if (div == null) return;
var span = document.createElement('span');
span.id = 'mw-hidden-catlinks-switch';
span.innerHTML = ">>";
div.insertBefore(span, div.firstChild);
return;
}
/* Class che aggiunge "target= '_blank'" ai link */
function target_blank () {
var tags = getElementsByClass(document.getElementsByTagName('body')[0], "target-blank");
if (tags == null) return;
var i, j, links;
for (i=0; i < tags.length; i++) {
links = tags[i].getElementsByTagName('a');
for (j=0; j < links.length; j++) links[j].target = '_blank';
}
return;
}
/* Visualizza note come tooltip */
/* by Sanjilops - http://nonciclopedia.wikia.com/wiki/Utente:Sanjilops */
var disablereftooltip = false;
function ref_tooltip () {
if (disablereftooltip) return;
var refs = getElementsByClass(document.getElementById('bodyContent'), "reference", 'sup');
if (!refs) return;
for (var i = 0; i < refs.length; i++) Do(refs[i]);
return;
function Do (ref) {
var span = document.createElement('span');
var id = ref.id.substr('cite_ref-'.length);
span.className = "reference-tt";
span.id = "cite_tt-" + id;
var li = document.getElementById('cite_note-' + id.replace(/_(\d+)-\d+$/, '-$1'));
if (!li) return;
var temp = li.innerHTML;
temp = temp.split(/^.+a href=\"#cite_ref-.+\" title=\"\">.+?<\/a>(<\/sup>)? /);
span.innerHTML = (temp.length)? temp[temp.length - 1] : temp;
if (ref.offsetLeft < document.getElementById('bodyContent').offsetWidth/2) span.style.left = (ref.offsetWidth - 1) + 'px';
else span.style.right = (ref.offsetWidth - 1) + 'px';
temp = getText(span);
temp = temp.length * 12;
span.style.width = (temp < 400)? temp + 'px' : "400px";
ref.appendChild(span);
return;
}
}
/* Funzione che imposta il tasto "modifica" sulla versione corrente nella schermata delle differenze; non attiva di default.
* Per attivarla inserire nel proprio monobook.js il codice:
addOnloadHook(editcurrentid);
*/
function editcurrentid () {
var b = document.getElementById('ca-edit');
if (!b) return;
if (getElementsByClass(document, 'diff', 'table').length == 0) return;
var l = b.firstChild;
l.href = l.href.replace(/&oldid=\d+/, '');
appendText(l, '*');
return;
}
/* multiSFX */
var multislide_time = 1000;
var multislide_interval = 10;
var noMultislide = false;
var multislide_state = new Object();
var multislide_master = new Object();
function multislide_startup () {
if (noMultislide) return;
var toggles = getElementsByClass(document, "multislideToggle");
if (!toggles.length) return;
var names = new Array();
var id = '', i, elements, master;
for (var I=0; I< toggles.length; I++) {
id = toggles[I].title;
if (String(names).indexOf(id) != -1) continue;
names[names.length] = id;
multislide_state[id] = false;
master = document.getElementById(id + "Master");
if (master) {
multislide_master[id] = new Object();
multislide_master[id].onload = hasClass(master, "slideOnload");
multislide_master[id].time = (/slideTime-\d+/.test(master.className))? parseInt(master.className.match(/slideTime-(\d+)/)[1]) : -1;
multislide_master[id].fade = hasClass(master, "slideFade");
}
else multislide_master[id] = null;
}
var dom, n;
for (I=0; I< names.length; I++) {
id = names[I];
n = 0;
dom = document.getElementsByTagName('body')[0].getElementsByTagName('*');
for (i = 0; i < dom.length; i++) {
if (dom[i].title == id && dom[i].nodeName.toUpperCase() != 'A') {
if (hasClass(dom[i], "multislideToggle")) {
dom[i].setAttribute('name', id + "-Toggle");
CreateToggle(dom[i], id, n);
n++;
}
else {
dom[i].setAttribute('name', id + "-Content");
SetStartPosition(dom[i]);
}
dom[i].removeAttribute('title');
}
}
if (multislide_master[id] && multislide_master[id].onload) multislide_toggle(id, multislide_master[id].time);
}
return;
function CreateToggle (el, id, n) {
var time = (/slideTime-\d+/.test(el.className))? parseInt(el.className.match(/slideTime-(\d+)/)[1]) : -1;
var fade = hasClass(el, "slideFade");
if (hasClass(el, "slideHover")) {
el.onmouseover = function () {multislide_toggle(id, time, fade, true); return;}
el.onmouseout = function () {multislide_toggle(id, time, fade, false); return;}
}
else el.onclick = function () {multislide_toggle(id, time, fade); return;};
var On = getElementsByClass(el, "slideOn")[0];
if (!On) return;
var toggle;
if (el.firstChild.nodeType != 1) {
toggle = document.createElement('span');
toggle.innerHTML = el.firstChild.nodeValue;
el.replaceChild(toggle, el.firstChild);
}
else toggle = el.firstChild;
toggle.id = id + "-toggle" + n; /* dato che n è i, gli id possono non essere consecutivi */
On.id = id + "-toggle" + n + "-on";
var Off = getElementsByClass(el, "slideOff")[0];
if (!Off) {
Off = toggle.cloneNode(true);
Off.style.display = 'none';
el.appendChild(Off);
}
Off.id = id + "-toggle" + n + "-off";
return;
}
function SetStartPosition (el) {
var height = el.offsetHeight;
var width = el.offsetWidth;
if (hasClass(el, "slideFromTop")) {
el.style.top = '-' + height + 'px';
return;
}
if (hasClass(el, "slideFromBottom")) {
el.style.bottom = '-' + height + 'px';
return;
}
if (!hasClass(el.parentNode, "slideNoResize") && (el.parentNode.style == undefined || !el.parentNode.style.height)) el.parentNode.style.height = height + 'px';
if (hasClass(el, "slideFromLeft")) {
el.style.left = '-' + width + 'px';
return;
}
if (hasClass(el, "slideFromRight")) el.style.right = '-' + width + 'px';
return;
}
}
function multislide_toggle(id, toggle_time, toggle_fade, hoverWantedState) {
if(hoverWantedState != undefined && hoverWantedState == multislide_state[id]) return;
var contents = getElementsByName(id + "-Content");
var el, time, fade;
for (var i = 0; i < contents.length; i++) {
el = contents[i];
if (/slideTime-\d+/.test(el.className)) time = parseInt(el.className.match(/slideTime-(\d+)/)[1]);
else {
if (toggle_time != -1) time = toggle_time;
else {
if (multislide_master[id] && multislide_master[id].time != -1) time = multislide_master[id].time;
else time = multislide_time;
}
}
fade = hasClass(el, "slideFade") || toggle_fade || (multislide_master[id] && multislide_master[id].fade);
var dir = el.className.match(/slideFrom(Top|Bottom|Left|Right)/)[0].substr(9).toLowerCase();
var framesize;
if (!multislide_state[id]) {
if (dir == 'top' || dir == 'bottom') framesize = el.parentNode.offsetHeight + el.offsetHeight;
else if (dir == 'left' || dir == 'right') framesize = el.parentNode.offsetWidth + el.offsetWidth;
Slide(el, dir, 0, framesize, time, multislide_interval);
}
else {
var size;
if (dir == 'top' || dir == 'bottom') { size = el.offsetHeight; framesize = el.parentNode.offsetHeight - size; }
else if (dir == 'left' || dir == 'right') { size = el.offsetWidth; framesize = el.parentNode.offsetWidth - size; }
Slide(el, dir, 0 - size, framesize, time, multislide_interval);
}
if (fade) _fade(el, time, multislide_state[id]);
}
var toggles = getElementsByName(id + "-Toggle");
for (var i = 0; i < toggles.length; i++) {
var el = document.getElementById(id + "-toggle" + i);
if (!el) continue;
el.innerHTML = (multislide_state[id])? document.getElementById(id + "-toggle" + i + "-off").innerHTML : document.getElementById(id + "-toggle" + i + "-on").innerHTML;
}
multislide_state[id] = !multislide_state[id];
return;
function _fade (el, time, rev) {
setTimeout(function () {Fade(el, time, multislide_interval, rev, (rev? 0.8 : 1)); }, 1);
setTimeout(function () {el.style.filter = "alpha(opacity=100)"; el.style.opacity = 1; }, time + 5*multislide_interval);
return;}
}
var multifade_time = 1000;
var multifade_interval = 10;
var multifade_state = new Object();
var multifade_master = new Object();
var noMultifade = false;
function multifade_startup () {
if (noMultifade) return;
var toggles = getElementsByClass(document, "multifadeToggle");
if (!toggles.length) return;
var names = new Array();
var id = '', i, elements, master;
for (var I=0; I< toggles.length; I++) {
id = toggles[I].title;
if (String(names).indexOf(id) != -1) continue;
names[names.length] = id;
multifade_state[id] = false;
master = document.getElementById(id + "Master");
if (master) {
multifade_master[id] = new Object();
multifade_master[id].onload = hasClass(master, "fadeOnload");
multifade_master[id].time = (/fadeTime-\d+/.test(master.className))? parseInt(master.className.match(/fadeTime-(\d+)/)[1]) : -1;
}
else multifade_master[id] = null;
}
var dom, n;
for (I=0; I< names.length; I++) {
id = names[I];
n = 0;
dom = document.getElementsByTagName('body')[0].getElementsByTagName('*');
for (i = 0; i < dom.length; i++) {
if (dom[i].title == id && dom[i].nodeName.toUpperCase() != 'A') {
if (hasClass(dom[i], "multifadeToggle")) {
dom[i].setAttribute('name', id + "-Toggle");
CreateToggle(dom[i], id, n);
n++;
}
else {
dom[i].setAttribute('name', id + "-Content");
dom[i].style.opacity = 0;
dom[i].style.filter = 'alpha(opacity=0)';
}
dom[i].removeAttribute('title');
}
}
if (multifade_master[id] && multifade_master[id].onload) multifade_toggle(id, multifade_master[id].time);
}
return;
function CreateToggle (el, id, n) {
el.setAttribute('name', id + "-Toggle");
var time = (/fadeTime-\d+/.test(el.className))? parseInt(el.className.match(/fadeTime-(\d+)/)[1]) : -1;
if (hasClass(el, "fadeHover")) {
el.onmouseover = function () {multifade_toggle(id, time, true); return;}
el.onmouseout = function () {multifade_toggle(id, time, false); return;}
}
else el.onclick = function () {multifade_toggle(id, time); return;};
var On = getElementsByClass(el, "fadeOn")[0];
if (!On) return;
var toggle;
if (el.firstChild.nodeType != 1) {
toggle = document.createElement('span');
toggle.innerHTML = el.firstChild.nodeValue;
el.replaceChild(toggle, el.firstChild);
}
else toggle = el.firstChild;
toggle.id = id + "-toggle" + n; /* dato che n è i, gli id possono non essere consecutivi */
On.id = id + "-toggle" + n + "-on";
var Off = getElementsByClass(el, "fadeOff")[0];
if (!Off) {
Off = toggle.cloneNode(true);
Off.style.display = 'none';
el.appendChild(Off);
}
Off.id = id + "-toggle" + n + "-off";
return;
}
}
function multifade_toggle(id, general_time, hoverWantedState) {
if(hoverWantedState != undefined && hoverWantedState == multifade_state[id]) return;
var contents = getElementsByName(id + "-Content");
var el, time;
for (var i = 0; i < contents.length; i++) {
el = contents[i];
if (/fadeTime-\d+/.test(el.className)) time = parseInt(el.className.match(/fadeTime-(\d+)/)[1]);
else {
if (general_time != -1) time = general_time;
else {
if (multifade_master[id] && multifade_master[id].time != -1) time = multifade_master[id].time;
else time = multifade_time;
}
}
Fade(el, time, multifade_interval, multifade_state[id], multifade_state[id]? 0.8 : 1);
}
var toggles = getElementsByName(id + "-Toggle");
for (var i = 0; i < toggles.length; i++) {
var el = document.getElementById(id + "-toggle" + i);
if (!el) continue;
el.innerHTML = (multifade_state[id])? document.getElementById(id + "-toggle" + i + "-off").innerHTML : document.getElementById(id + "-toggle" + i + "-on").innerHTML;
}
multifade_state[id] = !multifade_state[id];
return;
}
/* Parser for simple math expressions
Created by MFH for Nonciclopedia */
function opSolve(opArray, posArray) {
var opDivided = new Array(Array(opArray[posArray[0]][0]));
var posDivided = new Array(Array(posArray[0], 0)); /* Position, length-1*/
var opDivInd = 0;
for (var i = 1; i < posArray.length; i++) { /* Separates the different brackets*/
if (posArray[i] == posArray[i-1] + 1) {
opDivided[opDivInd].push(opArray[posArray[i]][0]);
posDivided[opDivInd][1] = posDivided[opDivInd][1] + 1;
}
else {
opDivInd = opDivInd + 1;
posDivided.push(Array(posArray[i], 1));
}
}
for (var i = 0; i <= opDivInd; i++) {
for (var j = 1; j < opDivided[opDivInd].length - 1; j++) {
if (opDivided[i][j] == '^') {
opDivided[i][j-1] = Math.pow(parseFloat(opDivided[i][j-1]),parseFloat(opDivided[i][j+1]));
opDivided[i].splice(j, 2);
j = j - 1;
}
}
for (var j = 1; j < opDivided[opDivInd].length - 1; j++) {
if (opDivided[i][j] == '*') {
opDivided[i][j-1] = parseFloat(opDivided[i][j-1])*parseFloat(opDivided[i][j+1]);
opDivided[i].splice(j, 2);
j = j - 1;
}
if (opDivided[i][j] == '/') {
opDivided[i][j-1] = parseFloat(opDivided[i][j-1])/parseFloat(opDivided[i][j+1]);
opDivided[i].splice(j, 2);
j = j - 1;
}
}
for (var j = 1; j < opDivided[opDivInd].length - 1; j++) {
if (opDivided[i][j] == '+') {
opDivided[i][j-1] = parseFloat(opDivided[i][j-1])+parseFloat(opDivided[i][j+1]);
opDivided[i].splice(j, 2);
j = j - 1;
}
if (opDivided[i][j] == '-') {
opDivided[i][j-1] = parseFloat(opDivided[i][j-1])-parseFloat(opDivided[i][j+1]);
opDivided[i].splice(j, 2);
j = j - 1;
}
}
}
for (var i = posDivided.length -1; i >= 0; i--) {
opArray[posDivided[i][0]] = Array(opDivided[i][0], opArray[posDivided[i][0]][1] - 1);
opArray.splice(posDivided[i][0]+1, posDivided[i][1]);
}
return opArray;
}
function math_parser(operation, xValue) {
var opArray = new Array();
var brInd = 0; /* Bracket index */
var brIndMax = 0;
for (var i = 0; i < operation.length; i++) { /* Divides the string in single characters */
var textChunk = operation.substr(i,1);
if (textChunk != ' ') { /* Removes useless spaces */
if (textChunk == '(') { /* Removes brackets, conserving the information */
brInd = brInd + 1;
if (brInd > brIndMax) {
brIndMax = brInd;
}
}
else if (textChunk == ')') {
brInd = brInd - 1;
}
else if (textChunk == 'x') {
opArray.push(Array(xValue, brInd));
}
else {
opArray.push(Array(textChunk, brInd));
}
}
}
i = 0;
while (i < opArray.length - 1) { /* Puts numbers together again */
if ((opArray[i][0].match(/[0-9\.]/) || (opArray[i][0].match(/-/) && (i == 0 || opArray[i-1][1] < opArray[i][1]))) && opArray[i+1][0].match(/[0-9\.]/)) {
/* If is a number or a comma, or if is a minus at the beginnig of a bracket; and the following is a number or a comma */
opArray[i][0] = opArray[i][0] + opArray[i+1][0];
opArray.splice(i+1, 1);
}
else {
i++;
}
}
for (var i = brIndMax; i >= 0; i--) {
var posArray = new Array();
for (var j = 0; j < opArray.length; j++) {
if (opArray[j][1] == i) {
posArray.push(j);
}
}
opArray = opSolve(opArray, posArray);
}
return opArray[0][0];
}
/*Analisi delle visite*/
function init() {
codice = document.createElement('script');
codice.type = 'text/javascript';
if (wgUserName) {
codice.innerHTML = "var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-17496928-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();";
}
else {
codice.innerHTML = "var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-17496918-1']); _gaq.push(['_trackPageview']); (function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();";
}
headTag = document.getElementsByTagName("head")[0];
headTag.appendChild(codice);
}
addOnloadHook(init);
/* Funzione returnto in Special:Signup - disattivata per problemi */
/*function entraSignUp() {
if(!wgUserName) {
document.getElementById('pt-login').innerHTML='<a accesskey="o" title="La registrazione è consigliata, anche se non obbligatoria [o]" href="/index.php?title=Speciale:Signup&returnto=' + wgPageName + '>Entra / Registrati</a>'
}
}
addOnloadHook(entraSignUp);*/
function facebooklikeboxTEST() {
window.fbAsyncInit = function() {
FB.init({appId: '331743818234', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
addOnloadHook(facebooklikeboxTEST);
}