|
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">×</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"-->Rukopisy:</label>
|
|
29 |
</div>
|
|
30 |
<div class="col-xs-12 col-sm-8">
|
|
31 |
<!--<select id="manuscript" 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>TODO-->
|
|
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 |
let manuSelect = new vanillaSelectBox("#manuscript");
|
|
295 |
|
|
296 |
let modal = $(this);
|
|
297 |
modal.find('.modal-title').text(title);
|
|
298 |
modal.find('#mood').change(() => moodMChange(modal));
|
|
299 |
modal.find('#irregular').change(() => irregularMChange(modal));
|
|
300 |
|
|
301 |
if(title === "Nový záznam"){
|
|
302 |
prefill(modal);
|
|
303 |
changeWordType();
|
|
304 |
modal.find('#submit-but').text("Založit");
|
|
305 |
modal.find('#submit-but').click(() => createData(modal));
|
|
306 |
} else {
|
|
307 |
const data_obj = data[pseudo_id];
|
|
308 |
modal.find('#submit-but').text("Upravit");
|
|
309 |
modal.find('#submit-but').click(() => editData(data_obj, modal));
|
|
310 |
changeWordType();
|
|
311 |
prefill(modal, data_obj);
|
|
312 |
moodMChange(modal);
|
|
313 |
irregularMChange(modal);
|
|
314 |
}
|
|
315 |
});
|
|
316 |
|
|
317 |
function changeWordType() {
|
|
318 |
let modal = $('#edit-modal');
|
|
319 |
const value = modal.find("#wordclass")[0].value;
|
|
320 |
let movedNode;
|
|
321 |
let beforeNode;
|
|
322 |
switch (value) {
|
|
323 |
case "N":
|
|
324 |
setElementVisibility([
|
|
325 |
true,
|
|
326 |
true,
|
|
327 |
true,
|
|
328 |
false,
|
|
329 |
false,
|
|
330 |
false,
|
|
331 |
false,
|
|
332 |
false,
|
|
333 |
false,
|
|
334 |
false,
|
|
335 |
false,
|
|
336 |
false,
|
|
337 |
false
|
|
338 |
], modal);
|
|
339 |
movedNode = modal.find("#case-wrapper");
|
|
340 |
beforeNode = modal.find("#countability-wrapper");
|
|
341 |
beforeNode.before(movedNode);
|
|
342 |
break;
|
|
343 |
case "A":
|
|
344 |
setElementVisibility([
|
|
345 |
true,
|
|
346 |
true,
|
|
347 |
true,
|
|
348 |
true,
|
|
349 |
true,
|
|
350 |
false,
|
|
351 |
false,
|
|
352 |
false,
|
|
353 |
false,
|
|
354 |
false,
|
|
355 |
false,
|
|
356 |
false,
|
|
357 |
false
|
|
358 |
], modal);
|
|
359 |
movedNode = modal.find("#case-wrapper");
|
|
360 |
beforeNode = modal.find("#countability-wrapper");
|
|
361 |
beforeNode.before(movedNode);
|
|
362 |
break;
|
|
363 |
case "P":
|
|
364 |
setElementVisibility([
|
|
365 |
true,
|
|
366 |
true,
|
|
367 |
true,
|
|
368 |
false,
|
|
369 |
false,
|
|
370 |
true,
|
|
371 |
false,
|
|
372 |
false,
|
|
373 |
false,
|
|
374 |
false,
|
|
375 |
false,
|
|
376 |
false,
|
|
377 |
false
|
|
378 |
], modal);
|
|
379 |
movedNode = modal.find("#case-wrapper");
|
|
380 |
beforeNode = modal.find("#countability-wrapper");
|
|
381 |
beforeNode.before(movedNode);
|
|
382 |
break;
|
|
383 |
case "C":
|
|
384 |
setElementVisibility([
|
|
385 |
true,
|
|
386 |
true,
|
|
387 |
true,
|
|
388 |
false,
|
|
389 |
false,
|
|
390 |
false,
|
|
391 |
false,
|
|
392 |
false,
|
|
393 |
false,
|
|
394 |
false,
|
|
395 |
false,
|
|
396 |
false,
|
|
397 |
false
|
|
398 |
], modal);
|
|
399 |
movedNode = modal.find("#case-wrapper");
|
|
400 |
beforeNode = modal.find("#countability-wrapper");
|
|
401 |
beforeNode.before(movedNode);
|
|
402 |
break;
|
|
403 |
case "V":
|
|
404 |
setElementVisibility([
|
|
405 |
true,
|
|
406 |
true,
|
|
407 |
true,
|
|
408 |
false,
|
|
409 |
false,
|
|
410 |
false,
|
|
411 |
true,
|
|
412 |
true,
|
|
413 |
true,
|
|
414 |
true,
|
|
415 |
true,
|
|
416 |
true,
|
|
417 |
false
|
|
418 |
], modal);
|
|
419 |
movedNode = modal.find("#case-wrapper");
|
|
420 |
beforeNode = modal.find("#vid-wrapper");
|
|
421 |
beforeNode.after(movedNode);
|
|
422 |
break;
|
|
423 |
case "D":
|
|
424 |
setElementVisibility([
|
|
425 |
false,
|
|
426 |
false,
|
|
427 |
false,
|
|
428 |
false,
|
|
429 |
true,
|
|
430 |
false,
|
|
431 |
false,
|
|
432 |
false,
|
|
433 |
false,
|
|
434 |
false,
|
|
435 |
false,
|
|
436 |
false,
|
|
437 |
false
|
|
438 |
], modal);
|
|
439 |
break;
|
|
440 |
case "R":
|
|
441 |
setElementVisibility([
|
|
442 |
true,
|
|
443 |
false,
|
|
444 |
false,
|
|
445 |
false,
|
|
446 |
false,
|
|
447 |
false,
|
|
448 |
false,
|
|
449 |
false,
|
|
450 |
false,
|
|
451 |
false,
|
|
452 |
false,
|
|
453 |
false,
|
|
454 |
false
|
|
455 |
], modal);
|
|
456 |
break;
|
|
457 |
case "J":
|
|
458 |
setElementVisibility([
|
|
459 |
false,
|
|
460 |
false,
|
|
461 |
false,
|
|
462 |
false,
|
|
463 |
false,
|
|
464 |
false,
|
|
465 |
false,
|
|
466 |
false,
|
|
467 |
false,
|
|
468 |
false,
|
|
469 |
false,
|
|
470 |
false,
|
|
471 |
true
|
|
472 |
], modal);
|
|
473 |
break;
|
|
474 |
case "I":
|
|
475 |
setElementVisibility([
|
|
476 |
false,
|
|
477 |
false,
|
|
478 |
false,
|
|
479 |
false,
|
|
480 |
false,
|
|
481 |
false,
|
|
482 |
false,
|
|
483 |
false,
|
|
484 |
false,
|
|
485 |
false,
|
|
486 |
false,
|
|
487 |
false,
|
|
488 |
false
|
|
489 |
], modal);
|
|
490 |
break;
|
|
491 |
case "T":
|
|
492 |
setElementVisibility([
|
|
493 |
false,
|
|
494 |
false,
|
|
495 |
false,
|
|
496 |
false,
|
|
497 |
false,
|
|
498 |
false,
|
|
499 |
false,
|
|
500 |
false,
|
|
501 |
false,
|
|
502 |
false,
|
|
503 |
false,
|
|
504 |
false,
|
|
505 |
false
|
|
506 |
], modal);
|
|
507 |
break;
|
|
508 |
default:
|
|
509 |
setElementVisibility([
|
|
510 |
false,
|
|
511 |
false,
|
|
512 |
false,
|
|
513 |
false,
|
|
514 |
false,
|
|
515 |
false,
|
|
516 |
false,
|
|
517 |
false,
|
|
518 |
false,
|
|
519 |
false,
|
|
520 |
false,
|
|
521 |
false,
|
|
522 |
false
|
|
523 |
], modal);
|
|
524 |
break;
|
|
525 |
}
|
|
526 |
}
|
|
527 |
|
|
528 |
const dynamicFields = [
|
|
529 |
"#case-wrapper",
|
|
530 |
"#countability-wrapper",
|
|
531 |
"#gender-wrapper",
|
|
532 |
"#shape-wrapper",
|
|
533 |
"#grade-wrapper",
|
|
534 |
"#type-wrapper",
|
|
535 |
"#mood-wrapper",
|
|
536 |
"#irregular-wrapper",
|
|
537 |
"#person-wrapper",
|
|
538 |
"#time-wrapper",
|
|
539 |
"#vid-wrapper",
|
|
540 |
"#v-type-wrapper",
|
|
541 |
"#k-type-wrapper"
|
|
542 |
];
|
|
543 |
|
|
544 |
const staticFields = [
|
|
545 |
"#word",
|
|
546 |
"#lemma",
|
|
547 |
"#manuscript",
|
|
548 |
"#position",
|
|
549 |
"#namedentity",
|
|
550 |
"#context",
|
|
551 |
"#wordclass"
|
|
552 |
];
|
|
553 |
|
|
554 |
function setElementVisibility(visibility, modal) {
|
|
555 |
for(let i = 0; i < dynamicFields.length && i < visibility.length; i++){
|
|
556 |
if(visibility[i] === true){
|
|
557 |
modal.find(dynamicFields[i]).show();
|
|
558 |
} else {
|
|
559 |
modal.find(dynamicFields[i]).hide();
|
|
560 |
}
|
|
561 |
modal.find(dynamicFields[i].replace("-wrapper", "")).val("");
|
|
562 |
}
|
|
563 |
}
|
|
564 |
|
|
565 |
function prefill(modal, data = null){
|
|
566 |
staticFields.forEach((item) => {
|
|
567 |
modal.find(item).val("");
|
|
568 |
});
|
|
569 |
|
|
570 |
modal.find("#namedentity").prop('checked', false);
|
|
571 |
|
|
572 |
dynamicFields.forEach((item) => {
|
|
573 |
modal.find(item.replace("-wrapper", "")).val("");
|
|
574 |
});
|
|
575 |
|
|
576 |
if(data !== null){
|
|
577 |
modal.find("#context").val(data.context);
|
|
578 |
modal.find("#namedentity").prop('checked', data.namedentity === 1);
|
|
579 |
|
|
580 |
let position = data.position1;
|
|
581 |
position += ((data.position2 !== null && data.position2.length > 0) ? ("/" + data.position2) : "");
|
|
582 |
position += ((data.positiondetail !== null && data.positiondetail.length > 0) ? ("/" + data.positiondetail) : "");
|
|
583 |
modal.find("#position").val(position);
|
|
584 |
|
|
585 |
modal.find("#word").val(data.word);
|
|
586 |
modal.find("#lemma").val(data.lemma.lemma);
|
|
587 |
modal.find("#manuscript").val(data.manuscript);
|
|
588 |
|
|
589 |
//dynamic setting
|
|
590 |
const morphem = data.tag.tag;
|
|
591 |
const wordclass = morphem.charAt(0);
|
|
592 |
modal.find("#wordclass").val(wordclass);
|
|
593 |
modal.find("#case").val((morphem.charAt(1) !== '-') ? morphem.charAt(1) : "");
|
|
594 |
modal.find("#countability").val((morphem.charAt(2) !== '-') ? morphem.charAt(2) : "");
|
|
595 |
modal.find("#gender").val((morphem.charAt(3) !== '-') ? morphem.charAt(3) : "");
|
|
596 |
modal.find("#grade").val((morphem.charAt(4) !== '-') ? morphem.charAt(4) : "");
|
|
597 |
modal.find("#shape").val((morphem.charAt(5) !== '-') ? morphem.charAt(5) : "");
|
|
598 |
|
|
599 |
if(morphem.charAt(7) !== '-'){
|
|
600 |
if(wordclass === 'J'){
|
|
601 |
modal.find("#k-type").val(morphem.charAt(7));
|
|
602 |
} else if(wordclass === 'P'){
|
|
603 |
modal.find("#type").val(morphem.charAt(7));
|
|
604 |
} else if(wordclass === 'V'){
|
|
605 |
if(codeToMood[morphem.charAt(7)] !== undefined) {
|
|
606 |
modal.find("#mood").val(morphem.charAt(7));
|
|
607 |
} else {
|
|
608 |
modal.find("#irregular").val(morphem.charAt(7));
|
|
609 |
}
|
|
610 |
}
|
|
611 |
}
|
|
612 |
|
|
613 |
modal.find("#person").val((morphem.charAt(8) !== '-') ? morphem.charAt(8) : "");
|
|
614 |
modal.find("#time").val((morphem.charAt(9) !== '-') ? morphem.charAt(9) : "");
|
|
615 |
modal.find("#v-type").val((morphem.charAt(10) !== '-') ? morphem.charAt(10) : "");
|
|
616 |
modal.find("#vid").val((morphem.charAt(11) !== '-') ? morphem.charAt(11) : "");
|
|
617 |
}
|
|
618 |
}
|
|
619 |
|
|
620 |
function editData(data, modal){
|
|
621 |
const formData = prepareFormData(modal);
|
|
622 |
formData.append("id", data.id);
|
|
623 |
|
|
624 |
//TODO the next three WILL be added in prepareFormData in future
|
|
625 |
formData.append("description", data.description);
|
|
626 |
formData.append("description2", data.description2);
|
|
627 |
formData.append("description3", data.description3);
|
|
628 |
|
|
629 |
formData.append("ending", data.ending);
|
|
630 |
formData.append("finished", data.finished);
|
|
631 |
formData.append("prefix", data.prefix);
|
|
632 |
formData.append("suffix", data.suffix);
|
|
633 |
|
|
634 |
var xhr = new XMLHttpRequest();
|
|
635 |
xhr.open("POST", "./controller/UpdateController.php");
|
|
636 |
xhr.send(formData);
|
|
637 |
}
|
|
638 |
|
|
639 |
function prepareFormData(modal) {
|
|
640 |
const formData = new FormData();
|
|
641 |
|
|
642 |
formData.append("namedentity", (modal.find("#namedentity")[0].checked) ? "1" : "0");
|
|
643 |
|
|
644 |
const position = modal.find("#position")[0].value.split("/");
|
|
645 |
formData.append("position1", position[0]);
|
|
646 |
formData.append("position2", (position[1] !== undefined) ? position[1] : "");
|
|
647 |
formData.append("positiondetail", (position[2] !== undefined) ? position[2] : "");
|
|
648 |
|
|
649 |
formData.append("word", modal.find("#word")[0].value);
|
|
650 |
formData.append("lemma", modal.find("#lemma")[0].value);
|
|
651 |
//TODO formData.append("manuscript", modal.find("#manuscript")[0].value);
|
|
652 |
formData.append("context", modal.find("#context")[0].value);
|
|
653 |
|
|
654 |
//morphem creation
|
|
655 |
let morphem = "";
|
|
656 |
const wordClass = modal.find("#wordclass")[0].value;
|
|
657 |
morphem += ((wordClass.length > 0) ? wordClass.value : "-");
|
|
658 |
morphem += ((modal.find("#case")[0].value.length > 0) ? modal.find("#case")[0].value : "-");
|
|
659 |
morphem += ((modal.find("#countability")[0].value.length > 0) ? modal.find("#countability")[0].value : "-");
|
|
660 |
morphem += ((modal.find("#gender")[0].value.length > 0) ? modal.find("#gender")[0].value : "-");
|
|
661 |
morphem += ((modal.find("#grade")[0].value.length > 0) ? modal.find("#grade")[0].value : "-");
|
|
662 |
morphem += ((modal.find("#shape")[0].value.length > 0) ? modal.find("#shape")[0].value : "-");
|
|
663 |
morphem += "-";
|
|
664 |
|
|
665 |
if(wordClass === "J"){
|
|
666 |
morphem += ((modal.find("#k-type")[0].value.length > 0) ? modal.find("#k-type")[0].value : "-");
|
|
667 |
} else if(wordClass === "P") {
|
|
668 |
morphem += ((modal.find("#type")[0].value.length > 0) ? modal.find("#type")[0].value : "-");
|
|
669 |
} else if(wordClass === "V"){
|
|
670 |
const value1 = modal.find("#mood")[0].value;
|
|
671 |
const value2 = modal.find("#irregular")[0].value;
|
|
672 |
if(value1.length > 0){
|
|
673 |
morphem += value1;
|
|
674 |
} else if(value2.length > 0){
|
|
675 |
morphem += value2;
|
|
676 |
} else {
|
|
677 |
morphem += "-";
|
|
678 |
}
|
|
679 |
} else {
|
|
680 |
morphem += "-";
|
|
681 |
}
|
|
682 |
|
|
683 |
morphem += ((modal.find("#person")[0].value.length > 0) ? modal.find("#person")[0].value : "-");
|
|
684 |
morphem += ((modal.find("#time")[0].value.length > 0) ? modal.find("#time")[0].value : "-");
|
|
685 |
morphem += ((modal.find("#v-type")[0].value.length > 0) ? modal.find("#v-type")[0].value : "-");
|
|
686 |
morphem += ((modal.find("#vid")[0].value.length > 0) ? modal.find("#vid")[0].value : "-");
|
|
687 |
formData.append("tag", morphem);
|
|
688 |
formData.append("pos", wordclassToNum[wordClass]);
|
|
689 |
|
|
690 |
return formData;
|
|
691 |
}
|
|
692 |
|
|
693 |
function moodMChange(modal) {
|
|
694 |
if(modal.find("#mood")[0].value !== ""){
|
|
695 |
modal.find("#irregular").prop('disabled', true);
|
|
696 |
modal.find("#irregular").prop('title', "Neurčitý slovesný tvar smí být nastaven pouze není-li nastaven způsob");
|
|
697 |
} else {
|
|
698 |
modal.find("#irregular").prop('disabled', false);
|
|
699 |
modal.find("#irregular").prop('title', "");
|
|
700 |
}
|
|
701 |
}
|
|
702 |
|
|
703 |
function irregularMChange(modal) {
|
|
704 |
if(modal.find("#irregular")[0].value !== ""){
|
|
705 |
modal.find("#mood").prop('disabled', true);
|
|
706 |
modal.find("#mood").prop('title', "Způsob smí být nastaven pouze není-li nastaven neurčitý slovesný tvar");
|
|
707 |
} else {
|
|
708 |
modal.find("#mood").prop('disabled', false);
|
|
709 |
modal.find("#mood").prop('title', "");
|
|
710 |
}
|
|
711 |
}
|
|
712 |
|
|
713 |
function createData(modal){
|
|
714 |
const formData = prepareFormData(modal);
|
|
715 |
|
|
716 |
formData.append("finished", false);
|
|
717 |
|
|
718 |
/* TODO connect to the proper controller
|
|
719 |
var xhr = new XMLHttpRequest();
|
|
720 |
xhr.open("POST", "../controller/UpdateController.php");
|
|
721 |
xhr.send(formData);
|
|
722 |
*/
|
|
723 |
}
|
|
724 |
</script>
|
Feature #8350: Vytvoření modalů detailu a editu - editform