Utente:Jalo/vector.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
Nessun oggetto della modifica |
||
Riga 92:
// TRADOTTO DA
function addTradottoDa()
{
Riga 116 ⟶ 115:
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
Riga 198 ⟶ 241:
pulsantiDescrPers["mito"] = 'Portale mitologia';
//TRADUCI WIKILINK:
pulsantiComandoPers["tradme"] = 'javascript:tradLink()';
pulsantiHotkeyPers["tradme"] = 'W';
Riga 206 ⟶ 249:
//test
//importScript('Utente:Jalo/Sandbox2');
//importStylesheet('Utente:Jalo/Sandbox2');
|