MediaWiki:Gadget-tradLink.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m variabile |
ForeignApi |
||
Riga 24:
OptDialog.parent.call( this, config );
}
// TODO Valutare se sia possibile usare un ProcessDialog
OO.inheritClass( OptDialog, OO.ui.Dialog );
OptDialog.static.name = 'optDialog';
// XXX Questo non viene visualizzato nei Dialog di base
OptDialog.static.title = 'Configurazione del tool TradLink';
OptDialog.prototype.initialize = function () {
var self = this;
Riga 107 ⟶ 109:
var lingue = getLingue();
// TODO Validare l'input per evitare questo caso
action: "query",▼
prop: "langlinks",▼
lllang: "it",▼
titles: $( '#wpTextbox1' ).textSelection( 'getSelection' ),▼
format: "json",▼
redirects: ""▼
▲ },
function( data ) {▼
var 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"▼
) {▼
$( '#wpTextbox1' ).textSelection( 'encapsulateSelection', {▼
pre: trad + "[",▼
post: "]"▼
} );▼
document.getElementById( 'wpTextbox1' ).selectionStart = selStart + trad.length;▼
document.getElementById( 'wpTextbox1' ).selectionEnd = selEnd + trad.length + 2;▼
new mw.ForeignApi( '//' + lingue[cod] + '.wikipedia.org/w/api.php' ).get( {
▲ return;
}▼
if (
▲ if ( typeof( data.query.pages[ key ] ) != "undefined" &&
▲ ) {
return;
}
}
var noLinkLabel = "[NO LINK]";
$( '#wpTextbox1' ).textSelection( 'encapsulateSelection', { } );▼
document.getElementById( 'wpTextbox1' ).selectionStart = selEnd;▼
document.getElementById( 'wpTextbox1' ).selectionEnd = selEnd + noLinkLabel.length;▼
} );
}
| |||