Utente:Jalo/vector.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica
Nessun oggetto della modifica
Riga 2:
 
var myLinks = new Array(['Voce su en.wiki','http://en.wikipedia.org/wiki/%TITOLO%'],['Voce su Commons','http://commons.wikimedia.org/wiki/Image:%TITOLO2%'],['Vecchio Edit-count','http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?user=Jalo&dbname=itwiki_p']);
 
// Firefox
 
//CONFIGURAZIONE POPUP
popupDelay = 2; // aspetta 2 secondi
popupQueriedRevertSummary = "Rollback da popup. Ripristinata la versione di $3";
 
//MOSTRA I TATTOO
//mw.loader.load("//it.wikipedia.org/w/index.php?title=Utente:Jalo/Tatoo&action=raw&ctype=text/javascript&dontcountme=s");
 
//NASCONDI IL COPYWARN SOTTO LA CASELLA DI MODIFICA
$( document ).ready ( function ()
{
if (document.getElementById("editpage-copywarn"))
document.getElementById("editpage-copywarn").style.display="none";
})
 
// TRADOTTO DA
function addTradottoDa()
{
interlinks = $.ajax({
url:mw.util.wikiScript('api'),
data: { action: 'query', format: 'xml', prop: 'langlinks', lllang: 'en', titles: wgTitle},
async:false
})
.responseText;
 
if (interlinks.indexOf("<ll lang") < 0)
enArticle = "";
else
{
enArticle = interlinks.substr(interlinks.indexOf("<ll lang"));
enArticle = enArticle.substr(enArticle.indexOf(">")+1);
enArticle = enArticle.substr(0,enArticle.indexOf("<"));
}
var my_date = new Date();
dataOggi = my_date.getDate()+" "+arrayMese[my_date.getMonth()+1]+" "+(1900+my_date.getYear());
addTextAtCursor("{{Tradotto da|en|"+enArticle+"|"+dataOggi+"|id}}\n","+Tradotto da","",0);
}
 
function tradLink()
{
var toTrad = mw.html.escape($('#wpTextbox1').textSelection('getSelection'));
var trad ="";
$.getJSON("http://en.wikipedia.org/w/api.php?callback=?",
{
action: "query",
prop: "langlinks",
lllang: "it",
titles: toTrad,
format: "json",
redirects: ""
},
function(data) {
selStart = document.getElementById('wpTextbox1').selectionStart;
selEnd = document.getElementById('wpTextbox1').selectionEnd;
if (typeof(data)!="undefined" &&
typeof(data.query)!="undefined" &&
typeof(data.query.pages)!="undefined")
{
for (var key in data.query.pages) {
if (typeof(data.query.pages[key])!="undefined" &&
typeof(data.query.pages[key].langlinks)!="undefined" &&
typeof(data.query.pages[key].langlinks[0])!="undefined" &&
typeof(data.query.pages[key].langlinks[0]["*"])!="undefined")
{
trad = data.query.pages[key].langlinks[0]["*"];
try {
mw.html.escape($('#wpTextbox1').textSelection('encapsulateSelection', { pre: trad + "[", post: "]" }));
} catch (err) {};
document.getElementById('wpTextbox1').selectionStart = selStart + trad.length;
document.getElementById('wpTextbox1').selectionEnd = selEnd + trad.length + 2;
 
return;
}
}
}
try {
mw.html.escape($('#wpTextbox1').textSelection('encapsulateSelection', { pre: "", post: "[NO LINK]" }));
} catch (err) {};
document.getElementById('wpTextbox1').selectionStart = selEnd;
document.getElementById('wpTextbox1').selectionEnd = selEnd + 9;
});
}
 
// Configurazione HOTKEYS
var tastiHotkeys = new Array();
tastiHotkeys["firma"] = 'F';
tastiHotkeys["case"] = 'C';
tastiHotkeys["obj"] = 'Z';
 
pulsantiComandoPers = new Array();
pulsantiHotkeyPers = new Array();
pulsantiDescrPers = new Array();
//SUP 2
pulsantiComandoPers["sup2"] = 'javascript:addTextAtCursor("²","","",1)';
pulsantiHotkeyPers["sup2"] = '2';
pulsantiDescrPers["sup2"] = 'Alla seconda';
 
//CITA
pulsantiComandoPers["cita"] = 'javascript:addTextAtCursor("<ref>{{Cita||}}</ref>","","",12)';
pulsantiHotkeyPers["cita"] = '';
pulsantiDescrPers["cita"] = '{{Cita}}';
 
//REFERENCES
pulsantiComandoPers["ref"] = 'javascript:addTextAtCursor(\'==Note==\\n{{references}}\\n\\n\',"","",0)';
pulsantiHotkeyPers["ref"] = 'R';
pulsantiDescrPers["ref"] = 'Note+references';
 
//PORTALE ANTICA ROMA
pulsantiComandoPers["roma"] = 'javascript:addTextAtCursor("{{Portale|Antica Roma|Germani|Storia}}","","",0)';
pulsantiHotkeyPers["roma"] = 'A';
pulsantiDescrPers["roma"] = 'Portali';
 
//INTERPROGETTO
pulsantiComandoPers["ipro2"] = 'javascript:addTextAtCursor("==Altri progetti==\\n{{interprogetto|","}}\\n\\n","",0)';
pulsantiHotkeyPers["ipro2"] = 'I';
pulsantiDescrPers["ipro2"] = 'Interprogetto + titolo';
 
//FOTO RICHIESTE:
pulsantiComandoPers["foto"] = 'javascript:addTextAtCursor("{{Richiesta"+" foto|}}","","",17)';
pulsantiHotkeyPers["foto"] = 'N';
pulsantiDescrPers["foto"] = 'Richiesta foto';
 
//TRADOTTO DA:
pulsantiComandoPers["mytradda"] = 'javascript:addTradottoDa()';
pulsantiHotkeyPers["mytradda"] = 'T';
pulsantiDescrPers["mytradda"] = 'Tradotto da';
 
//BUTTONGREEN PER CONTRIBUTI:
pulsantiComandoPers["butgreen"] = 'javascript:addTextAtCursor(" [[Immagine:ButtonGreen.svg|15px]] ","","",35)';
pulsantiHotkeyPers["butgreen"] = 'A';
pulsantiDescrPers["butgreen"] = 'ButtonGreen';
 
//TRADUCI WIKILINK:
pulsantiComandoPers["tradme"] = 'javascript:tradLink()';
pulsantiHotkeyPers["tradme"] = 'W';
pulsantiDescrPers["tradme"] = 'Traduci link';
 
//test
//importScript('Utente:Jalo/Sandbox2');
//importStylesheet('Utente:Jalo/Sandbox2');