Utente:Gvf/ToolbarButton.js
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();
}
}
// ToolbarButton
function ToolbarButton() {
var toolbar = null;
toolbar = document.getElementById("toolbar");
if (toolbar == null)
return;
var today = new Date();
var anno= today.getYear()+1900;
var tmp= today.getMonth()+1;
switch (tmp)
{
case 1:
var mese="gennaio"
break;
case 2:
var mese="febbraio"
break;
case 3:
var mese="marzo"
break;
case 4:
var mese="aprile"
break;
case 5:
var mese="maggio"
break;
case 6:
var mese="giugno"
break;
case 7:
var mese="luglio"
break;
case 8:
var mese="agosto"
break;
case 9:
var mese="settembre"
break;
case 10:
var mese="ottobre"
break;
case 11:
var mese="novembre"
break;
case 12:
var mese="dicembre"
break;
}
var nodes = toolbar.childNodes;
// elimino i bottoni che non mi interessano
// inserimento immagine
nodes[8].style.display = "none !important";
// linea
nodes[13].style.display = "none !important";
// pulsante IMMAGINE
tmp = document.createElement("a");
tmp.id = 'tb-addimg';
tmp.href = 'javascript:(function() {insertTags("[[immagine:","|thumb|200px|right|Descrizione]]","NomeFile");summ=document.getElementById("wpSummary");summ.value=summ.value+"Aggiunta immagine";})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/a/ad/ToolButton_img.png');
imag.setAttribute('alt','[Img2]');
imag.setAttribute('title','Immagine');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
// pulsante DA WIKIFICARE
tmp = document.createElement("a");
tmp.id = 'tb-wik';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{wik|'+mese+' '+anno+'}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{wik}}";})();';
var imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/7/71/Wikifichino.gif');
imag.setAttribute('alt','[Wik]');
imag.setAttribute('title','{{wikificare}}');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
// pulsante STUB
tmp = document.createElement("a");
tmp.id = 'tb-wik';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{stub}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{stub}}";})();';
var imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/1/11/Stubber.png');
imag.setAttribute('alt','[Stub]');
imag.setAttribute('title','{{stub}}');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
// pulsante DA AIUTARE
tmp = document.createElement("a");
tmp.id = 'tb-aiu';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{da aiutare|motivo="+(prompt("Motivo"))+"|data='+mese+' '+anno+'}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{da aiutare}}";})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/2/23/Aiutino.gif');
imag.setAttribute('alt','[Aiu]');
imag.setAttribute('title','{{da aiutare}}');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
// pulsante VOTO FAVOREVOLE +1
tmp = document.createElement("a");
tmp.id = 'tb-piu';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value=wpTextbox1.value+"* +1 ~~~ ~~~~~";summ=document.getElementById("wpSummary");summ.value=summ.value+"+1";document.getElementById("wpMinoredit").checked=1;})();';
var imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/f/f8/Favorevole.png');
imag.setAttribute('alt','[+1]');
imag.setAttribute('title','voto +1');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
// pulsante VOTO ASTENUTO =0
tmp = document.createElement("a");
tmp.id = 'tb-uguale';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value=wpTextbox1.value+"* 0 ~~~ ~~~~~";summ=document.getElementById("wpSummary");summ.value=summ.value+"astenuto";document.getElementById("wpMinoredit").checked=1;})();';
var imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/a/aa/Astenuto.png');
imag.setAttribute('alt','[=0]');
imag.setAttribute('title','voto =0');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
// pulsante VOTO CONTRARIO -1
tmp = document.createElement("a");
tmp.id = 'tb-meno';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value=wpTextbox1.value+"* -1 ~~~ ~~~~~";summ=document.getElementById("wpSummary");summ.value=summ.value+"-1";document.getElementById("wpMinoredit").checked=1;})();';
var imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/4/43/Contrario.png');
imag.setAttribute('alt','[-1]');
imag.setAttribute('title','voto -1');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
// 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 CANCELLA SUBITO
tmp = document.createElement("a");
tmp.id = 'tb-tcs';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{Cancella subito}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"cancellare perchè ";})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/f/f8/Wiki_del.gif');
imag.setAttribute('alt','[DEL]');
imag.setAttribute('title','{{cancella subito}}');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
// pulsante Template stemma ecclesiastico
tmp = document.createElement("a");
tmp.id = 'tb-tse';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value=wpTextbox1.value+"\\n{{StemmiEcclesiastici}}\\n";summ=document.getElementById("wpSummary");summ.value="- gfdl + template StemmiEcclesiastici";})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/4/44/ToolButton.png');
imag.setAttribute('alt','[PAPI]');
imag.setAttribute('title','{{Stemma eccesiastico}}');
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);
}
function myLoadFuncs()
{
/* addLoadEvent(ToolbarButton); */
ToolbarButton();
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();
}
/**** 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>