Utente:Dennis/Toolbar.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>
//Per informazioni [[Utente:Timendum/Javascript]]
//Addizione da fare per wiktionary
function $( document ).ready(func)
{
if (window.addEventListener)
window.addEventListener("load", func, false);
else if (window.attachEvent)
window.attachEvent("onload", func);
}
//Standardizzatore wiktionary
var typeArray=new Array();
typeArray["noun"]="Substantiv";
typeArray["adjective"]="Adjektiv";
var languageArray=new Array();
languageArray["it"]="Italienska";
languageArray["sv"]="Svenska";
languageArray["es"]="Spanska";
function standardize(tA){
from=tA.value
re=new RegExp("^ *== *([a-z]+) *== *\n *=== *([a-z]+) *=== *\n *''' *([a-z]+) *'''(.+)*\n[#|*]? *\\[\\[([a-z]+)\\]\\]([.|\n]*)","i");
reL=new RegExp(" *== *([a-zäåö]+) *== *","i");
reT=new RegExp("=== *([a-zäåö]+) *===","i");
reW=new RegExp(" *''' *([a-zäåö]+) *'''(.+)*","i");
reG=new RegExp("'''[a-zäåö]+'''(.*)","i")
reTr=new RegExp("# *\\[\\[([a-zäåö]+)\\]\\]","i")
reA=new RegExp("\\]\\]((.|\n)*)","i");
re1=new RegExp("^ *\\{\\{-([a-zäåö]{2})-\\}\\} *\n *\\{\\{-([a-zäåö]+)-\\}\\} *\n *''' *([a-zäåö]+) *'''(.+)*\n[#|*]? *\\[\\[([a-zäåö]+)\\]\\]([.|\n]*)","i");
reL1=new RegExp(" *\\{\\{-([a-zäåö]{2})-\\}\\} *","i");
reT1=new RegExp(" *\\{\\{-([a-zäåö]{3,})-\\}\\} *","i");
if(re.test(from)){
lin=from.match(reL);
lin[0]=lin[0].replace(reL,"$1");
lin=lin[0]
tip=from.match(reT);
tip[0]=tip[0].replace(reT,"$1");
tip=tip[0]
par=from.match(reW);
par[0]=par[0].replace(reW,"$1");
par=par[0]
if(from.match(reG)){
gen=from.match(reG)
gen[0]=gen[0].replace(reG,"$1");
gen=gen[0];
gen=gen.replace("/\\{/i","'");
}
trad=from.match(reTr);
trad[0]=trad[0].replace(reTr,"$1");
trad=trad[0]
after=from.match(reA);
after[0]=after[0].replace(reA,"$1");
after=after[0];
n="=="+lin+"==\n";
n+="==="+tip+"===\n";
n+="'''{{subst:PAGENAME}}'''";
n+=gen?gen+"\n":"\n";
n+="#[["+trad+"]]";
n+=after+"\n";
n+="[[Kategori:"+lin+" "+tip.toLowerCase()+"]]\n";
n+="[[Kategori:Språkindex för "+lin.toLowerCase()+" - "+par[0].charAt(0).toLowerCase()+"|"+par.substring(1,par.length)+"]]";
tA.value=n;
}
else if(re1.test(from)){
//1 atomo: lingua; 2 atomo:tipo parola; 3 atomo: parolaLingua; 4 atomo: parolaTradotta
lin=from.match(reL1);
lin[0]=lin[0].replace(reL1,"$1");
lin=lin[0]
lin=languageArray[lin];
tip=from.match(reT1);
tip[0]=tip[0].replace(reT1,"$1");
tip=tip[0]
tip=typeArray[tip];
par=from.match(reW);
par[0]=par[0].replace(reW,"$1");
par=par[0]
if(from.match(reG)){
gen=from.match(reG)
gen[0]=gen[0].replace(reG,"$1");
gen=gen[0];
reGC=new RegExp("{{(.+)}}");
gen=gen.replace(reGC,"''$1''")
}
trad=from.match(reTr);
trad[0]=trad[0].replace(reTr,"$1");
trad=trad[0]
after=from.match(reA);
after[0]=after[0].replace(reA,"$1");
after=after[0];
n="=="+lin+"==\n";
n+="==="+tip+"===\n";
n+="'''{{subst:PAGENAME}}'''";
n+=gen?gen+"\n":"\n";
n+="#[["+trad+"]]";
n+=after+"\n";
n+="[[Kategori:"+lin+" "+tip.toLowerCase()+"]]\n";
n+="[[Kategori:Språkindex för "+lin.toLowerCase()+" - "+par[0].charAt(0).toLowerCase()+"|"+par.substring(1,par.length)+"]]";
tA.value=n;
}
else{
alert("I cannot help you, I don't recognize how this word is written. Please contact user Dennis");
}
}
// Toolbar
function Toolbar() {
if (!dell)
dell = "";
if (!agg)
agg= "";
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;
if (dell.indexOf("hr") != -1 )
nodes[11].style.display = "none !important";
if (dell.indexOf("sig") != -1 )
nodes[10].style.display = "none !important";
if (dell.indexOf("now") != -1 )
nodes[9].style.display = "none !important";
if (dell.indexOf("mat") != -1 )
nodes[8].style.display = "none !important";
if (dell.indexOf("med") != -1 )
nodes[7].style.display = "none !important";
if (dell.indexOf("img") != -1 )
nodes[6].style.display = "none !important";
if (dell.indexOf("==") != -1 )
nodes[5].style.display = "none !important";
if (dell.indexOf("ext") != -1 )
nodes[4].style.display = "none !important";
if (dell.indexOf("lin") != -1 )
nodes[3].style.display = "none !important";
if (dell.indexOf("cor") != -1 )
nodes[2].style.display = "none !important";
if (dell.indexOf("gra") != -1 )
nodes[1].style.display = "none !important";
var imag = null;
if (agg.indexOf("wik") != -1 ) {
// pulsante DA WIKIFICARE
tmp = document.createElement("a");
ind=document.location.href
pagina=ind.substr(ind.lastIndexOf("title=")+6,ind.lastIndexOf("&")-1);
tmp.id = 'tb-wik';
//tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{"+pagina+"}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{wik}}";})();';
wpTextbox1=document.getElementById("wpTextbox1")
tmp.href = 'javascript:(function(){standardize(wpTextbox1)})();';
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);
}
if (agg.indexOf("stu") != -1 ) {
// 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}}";})();';
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);
}
if (agg.indexOf("aiu") != -1 ) {
// 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);
}
if (agg.indexOf("ben") != -1 ) {
// pulsante BENVENUTO
tmp = document.createElement("a");
tmp.id = 'tb-ben';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{benve|nome={{PAGENAME}}|~~~ ~~~~~}}"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"Benvenuto su it.wiki!";})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/7/74/Pulsante_benvenuto.png');
imag.setAttribute('alt','[Ben]');
imag.setAttribute('title','Benvenuto su it.wiki!');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
}
if (agg.indexOf("voto") != -1 ) { //Inizio voto
// pulsante VOTO FAVOREVOLE +1
tmp = document.createElement("a");
tmp.id = 'tb-piu';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value=wpTextbox1.value+"*{{subst:+1}} ~~~ ~~~~~";summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{+1}}";document.getElementById("wpMinoredit").checked=1;})();';
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+"*{{subst:0}} ~~~ ~~~~~";summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{0}}";document.getElementById("wpMinoredit").checked=1;})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/a/aa/Astenuto.png');
imag.setAttribute('alt','[=0]');
imag.setAttribute('title','Astenuto');
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+"*{{subst:-1}} ~~~ ~~~~~";summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{-1}}";document.getElementById("wpMinoredit").checked=1;})();';
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);
} // FINE VOTO
if (agg.indexOf("vand") != -1 ) {
// pulsante VANDALISMO
tmp = document.createElement("a");
tmp.id = 'tb-vnd';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{Vandalismo}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"Avviso vandalismo";document.getElementById("wpMinoredit").checked=1;})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/6/64/Wiki_vand.gif');
imag.setAttribute('alt','[Vnd]');
imag.setAttribute('title','Vandalismo');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
}
if (agg.indexOf("copy") != -1 ) {
// pulsante AVVISO CONTROLCOPY
tmp = document.createElement("a");
tmp.id = 'tb-ctrlcpy';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{Controlcopy|firma=~~~|motivo=probabile copia di materiale già pubblicato altrove e dunque non originale}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{Controlcopy}}!";document.getElementById("wpMinoredit").checked=1;})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/7/75/Wiki_c_copy.gif');
imag.setAttribute('alt','[Copy]');
imag.setAttribute('title','ControlCopy');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
}
if (agg.indexOf("test") != -1 ) {
// pulsante TEST
tmp = document.createElement("a");
tmp.id = 'tb-tes';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{Test}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"Avviso test";document.getElementById("wpMinoredit").checked=1;})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/4/40/Wiki_test.GIF');
imag.setAttribute('alt','[Tes]');
imag.setAttribute('title','Test');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
}
if (agg.indexOf("avcpy") != -1 ) {
// pulsante TEST
tmp = document.createElement("a");
tmp.id = 'tb-tes';
tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{Avvisocopyviol|articolo="+(prompt("Articolo"))+"|url="+(prompt("URL"))+"}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{Avvisocopyviol}}";})();';
imag = document.createElement("img");
imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/5/50/Wiki_copyviol.png');
imag.setAttribute('alt','[AvC]');
imag.setAttribute('title','Avviso violazione di copyright');
tmp.appendChild(imag);
toolbar.appendChild(tmp);
}
toolbar.appendChild(tmp);
}
$( document ).ready(Toolbar);
//</nowiki>
//</pre>