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' ) )
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 ][ "*" ]
▲ selEnd = document.getElementById( 'wpTextbox1' ).selectionEnd;
mw.html.escape( $( '#wpTextbox1' ).textSelection( 'encapsulateSelection', {▼
▲ pre: trad + "[",
post: "]"▼
▲ } ) );
document.getElementById( 'wpTextbox1' ).selectionStart = selStart + trad.length;
document.getElementById( 'wpTextbox1' ).selectionEnd = selEnd + trad.length + 2;
Riga 141 ⟶ 137:
}
}
document.getElementById( 'wpTextbox1' ).selectionStart = selEnd;
document.getElementById( 'wpTextbox1' ).selectionEnd = selEnd + 9;
| |||