Projekt

Obecné

Profil

Stáhnout (31.2 KB) Statistiky
| Větev: | Revize:
1
<div id="edit-modal" class="modal fade" role="dialog">
2
    <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
3
        <div class="modal-content">
4
            <div class="modal-header">
5
                <h4 class="modal-title"></h4>
6
                <button type="button" class="close" data-dismiss="modal">&times;</button>
7
            </div>
8
            <div class="modal-body">
9
                <div class="container">
10
                    <div class="row my-1">
11
                        <div class="col-xs-12 col-sm-4">
12
                            <label for="word">Slovo:</label>
13
                        </div>
14
                        <div class="col-xs-12 col-sm-8">
15
                            <input class="min-wdth" id="word"/>
16
                        </div>
17
                    </div>
18
                    <div class="row my-1">
19
                        <div class="col-xs-12 col-sm-4">
20
                            <label for="lemma">Lemma:</label>
21
                        </div>
22
                        <div class="col-xs-12 col-sm-8">
23
                            <input class="min-wdth" id="lemma"/>
24
                        </div>
25
                    </div>
26
                    <div class="row my-1">
27
                        <div class="col-xs-12 col-sm-4">
28
                            <label for="manuscript-m">Rukopisy:</label>
29
                        </div>
30
                        <div class="col-xs-12 col-sm-8">
31
                            <select id="manuscript-m" multiple>
32
                                <option value = "0">rukopis Vídeňský</option>
33
                                <option value = "1">zlomky Hanušovy</option>
34
                                <option value = "2">zlomky Hradecké</option>
35
                                <option value = "3">rukopis Cambridžský</option>
36
                                <option value = "4">rukopis Františkánský</option>
37
                                <option value = "5">zlomek Olomoucký</option>
38
                                <option value = "6">fragment Strahovský</option>
39
                                <option value = "7">zlomky Klementinsko-Křižovnické</option>
40
                                <option value = "8">zlomky Mnichovské</option>
41
                                <option value = "9">rukopis Lobkovický</option>
42
                                <option value = "10">rukopis Pelclův</option>
43
                                <option value = "11">rukopis Cerronský</option>
44
                                <option value = "12">rukopis Fürstenberský</option>
45
                                <option value = "13">rukopis Zebererův</option>
46
                                <option value = "14">vydání Pavla Ješína z Bezdězi, Praha 1620</option>
47
                                <option value = "15">básně připsané při Pulkavově kronice v rukopisu Litoměřickém</option>
48
                            </select>
49
                        </div>
50
                    </div>
51
                    <div class="row my-1">
52
                        <div class="col-xs-12 col-sm-4">
53
                            <label for="position">Pozice:</label>
54
                        </div>
55
                        <div class="col-xs-12 col-sm-8">
56
                            <input class="min-wdth" id="position" title="Jedotlivé oddíly zadávejte oddělené lomítkem (bez mezery)" />
57
                        </div>
58
                    </div>
59
                    <div class="row my-1">
60
                        <div class="col-xs-12 col-sm-4">
61
                            <label for="namedentity">Vlastní jméno:</label>
62
                        </div>
63
                        <div class="col-xs-12 col-sm-8">
64
                            <input type="checkbox" id="namedentity"/>
65
                        </div>
66
                    </div>
67
                    <div class="row my-1">
68
                        <div class="col-xs-12 col-sm-4">
69
                            <label for="context">Kontext:</label>
70
                        </div>
71
                        <div class="col-xs-12 col-sm-8">
72
                            <input class="min-wdth" id="context"/>
73
                        </div>
74
                    </div>
75
                    <div class="row my-1">
76
                        <div class="col-xs-12 col-sm-4">
77
                            <label for="wordclass">Slovní druh:</label>
78
                        </div>
79
                        <div class="col-xs-12 col-sm-8">
80
                            <select class="min-wdth" onchange="changeWordType()"  id="wordclass">
81
                                <option selected="selected" value = "">Nevybráno</option>
82
                                <option value = "N">Substantiva</option>
83
                                <option value = "A">Adjektiva</option>
84
                                <option value = "P">Pronomina</option>
85
                                <option value = "C">Numeralia</option>
86
                                <option value = "V">Verba</option>
87
                                <option value = "D">Adverbia</option>
88
                                <option value = "R">Prepozice</option>
89
                                <option value = "J">Konjunkce</option>
90
                                <option value = "I">Interjekce</option>
91
                                <option value = "T">Partikule</option>
92
                            </select>
93
                        </div>
94
                    </div>
95

    
96
                    <!-- conditional render -->
97
                    <div class="row my-1" id="person-wrapper">
98
                        <div class="col-xs-12 col-sm-4">
99
                            <label for="person">Osoba:</label>
100
                        </div>
101
                        <div class="col-xs-12 col-sm-8">
102
                            <select class="min-wdth" id="person">
103
                                <option selected="selected" value = "">Nevybráno</option>
104
                                <option value = "1">1.</option>
105
                                <option value = "2">2.</option>
106
                                <option value = "3">3.</option>
107
                            </select>
108
                        </div>
109
                    </div>
110
                    <div class="row my-1" id="case-wrapper">
111
                        <div class="col-xs-12 col-sm-4">
112
                            <label for="case">Pád:</label>
113
                        </div>
114
                        <div class="col-xs-12 col-sm-8">
115
                            <select class="min-wdth" id="case">
116
                                <option selected="selected" value = "">Nevybráno</option>
117
                                <option value = "1">Nominativ</option>
118
                                <option value = "2">Genitiv</option>
119
                                <option value = "3">Dativ</option>
120
                                <option value = "4">Akuzativ</option>
121
                                <option value = "5">Vokativ</option>
122
                                <option value = "6">Lokál</option>
123
                                <option value = "7">Instrumentál</option>
124
                            </select>
125
                        </div>
126
                    </div>
127
                    <div class="row my-1" id="countability-wrapper">
128
                        <div class="col-xs-12 col-sm-4">
129
                            <label for="countability">Číslo:</label>
130
                        </div>
131
                        <div class="col-xs-12 col-sm-8">
132
                            <select class="min-wdth" id="countability">
133
                                <option selected="selected" value = "">Nevybráno</option>
134
                                <option value = "S">Singulár</option>
135
                                <option value = "P">Plurál</option>
136
                                <option value = "D">Duál</option>
137
                            </select>
138
                        </div>
139
                    </div>
140
                    <div class="row my-1" id="gender-wrapper">
141
                        <div class="col-xs-12 col-sm-4">
142
                            <label for="gender">Rod:</label>
143
                        </div>
144
                        <div class="col-xs-12 col-sm-8">
145
                            <select class="min-wdth" id="gender">
146
                                <option selected="selected" value = "">Nevybráno</option>
147
                                <option value = "M">Maskulinum</option>
148
                                <option value = "F">Femininum</option>
149
                                <option value = "N">Neutrum</option>
150
                            </select>
151
                        </div>
152
                    </div>
153
                    <div class="row my-1" id="shape-wrapper">
154
                        <div class="col-xs-12 col-sm-4">
155
                            <label for="shape">Tvar:</label>
156
                        </div>
157
                        <div class="col-xs-12 col-sm-8">
158
                            <select class="min-wdth" id="shape">
159
                                <option selected="selected" value = "">Nevybráno</option>
160
                                <option value = "C">Složený</option>
161
                                <option value = "N">Jmenný</option>
162
                            </select>
163
                        </div>
164
                    </div>
165
                    <div class="row my-1" id="grade-wrapper">
166
                        <div class="col-xs-12 col-sm-4">
167
                            <label for="grade">Stupeň:</label>
168
                        </div>
169
                        <div class="col-xs-12 col-sm-8">
170
                            <select class="min-wdth" id="grade">
171
                                <option selected="selected" value = "">Nevybráno</option>
172
                                <option value = "1">Pozitiv</option>
173
                                <option value = "2">Komparativ</option>
174
                                <option value = "3">Superlativ</option>
175
                            </select>
176
                        </div>
177
                    </div>
178
                    <div class="row my-1" id="type-wrapper">
179
                        <div class="col-xs-12 col-sm-4">
180
                            <label for="type">Druh:</label>
181
                        </div>
182
                        <div class="col-xs-12 col-sm-8">
183
                            <select class="min-wdth" id="type">
184
                                <option selected="selected" value = "">Nevybráno</option>
185
                                <option value = "P">Personalia</option>
186
                                <option value = "S">Posesiva</option>
187
                                <option value = "D">Demonstrativa</option>
188
                                <option value = "Q">Interogativa</option>
189
                                <option value = "J">Relativa</option>
190
                                <option value = "Z">Indefinita</option>
191
                                <option value = "L">Limitativa</option>
192
                                <option value = "W">Negativa</option>
193
                            </select>
194
                        </div>
195
                    </div>
196
                    <div class="row my-1" id="time-wrapper">
197
                        <div class="col-xs-12 col-sm-4">
198
                            <label for="time">Čas:</label>
199
                        </div>
200
                        <div class="col-xs-12 col-sm-8">
201
                            <select class="min-wdth" id="time">
202
                                <option selected="selected" value = "">Nevybráno</option>
203
                                <option value = "P">Prézens</option>
204
                                <option value = "A">Aorist</option>
205
                                <option value = "R">Préteritum</option>
206
                                <option value = "I">Imperfektum</option>
207
                                <option value = "H">Plusquamperfektum</option>
208
                                <option value = "F">Futurum</option>
209
                            </select>
210
                        </div>
211
                    </div>
212
                    <div class="row my-1" id="mood-wrapper">
213
                        <div class="col-xs-12 col-sm-4">
214
                            <label for="mood">Způsob:</label>
215
                        </div>
216
                        <div class="col-xs-12 col-sm-8">
217
                            <select class="min-wdth" id="mood" onchange="moodChange()">
218
                                <option selected="selected" value = "">Nevybráno</option>
219
                                <option value = "d">Indikativ</option>
220
                                <option value = "i">Imperativ</option>
221
                                <option value = "c">Kondicionál</option>
222
                            </select>
223
                        </div>
224
                    </div>
225
                    <div class="row my-1" id="irregular-wrapper">
226
                        <div class="col-xs-12 col-sm-4">
227
                            <label for="irregular">Neurčitý slovesný tvar:</label>
228
                        </div>
229
                        <div class="col-xs-12 col-sm-8">
230
                            <select class="min-wdth" id="irregular" onchange="irregularChange()">
231
                                <option selected="selected" value = "">Nevybráno</option>
232
                                <option value = "f">Infinitiv</option>
233
                                <option value = "S">Supinum</option>
234
                                <option value = "e">Přech. přítomný</option>
235
                                <option value = "m">Přech. minulý</option>
236
                                <option value = "A">Part. perf. akt.</option>
237
                                <option value = "P">Part. perf. pas.</option>
238
                            </select>
239
                        </div>
240
                    </div>
241
                    <div class="row my-1" id="v-type-wrapper">
242
                        <div class="col-xs-12 col-sm-4">
243
                            <label for="v-type">Slovesný rod:</label>
244
                        </div>
245
                        <div class="col-xs-12 col-sm-8">
246
                            <select class="min-wdth" id="v-type">
247
                                <option selected="selected" value = "">Nevybráno</option>
248
                                <option value = "A">Aktivum</option>
249
                                <option value = "P">Pasivum</option>
250
                            </select>
251
                        </div>
252
                    </div>
253
                    <div class="row my-1" id="vid-wrapper">
254
                        <div class="col-xs-12 col-sm-4">
255
                            <label for="vid">Slovesný vid:</label>
256
                        </div>
257
                        <div class="col-xs-12 col-sm-8">
258
                            <select class="min-wdth" id="vid">
259
                                <option selected="selected" value = "">Nevybráno</option>
260
                                <option value = "P">Perfektivum</option>
261
                                <option value = "I">Imperfektivum </option>
262
                            </select>
263
                        </div>
264
                    </div>
265
                    <div class="row my-1" id="k-type-wrapper">
266
                        <div class="col-xs-12 col-sm-4">
267
                            <label for="k-type">Typ:</label>
268
                        </div>
269
                        <div class="col-xs-12 col-sm-8">
270
                            <select class="min-wdth" id="k-type">
271
                                <option selected="selected" value = "">Nevybráno</option>
272
                                <option value = "V">Větná</option>
273
                                <option value = "C">Členská</option>
274
                                <option value = "N">Navazovací</option>
275
                                <option value = "P">Spojení s přechodníkem</option>
276
                            </select>
277
                        </div>
278
                    </div>
279
                </div>
280
            </div>
281
            <div class="modal-footer">
282
                <button type="button" id="submit-but" class="btn btn-default" data-dismiss="modal"></button>
283
                <button type="button" class="btn btn-default" data-dismiss="modal">Zavřít</button>
284
            </div>
285
        </div>
286
    </div>
287
</div>
288

    
289
<script>
290
    $('#edit-modal').on('show.bs.modal', function (event) {
291
        const button = $(event.relatedTarget);
292
        const pseudo_id = button.data('pseudo-id');// Extract info from data-* attributes
293
        const title = button.data('title');// Extract info from data-* attributes
294
        $('#manuscript-m').multiSelect({
295
            'noneText': 'Nevybráno',
296
        });
297

    
298
        let modal = $(this);
299
        modal.find('.modal-title').text(title);
300
        modal.find('#mood').change(() => moodMChange(modal));
301
        modal.find('#irregular').change(() => irregularMChange(modal));
302

    
303
        if(title === "Nový záznam"){
304
            prefill(modal);
305
            changeWordType();
306
            modal.find('#submit-but').text("Založit");
307
            modal.find('#submit-but').click(() => createData(modal));
308
        } else {
309
            const data_obj = data[pseudo_id];
310
            modal.find('#submit-but').text("Upravit");
311
            modal.find('#submit-but').click(() => editData(data_obj, modal));
312
            changeWordType();
313
            prefill(modal, data_obj);
314
            moodMChange(modal);
315
            irregularMChange(modal);
316
        }
317
    });
318

    
319
    function changeWordType() {
320
        let modal = $('#edit-modal');
321
        const value = modal.find("#wordclass")[0].value;
322
        let movedNode;
323
        let beforeNode;
324
        switch (value) {
325
            case "N":
326
                setElementVisibility([
327
                    true,
328
                    true,
329
                    true,
330
                    false,
331
                    false,
332
                    false,
333
                    false,
334
                    false,
335
                    false,
336
                    false,
337
                    false,
338
                    false,
339
                    false
340
                ], modal);
341
                movedNode = modal.find("#case-wrapper");
342
                beforeNode = modal.find("#countability-wrapper");
343
                beforeNode.before(movedNode);
344
                break;
345
            case "A":
346
                setElementVisibility([
347
                    true,
348
                    true,
349
                    true,
350
                    true,
351
                    true,
352
                    false,
353
                    false,
354
                    false,
355
                    false,
356
                    false,
357
                    false,
358
                    false,
359
                    false
360
                ], modal);
361
                movedNode = modal.find("#case-wrapper");
362
                beforeNode = modal.find("#countability-wrapper");
363
                beforeNode.before(movedNode);
364
                break;
365
            case "P":
366
                setElementVisibility([
367
                    true,
368
                    true,
369
                    true,
370
                    false,
371
                    false,
372
                    true,
373
                    false,
374
                    false,
375
                    false,
376
                    false,
377
                    false,
378
                    false,
379
                    false
380
                ], modal);
381
                movedNode = modal.find("#case-wrapper");
382
                beforeNode = modal.find("#countability-wrapper");
383
                beforeNode.before(movedNode);
384
                break;
385
            case "C":
386
                setElementVisibility([
387
                    true,
388
                    true,
389
                    true,
390
                    false,
391
                    false,
392
                    false,
393
                    false,
394
                    false,
395
                    false,
396
                    false,
397
                    false,
398
                    false,
399
                    false
400
                ], modal);
401
                movedNode = modal.find("#case-wrapper");
402
                beforeNode = modal.find("#countability-wrapper");
403
                beforeNode.before(movedNode);
404
                break;
405
            case "V":
406
                setElementVisibility([
407
                    true,
408
                    true,
409
                    true,
410
                    false,
411
                    false,
412
                    false,
413
                    true,
414
                    true,
415
                    true,
416
                    true,
417
                    true,
418
                    true,
419
                    false
420
                ], modal);
421
                movedNode = modal.find("#case-wrapper");
422
                beforeNode = modal.find("#vid-wrapper");
423
                beforeNode.after(movedNode);
424
                break;
425
            case "D":
426
                setElementVisibility([
427
                    false,
428
                    false,
429
                    false,
430
                    false,
431
                    true,
432
                    false,
433
                    false,
434
                    false,
435
                    false,
436
                    false,
437
                    false,
438
                    false,
439
                    false
440
                ], modal);
441
                break;
442
            case "R":
443
                setElementVisibility([
444
                    true,
445
                    false,
446
                    false,
447
                    false,
448
                    false,
449
                    false,
450
                    false,
451
                    false,
452
                    false,
453
                    false,
454
                    false,
455
                    false,
456
                    false
457
                ], modal);
458
                break;
459
            case "J":
460
                setElementVisibility([
461
                    false,
462
                    false,
463
                    false,
464
                    false,
465
                    false,
466
                    false,
467
                    false,
468
                    false,
469
                    false,
470
                    false,
471
                    false,
472
                    false,
473
                    true
474
                ], modal);
475
                break;
476
            case "I":
477
                setElementVisibility([
478
                    false,
479
                    false,
480
                    false,
481
                    false,
482
                    false,
483
                    false,
484
                    false,
485
                    false,
486
                    false,
487
                    false,
488
                    false,
489
                    false,
490
                    false
491
                ], modal);
492
                break;
493
            case "T":
494
                setElementVisibility([
495
                    false,
496
                    false,
497
                    false,
498
                    false,
499
                    false,
500
                    false,
501
                    false,
502
                    false,
503
                    false,
504
                    false,
505
                    false,
506
                    false,
507
                    false
508
                ], modal);
509
                break;
510
            default:
511
                setElementVisibility([
512
                    false,
513
                    false,
514
                    false,
515
                    false,
516
                    false,
517
                    false,
518
                    false,
519
                    false,
520
                    false,
521
                    false,
522
                    false,
523
                    false,
524
                    false
525
                ], modal);
526
                break;
527
        }
528
    }
529

    
530
    const dynamicFields = [
531
        "#case-wrapper",
532
        "#countability-wrapper",
533
        "#gender-wrapper",
534
        "#shape-wrapper",
535
        "#grade-wrapper",
536
        "#type-wrapper",
537
        "#mood-wrapper",
538
        "#irregular-wrapper",
539
        "#person-wrapper",
540
        "#time-wrapper",
541
        "#vid-wrapper",
542
        "#v-type-wrapper",
543
        "#k-type-wrapper"
544
    ];
545

    
546
    const staticFields = [
547
        "#word",
548
        "#lemma",
549
        "#manuscript-m",
550
        "#position",
551
        "#namedentity",
552
        "#context",
553
        "#wordclass"
554
    ];
555

    
556
    function setElementVisibility(visibility, modal) {
557
        for(let i = 0; i < dynamicFields.length &&  i < visibility.length; i++){
558
            if(visibility[i] === true){
559
                modal.find(dynamicFields[i]).show();
560
            } else {
561
                modal.find(dynamicFields[i]).hide();
562
            }
563
            modal.find(dynamicFields[i].replace("-wrapper", "")).val("");
564
        }
565
    }
566

    
567
    function prefill(modal, data = null){
568
        staticFields.forEach((item) => {
569
            modal.find(item).val("");
570
        });
571

    
572
        modal.find("#namedentity").prop('checked', false);
573

    
574
        dynamicFields.forEach((item) => {
575
            modal.find(item.replace("-wrapper", "")).val("");
576
        });
577

    
578
        if(data !== null){
579
            modal.find("#context").val(data.context);
580
            modal.find("#namedentity").prop('checked', data.namedentity === 1);
581

    
582
            let position = data.position1;
583
            position += ((data.position2 !== null && data.position2.length > 0) ? ("/" + data.position2) : "");
584
            position += ((data.positiondetail !== null && data.positiondetail.length > 0) ? ("/" + data.positiondetail) : "");
585
            modal.find("#position").val(position);
586

    
587
            modal.find("#word").val(data.word);
588
            modal.find("#lemma").val(data.lemma.lemma);
589
            modal.find("#manuscript-m").val(data.manuscript);
590

    
591
            //dynamic setting
592
            const morphem = data.tag.tag;
593
            const wordclass = morphem.charAt(0);
594
            modal.find("#wordclass").val(wordclass);
595
            modal.find("#case").val((morphem.charAt(1) !== '-') ? morphem.charAt(1) : "");
596
            modal.find("#countability").val((morphem.charAt(2) !== '-') ? morphem.charAt(2) : "");
597
            modal.find("#gender").val((morphem.charAt(3) !== '-') ? morphem.charAt(3) : "");
598
            modal.find("#grade").val((morphem.charAt(4) !== '-') ? morphem.charAt(4) : "");
599
            modal.find("#shape").val((morphem.charAt(5) !== '-') ? morphem.charAt(5) : "");
600

    
601
            if(morphem.charAt(7) !== '-'){
602
                if(wordclass === 'J'){
603
                    modal.find("#k-type").val(morphem.charAt(7));
604
                } else if(wordclass === 'P'){
605
                    modal.find("#type").val(morphem.charAt(7));
606
                } else if(wordclass === 'V'){
607
                    if(codeToMood[morphem.charAt(7)] !== undefined) {
608
                        modal.find("#mood").val(morphem.charAt(7));
609
                    } else {
610
                        modal.find("#irregular").val(morphem.charAt(7));
611
                    }
612
                }
613
            }
614

    
615
            modal.find("#person").val((morphem.charAt(8) !== '-') ? morphem.charAt(8) : "");
616
            modal.find("#time").val((morphem.charAt(9) !== '-') ? morphem.charAt(9) : "");
617
            modal.find("#v-type").val((morphem.charAt(10) !== '-') ? morphem.charAt(10) : "");
618
            modal.find("#vid").val((morphem.charAt(11) !== '-') ? morphem.charAt(11) : "");
619
        }
620
    }
621

    
622
    function editData(data, modal){
623
        const formData = prepareFormData(modal);
624
        formData.append("id", data.id);
625

    
626
        //TODO the next three WILL be added in prepareFormData in future
627
        formData.append("description", data.description);
628
        formData.append("description2", data.description2);
629
        formData.append("description3", data.description3);
630

    
631
        formData.append("ending", data.ending);
632
        formData.append("finished", data.finished);
633
        formData.append("prefix", data.prefix);
634
        formData.append("suffix", data.suffix);
635

    
636
        var xhr = new XMLHttpRequest();
637
        xhr.open("POST", "./controller/UpdateController.php");
638
        xhr.send(formData);
639
    }
640

    
641
    function prepareFormData(modal) {
642
        const formData = new FormData();
643

    
644
        formData.append("namedentity", (modal.find("#namedentity")[0].checked) ? "1" : "0");
645

    
646
        const position = modal.find("#position")[0].value.split("/");
647
        formData.append("position1", position[0]);
648
        formData.append("position2", (position[1] !== undefined) ? position[1] : "");
649
        formData.append("positiondetail", (position[2] !== undefined) ? position[2] : "");
650

    
651
        formData.append("word", modal.find("#word")[0].value);
652
        formData.append("lemma", modal.find("#lemma")[0].value);
653
        formData.append("manuscript", modal.find("#manuscript-m")[0].value);
654
        formData.append("context", modal.find("#context")[0].value);
655

    
656
        //morphem creation
657
        let morphem = "";
658
        const wordClass = modal.find("#wordclass")[0].value;
659
        morphem += ((wordClass.length > 0) ? wordClass.value : "-");
660
        morphem += ((modal.find("#case")[0].value.length > 0) ? modal.find("#case")[0].value : "-");
661
        morphem += ((modal.find("#countability")[0].value.length > 0) ? modal.find("#countability")[0].value : "-");
662
        morphem += ((modal.find("#gender")[0].value.length > 0) ? modal.find("#gender")[0].value : "-");
663
        morphem += ((modal.find("#grade")[0].value.length > 0) ? modal.find("#grade")[0].value : "-");
664
        morphem += ((modal.find("#shape")[0].value.length > 0) ? modal.find("#shape")[0].value : "-");
665
        morphem += "-";
666

    
667
        if(wordClass === "J"){
668
            morphem += ((modal.find("#k-type")[0].value.length > 0) ? modal.find("#k-type")[0].value : "-");
669
        } else if(wordClass === "P") {
670
            morphem += ((modal.find("#type")[0].value.length > 0) ? modal.find("#type")[0].value : "-");
671
        } else if(wordClass === "V"){
672
            const value1 = modal.find("#mood")[0].value;
673
            const value2 = modal.find("#irregular")[0].value;
674
            if(value1.length > 0){
675
                morphem += value1;
676
            } else if(value2.length > 0){
677
                morphem += value2;
678
            } else {
679
                morphem += "-";
680
            }
681
        } else {
682
            morphem += "-";
683
        }
684

    
685
        morphem += ((modal.find("#person")[0].value.length > 0) ? modal.find("#person")[0].value : "-");
686
        morphem += ((modal.find("#time")[0].value.length > 0) ? modal.find("#time")[0].value : "-");
687
        morphem += ((modal.find("#v-type")[0].value.length > 0) ? modal.find("#v-type")[0].value : "-");
688
        morphem += ((modal.find("#vid")[0].value.length > 0) ? modal.find("#vid")[0].value : "-");
689
        formData.append("tag", morphem);
690
        formData.append("pos", wordclassToNum[wordClass]);
691

    
692
        return formData;
693
    }
694

    
695
    function moodMChange(modal) {
696
        if(modal.find("#mood")[0].value !== ""){
697
            modal.find("#irregular").prop('disabled', true);
698
            modal.find("#irregular").prop('title', "Neurčitý slovesný tvar smí být nastaven pouze není-li nastaven způsob");
699
        } else {
700
            modal.find("#irregular").prop('disabled', false);
701
            modal.find("#irregular").prop('title', "");
702
        }
703
    }
704

    
705
    function irregularMChange(modal) {
706
        if(modal.find("#irregular")[0].value !== ""){
707
            modal.find("#mood").prop('disabled', true);
708
            modal.find("#mood").prop('title', "Způsob smí být nastaven pouze není-li nastaven neurčitý slovesný tvar");
709
        } else {
710
            modal.find("#mood").prop('disabled', false);
711
            modal.find("#mood").prop('title', "");
712
        }
713
    }
714

    
715
    function createData(modal){
716
        const formData = prepareFormData(modal);
717

    
718
        formData.append("finished", false);
719

    
720
        /* TODO create with merge
721
        var xhr = new XMLHttpRequest();
722
        xhr.open("POST", "../controller/InsertController.php");
723
        xhr.send(formData);
724
        */
725
    }
726
</script>
(2-2/3)