blob: 71253bb42fd57217f299be8e1a64b5b16c2ea78b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
$( function () {
var appendFromSelect = function ( selectid, targetid ) {
'use strict';
var select = document.getElementById( selectid ),
target = document.getElementById( targetid ),
atxt;
if ( !target || !select ) {
return;
}
atxt = select.options[ select.selectedIndex ].value;
if ( !atxt ) {
return;
}
if ( target.value.replace( /\s+/g, '' ) !== '' ) {
atxt = ', ' + atxt;
}
atxt = target.value + atxt;
atxt = atxt.replace( /\bdefault\b[,\s]*/i, '' );
target.value = atxt;
};
$( '.mw-translate-jssti' ).on( 'click', function () {
var sourceId = $( this ).data( 'translate-jssti-sourceid' ),
targetId = $( this ).data( 'translate-jssti-targetid' );
appendFromSelect( sourceId, targetId );
} );
} );
|