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

Contenuto cancellato Contenuto aggiunto
Semplificazioni varie
-escape che non fanno nulla e try{} dalla dubbia utilità
Riga 103:
var lingue = getLingue();
 
var toTrad = mw.html.escape( $( '#wpTextbox1' ).textSelection( 'getSelection' ) );,
selEndselStart = document.getElementById( 'wpTextbox1' ).selectionEnd;selectionStart,
selEnd = document.getElementById( 'wpTextbox1' ).selectionEnd;
$.getJSON( "https://" + lingue[ cod ] + ".wikipedia.org/w/api.php?callback=?", {
action: "query",
Riga 123 ⟶ 125:
typeof( data.query.pages[ key ].langlinks[ 0 ][ "*" ] ) != "undefined"
) {
var trad = data.query.pages[ key ].langlinks[ 0 ][ "*" ],;
selStart = document.getElementById$( '#wpTextbox1' ).selectionStarttextSelection( 'encapsulateSelection', {
pre: trad + "[",
selEnd = document.getElementById( 'wpTextbox1' ).selectionEnd;
try post: {"]"
} ) );
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;
Riga 141 ⟶ 137:
}
}
mw.html.escape( $( '#wpTextbox1' ).textSelection( 'encapsulateSelection', {
try {
postpre: "]",
mw.html.escape( $( '#wpTextbox1' ).textSelection( 'encapsulateSelection', {
prepost: "[NO LINK]",
post:} "[NO LINK]");
} ) );
} catch ( err ) {
// ...?
}
document.getElementById( 'wpTextbox1' ).selectionStart = selEnd;
document.getElementById( 'wpTextbox1' ).selectionEnd = selEnd + 9;