Wikizionario:Vector.js/VectorCompleto.js
(Reindirizzamento da Utente:Pierpao/Vector)
/*
<nowiki> */
/**
* Derivato dal monobook.js di [[:en:User:Wayward]], basato su [[:en:User:Alphax/monobook.js]]
* Necessita dell'[[Wikipedia:Monobook.js/monobook.css|apposito monobook.css]]
* Testato su Firefox e IE
* Contiene codice preso dagli script di [[Utente:Salvatore Ingala]], [[Utente:Paulatz]], [[Utente:Helios89]], [[Utente:Timendum]], [[Utente:Senpai]], [[Utente:Kiado]], [[Utente:Pietrodn]]
* Reso modulare ed elaborato da [[Utente:Jalo]]
* Forked from [[User:ABCD/monobook.js]] around April 2005
* Dual licensed under the GFDL and GPL
*/
/** VARIABILI GLOBALI **/
// Utilities del monobook<br/>
// Vedi [[Wikipedia:Monobook.js/Utils.js]]
importScript('Wikipedia:Monobook.js/Utils.js');
//script per il conteggio dei wikilink doppi
if (document.title.indexOf("Modifica") != -1) //usato solo in modifica
importScript('Wikipedia:Monobook.js/WikilinkDoppi.js');
//Questa variabile contiene il nome del browser utilizzato. Molto utile per evitare problemi
// di incompatibilita' tra la varie funzioni Javascript
// Si autovalorizza. Le sottovariabili da usare sono "BrowserDetect.browser", "BrowserDetect.version"
// e "BrowserDetect.OS"
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari"
},
{
prop: window.opera,
identity: "Opera"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]
};
BrowserDetect.init();
/**** Inizializzazione ****/
//Ritorna true se la variabile toLoad contiene l'opzione str
mustLoad = (function(){
mustLoadCache = {};
var A = toLoad ? toLoad.split(' ') : [];
for(var i = 0; i < A.length; i++)
if (A[i])
mustLoadCache[A[i]] = true;
return function(str){
return mustLoadCache[str] === true;
};
})();
/** Codice di compatibilità con WikEd **/
//Copia dal frame di wikEd (http://en.wikipedia.org/wiki/User:Cacycle/wikEd.js) alla wpTextbox1 textarea
function WEUpdateTextarea(){
if (typeof(wikEd) != "undefined" && wikEd && wikEd.useWikEd)
WikEdUpdateTextarea();
}
//Copia la wpTextbox1 textarea nel frame del wikEd
function WEUpdateFrame(){
if (typeof(wikEd) != "undefined" && wikEd && wikEd.useWikEd)
WikEdUpdateFrame();
}
// Aggiunge il link "Novita'" nella barra superiore
// Apre gli "Osservati Speciali" mostrando solo le modifiche avvenute dopo l'ultima volta che ci sei passato
if (mustLoad("since"))
function addSince(){
var watchlist = document.getElementById('pt-watchlist');
var newpt = document.createElement('li');
var link = document.createElement('a');
link.id = 'listSince';
link.href = '#modifiche da...';
var fixLinkHref = function () {
// Leggi il cookie
var then = GetCookie('wikiSince');
if (then == '') // Se il cookie non esiste
then = +(new Date()) - (1000 * 60 * 60 * 24 * 3); // visualizza gli ultimi tre giorni
var url = mw.config.get("wgServer") + '/wiki/Speciale:OsservatiSpeciali';
var days = ( +(new Date()) - then )/(1000 * 60 * 60 * 24); // trasforma i millisecondi in giorni
this.href = url + '?days=' + days;
return true;
};
link.onclick = fixLinkHref;
link.onmousedown = fixLinkHref;
// Crea la stringa mostrata a video
link.appendChild(document.createTextNode("Novità"));
// Se siamo sugli Osservati Speciali
if (mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgCanonicalSpecialPageName') == "Watchlist")
{
// Aggiorna il cookie
var cookieExpire = new Date(); // scadenza del cookie
cookieExpire.setTime(cookieExpire.getTime() + (30 * 24 * 60 * 60 * 1000)); // il cookie scade dopo un mese
SetCookie('wikiSince', +(new Date()), cookieExpire.toGMTString(), '/');
}
// just one little ID attribute would be _so_ nice...
newpt.appendChild(link);
watchlist.parentNode.insertBefore(newpt, watchlist.nextSibling);
}
/**** Carica le funzioni personalizzate ****/
jQuery(document).ready(function($){
saveHistoryToCookie(); //memorizza le pagine visitate in un cookie
changeLinks();
addNavBarLinks();
addToolBoxLinks();
if(mw.config.get('wgNamespaceNumber') != -1){ //non nelle pagine speciali
if (mustLoad("ns0")) addEditSection0();
if (mustLoad("led")) lastEdit();
if (mustLoad("purg")) addPurge();
// fa casino con vector. Lancia tonnellate di errori if (mustLoad("tabs")) add_tabs();
}
if (mustLoad("chat")) addChat();
if (mustLoad("since")) addSince();
if (mustLoad("allp")) setup_allpages_button();
// temporaneamente disabilitato ta['pt-logout'] = ['x', 'Logout (esci)']; //cambia l'accesskey per "logout"
// temporaneamente disabilitato akeytt();
});
//Modifica la sezione 0 della pagina
function addEditSection0(){
if(!document.getElementById('ca-history'))
return;
var newLink = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit§ion=0';
mw.util.addPortletLink('p-cactions', newLink, '0', 'ca-edit-0', 'Modifica la sezione 0');
}
/** AutoComplete: Based on http://www.webreference.com/programming/javascript/gr/column5/ **/
function AutoComplete(db, oText, /* optional */ nMaxSize){
this.oText = oText;
this.nMaxSize = nMaxSize || 20;
var oDiv = document.createElement('div');
oDiv.style.border = '2px solid green';
oDiv.style.position = 'absolute';
oDiv.style.visibility = 'hidden';
oDiv.style.backgroundColor = 'white';
this.oDiv = oDiv;
oText.parentNode.insertBefore(oDiv, oText.nextSibling);
this.db = db.sort();
oText.AutoComplete = this;
oText.onkeyup = AutoComplete.prototype.onTextChange;
oText.onblur = AutoComplete.prototype.onTextBlur;
};
AutoComplete.prototype.onTextBlur = function(){ this.AutoComplete.onblur(); };
AutoComplete.prototype.onblur = function(){ this.oDiv.style.visibility = "hidden"; };
AutoComplete.prototype.onTextChange = function(){ this.AutoComplete.onchange(); };
AutoComplete.prototype.onDivMouseDown = function(){ this.AutoComplete.oText.value = this.innerHTML; };
AutoComplete.prototype.onDivMouseOver = function(){ this.style.backgroundColor = 'lime'; };
AutoComplete.prototype.onDivMouseOut = function(){ this.style.backgroundColor = 'white'; };
AutoComplete.prototype.onchange = function(){
var txt = this.oText.value;
var aStr = [];
for(var i = 0; i < this.db.length; i++)
if(this.db[i].toLowerCase().indexOf(txt.toLowerCase()) == 0)
aStr.push(this.db[i]);
var nCount = aStr.length;
if ((this.nMaxSize == -1) || ((nCount < this.nMaxSize) && (nCount > 0))){
while (this.oDiv.hasChildNodes())
this.oDiv.removeChild(this.oDiv.firstChild);
var i, n = aStr.length;
for (i = 0; i < n; i++){
var d = document.createElement('div');
this.oDiv.appendChild(d);
d.appendChild(document.createTextNode(aStr[i]));
d.onmousedown = AutoComplete.prototype.onDivMouseDown;
d.onmouseover = AutoComplete.prototype.onDivMouseOver;
d.onmouseout = AutoComplete.prototype.onDivMouseOut;
d.AutoComplete = this;
}
this.oDiv.style.left = this.oText.offsetLeft+'px'; //NON-STANDARD! offsetLeft
this.oDiv.style.top = (this.oText.offsetTop+this.oText.clientHeight)+'px'; //NON-STANDARD! offsetTop e clientHeight
this.oDiv.style.visibility = "visible";
}
else {
this.oDiv.innerHTML = "";
this.oDiv.style.visibility = "hidden";
}
};
/** AutoComplete END **/
// Recupera il valore di un cookie
function GetCookie(name)
{
var cookie = ' ' + document.cookie;
var search = ' ' + name + '=';
var setStr = '';
var offset = 0;
var end = 0;
offset = cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = cookie.indexOf(';', offset)
if (end == -1)
end = cookie.length;
setStr = cookie.substring(offset, end);
setStr = setStr.replace(/\\+/g, ' ');
setStr = decodeURIComponent(setStr);
}
return(setStr);
}
// Setta il valore di un cookie
function SetCookie(name, value, expires, path, domain, secure)
{
var cookie = name + '=' + encodeURIComponent(value);
if (expires != null)
cookie += '; expires=' + expires
if (path != null)
cookie += '; path=' + path;
if (domain != null)
cookie += '; domain=' + domain;
if (secure != null)
cookie += '; secure';
document.cookie = cookie;
}
/** WikiHistory **/
function getHistoryFromCookie(){
var c = GetCookie("wikiHistory");
var hist = c ? c.split('#') : [];
for(var i = 0; i < hist.length; i++)
hist[i] = decodeURIComponent(hist[i]);
return hist;
}
function saveHistoryToCookie(){
if(mw.config.get('wgNamespaceNumber') < 0) return;
var c = GetCookie("wikiHistory"), i;
var h = c ? c.split('#') : [];
var current = encodeURIComponent(mw.config.get('wgPageName').replace(/_/g, ' ')), found = -1;
for(i = 0; i < h.length; i++)
if(h[i] == current){
found = i; break;
}
if(found == -1)
h.push(current);
else
h[found] = null;
var newh = [];
for(i = Math.max(0, h.length - 100); i < h.length; i++)
if(h[i] != null)
newh.push(h[i]);
var expire = new Date(); // scadenza del cookie
expire.setTime(expire.getTime() + (60 * 60 * 1000)); //scadenza di un'ora
SetCookie('wikiHistory', newh.join('#'), expire.toGMTString(), '/');
}
/** WikiHistory END **/
/**** Personalizza i link della barra personale ****/
function changeLinks()
{
if (mustLoad("lks"))
{
// Modifica i link
document.getElementById('pt-mytalk').firstChild.innerHTML = 'discussioni';
document.getElementById('pt-preferences').firstChild.innerHTML = 'preferenze';
document.getElementById('pt-watchlist').firstChild.innerHTML = 'osservati speciali';
document.getElementById('pt-mycontris').firstChild.innerHTML = 'contributi';
}
if (mustLoad("orol"))
{
// Aggiunge l'orologio
mw.util.addPortletLink('p-personal', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?title=' + mw.config.get('wgPageName') + '&action=purge', '', 'utcdate');
showtime();
}
}
/**** Aggiunge il tab "purge" ****/
function addPurge(){
if(!document.getElementById('ca-history'))
return;
var newLink = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName') + '&action=purge';
mw.util.addPortletLink('p-cactions', newLink, 'purge', 'ca-purge', 'Pulisci la cache', 'g');
}
/**** Aggiunge il tab "ultima modifica" ****/
function lastEdit(){
if(!document.getElementById('ca-history'))
return;
var newLink = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName') + '&diff=0';
mw.util.addPortletLink('p-cactions', newLink, 'ultima modifica', 'ca-ledit', 'Ultima modifica', 'u');
}
/**** Menu "strumenti vari" ****/
//Sostituzioni automatiche
function fixformat(){
WEUpdateTextarea();
var txt = document.getElementById('wpTextbox1');
txt.value = txt.value
.replace(/\’/g, "'")
.replace(/ '([\w\ ]+)' /g, ' "$1" ')
.replace(/“/g,'"')
.replace(/”/g,'"')
.replace(/–/g, '-')
.replace(/,,/g, ',')
.replace(/ m2 /g, ' m² ')
.replace(/a' /g, "à ")
.replace(/([^p])o' /g, "$1ò ")
.replace(/u' /g, "ù ")
.replace(/i' /g, "ì ")
.replace(/ anzich(è|e')/g, " anziché")
.replace(/ affinch(è|e')/g, " affinché")
.replace(/ bench(è|e')/g, " benché")
.replace(/ cioé/g, " cioè")
.replace(/ Dè /g, " De' ")
.replace(/ dè /g, " de' ")
.replace(/ dò/g, " do")
.replace(/E' /g, "È ")
.replace(/É /g, "È ")
.replace(/ e' /g, " è ")
.replace(/ é/g, " è")
.replace(/ fà /g, " fa ")
.replace(/ fè /g, " fe' ")
.replace(/ Frà /g, " Fra' ")
.replace(/ fù /g, " fu ")
.replace(/ mò /g, " mo' ")
.replace(/ nè /g, " né ")
.replace(/ ne' /g, " né ")
.replace(/ nonch(è|e')/g, " nonché")
.replace(/ pè /g, " pe' ")
.replace(/ perch(è|e')/g, " perché")
.replace(/ per(ó|o') /g,' però ')
.replace(/ piu' /g, " più ")
.replace(/ pò/g, " po'")
.replace(/ poich(è|e') /g, " poiché ")
.replace(/ propio/g, " proprio")
.replace(/ (puo|puo') /gi,' può ')
.replace(/ quì /gi, " qui ")
.replace(/ quà /gi, " qua ")
.replace(/ qual'è/gi, " qual è")
.replace(/ sà /gi, " sa ")
.replace(/ sè /gi, " sé ")
.replace(/si' /g, "sì")
.replace(/ sò /g, " so ")
.replace(/ sù /g, " su ")
.replace(/ tr(è|e'|é) /g, " tre ")
.replace(/ sucessivo /gi, " successivo ")
.replace(/</g,'<')
.replace(/>/g,'>')
.replace(/&/g,'&')
.replace(/"/g,'"')
.replace(/à/g,'à')
.replace(/è/g,'è')
.replace(/é/g,'é')
.replace(/ì/g,'ì')
.replace(/¡/g,'¡')
.replace(/¢/g,'¢')
.replace(/£/g,'£')
.replace(/¥/g,'¥')
.replace(/´/g,"'")
.replace(/±/g,'±')
.replace(/×/g,'×')
.replace(/÷/g,'÷')
.replace(/µ/g,'µ')
.replace(/°/g,'°')
.replace(/¼/g,'¼')
.replace(/½/g,'½')
.replace(/¾/g,'¾')
.replace(/¹/g,'¹')
.replace(/²/g,'²')
.replace(/³/g,'³')
.replace(/§/g,'§')
.replace(/<\/?(b|strong)>/gi, "'''")
.replace(/<\/?(i|em|var)>/gi, "''")
.replace(/<br>\n\n/g,'\n\n')
.replace(/<br>/gi,'<br />')
.replace(/\n<hr[ \/]*>\n/gi, '\n----\n')
.replace(/ +<hr[ \/]*> +/gi, '\n----\n')
.replace(/<hr ([^>\/]+?)>/gi,'<hr $1 />')
.replace(/\n *<h1> *([^<]+?) *<\/h1> *\n/gi, "\n= $1 =\n")
.replace(/\n *<h2> *([^<]+?) *<\/h2> *\n/gi, "\n== $1 ==\n")
.replace(/\n *<h3> *([^<]+?) *<\/h3> *\n/gi, "\n=== $1 ===\n")
.replace(/\n *<h4> *([^<]+?) *<\/h4> *\n/gi, "\n==== $1 ====\n")
.replace(/\n *<h5> *([^<]+?) *<\/h5> *\n/gi, "\n===== $1 =====\n")
.replace(/\n *<h6> *([^<]+?) *<\/h6> *\n/gi, "\n====== $1 =======\n")
;
document.getElementById('wpSummary').value += "+formattazione ";
WEUpdateFrame();
}
//Cerca e sostituisci
function replace(){
WEUpdateTextarea();
var s = prompt("Search regexp?");
if(s){
var r = prompt("Replace regexp?");
if(!r && r != '') return;
var txt = document.getElementById('wpTextbox1');
txt.value = txt.value.replace(new RegExp(s, "g"), r);
}
WEUpdateFrame();
}
/**** Funzioni per le pagine di discussione ****/
// Aggiunge il messaggio "msg" alla pagina editata, scrive "summ" nell'oggetto,
// segna o meno "segui questa pagina" a seconda dell'impostazione precedente
// e spunta "modifica minore"
function edit_summary_watch(msg, summ, watch, minor)
{
WEUpdateTextarea();
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += msg;
f.wpSummary.value = summ;
f.wpWatchthis.checked = watch;
f.wpMinoredit.checked = minor;
WEUpdateFrame();
}
// Come il precedente, ma aggiunge "msg" all'inizio della pagina
function edit_summary_watch2(msg, summ, watch, minor)
{
WEUpdateTextarea();
var f = document.editform, t = f.wpTextbox1;
t.value = msg + '\n' + t.value;
f.wpSummary.value = summ;
f.wpWatchthis.checked = watch;
f.wpMinoredit.checked = minor;
WEUpdateFrame();
}
/**** Aggiunge i tab e i menu ****/
// aggiunge vari tabs e menu-tabs
function add_tabs()
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
//Solo per le pagine di discussioni degli utenti
if((document.title.indexOf("Modifica") != -1) && (document.title.indexOf("Discussioni utente") != -1))
{
addlimenu(tabs, 'Messaggi talk', 'talkm');
var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
addlilink(talkm,'javascript:edit_summary_watch("{{subst:benve|~~~~}}", "Benvenuto", false, true)','welcome', 'pb-welcome');
ta['pb-welcome'] = new Array('b', 'Da il benvenuto');
addlilink(talkm,'javascript:edit_summary_watch("{{test}} ~~~~", "test", false, true)','Test', '');
addlilink(talkm,'javascript:edit_summary_watch("{{vandalismo}} ~~~~", "Avviso vandalismo", false, true)','Vandal', '');
addlilink(talkm,'javascript:edit_summary_watch("{{spam}}", "spam", false, true)','Spam', '');
addlilink(talkm,'javascript:edit_summary_watch("{{Avvisocopyviol|articolo=|url=}} ~~~~","avviso possibile violazione di copyright",false,true)','avviso cv','');
addlilink(talkm,'javascript:edit_summary_watch("{{cancellazione|Titolo_pagina}} ~~~~","avviso proposta di cancellazione",false,true)','avviso canc','');
}
else if (document.title.indexOf("Modifica") != -1) // Solo durante le modifiche
{
addlimenu(tabs, 'strumenti vari', 'tools');
var tools = document.getElementById('tools').getElementsByTagName('ul')[0];
addlilink(tools,'javascript:fixformat()','format', '');
addlilink(tools,'javascript:replace()','replace', '');
addlilink(tools,'javascript:edit_summary_watch2("{{cancella subito|motivo=}}", "cancimm", false, true)','cancimm', '');
addlilink(tools,'javascript:edit_summary_watch2("{{cancelcopy|firma=~~~|fonte=}}", "cancelcopy", false, true)','cancelcopy', '');
addlilink(tools,'javascript:edit_summary_watch2("{{cancellazione}}", "cancellare", false, true)','da cancellare', '');
addlilink(tools,'javascript:WikilinkDoppi()', 'Wikilink doppi', '');
}
}
/**** Aggiunge i link nel portlet "navigazione" ****/
function addNavBarLinks()
{
var navbar = 'p-navigation';
if (mustLoad("nav") || mustLoad("aut"))
mw.util.addPortletLink(navbar, '/wiki/Wikipedia:Autorizzazioni_ottenute', 'Autorizzazioni ottenute', '');
if (mustLoad("nav") || mustLoad("csu"))
mw.util.addPortletLink(navbar, '/wiki/Categoria:Da_cancellare_subito', 'Cancella subito', '');
if (mustLoad("nav") || mustLoad("blk"))
mw.util.addPortletLink(navbar, '/wiki/Speciale:Ipblocklist', 'Block Log', '');
if (mustLoad("nav") || mustLoad("log"))
mw.util.addPortletLink(navbar, '/wiki/Speciale:Log', 'Log', '');
if (mustLoad("nav") || mustLoad("mcss"))
mw.util.addPortletLink(navbar, '/w/index.php?title=Utente:' + mw.config.get('wgUserName') + '/vector.css&action=edit', 'vector.css', '');
if (mustLoad("nav") || mustLoad("mjs"))
mw.util.addPortletLink(navbar, '/w/index.php?title=Utente:' + mw.config.get('wgUserName') + '/vector.js&action=edit', 'vector.js', '');
if (mustLoad("nav") || mustLoad("pca"))
mw.util.addPortletLink(navbar, '/wiki/Wikipedia:Pagine_da_cancellare', 'Pagine da cancellare', '');
if (mustLoad("nav") || mustLoad("newp"))
mw.util.addPortletLink(navbar, '/wiki/Speciale:Newpages', 'Pagine nuove', '');
if (mustLoad("nav") || mustLoad("rich"))
mw.util.addPortletLink(navbar, '/wiki/Wikipedia:Richieste_agli_amministratori', 'Richieste agli amministratori', '');
if (mustLoad("nav") || mustLoad("sand"))
mw.util.addPortletLink(navbar, '/wiki/Utente:' + mw.config.get('wgUserName') + '/Sandbox', 'Sandbox', '');
if (mustLoad("nav") || mustLoad("admin"))
mw.util.addPortletLink(navbar, '/wiki/Utente:' + mw.config.get('wgUserName') + '/strumenti admin', 'Strumenti Admin', '');
if (mustLoad("nav") || mustLoad("stub"))
mw.util.addPortletLink(navbar, '/wiki/Categoria:Stub', 'Stub', '');
if (mustLoad("nav") || mustLoad("prob"))
mw.util.addPortletLink(navbar, '/wiki/Wikipedia:Utenti problematici', 'Utenti problematici', '');
if (mustLoad("nav") || mustLoad("vand"))
mw.util.addPortletLink(navbar, '/wiki/Wikipedia:Vandalismi_in_corso', 'Vandalismi in corso', '');
if (mustLoad("nav") || mustLoad("bot")) {
if (typeof(nomeBot) != "undefined")
{
mw.util.addPortletLink(navbar, '/wiki/Speciale:Contributi/' + nomeBot, 'Contributi ' + nomeBot, '');
}
}
// Se sono stati stati installati alcuni collegamenti personali
if (typeof(myLinks) != 'undefined')
for (var i = 0; i < myLinks.length; i++)
{
nome = myLinks[i][0];
link = myLinks[i][1];
// Sostituisco %TITOLO% con il titolo della voce
var link = link.replace(/%TITOLO%/, mw.config.get('wgPageName'));
// Sostituisco %TITOLO2% con il titolo della voce senza namespace
var link = link.replace(/%TITOLO2%/, mw.config.get('wgTitle'));
//Aggiungo il link
mw.util.addPortletLink(navbar, link, nome, '');
}
}
/**** Aggiunge i link nel portlet "strumenti" ****/
function addToolBoxLinks()
{
var tb = 'p-tb';
//Edit count
if (mustLoad("stru") || mustLoad("uec"))
{
mw.util.addPortletLink(tb, 'http://toolserver.org/~tparis/count/index.php?name=' + mw.config.get('wgUserName') + '&lang=it&wiki=wikipedia', 'Edit count (' + mw.config.get('wgUserName') + ')', '');
var cur_user = "";
if (mw.config.get('wgCanonicalNamespace') == "User" || mw.config.get('wgCanonicalNamespace') == "User_talk"){
var slashpos = mw.config.get('wgTitle').indexOf('/');
cur_user = slashpos != -1 ? mw.config.get('wgTitle').substr(0, slashpos) : mw.config.get('wgTitle');
}
if (cur_user != "") //Se siamo in una pagina/sottopagina della pagina utente/discussione
{
mw.util.addPortletLink(tb, 'http://toolserver.org/~tparis/count/index.php?name=' + cur_user + '&lang=it&wiki=wikipedia', 'Edit count (' + cur_user + ')', '');
mw.util.addPortletLink(tb, 'http://tools.wikimedia.de/~luxo/contributions/contributions.php?user=' + cur_user + '&lang=it', 'Contributi interprogetto (' + cur_user + ')', '');
}
}
// if (mustLoad("stru") || mustLoad("vpop"))
// mw.util.addPortletLink(tb, 'http://tools.wikimedia.de/~henna/VPopSpeed/index.php?projlang=it', 'VPopSpeed', '');
username_a = document.URL.match(/([0-9]+\.){3}[0-9]+/);
if (username_a!=null)
{
username = username_a[0];
if (mustLoad("stru") || mustLoad("whois"))
mw.util.addPortletLink(tb, 'http://whois.domaintools.com/'+username,'User\'s Whois', 'Whois', '');
}
mw.util.addPortletLink(tb, 'javascript:var code = getpagecontent("Wikipedia:Monobook.js/Setup.js"); if(code) eval(code);', 'Setup', '');
mw.util.addPortletLink(tb, 'javascript:var code1 = getpagecontent("Wikipedia:Monobook.js/Pulsanti_personali.js"); if(code1) eval(code1);', 'Pulsanti personali', '');
mw.util.addPortletLink(tb, 'javascript:var code1 = getpagecontent("Wikipedia:Monobook.js/Collegamenti_personali.js"); if(code1) eval(code1);', 'Collegamenti personali', '');
if (mustLoad("stru") || mustLoad("vfol"))
if (BrowserDetect.browser=="Firefox" || BrowserDetect.browser=="Mozilla" || BrowserDetect.browser=="Netscape")
{
// Abilita/Disabilita il VFonLine
var scritta = GetCookie('wikiVFOL');
if (scritta == '') // Se il cookie non esiste
scritta = "disabilitato"; // per default e' disabilitato
mw.util.addPortletLink(tb, 'javascript:enableVFOL()', 'VFonLine '+scritta, 'vfol');
// Pulsanti di gestione delle liste (solo nelle pagine di modifica e solo se e' abilitato il VFOL)
if (GetCookie('wikiVFOL') == "abilitato")
{
mw.util.addPortletLink(tb, 'javascript:ModificaListaVFOL("White")', 'Modifica la White List', 'vfol1');
document.getElementById('vfol1').firstChild.accessKey = '1';
document.getElementById('vfol1').title = 'Alt-Shift-1';
mw.util.addPortletLink(tb, 'javascript:ModificaListaVFOL("Black")', 'Modifica la Black List', 'vfol2');
document.getElementById('vfol2').firstChild.accessKey = '2';
document.getElementById('vfol2').title = 'Alt-Shift-2';
}
}
}
/**** L'orologio che si aggiorna automaticamente ****/
function showtime()
{
var now = new Date();
document.getElementById('utcdate').firstChild.innerHTML = now.toLocaleString().replace(/GMT/, "CET");
setTimeout('showtime()', 300);
}
//Aggiunge qualcosa ad un portlet.
//PARAMS:
//* id: id del portlet.
//* obj: L'oggetto da aggiungere
function addToPortlet(id, obj)
{
var f = document.getElementById(id);
f = f.getElementsByTagName("div")[0];
f.appendChild(obj);
}
/**** Aggiunge il pulsante "Allpages" nel portlet "ricerca" ****/
function setup_allpages_button(){
//Non funziona correttamente con simpleSearch (Usability Initiative)
if (document.getElementById("simpleSearch"))
return;
var b = document.createElement('input');
b.type = "button";
b.value = "Allpages";
b.onclick = function(){
top.location.href = mw.config.get("wgServer") + '/wiki/Speciale:Allpages/' + document.getElementById('searchInput').value;
};
addToPortlet("p-search", document.createElement("hr"));
addToPortlet("p-search", b);
}
// Aggiunge indirizzi nella toolbar personale
// code stolen from [[wikt:en:User:Hippietrail]]
function addChat() {
var myprefs = document.getElementById('pt-mycontris');
var newpt, newa;
newpt = document.createElement('li');
newpt.id = 'id_chat';
newa = document.createElement('a');
newa.href='irc://calvino.freenode.net/wikipedia-it' ;
newa.appendChild(document.createTextNode('chat'));
newpt.appendChild(newa);
myprefs.parentNode.insertBefore(newpt, myprefs);
}
/** Rende il titolo editabile, in modo da usarlo come casella di ricerca **/
if (mustLoad("edt"))
$(function() {
if (typeof correctTitle != 'undefined'){
correctTitle(); // Rendo compatibile con 'titolo errato'
window.disableRealTitle = 1; // L'ho già eseguita, evito che venga eseguita di nuovo
}
if ((document.title.indexOf('Modifica ') == -1) &&
(document.title.indexOf('Utente:Senpai/Filtra le ultime modifiche') == -1) &&
(document.title.indexOf('Utente:Senpai/Tutte le ultime modifiche') == -1) &&
(document.title.indexOf('Utente:Senpai/Ultime modifiche anonime') == -1) &&
(document.title.indexOf('Utente:Senpai/Segui gli osservati speciali') == -1) &&
(document.title.indexOf('Utente:Senpai/Controllo ortografico') == -1))
{
var $staticTitle = $('h1').first();
var titleText = $staticTitle.text();
titleText = titleText.replace(/\t/g,"");
var $editableTitle = $('<input type="text" />')
.attr('id', 'editable-title')
.css({
width: '100%',
fontSize: 'x-large',
backgroundColor: 'transparent',
borderStyle: 'none',
borderBottomStyle: 'solid',
borderBottomWidth: '1px'
})
.val(titleText)
.change(function(){
document.location.href = mw.config.get("wgServer") + '/wiki/' + $(this).val();
})
.focus(function(){
$(this).css('backgroundColor', '#ddf');
})
.blur(function(){
$(this).css('backgroundColor', 'transparent');
})
.keypress(function(evt){
if (evt.which == 13)
$(this).change();
});
$staticTitle.replaceWith($editableTitle);
}
});
/* INIZIO Dynamic pages */
function mbAddTrustedPages(/* params */){
if (typeof mbTrustedPages == 'undefined') mbTrustedPages = {};
for(var i = 0; i < arguments.length; i++)
mbTrustedPages[arguments[i]] = true;
}
$(function (){
if(!mw.config.get('wgIsArticle')) return; //non in modifica
if(typeof mbTrustedPages == 'undefined') return;
if (mbTrustedPages[mw.config.get('wgPageName')] == true){
var pre = document.getElementById('javascriptCode');
if (!pre) return;
var code = pre.innerHTML.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<");
//eval(code);
var script = document.createElement('script');
script.appendChild(document.createTextNode(code));
document.body.appendChild(script);
}
});
/* FINE Dynamic pages */
//Importa la toolbar
if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit")
importScript("Wikipedia:Monobook.js/MonobookCompleto.js/Vector/Toolbar.js");
/**** Fine ****/
// </nowiki></pre>
// script "recent Senpaio" ver. 1.0<br/>
// Vedi [[Utente:Senpai/monobook/recent2.js]], derivato dall'[[:en:User:Lupin/Anti-vandal_tool|Anti-vandal tool]] di [[:en:user:Lupin]]; tradotto ed adattato da [[Utente:Senpai]] e [[Utente:Valepert]]
// <pre><nowiki>
if (mustLoad("avan"))
importScript('Utente:Senpai/monobook/recent2.js');
// </nowiki></pre>
// script "Catwatch" ver. 1.0<br/>
// Tradotto da [[Utente:Jalo|Jalo]]
// Vedi [[Wikipedia:Monobook.js/Catwatch.js]]
// <pre><nowiki>
if (mw.config.get('wgPageName')=="Speciale:OsservatiSpeciali" && mustLoad("cwtch"))
importScript('Wikipedia:Monobook.js/Catwatch.js');
// </nowiki></pre>
// script "ricerca in Namespace"<br/>
// Vedi [[Wikipedia:Monobook.js/namespaceSearch.js]], derivato dal tool di [[:en:User:Ilmari Karonen|Ilmari Karonen]]; tradotto ed adattato da [[Utente:Jalo|Jalo]]
// <pre><nowiki>
if (mustLoad("nms"))
importScript('Wikipedia:Monobook.js/namespaceSearch.js');
// </nowiki></pre>
// script "Quick Edit"<br/>
// Vedi [[Wikipedia:Monobook.js/QuickEdit.js]] di [[:de:Benutzer:ASM]]
// <pre><nowiki>
if (mustLoad("qed"))
{
//Workaround: bug in quickedit, non sempre il file delle lingue viene caricato in tempo
mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:ASM/quickedit-lang.js&action=raw&ctype=text/javascript');
mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:ASM/quickedit.js&action=raw&ctype=text/javascript');
}
// </nowiki></pre>
if (mustLoad("wed"))
if (BrowserDetect.browser!="Explorer") //non va con IE
{
// installa la traduzione del wikEd
// <pre><nowiki>
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Jalo/wikEd_international_it.js&action=raw&ctype=text/javascript');
// </nowiki></pre>
// installa il [[Wikipedia:Monobook.js/WikEd|wikEd]], editor di testo
// <pre><nowiki>
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript');
// </nowiki></pre>
}
// script Cronologia della pagina"<br/>
// Vedi [[Wikipedia:Monobook.js/MostraModifiche.js]] di [[:nl:User:JePe]]
// <pre><nowiki>
if (mustLoad("rch"))
if (BrowserDetect.browser!="Explorer") //non va con IE
importScript('Wikipedia:Monobook.js/MostraModifiche.js');
// </nowiki></pre>
// script "Command line"<br/>
// Vedi [[Utente:Salvatore_Ingala/commandline.js]] di [[Utente:Salvatore_Ingala]]
// NOTA: deve rimanere DOPO wikEd per motivi di compatibilità!
// <pre><nowiki>
if (mustLoad("cmd"))
importScript('Utente:Salvatore_Ingala/commandline.js');
// </nowiki></pre>
// script Notiziario del Monobook"<br/>
// Vedi [[Wikipedia:Monobook.js/Notiziario.js]]
// Questo script viene eseguito sempre, non ha bisogno del controllo 'mustLoad'
// <pre><nowiki>
if (mw.config.get('wgCanonicalNamespace') == 'User_talk' && mw.config.get('wgTitle') == mw.config.get('wgUserName') && typeof(disabilitaNotiziario)=="undefined")
importScript('Wikipedia:Monobook.js/Notiziario.js');
// </nowiki></pre>
// script del retropatrolling<br/>
// Vedi [[Wikipedia:VPopSpeed]]
// <pre><nowiki>
if (mustLoad("vpop"))
if (BrowserDetect.browser!="Explorer") //non va con IE
importScript('Utente:Henna/VPopSpeed.js');
// </nowiki></pre>
// script del Vandal Fighter on Line<br/>
// Vedi [[Wikipedia:Monobook.js/VFonLine]]
// Scritto da [[Utente:Jalo|Jalo]]
// <pre><nowiki>
if (mustLoad("vfol"))
{
importScript('Wikipedia:Monobook.js/VFonLine.js');
}
// script "Popup di navigazione"<br/>
// Vedi [[:en:User:Lupin/popups.js]] di [[:en:User:Lupin|Lupin]]
// <pre><nowiki>
if (mustLoad("popup"))
importScript('Wikipedia:Monobook.js/strings-it.js');
if (mustLoad("popup"))
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript');
// </nowiki></pre>
// Script di Link Complete
// Scritto da [[:en:Utente:Zocky]]
// [[:en:User:Zocky/LinkComplete.js]]
// Vedi [[:en:User:Zocky/Link_Complete]]
if (mustLoad("linkcomplete"))
{
importScript('MediaWiki:Gadget-LinkComplete.js');
}
// Script di Quick-Delete
// Vedi [[:m:MediaWiki talk:Quick-delete.js]]
if (mustLoad("qdel"))
{
importScript('Wikipedia:Monobook.js/Quick-delete.js');
}
// Unwatch. Aggiunge "non seguire" nella pagina degli osservati speciali
// Vedi [[Wikipedia:Monobook.js/Unwatch.js]]
if (mustLoad("unw"))
{
importScript('Wikipedia:Monobook.js/Unwatch.js');
}
// Cancella sezione. Aggiunge i link "cancella" da parte ad ogni sezione
if (mustLoad("dels"))
{
importScript('Wikipedia:Monobook.js/deledesection.js');
}
// Trasforma le cronologie incollate in versioni con wikilink
if(document.title.indexOf("Discussione") != -1 )
{
importScript('Wikipedia:Monobook.js/Cronologia.js');
}
// Verifica requisiti di voto di un utente
if (mustLoad("nav")||mustLoad("requi"))
{
importScript('Wikipedia:Monobook.js/Requisiti.js');
}
// Link cliccabili in crono
if (mustLoad("clink"))
{
var autolinkParseLink = false; // se si usa il wikEd
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Lenore/autolink.js&action=raw&ctype=text/javascript');
}
/*** Collegamento diretto alla pagina delle Voci di Qualità */
$(function(){
mw.util.addPortletLink('p-navigation', '/wiki/Wikipedia:Voci_di_qualit%C3%A0',
'Voci di Qualità', 't-vdq', 'Voci di Qualità', '', '#n-help');
});
// </nowiki>