Utente:Tino/TradottoDa.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
Nessun oggetto della modifica |
||
Riga 10:
(function (mw, $) {
'use strict';
var inputArea = $('#wpTextbox1');
var keystrokeDefault = true;
$(function() {
if (!e.altKey && !e.shiftKey && !e.metaKey &&
e.ctrlKey && e.keyCode === 89 /* "y" key */ &&
mw.config.get('wgNamespaceNumber') === 1 /* talkpage only */) {
// get language from the input in the textarea (last 2 chars)
var cursorPosition = $(e.target).textSelection('getCaretPosition'),
lang =
var wiki = lang + 'wiki';
Riga 29 ⟶ 31:
var page = mw.config.get('wgTitle');
// query wikidata to get the title in the other language
$.ajax({
url: '//www.wikidata.org/w/api.php',
Riga 44 ⟶ 47:
dataType: 'jsonp',
success: function(data) {
var monthNames = [▼
'gennaio', 'febbraio', 'marzo', 'aprile',▼
'maggio', 'giugno', 'luglio', 'agosto',▼
'settembre', 'ottobre', 'novembre', 'dicembre'▼
]; ▼
var text = lang + '|';▼
var index;
Riga 56 ⟶ 53:
var title = data.entities[index].sitelinks[wiki].title;
// query the other wikipedia to get revision info
$.ajax({
url: '//' + lang + '.wikipedia.org/w/api.php',
Riga 66 ⟶ 64:
dataType: 'jsonp',
success: function(voiceData) {
// regex to extract the date from a timestamp
var dateRegex = /([0-9]{4})-([0-9]{2})-([0-9]{2}).*/;
▲ var monthNames = [
▲ 'gennaio', 'febbraio', 'marzo', 'aprile',
▲ 'maggio', 'giugno', 'luglio', 'agosto',
▲ 'settembre', 'ottobre', 'novembre', 'dicembre'
▲ ];
// text to be added after the cursor position
▲ var text = lang + '|';
for (index in voiceData.query.pages) {
Riga 87 ⟶ 95:
// insert template completion
});
inputArea.textSelection('encapsulateSelection', {
peri: text,
replace: true
});
}
}
});
}
}
Riga 100 ⟶ 112:
});
// prevent default browser action only when needed
if (!e.altKey && !e.shiftKey && !e.metaKey &&
e.ctrlKey && e.keyCode === 89 /* "y" key */ ) {
|