Utente:Gvf/ToolbarButton.js

Versione del 18 nov 2007 alle 17:54 di Gvf (discussione | contributi) (cambio immagine bottone decenni)

Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.


Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.

// <pre> 
// <nowiki>
// Basato su [[Utente:Timendum/Javascript]] che ringrazio

if (window.addEventListener) window.addEventListener("load",myLoadFuncs,false);
else if (window.attachEvent) window.attachEvent("onload",myLoadFuncs);
else
{
    window.previousLoadFunction = window.onload;
    window.onload = function()
    {
        window.previousLoadFunction();
        myLoadFuncs();
    }
}
function myLoadFuncs()
{
    /* addLoadEvent(ToolbarButton); */
    ToolbarButton();     // modifica la Toolbar
    // addPurge();        // aggiunge pulsante "purge"
    // add_tabs();        // aggiunge i tab 
    //addToolBoxLinks(); // aggiunge i link nel portlet "strumenti"
    //addNavBarLinks();  // aggiunge i link nel portlet "navigazione"
    // ta['pt-logout'] = ['x', 'Logout (esci)']; //cambia l'accesskey per "logout"
    //akeytt();    
}

function GvfAddButton(id,testo,img,js) {
  var toolbar = null;
  toolbar = document.getElementById("toolbar");
 
  var tmp = document.createElement("a");
  tmp.id = 'tb-'+id;
  tmp.href = "javascript:(function () {"+js+"})();";
  var imag = document.createElement("img");
  imag.setAttribute('border',0);
  imag.setAttribute('height',32);
  imag.setAttribute('src',img);
  imag.setAttribute('alt','['+id+']');
  imag.setAttribute('title',testo);
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);
}

function Decenni() {
  wpTextbox1=document.getElementById("wpTextbox1");
  wpTextbox1.value=wpTextbox1.value
		.replace("anni '20", "anni venti")
		.replace("anni '30", "anni trenta")
		.replace("anni '40", "anni quaranta")
		.replace("anni '50", "anni cinquanta")
		.replace("anni '60", "anni sessanta")
		.replace("anni '70", "anni settanta")
		.replace("anni '80", "anni ottanta")
		.replace("anni '90", "anni novanta")
}
/**** Personalizzazione della ToolBar ****/

// ToolbarButton
function ToolbarButton() {
  var toolbar = null;
  toolbar = document.getElementById("toolbar");
  if (toolbar == null)
    return;
  
  var today = new Date();
  var anno= today.getYear()+1900;

  var nodes = toolbar.childNodes;
  // elimino i bottoni che non mi interessano (indici validi solo per FF)
  //nodes[3].style.display = "none !important";  // grassetto
  //nodes[4].style.display = "none !important";  // corsivo
  //nodes[6].style.display = "none !important";  // link ext
  //nodes[7].style.display = "none !important";  // intestazione
  //nodes[8].style.display = "none !important";  // inserimento immagine
  //nodes[9].style.display = "none !important";  // link multimedia
  //nodes[10].style.display = "none !important";  // math
  //nodes[13].style.display = "none !important"; // linea
  //nodes[14].style.display = "none !important"; // red


// pulsante IMMAGINE a sinistra
GvfAddButton('addimg-l',
  'Immagine a sinistra',
  'http://upload.wikimedia.org/wikipedia/it/d/d9/ToolButton_img_l.png',
  'insertTags("[[Immagine:","|thumb|180px|left|Descrizione]]","NomeFile");TimenSA("Aggiunta immagine");'
  );

// pulsante IMMAGINE a destra
GvfAddButton('addimg-r',
  'Immagine a destra',
  'http://upload.wikimedia.org/wikipedia/it/d/d9/ToolButton_img_r.png',
  'insertTags("[[Immagine:","|thumb|180px|right|Descrizione]]","NomeFile");TimenSA("Aggiunta immagine");'
  );

// pulsante CANCELCOPY
//  tmp = document.createElement("a");
//  tmp.id = 'tb-cyc';
//  tmp.href = 'javascript:(function() //{wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{cancelcopy|firma=~~~|fonte="+(prompt("Fonte")) //+"}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{cancella //subito copyviol}} ";})();';
//  imag = document.createElement("img");
//  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/d/de/Wiki_copydel.gif');
//  imag.setAttribute('alt','[DCP]');
//  imag.setAttribute('title','{{cancelcopy}}');
//  tmp.appendChild(imag);
//  toolbar.appendChild(tmp);

// pulsante COPYVIOL
//  tmp = document.createElement("a");
//  tmp.id = 'tb-cvi';
//  tmp.href = 'javascript:(function() //{wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{ViolazioneCopyright|url="+(prompt("Fonte")) //+"}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"copyviol //";})();';
//  imag = document.createElement("img");
//  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/5/50/Wiki_copyviol.png');
//  imag.setAttribute('alt','[CVI]');
//  imag.setAttribute('title','{{copyviol}}');
//  tmp.appendChild(imag);
//  toolbar.appendChild(tmp);


// pulsante Template stemma stato
  tmp = document.createElement("a");
  tmp.id = 'tb-tss';
  tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="Stemma "+(prompt("Stato"))+"\\n\\n{{StemmiNazionali|continente="+(prompt("Continente"))+"}}\\n";summ=document.getElementById("wpSummary");summ.value="- gfdl + template StemmiNazionali";})();';
  imag = document.createElement("img");
  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/4/44/ToolButton.png');
  imag.setAttribute('alt','[STATO]');
  imag.setAttribute('title','{{Stemma stato}}');
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);

// pulsante Template stemma comune
  tmp = document.createElement("a");
  tmp.id = 'tb-tsc';
  tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{StemmiComunaliItaliani\\n|comune="+(prompt("Comune"))+"\\n|provincia="+(prompt("Provincia"))+"\\n|autorizzazione=\\n|fonte=\\n|OTRS=\\n}}";summ=document.getElementById("wpSummary");summ.value="+ template StemmiComunaliItaliani";})();';
  imag = document.createElement("img");
  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/4/44/ToolButton.png');
  imag.setAttribute('alt','[COMU]');
  imag.setAttribute('title','{{Stemma comune}}');
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);

// pulsante Categoria:utente
  tmp = document.createElement("a");
  tmp.id = 'tb-ciuw';
  tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value=wpTextbox1.value+"[[Categoria:Immagini utenti di Wikipedia]]";summ=document.getElementById("wpSummary");summ.value="+ categoria immagini utenti wikipedia";})();';
  imag = document.createElement("img");
//  imag.setAttribute('src','');
  imag.setAttribute('alt','[CIUW]');
  imag.setAttribute('title','[[Categoria:Immagini utenti di Wikipedia]]');
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);

// pulsante {{Avvisocopyviol}}
  tmp = document.createElement("a");
  tmp.id = 'tb-acv';
  tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value=wpTextbox1.value+"{{Avvisocopyviol|url=|voce=}}\\n~~~~";summ=document.getElementById("wpSummary");summ.value="+ Avviso copyviol";})();';
  imag = document.createElement("img");
  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/4/44/ToolButton.png');
  imag.setAttribute('alt','[AvCV]');
  imag.setAttribute('title','{{Avvisocopyviol}}');
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);

GvfAddButton('coord',
  '{{Coord}}',
  'http://upload.wikimedia.org/wikipedia/it/9/9e/ToolButton_coord.png',
  'Param=prompt("Latitudine,Longitudine");Param=Param.replace(", ","|"); Param=Param.replace(",","|"); TimenPr("{{Coord|"+Param+"|scale:2000|format=dms|display=title}}\\n");TimenSA("+ template Coord");'
  );

GvfAddButton('decenni',
  'Fix decenni',
  'http://upload.wikimedia.org/wikipedia/it/e/e3/ToolButtonDecenni.png',
  "Decenni();TimenSA('* decenni');"
  );
}

/**** Aggiunge un generico tab ****/

function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

/**** Aggiunge un tab come menu ****/

function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '#';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}

/**** Aggiunge il tab "purge" ****/

function addPurge()
{
    ta['ca-purge'] = ['g', 'Pulisci la cache'];
    if(!document.getElementById) return;
    var x = document.getElementById('ca-history');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(!x) return;
    if(x.children) x = x.children[0];
    else x = x.childNodes[0];
    
    var pf = document.createElement('form');
    pf.action = '?action=purge';
    pf.method = 'POST';
    pf.id = 'pf';
    x.appendChild(pf);
    
    addlilink(tabs, 'javascript:document.getElementById("pf").submit();', 'purge', 'ca-purge');
    akeytt();
}
// </nowiki>
// </pre>