MediaWiki:Gadget-tradLink.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
meglio
m fix
 
(5 versioni intermedie di uno stesso utente non sono mostrate)
Riga 40:
} );
this.addError = function ( error ) {
thisself.errorContainer.setLabel(
new OO.ui.HtmlSnippet( '<span class="tradlinks-error">' + error + '</span>' )
);
};
this.clearError = function () {
thisself.errorContainer.setLabel( '' );
};
 
Riga 172:
function tradLink( cod ) {
var lingue = getLingue();
 
if ( lingue[cod] === 'it' ) {
// TODO Validare l'input per evitare questo caso
return;
}
 
new mw.ForeignApi( '//' + lingue[cod] + '.wikipedia.org/w/api.php' ).get( {
Riga 200 ⟶ 195:
var trad = data.query.pages[ key ].langlinks[ 0 ][ "*" ];
$( '#wpTextbox1' ).textSelection( 'encapsulateSelection', {
pre: trad + "[|",
post: "]"
} );
document.getElementById( 'wpTextbox1' ).selectionStart = selStart + trad.length + 1;
document.getElementById( 'wpTextbox1' ).selectionEnd = selEnd + trad.length + 21;
return;
}
Riga 219 ⟶ 213:
}
 
$( function () {
// setup hotkeys
$( '#wpTextbox1' ).keydown( function( event ) {
if ( event.altKey && !event.shiftKey && !event.ctrlKey && !event.metaKey ) {
if ( event.which === 48 ) {
event.preventDefault();
mw.loader.using( [ 'oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.widgets' ] )
.done( showDialog )
.fail( function() { console.error( 'Errore configurazione tradLink' ); } );
} else if ( event.which >= 49 && event.which < 57 ) {
event.preventDefault();
tradLink( event.which - 49 );
}
}
} );
} );
}( mediaWiki, jQuery ) );