summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/resources/js/ext.translate.selecttoinput.js
blob: 52ded495402532f893ad779f9fbdcb339444ceeb (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
window.appendFromSelect = function ( selectid, targetid ) {
	'use strict';

	var select, target, atxt;

	select = document.getElementById( selectid );
	target = document.getElementById( targetid );

	if ( !target || !select ) {
		return;
	}

	atxt = select.options[ select.selectedIndex ].value;

	if ( !atxt ) {
		return;
	}

	/* Ugly hack */

	target.value = target.value.replace( /default/, '' );

	if ( target.value.replace( /[\s\t\n]/ig, '' ) !== '' ) {
		atxt = ', ' + atxt;
	}
	target.value += atxt;
};