Utente:IPork/wikisource completo.js

Da Wikisource.

Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.

  • Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
  • Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
  • Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
  • Opera: premi Ctrl-F5.
// <pre>
// <nowiki>
//-------------------------------------------------------------------------------
//                              CODICI USATI DAL SISTEMA
//-------------------------------------------------------------------------------
function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    na.accesskey = key;
    var pref = 'alt-';
    if(((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1)) || navigator.userAgent.toLowerCase().indexOf( 'mac' ) != -1 ) pref = 'control-';
    if(clientPC.indexOf('opera')!=-1) pref = 'shift-esc-';
    if(key && title) na.title = title + ' [' + pref + key + ']';
    else if(title) na.title = title;
    else if(key) na.title = '[' + pref + key + ']';
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}
function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    addlilink(tabs, url, name, id, title, key);
}
function addToolboxLink(url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, url, name, id);
}
function changeLinks(){
    if(!document.getElementById) return;
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'Discussioni';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'Preferenze';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'Osservati';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'Contributi';
    document.getElementById('pt-logout').firstChild.innerHTML = 'Esci';
}

//-------------------------------------------------------------------------------
//                              FUNZIONI COMUNI
//-------------------------------------------------------------------------------
// PURGE PER PULIRE LA CACHE IN OGNI PAGINA
//-------------------------------------------------------------------------------
function addPurge(){
    var x = document.getElementById('ca-history');
    if(!x) return;
    if(x.children) x = x.children[0].href;
    else x = x.childNodes[0].href;
    addTab(x.replace(/=history/, "=purge"), 'purge', 'ca-purge', 'Purga la cache per questa pagina', 'g');
}
//-------------------------------------------------------------------------------
// FIXFORMAT - FORMATTA I TESTI PER CORREGGERE GLI ERRORI COMUNI
//-------------------------------------------------------------------------------
function fixformat(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = txt.value
        .replace(/\’/g, "'")
        .replace(/E' /g, "È ")
        .replace(/É /g, "È ")
        .replace(/ pò/g, " po'")
        .replace(/ e'/g, " è")
        .replace(/ é/g, " è")
        .replace(/ nè /g, " né ")
        .replace(/ ne' /g, " né ")
        .replace(/piu'/g, "più")
        .replace(/ quà/g, " qua")
        .replace(/affinchè/g, "affinché")
        .replace(/affinche' /g, "affinché ")
        .replace(/sicchè/g, "sicché")
        .replace(/benchè/g, "benché")
        .replace(/benche' /g, "benché ")
        .replace(/perchè/g, "perché")
        .replace(/perche' /g, "perché ")
        .replace(/poichè/g, "perché")
        .replace(/poiche' /g, "poiché ")
        .replace(/<\/?(b|strong)>/gi, "'''")
        .replace(/<\/?(i|em|var)>/gi, "''")
         //.replace(/\{\{([Ss]u[bp])\|([^}]+)\}\}/g, "{{subst:$1|$2}}")
         //.replace(/<\/div +>/gi, "</div>");
    form.wpSummary.value += "Formattazione testo";
    form.wpMinoredit.checked = true;
}
//-------------------------------------------------------------------------------
// REPLACE - TROVA-SOTITUISCI USANDO REGEX
//-------------------------------------------------------------------------------
function replace() {
    var s = prompt("Cerca regexp?");
    if(s) {
        var r = prompt("Sostituisci regexp?");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "g"), r);
    }
}
//-------------------------------------------------------------------------------
// VOTA - INSERISCE LA SEZIONE LINKATA PER FACILITARE LE VOTAZIONI
//-------------------------------------------------------------------------------
function vota(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value += '{{Vota}}\n';
    form.wpSummary.value = 'Vota';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// PIU - VOTO POSITIVO
//-------------------------------------------------------------------------------
function piu(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value += '{{+1}}\n';
    form.wpSummary.value = '+1';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// MENO - VOTO NEGATIVO
//-------------------------------------------------------------------------------
function meno(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value += '{{-1}}\n';
    form.wpSummary.value = '-1';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// ZERO - VOTO INDIFFERENTE
//-------------------------------------------------------------------------------
function zero(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value += '{{0}}\n';
    form.wpSummary.value = '0';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// CONTAVOTI - INSERISCE TABELLA RIEPILOGATIVA POST VOTAZIONE
//-------------------------------------------------------------------------------
function contavoti(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value += '{{ContaVoti\n|NumeroVotanti=\n|NumeroFavorevoli=\n|NumeroContrari=\n|NumeroAstenuti=\n}}\n';
    form.wpSummary.value = 'Conteggio dei voti';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// CAT - INSERISCE LA CATEGORIA
//-------------------------------------------------------------------------------
function cat(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '[[Categoria:]]';
    form.wpSummary.value = 'Aggiunta categoria';
    form.wpMinoredit.checked = true; 
}

//-------------------------------------------------------------------------------
//                              FUNZIONI SPECIFICHE PER NAMESPACE
//-------------------------------------------------------------------------------
//               UTENTE:
//-------------------------------------------------------------------------------
// BLOCCOIP - INSERISCE IL TEMPLATE PER BLOCCO CAUSA VANDALISMI RIPETUTI
//-------------------------------------------------------------------------------
function bloccoip(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value = '{{Vandalo recidivo}}' + txt.value;
    form.wpSummary.value = 'IP bloccato per vandalismi ripetuti';
}
//-------------------------------------------------------------------------------
// STRUMENTI PER AMMINISTRATORI - BLOCCO UTENTE
//-------------------------------------------------------------------------------
function do_blockip_stuff(){
    var form = document.getElementById('blockip');
    form.wpBlockReason.focus();
    var target = getParam('ip');
    if(target == '') return;
    addTab('/wiki/Speciale:Log/block?page=Utente:' + target, 'log dei blocchi', 'ca-blocklog');
}
function add_block_tab(){
    var c1 = document.getElementById('column-one');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
    editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));
    editlk = editlk.substring(editlk.indexOf(':') + 1);
    var slloc = editlk.indexOf('/');
    if(slloc > 0) editlk = editlk.substring(0, slloc);
    addTab('/wiki/Speciale:Blockip?ip=' + editlk, 'blocca utente', 'ca-block');
    addTab('/wiki/Speciale:Log/block?page=Utente:' + editlk, 'log dei blocchi', 'ca-blocklog');
}
function blockip(){
    if(document.title.indexOf('Utente:') == 0 || document.title.indexOf('Discussioni utente:') == 0)
        add_block_tab();
    else if(document.title.indexOf('Block user') == 0) 
        do_blockip_stuff();
}
function getParam(name){
    if(location.search){
        for(var x in location.search.substring(1).split('&')){
            var eq = x.indexOf('=');
            if(x.substring(0, eq) == name) return x.substring(eq + 1);
        }
    }
    return '';
}
//-------------------------------------------------------------------------------
//               DISCUSSIONE UTENTE:
//-------------------------------------------------------------------------------
// WELCOME - PER DARE IL BENVENUTO AI NUOVI UTENTI
//-------------------------------------------------------------------------------
function welcome(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{Benvenuto|nome={{PAGENAME}}|firma=~~~~}}';
    form.wpSummary.value = 'Benvenuto';
}
//-------------------------------------------------------------------------------
// RISPOSTA - PER INDICARE CHE LA RISPOSTA AD UN MESSAGGIO È ALTROVE
//-------------------------------------------------------------------------------
function risposta(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += 'Ti ho risposto [[PAGINA|qui]]. ~~~~';
    form.wpSummary.value = 'Risposta al tuo messaggio';
}
//-------------------------------------------------------------------------------
// BLOCCO - INSERISCE AVVISO PER BLOCCO RICEVUTO
//-------------------------------------------------------------------------------
function blocco(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{Blocco|MOTIVO|DURATA}}';
    form.wpSummary.value = 'Blocco utente';
}
//-------------------------------------------------------------------------------
// AVVISONUI - AVVISA L'UTENTE CHE HA SCELTO UN NOME UTENTE INAPPROPRIATO
//-------------------------------------------------------------------------------
function avvisonui(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += 'Come indicato nella pagina [[Aiuto:Nome utente]] hai scelto un nome utente scorretto. Ti invito entro una settimana ad indicare su [[Wikisource:Burocrati/Rinominare|questa pagina]] un nuovo nome che sostituirà l\'attuale. In caso contrario provvederemo a bloccare questo account. ~~~~';
    form.wpSummary.value = 'Nome utente inappropriato';
}
//-------------------------------------------------------------------------------
// NUI - INSERISCE IL MOTIVO DEL BLOCCO PER NOME UTENTE INAPPROPRIATO
//-------------------------------------------------------------------------------
function nui(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{BloccoNomeUtente}}';
    form.wpSummary.value = 'Blocco nome utente';
}
//-------------------------------------------------------------------------------
// SPAM - INVITA L'UTENTE A NON PROSEGUIRE CON LO SPAM
//-------------------------------------------------------------------------------
function spam(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{Spam}}';
    form.wpSummary.value = 'Spam';
}
//-------------------------------------------------------------------------------
// TEST - INVITA L'UTENTE A NON PROSEGUIRE CON I TEST SULLE PAGINE
//-------------------------------------------------------------------------------
function test(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{test}}';
    form.wpSummary.value = 'Test';
}
//-------------------------------------------------------------------------------
// VANDALISMO - INVITA L'UTENTE A NON PROSEGUIRE CON I VANDALISMI
//-------------------------------------------------------------------------------
function vandalismo(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{vandalismo}}';
    form.wpSummary.value = 'Vandalismo';
}

//-------------------------------------------------------------------------------
//               IMMAGINE:
//-------------------------------------------------------------------------------
// UNVERIFIED - PER LE IMMAGINI CHE NON HANNO INDICATA UNA LICENZA
//-------------------------------------------------------------------------------
function unverified(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{unverified}}\n' + txt.value;
    form.wpSummary.value = 'unverified';
    form.wpMinoredit.checked = true;  
}

//-------------------------------------------------------------------------------
//               CATEGORIA:
//-------------------------------------------------------------------------------
// VEDIANCHE - INSERISCE IL TEMPLATE VEDI ANCHE
//-------------------------------------------------------------------------------
function vedianche(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value = '{{Vedi anche|NOME PAGINA}}\n' + txt.value;
    form.wpSummary.value = '+ vedi anche';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// VEDIANCHECATEGORIA - INSERISCE IL TEMPLATE VEDI ANCHE CATEGORIA
//-------------------------------------------------------------------------------
function vedianchecategoria(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value = '{{Vedi anche categoria|NOME CATEGORIA}}\n' + txt.value;
    form.wpSummary.value = '+ vedi anche categoria';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// VEDIANCHEPROGETTO - INSERISCE IL TEMPLATE VEDI ANCHE PROGETTO
//-------------------------------------------------------------------------------
function vediancheprogetto(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value = '{{Vedi anche progetto|NOME PROGETTO}}\n' + txt.value;
    form.wpSummary.value = '+ vedi anche progetto';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// VEDIANCHEWIKIPEDIA - INSERISCE IL TEMPLATE VEDI ANCHE WIKIPEDIA
//-------------------------------------------------------------------------------
function vedianchewikipedia(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value = '{{Vedi anche Wikipedia|NOME PAGINA}}\n' + txt.value;
    form.wpSummary.value = '+ vedi anche Wikipedia';
    form.wpMinoredit.checked = true; 
}

//-------------------------------------------------------------------------------
//               AIUTO:
//-------------------------------------------------------------------------------
// MIGLIORARE - INSERISCE L'INVITO A PERFEZIONARE LA PAGINA DI AIUTO
//-------------------------------------------------------------------------------
function migliorare(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Da migliorare}}\n' + txt.value;
    form.wpSummary.value = 'Pagina di aiuto da migliorare';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// SUGGERIMENTO - INSERISCE UN BOX PER AGGIUNGERE UN SUGGERIMENTO
//-------------------------------------------------------------------------------
function suggerimento(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value += '{{Suggerimento\n|testo=\n}}\n';
    form.wpSummary.value = 'Aggiunto suggerimento';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// ESEMPIO - INSERISCE UN BOX PER AGGIUNGERE UN ESEMPIO
//-------------------------------------------------------------------------------
function esempio(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value += '{{Esempio\n|testo=\n}}\n';
    form.wpSummary.value = 'Aggiunto esempio';
    form.wpMinoredit.checked = true;  
}

//-------------------------------------------------------------------------------
//               TEMPLATE:
//-------------------------------------------------------------------------------
// ESOTERIC - PER AVVISARE CHE SI TRATTA DI UN TEMPLATE CONDIZIONALE
//-------------------------------------------------------------------------------
function esoteric(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value = '<noinclude>{{esoteric}}</noinclude>' + txt.value;
    form.wpSummary.value = 'Template con variabili condizionali';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// NOINCLUDE - INSERISCE IL CODICE NOINCLUDE
//-------------------------------------------------------------------------------
function noinclude(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '<noinclude></noinclude>';
    form.wpSummary.value = '';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// INCLUDEONLY - INSERISCE IL CODICE INCLUDEONLY
//-------------------------------------------------------------------------------
function includeonly(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '<includeonly></includeonly>';
    form.wpSummary.value = '';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// DESCRIZIONE - INSERISCE IL CODICE PER LA DESCRIZIONE DEL TEMPLATE
//-------------------------------------------------------------------------------
function descrizione(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '<noinclude>__NOEDITSECTION__\n<div class="toccolours" style="clear:both; margin-bottom: 0.5em; font-size: 90%;">\n=== Descrizione ===\n...\n=== Uso ===\nRicopiare il testo sottostante e modificare le \'\'parole in corsivo\'\' in base alle esigenze.\n: \'\'\'<nowiki>{{</nowiki>\'\'\'\n: \'\'\'<nowiki></nowiki>\'\'\'\'\'PAROLA IN CORSIVO\'\'\n: \'\'\'<nowiki>}}</nowiki>\'\'\'\n=== Approfondimento ===\nUna guida completa all\'uso di questo template si trova nella pagina \'\'\'[[Aiuto:]]\'\'\'.\n</div>[[Categoria:|{{PAGENAME}}]]</noinclude>\n';
    form.wpSummary.value = 'Aggiunta descrizione del template';
    form.wpMinoredit.checked = true; 
}

//-------------------------------------------------------------------------------
//               AUTORE:
//-------------------------------------------------------------------------------
// AUTORE: INSERISCE IL TEMPLATE AUTORE
//-------------------------------------------------------------------------------
function autore(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value = '{{autore\n|NomeCognome=\n|Cognome,Nome=\n|InizialeCognome=\n|Date=\n|ProfessioneNazionalità=\n|NomeWikipedia=\n|NomeWikiquote=\n|NomeWikicommons=\n|TOC=si\n|NomeImmagine=\n}}\n' + txt.value;
    form.wpSummary.value = 'Aggiunto template autore';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// CASSETTOAUTORE - INSERISCE IL CASSETTO
//-------------------------------------------------------------------------------
function cassettoautore(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{Cassetto\n|MargineDestro=190\n|Titolo=\n|Testo=\n}}\n';
    form.wpSummary.value = 'Aggiunto cassetto';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// REFAUTORE - AGGIUNGE IL CODICE REF PER LE NOTE
//-------------------------------------------------------------------------------
function refautore(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '<ref></ref>';
    form.wpSummary.value = 'Aggiunta nota';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// NOTEAUTORE - AGGIUNGE LA SEZIONE NOTE
//-------------------------------------------------------------------------------
function noteautore(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '==== Note ====\n<div class="references-small"><references/></div>\n';
    form.wpSummary.value = 'Aggiunta sezione per le note';
    form.wpMinoredit.checked = true; 
}

//-------------------------------------------------------------------------------
//               PRINCIPALE:
//-------------------------------------------------------------------------------
// DISAMBIGUA - PER CREARE UNA PAGINA DI DISAMBIGUAZIONE
//-------------------------------------------------------------------------------
function disambigua(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value = '{{Disambigua}}' + txt.value;
    form.wpSummary.value = 'Creata pagina di disambiguazione';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// POEM - INSERISCE IL CODICE POEM
//-------------------------------------------------------------------------------
function poem(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '<poem>\n\n</poem>\n';
    form.wpSummary.value = 'Formattato testo con poem';
    form.wpMinoredit.checked = true; 
}
//-------------------------------------------------------------------------------
// COPYRIGHT - PER SEGNALARE UN TESTO IN ODORE DI COPYVIOL
//-------------------------------------------------------------------------------
function copyright(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{ViolazioneCopyright|url=}}';
    form.wpSummary.value = 'Possibile violazione di copyright';
}
//-------------------------------------------------------------------------------
// CANCELLARE - PER SEGNALARE UNA PAGINA DA CANCELLARE SUBITO
//-------------------------------------------------------------------------------
function cancellare(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{cancella subito}}\n' + txt.value;
    form.wpSummary.value = 'Pagina da cancellare subito';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// CANCELLARE PER MANCANZA FONTE - PER SEGNALARE UNA PAGINA DA CANCELLARE 
//-------------------------------------------------------------------------------
function cancellaremancanzafonte(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Da cancellare per mancanza di fonte|firma=~~~~}}\n' + txt.value;
    form.wpSummary.value = 'Pagina da cancellare per mancanza fonte';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// CONTROLLARE - PER SEGNALARE UN TESTO DA CONTROLLARE
//-------------------------------------------------------------------------------
function controllare(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{da controllare|firma=~~~~|motivo=descrizione del motivo}}\n' + txt.value;
    form.wpSummary.value = 'Pagina da controllare';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// TRADURRE - PER SEGNALARE UN TESTO DA TRADURRE
//-------------------------------------------------------------------------------
function tradurre(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Da tradurre|lingua=lingua}}\n' + txt.value;
    form.wpSummary.value = 'Da tradurre';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// WIP - PER SEGNALARE UN WORK IN PROGRESS
//-------------------------------------------------------------------------------
function wip(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{WIP|[[Utente:iPork|iPork]]}}\n' + txt.value;
    form.wpSummary.value = 'Work in progress';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// BLOCCOVANDALO - PER SEGNALARE UNA PAGINA BLOCCATA PER VANDALISMI
//-------------------------------------------------------------------------------
function bloccovandalo(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Avvisobloccovandalismo}}\n' + txt.value;
    form.wpSummary.value = 'Pagina bloccata per vandalismi';
    form.wpMinoredit.checked = true;  
}

//-------------------------------------------------------------------------------
//               DISCUSSIONE PRINCIPALE:
//-------------------------------------------------------------------------------
// INFOTESTO - INSERISCE IL TEMPLATE INFOTESTO 
//-------------------------------------------------------------------------------
function infotesto(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Infotesto\n|Edizione=\n|Fonte=\n|TradottoDa=\n|ContributoDi=\n|SAL=\n|Note=\n|RilettoDa=\n}}\n' + txt.value;
    form.wpSummary.value = 'Informazioni sul testo';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// INFOTESTOBIBBIA - INSERISCE IL TEMPLATE INFOTESTO BIBBIA
//-------------------------------------------------------------------------------
function infotestobibbia(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Infotesto bibbia\n|Edizione=\n|Fonte=\n|TradottoDa=\n|ContributoDi=\n|SAL=\n|Note=\n|RilettoDa=\n}}\n' + txt.value;
    form.wpSummary.value = 'Informazioni sul testo';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// INFOTESTOCANTASTORIA - INSERISCE IL TEMPLATE INFOTESTO CANTASTORIA
//-------------------------------------------------------------------------------
function infotestocantastoria(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Infotesto cantastoria\n|Edizione=\n|Incisioni=\n|Fonte=\n|TradottoDa=\n|ContributoDi=\n|SAL=\n|Note=\n|RilettoDa=\n}}\n' + txt.value;
    form.wpSummary.value = 'Informazioni sul testo';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// INFOTESTOCRISTIANESIMO - INSERISCE IL TEMPLATE INFOTESTO CRISTIANESIMO
//-------------------------------------------------------------------------------
function infotestocristianesimo(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Infotesto cristianesimo\n|Edizione=\n|Fonte=\n|TradottoDa=\n|ContributoDi=\n|SAL=\n|Note=\n|RilettoDa=\n}}\n' + txt.value;
    form.wpSummary.value = 'Informazioni sul testo';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// INFOTESTO DIRITTO - INSERISCE IL TEMPLATE INFOTESTO DIRITTO
//-------------------------------------------------------------------------------
function infotestodiritto(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Infotesto diritto\n|Edizione=\n|Fonte=\n|TradottoDa=\n|ContributoDi=\n|SAL=\n|Note=\n|RilettoDa=\n}}\n' + txt.value;
    form.wpSummary.value = 'Informazioni sul testo';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// INFOTESTO LETTERATURA - INSERISCE IL TEMPLATE INFOTESTO LETTERATURA
//-------------------------------------------------------------------------------
function infotestoletteratura(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Infotesto letteratura\n|Edizione=\n|Fonte=\n|TradottoDa=\n|ContributoDi=\n|SAL=\n|Note=\n|RilettoDa=\n}}\n' + txt.value;
    form.wpSummary.value = 'Informazioni sul testo';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// INFOTESTOOPENSOURCE - INSERISCE IL TEMPLATE INFOTESTO OPEN SOURCE
//-------------------------------------------------------------------------------
function infotestoopensource(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{Infotesto open source\n|Edizione=\n|Fonte=\n|TradottoDa=\n|ContributoDi=\n|SAL=\n|Note=\n|RilettoDa=\n}}\n' + txt.value;
    form.wpSummary.value = 'Informazioni sul testo';
    form.wpMinoredit.checked = true;  
}
//-------------------------------------------------------------------------------
// INFOTESTOPAGINECOLLEGATE - INSERISCE RIMANDO ALLA PAGINA CON LE INFORMAZIONI
//-------------------------------------------------------------------------------
function infotestopaginecollegate(){
    if(popupInfotestoPagineCollegate=true) {
        var nomepaginaprincipale = prompt("Inserisci il nome della pagina principale");
        if(nomepaginaprincipale) {
            var form = document.editform;
            var txt = form.wpTextbox1;
            txt.value = '{{Infotesto pagine collegate\n|NomePaginaPrincipale=' + nomepaginaprincipale + '\n}}\n' + txt.value;
            form.wpSummary.value = 'Informazioni sul testo';
            form.wpMinoredit.checked = true;  
        }
    }else{
            var form = document.editform;
            var txt = form.wpTextbox1;
            txt.value = '{{Infotesto pagine collegate\n|NomePaginaPrincipale=\n}}\n' + txt.value;
            form.wpSummary.value = 'Informazioni sul testo';
            form.wpMinoredit.checked = true;  
    }
}

function setOptions() {
	newOption('popupInfotestoPagineCollegate',               true);
}



//-------------------------------------------------------------------------------
//                              MENU A SINISTRA
//-------------------------------------------------------------------------------
// ELENCA I COLLEGAMENTI ROSSI
//-------------------------------------------------------------------------------
function listRedLinks() {
    var len=document.links.length;
    var output=document.createElement('div');
    output.innerHTML='<h2>Collegamenti verso pagine inesistenti</h2>';
    var gotSome=false;
    for (var i=0; i<len; ++i) {
        if (document.links[i].className=='new') {
            gotSome=true;
            var l=document.links[i].cloneNode(true);
            output.appendChild(l);
            output.appendChild(document.createElement('br'));
        }
    }
    if (gotSome){
        output.appendChild(document.createElement('hr'));
        var h1=document.getElementsByTagName('h1')[0];
        h1.parentNode.insertBefore(output, h1.nextSibling);
    }
}
$(function(){addToolboxLink('javascript:listRedLinks()', 'Elenca i link rossi');});

//-------------------------------------------------------------------------------
//                              MENU IN ALTO
//-------------------------------------------------------------------------------
function morelinks(){
  if(document.title.indexOf("Modifica di Utente:") == 0){
        addTab('javascript:bloccoip()', 'Blocco IP');
    }else if(document.title.indexOf("Modifica di Discussioni utente:") == 0){
        addTab('javascript:welcome()', 'Benvenuto');
        addTab('javascript:risposta()', 'Risposta');
        addTab('javascript:blocco()', 'Blocco');
        addTab('javascript:avvisonui()', 'Avviso NUI');
        addTab('javascript:nui()', 'Blocco NUI');
        addTab('javascript:spam()', 'Spam');
        addTab('javascript:test()', 'Test');
        addTab('javascript:vandalismo()', 'Vand');
    }else if(document.title.indexOf("Modifica di Immagine:") == 0){
        addTab('javascript:unverified()', 'Unv');
    }else if(document.title.indexOf("Modifica di Categoria:") == 0){
        addTab('javascript:vedianche()', 'Vd. anche');
        addTab('javascript:vedianchecategoria()', 'Vd. categoria');
        addTab('javascript:vediancheprogetto()', 'Vd. progetto');
        addTab('javascript:vedianchewikipedia()', 'Vd. Wikipedia');
        addTab('javascript:cat()', 'Cat');
    }else if(document.title.indexOf("Modifica di Discussioni categoria:") == 0){
        addTab('javascript:vota()', 'Vota');
        addTab('javascript:piu()', '+1');
        addTab('javascript:meno()', '-1');
        addTab('javascript:zero()', '0');
        addTab('javascript:contavoti()', 'Conta voti');
    }else if(document.title.indexOf("Modifica di Aiuto:") == 0){
        addTab('javascript:replace()', 'Sostituisci');
        addTab('javascript:fixformat()', 'Formatta');
        addTab('javascript:suggerimento()', 'Sugg');
        addTab('javascript:esempio()', 'Esempio');
        addTab('javascript:migliorare()', 'Migliorare');
    }else if(document.title.indexOf("Modifica di Discussioni aiuto:") == 0){
        addTab('javascript:vota()', 'Vota');
        addTab('javascript:piu()', '+1');
        addTab('javascript:meno()', '-1');
        addTab('javascript:zero()', '0');
        addTab('javascript:contavoti()', 'Conta voti');
    }else if(document.title.indexOf("Modifica di Wikisource:") == 0){
        addTab('javascript:replace()', 'Sostituisci');
        addTab('javascript:fixformat()', 'Formatta');
        addTab('javascript:suggerimento()', 'Sugg');
        addTab('javascript:esempio()', 'Esempio');
        addTab('javascript:vota()', 'Vota');
        addTab('javascript:piu()', '+1');
        addTab('javascript:meno()', '-1');
        addTab('javascript:zero()', '0');
        addTab('javascript:contavoti()', 'Conta voti');
    }else if(document.title.indexOf("Modifica di Discussioni Wikisource:") == 0){
        addTab('javascript:vota()', 'Vota');
        addTab('javascript:piu()', '+1');
        addTab('javascript:meno()', '-1');
        addTab('javascript:zero()', '0');
        addTab('javascript:contavoti()', 'Conta voti');
    }else if(document.title.indexOf("Modifica di Template:") == 0){
        addTab('javascript:esoteric()', 'Esoteric');
        addTab('javascript:noinclude()', 'No include');
        addTab('javascript:includeonly()', 'Include only');
        addTab('javascript:descrizione()', 'Descrizione');
    }else if(document.title.indexOf("Modifica di Discussioni template:") == 0){
        addTab('javascript:vota()', 'Vota');
        addTab('javascript:piu()', '+1');
        addTab('javascript:meno()', '-1');
        addTab('javascript:zero()', '0');
        addTab('javascript:contavoti()', 'Conta voti');
    }else if(document.title.indexOf("Modifica di Autore:") == 0){
        addTab('javascript:autore()', 'Aut');
        addTab('javascript:cassettoautore()', 'Cass');
        addTab('javascript:cat()', 'Cat');
        addTab('javascript:refautore()', 'Ref');
        addTab('javascript:noteautore()', 'Note');
    }else if(document.title.indexOf("Modifica di Discussioni autore:") == 0){
    }else if(document.title.indexOf("Modifica di Discussione:") == 0){
        addTab('javascript:infotesto()', 'it');
        addTab('javascript:infotestobibbia()', 'it.bibb');
        addTab('javascript:infotestocantastoria()', 'it.cant');
        addTab('javascript:infotestocristianesimo()', 'it.crist');
        addTab('javascript:infotestodiritto()', 'it.dir');
        addTab('javascript:infotestoletteratura()', 'it.lett');
        addTab('javascript:infotestoopensource()', 'it.open');
        addTab('javascript:infotestopaginecollegate()', 'it.capitoli');
    }else if(document.title.indexOf("Modifica di") == 0){
        addTab('javascript:replace()', 'Sostituisci');
        addTab('javascript:fixformat()', 'Formatta');
        addTab('javascript:poem()', 'Poem');
        addTab('javascript:cancellare()', 'Canc');
        addTab('javascript:cancellaremancanzafonte()', 'CancNoFonte');
        addTab('javascript:controllare()', 'Contr');
        addTab('javascript:disambigua()', 'Dis');
        addTab('javascript:tradurre()', 'Trad');
        addTab('javascript:wip()', 'WIP');
        addTab('javascript:copyright()', 'Copy');
        addTab('javascript:bloccovandalo()', 'Vand')
    }
    var tabs = document.getElementById('p-cactions').cloneNode(true);
    tabs.id = 'mytabs';
    var listitems = tabs.getElementsByTagName('LI');
    for (i=0;i<listitems.length;i++) {
      if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
    }
    document.getElementById('column-content').appendChild(tabs);
}

//-------------------------------------------------------------------------------
//                              CODICE PER CARICARE LE DIVERSE FUNZIONI
//-------------------------------------------------------------------------------
function myLoadFuncs(){
    addPurge();
    changeLinks();
    morelinks();
    blockip();
    setOptions();
}
if (window.addEventListener) window.addEventListener("load",myLoadFuncs,false);
else if (window.attachEvent) window.attachEvent("onload",myLoadFuncs);
else{
    window._old_ABCD_onload = window.onload;
    window.onload = function(){
        window._old_ABCD_onload();
        myLoadFuncs();
    }
if (window.addEventListener) window.addEventListener("load",morelinks,false);
else if (window.attachEvent) window.attachEvent("onload",morelinks);
}
//</nowiki>
//</pre>