Utente:Tino/TradottoDa.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
rimuovo categorie |
||
(4 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 10:
* @author [[Utente:Tino]]
*/
/* <nowiki> */
(function (mw, $) {
'use strict';
Riga 22 ⟶ 25:
var inputArea = $('#wpTextbox1');
// flag for default browser behaviour on the shortcut
Riga 68 ⟶ 70:
];
// text
var text = '{{tradotto da|' + lang + '|';
var index;
Riga 90 ⟶ 92:
// insert template completion
inputArea.textSelection('setSelection', {▼
start: cursor - 2,▼
end: cursor▼
});▼
inputArea.textSelection('encapsulateSelection', {
peri: text,
Riga 121 ⟶ 119:
dataType: 'jsonp',
success: function(data) {
if (!data.success)
var wiki = lang + 'wiki';
Riga 126 ⟶ 127:
var index;
for (index in data.entities) {
// the voice may not exist in the specified language
if (!data.entities[index].sitelinks[wiki])
var title = data.entities[index].sitelinks[wiki].title;
Riga 143 ⟶ 149:
keystrokeDefault = false;
var prevText, cursor, beginning, langMatch;
// get cursor position and select "{{tradotto da|ll" on keypress
cursor = inputArea.textSelection('getCaretPosition');
prevText = inputArea.val().substring(0, cursor);
beginning = prevText.toLowerCase().lastIndexOf('{{tradotto da');
prevText = prevText.substring(beginning);
{start: beginning, end: cursor});
// get language from the input in the textarea (last 2 chars)
if (!langMatch || !langMatch[1])
return;
queryWikidata(
});
Riga 161 ⟶ 176:
});
}(mediaWiki, jQuery));
/* </nowiki> */
|