1
1
const bootstrap = require ( 'bootstrap' ) ;
2
2
const style = require ( './main.css' ) ;
3
3
4
+ const availableLanguages = [
5
+ 'ar' , 'bn' , 'bs' , 'bg' , 'zh' , 'hr' , 'cs' , 'da' , 'nl' , 'en' ,
6
+ 'et' , 'fi' , 'fr' , 'de' , 'el' , 'gu' , 'he' , 'hi' , 'hu' , 'ga' ,
7
+ 'id' , 'it' , 'ja' , 'ko' , 'lv' , 'lt' , 'ms' , 'ml' , 'mt' , 'ne' ,
8
+ 'nb' , 'pl' , 'pt' , 'ro' , 'ru' , 'si' , 'sk' , 'sl' , 'es' , 'sv' ,
9
+ 'ta' , 'te' , 'th' , 'tr' , 'uk' , 'ur' , 'vi' , 'cy'
10
+ ] ;
11
+
4
12
// global variables
5
13
const app = {
6
14
images : {
@@ -19,6 +27,14 @@ window.onload = () => {
19
27
form . addEventListener ( 'submit' , get ) ;
20
28
inputImages . addEventListener ( 'change' , _uploadImages ) ;
21
29
30
+ for ( let lang of availableLanguages ) {
31
+ const option = document . createElement ( "option" ) ;
32
+ option . textContent = lang ;
33
+ option . value = lang ;
34
+ option . selected = ( lang === 'en' ) ;
35
+ document . getElementById ( 'formControlLang' ) . appendChild ( option ) ;
36
+ }
37
+
22
38
document . getElementById ( 'lineDivisionCheck' ) . addEventListener ( 'change' , ( e ) => {
23
39
if ( e . target . checked ) {
24
40
document . getElementById ( 'textDelimiterField' ) . classList . add ( 'd-none' ) ;
@@ -41,6 +57,7 @@ const get = async (e) => {
41
57
let textArea = encodeURIComponent ( document . getElementById ( 'formControlTextarea' ) . value ) ;
42
58
const shouldDivide = document . getElementById ( 'lineDivisionCheck' ) . checked ;
43
59
const lang = encodeURIComponent ( document . getElementById ( 'formControlLang' ) . value ) ;
60
+ console . log ( `lang=${ lang } ` ) ;
44
61
app . images . randomPlacement = document . getElementById ( 'imagePlacementCheck' ) . checked ;
45
62
46
63
let handler = `text` ;
@@ -78,7 +95,6 @@ const handleErr = (res = {success: false}) => {
78
95
}
79
96
80
97
const _uploadImages = async ( e ) => {
81
- // display fields
82
98
document . getElementById ( 'imagePlacementField' ) . classList . replace ( 'd-none' , 'd-block' ) ;
83
99
console . log ( document . getElementById ( 'imagePlacementField' ) ) ;
84
100
0 commit comments