MediaWiki:Common.js: differenze tra le versioni
Da Wiki.
Riga 230: | Riga 230: | ||
"speedTip": "Inserisci Tabella", | "speedTip": "Inserisci Tabella", | ||
"tagOpen": '{| border=1 cellpadding=5 cellspacing=0 style="border-collapse: collapse;"\n|-\n', | "tagOpen": '{| border=1 cellpadding=5 cellspacing=0 style="border-collapse: collapse;"\n|-\n', | ||
− | "tagClose | + | "tagClose": "! titolo1\n! titolo2 \n! titolo3\n|-\n| r1_cella1 || r1_cella2 || r1_cella3\n|-\n| r2_cella1 \n| r2_cella2 \n| r2_cella3\n|}", |
− | + | "sampleText": ""}; | |
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
"imageFile": "/w/skins/common/images/button_train.png", | "imageFile": "/w/skins/common/images/button_train.png", | ||
"speedTip": "Inserisci Template Come Arrivare", | "speedTip": "Inserisci Template Come Arrivare", | ||
"tagOpen": '{{ComeArrivare\n', | "tagOpen": '{{ComeArrivare\n', | ||
− | "tagClose | + | "tagClose": "|auto=\n info auto\n|treno=\n info treno\n|aereo=\n info aereo\n|mare=\n info mare\n}}", |
− | + | "sampleText": ""}; | |
}; | }; | ||
Versione delle 17:11, 7 feb 2008
//<pre> /* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti. */ //============================================================ // Menu caratteri speciali --- da it.wikipedia.org --- //============================================================ function addLoadEvent(func) { if (window.addEventListener) window.addEventListener("load", func, false); else if (window.attachEvent) window.attachEvent("onload", func); } /** * Aggiunge il menu a tendina per selezionare un sottoinsieme di caratteri speciali * Attenzione: l'ordine della lista deve corrispondere a quello di MediaWiki:Edittools ! */ function addCharSubsetMenu() { var specialchars = document.getElementById('specialchars'); if (specialchars) { var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">"; menu += "<option>Wiki</option>"; menu += "<option>Latino esteso</option>"; menu += "<option>Greco antico</option>"; menu += "<option>Greco moderno</option>"; menu += "<option>Cirillico</option>"; menu += "<option>Arabo</option>"; menu += "<option>Ebraico e yiddish</option>"; menu += "<option>Armeno</option>"; menu += "<option>Geroglifico</option>"; menu += "<option>Vietnamita</option>"; menu += "<option>IPA</option>"; menu += "<option>Matematica</option>"; menu += "</select>"; specialchars.innerHTML = menu + specialchars.innerHTML; /* default subset - try to use a cookie some day */ chooseCharSubset(0); } } /* select subsection of special characters */ function chooseCharSubset(s) { var l = document.getElementById('specialchars').getElementsByTagName('p'); for (var i = 0; i < l.length ; i++) { l[i].style.display = i == s ? 'inline' : 'none'; l[i].style.visibility = i == s ? 'visible' : 'hidden'; } } addLoadEvent(addCharSubsetMenu); // END Menu caratteri speciali //---------------------------------------------------------- //---------------------------------------------------------- //@TDB 28/11/2007 BUG#16 - Start String.prototype.toCapitalCase = function() { var bInWord = false; var output = ""; var re = /[\s\*\#\'\"\{\}\[\]\(\)\|\_\-\,\.;:=]/; var c; for (i = 0; i < this.length; i++) { c = this.charAt(i).toLowerCase(); //?? if( !re.test(c) ) //test word-limit char { if( !bInWord ) { c = c.toUpperCase(); bInWord = true; } } else { bInWord = false; } output = output + c; } return output; } //mixed -> uppercase -> lowercase -> capitalcase function SwitchCase(s, s1) { var aPattern = new Array(/[A-Z]/, /[a-z]/); var aFlag = new Array; for ( var i = 0; i < 2; i++ ) { aFlag[i] = s.search(aPattern[i]); } if( aFlag[0]!=-1 && aFlag[1]!=-1 ) {//mixed s = s.toUpperCase(); } else if( aFlag[0]!=-1 ) { // uppercase s = s.toLowerCase(); } else if( aFlag[1]!=-1 ) {// lowercase s = s.toCapitalCase(); } return { "selText": s, "sBefore": s1 }; } //@TDB 28/11/2007 BUG#16 - End //---------------------------------------------------------- //@TDB 28/11/2007 BUG#8 function HandleList(selText, s1, cList, bIns) { var re = /[\r\f\n]/; selText = HandleList_SelText(selText, cList, bIns); //s1 null means that it's not possible to get text before selection if(s1!=null) { //case: ins + void string if(bIns && s1.length == 0) { selText = cList + selText; } //check to avoid not visible selected line //@TDB 06/12/2007 new case: selText void else if( !(re.test(selText.charAt(0)) && !re.test(selText.charAt(1))) && !(selText.length == 0 && s1.length!=0 && re.test(s1.charAt(s1.length - 1)) ) ) { s1 = HandleList_CurrLine(s1, cList, bIns); } //case: del + void string or boundary condition if( !bIns && (s1.length == 0 || re.test(s1.charAt(s1.length - 1))) && selText.charAt(0) == cList) { selText = selText.substring(1); } } return { "selText": selText, "sBefore": s1 }; // support functions function HandleList_SelText(s, cList, bIns) { var bInLine = true; var output = ""; for (i = 0; i < s.length; i++) { c = s.charAt(i); if(re.test(c)) //newline char found { bInLine = false; output = output + c; } else { if(!bInLine) { if(bIns) output = output + cList + c; else if(c != cList) output = output + c; bInLine = true; } else output = output + c; } } return output; } function HandleList_CurrLine(s, cList, bIns) { var output = ""; var iStartLine = 0; for (i = s.length - 1; i >= 0; i--) { c = s.charAt(i); if(re.test(c)) //newline char found { iStartLine = i + 1; break; } } if(bIns) { output = s.substring(0, iStartLine) + cList + s.substring(iStartLine); } else if(s.charAt(iStartLine) == cList) { output = s.substring(0, iStartLine) + s.substring(iStartLine + 1); } else { output = s; } return output; } } function InsList(selText, s1) { return HandleList(selText, s1, "*", true); } function DelList(selText, s1) { return HandleList(selText, s1, "*", false); } // extra toolbar list if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/w/skins/common/images/button_case.png", "speedTip": "Maiuscole/Minuscole", "tagOpen": "", "tagClose": "", "sampleText": "fn=SwitchCase; holdSel=true;"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/w/skins/common/images/button_li_r.png", "speedTip": "Inserisci Lista", "tagOpen": "", "tagClose": "", "sampleText": "fn=InsList; holdSel=true;"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/w/skins/common/images/button_li_l.png", "speedTip": "Cancella Lista", "tagOpen": "", "tagClose": "", "sampleText": "fn=DelList; holdSel=true;"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/w/skins/common/images/button_table.png", "speedTip": "Inserisci Tabella", "tagOpen": '{| border=1 cellpadding=5 cellspacing=0 style="border-collapse: collapse;"\n|-\n', "tagClose": "! titolo1\n! titolo2 \n! titolo3\n|-\n| r1_cella1 || r1_cella2 || r1_cella3\n|-\n| r2_cella1 \n| r2_cella2 \n| r2_cella3\n|}", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "/w/skins/common/images/button_train.png", "speedTip": "Inserisci Template Come Arrivare", "tagOpen": '{{ComeArrivare\n', "tagClose": "|auto=\n info auto\n|treno=\n info treno\n|aereo=\n info aereo\n|mare=\n info mare\n}}", "sampleText": ""}; }; // ------------------------------------------------------- // @TDB 05/12/2007 BUG#43 function bookmark(title,url){ //handle firefox, opera and explorer if (window.sidebar) window.sidebar.addPanel(title, url, ""); else if(window.opera && window.print){ var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); } else if(document.all) window.external.AddFavorite(url, title); } //</pre>