1 |
e278dcbf
|
Ondřej Anděl
|
<script>
|
2 |
31a2bb94
|
Anděl Ondřej
|
let pageIndex = 0;
|
3 |
|
|
let itemPerPage = 50;
|
4 |
|
|
let itemCount = 0;
|
5 |
|
|
let pageCount = 0;
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
//what to do when page renders
|
9 |
e278dcbf
|
Ondřej Anděl
|
window.onload = function() {
|
10 |
a908ef13
|
Anděl Ondřej
|
let sourceSelect = new vanillaSelectBox("#source");
|
11 |
e278dcbf
|
Ondřej Anděl
|
filtersChange();
|
12 |
fb32f0e8
|
Anděl Ondřej
|
fetchData(false);
|
13 |
31a2bb94
|
Anděl Ondřej
|
|
14 |
|
|
//page-label listener
|
15 |
|
|
document.getElementById('page-label').addEventListener('keyup',function(e){
|
16 |
|
|
if (e.key === 'Enter' || e.keyCode === 13) {
|
17 |
|
|
this.blur();
|
18 |
|
|
}
|
19 |
|
|
});
|
20 |
e278dcbf
|
Ondřej Anděl
|
};
|
21 |
|
|
</script>
|
22 |
|
|
|
23 |
|
|
<div class="search-filters container" onload="filtersChange()">
|
24 |
9a7b1f4c
|
Ondřej Anděl
|
<div class="row">
|
25 |
|
|
<div class="mr-3">
|
26 |
a908ef13
|
Anděl Ondřej
|
<label for="wordshape" class="mr-2">Slovo</label>
|
27 |
9a7b1f4c
|
Ondřej Anděl
|
<input type="text" id="wordshape">
|
28 |
|
|
</div>
|
29 |
fb32f0e8
|
Anděl Ondřej
|
<div class="mr-3">
|
30 |
|
|
<label for="lemma" class="mr-2">Lemma</label>
|
31 |
|
|
<input type="text" id="lemma">
|
32 |
|
|
</div>
|
33 |
9a7b1f4c
|
Ondřej Anděl
|
<div class="mr-3">
|
34 |
|
|
<label for="source" class="mr-2">Rukopisný pramen</label>
|
35 |
a908ef13
|
Anděl Ondřej
|
<select id="source" multiple>
|
36 |
fb32f0e8
|
Anděl Ondřej
|
<option value = "0">rukopis Vídeňský</option>
|
37 |
|
|
<option value = "1">zlomky Hanušovy</option>
|
38 |
|
|
<option value = "2">zlomky Hradecké</option>
|
39 |
|
|
<option value = "3">rukopis Cambridžský</option>
|
40 |
|
|
<option value = "4">rukopis Františkánský</option>
|
41 |
|
|
<option value = "5">zlomek Olomoucký</option>
|
42 |
|
|
<option value = "6">fragment Strahovský</option>
|
43 |
|
|
<option value = "7">zlomky Klementinsko-Křižovnické</option>
|
44 |
|
|
<option value = "8">zlomky Mnichovské</option>
|
45 |
|
|
<option value = "9">rukopis Lobkovický</option>
|
46 |
|
|
<option value = "10">rukopis Pelclův</option>
|
47 |
|
|
<option value = "11">rukopis Cerronský</option>
|
48 |
|
|
<option value = "12">rukopis Fürstenberský</option>
|
49 |
|
|
<option value = "13">rukopis Zebererův</option>
|
50 |
|
|
<option value = "14">vydání Pavla Ješína z Bezdězi, Praha 1620</option>
|
51 |
|
|
<option value = "15">básně připsané při Pulkavově kronice v rukopisu Litoměřickém</option>
|
52 |
a908ef13
|
Anděl Ondřej
|
</select>
|
53 |
9a7b1f4c
|
Ondřej Anděl
|
</div>
|
54 |
|
|
<div class="mr-3">
|
55 |
a908ef13
|
Anděl Ondřej
|
<label for="location" class="mr-2">Pozice</label>
|
56 |
9a7b1f4c
|
Ondřej Anděl
|
<input type="text" id="location">
|
57 |
|
|
</div>
|
58 |
e278dcbf
|
Ondřej Anděl
|
|
59 |
|
|
|
60 |
|
|
<div class="mr-3">
|
61 |
|
|
<label for="wordclass" class="mr-2">Slovní druh</label>
|
62 |
|
|
<select onchange="filtersChange()" id="wordclass">
|
63 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
64 |
fb32f0e8
|
Anděl Ondřej
|
<option value = "N">Substantiva</option>
|
65 |
|
|
<option value = "A">Adjektiva</option>
|
66 |
|
|
<option value = "P">Pronomina</option>
|
67 |
|
|
<option value = "C">Numeralia</option>
|
68 |
|
|
<option value = "V">Verba</option>
|
69 |
|
|
<option value = "D">Adverbia</option>
|
70 |
|
|
<option value = "R">Prepozice</option>
|
71 |
|
|
<option value = "J">Konjunkce</option>
|
72 |
|
|
<option value = "I">Interjekce</option>
|
73 |
|
|
<option value = "T">Partikule</option>
|
74 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
75 |
|
|
</div>
|
76 |
|
|
|
77 |
|
|
<script>
|
78 |
|
|
function filtersChange() {
|
79 |
|
|
const value = document.getElementById("wordclass").value;
|
80 |
|
|
switch (value) {
|
81 |
fb32f0e8
|
Anděl Ondřej
|
case "N":
|
82 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
83 |
|
|
true,
|
84 |
|
|
true,
|
85 |
|
|
true,
|
86 |
|
|
false,
|
87 |
|
|
false,
|
88 |
|
|
false,
|
89 |
|
|
false,
|
90 |
|
|
false,
|
91 |
|
|
false,
|
92 |
|
|
false,
|
93 |
|
|
false,
|
94 |
|
|
false
|
95 |
|
|
]);
|
96 |
|
|
break;
|
97 |
fb32f0e8
|
Anděl Ondřej
|
case "A":
|
98 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
99 |
|
|
true,
|
100 |
|
|
true,
|
101 |
|
|
true,
|
102 |
|
|
true,
|
103 |
|
|
true,
|
104 |
|
|
false,
|
105 |
|
|
false,
|
106 |
|
|
false,
|
107 |
|
|
false,
|
108 |
|
|
false,
|
109 |
|
|
false,
|
110 |
|
|
false
|
111 |
|
|
]);
|
112 |
|
|
break;
|
113 |
fb32f0e8
|
Anděl Ondřej
|
case "P":
|
114 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
115 |
|
|
true,
|
116 |
|
|
true,
|
117 |
|
|
true,
|
118 |
|
|
false,
|
119 |
|
|
false,
|
120 |
|
|
true,
|
121 |
|
|
false,
|
122 |
|
|
false,
|
123 |
|
|
false,
|
124 |
|
|
false,
|
125 |
|
|
false,
|
126 |
|
|
false
|
127 |
|
|
]);
|
128 |
|
|
break;
|
129 |
fb32f0e8
|
Anděl Ondřej
|
case "C":
|
130 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
131 |
|
|
true,
|
132 |
|
|
true,
|
133 |
|
|
true,
|
134 |
|
|
false,
|
135 |
|
|
false,
|
136 |
|
|
false,
|
137 |
|
|
false,
|
138 |
|
|
false,
|
139 |
|
|
false,
|
140 |
|
|
false,
|
141 |
|
|
false,
|
142 |
|
|
false
|
143 |
|
|
]);
|
144 |
|
|
break;
|
145 |
fb32f0e8
|
Anděl Ondřej
|
case "V":
|
146 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
147 |
|
|
true,
|
148 |
|
|
true,
|
149 |
|
|
true,
|
150 |
|
|
false,
|
151 |
|
|
false,
|
152 |
|
|
false,
|
153 |
|
|
true,
|
154 |
|
|
true,
|
155 |
|
|
true,
|
156 |
|
|
true,
|
157 |
|
|
true,
|
158 |
|
|
false
|
159 |
|
|
]);
|
160 |
|
|
break;
|
161 |
fb32f0e8
|
Anděl Ondřej
|
case "D":
|
162 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
163 |
|
|
false,
|
164 |
|
|
false,
|
165 |
|
|
false,
|
166 |
|
|
false,
|
167 |
|
|
true,
|
168 |
|
|
false,
|
169 |
|
|
false,
|
170 |
|
|
false,
|
171 |
|
|
false,
|
172 |
|
|
false,
|
173 |
|
|
false,
|
174 |
|
|
false
|
175 |
|
|
]);
|
176 |
|
|
break;
|
177 |
fb32f0e8
|
Anděl Ondřej
|
case "R":
|
178 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
179 |
|
|
true,
|
180 |
|
|
false,
|
181 |
|
|
false,
|
182 |
|
|
false,
|
183 |
|
|
false,
|
184 |
|
|
false,
|
185 |
|
|
false,
|
186 |
|
|
false,
|
187 |
|
|
false,
|
188 |
|
|
false,
|
189 |
|
|
false,
|
190 |
|
|
false
|
191 |
|
|
]);
|
192 |
|
|
break;
|
193 |
fb32f0e8
|
Anděl Ondřej
|
case "J":
|
194 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
195 |
|
|
false,
|
196 |
|
|
false,
|
197 |
|
|
false,
|
198 |
|
|
false,
|
199 |
|
|
false,
|
200 |
|
|
false,
|
201 |
|
|
false,
|
202 |
|
|
false,
|
203 |
|
|
false,
|
204 |
|
|
false,
|
205 |
|
|
false,
|
206 |
|
|
true
|
207 |
|
|
]);
|
208 |
|
|
break;
|
209 |
fb32f0e8
|
Anděl Ondřej
|
case "I":
|
210 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
211 |
|
|
false,
|
212 |
|
|
false,
|
213 |
|
|
false,
|
214 |
|
|
false,
|
215 |
|
|
false,
|
216 |
|
|
false,
|
217 |
|
|
false,
|
218 |
|
|
false,
|
219 |
|
|
false,
|
220 |
|
|
false,
|
221 |
|
|
false,
|
222 |
|
|
false
|
223 |
|
|
]);
|
224 |
|
|
break;
|
225 |
fb32f0e8
|
Anděl Ondřej
|
case "T":
|
226 |
e278dcbf
|
Ondřej Anděl
|
setFilerVisibility([
|
227 |
|
|
false,
|
228 |
|
|
false,
|
229 |
|
|
false,
|
230 |
|
|
false,
|
231 |
|
|
false,
|
232 |
|
|
false,
|
233 |
|
|
false,
|
234 |
|
|
false,
|
235 |
|
|
false,
|
236 |
|
|
false,
|
237 |
|
|
false,
|
238 |
|
|
false
|
239 |
|
|
]);
|
240 |
|
|
break;
|
241 |
|
|
default:
|
242 |
|
|
setFilerVisibility([
|
243 |
|
|
false,
|
244 |
|
|
false,
|
245 |
|
|
false,
|
246 |
|
|
false,
|
247 |
|
|
false,
|
248 |
|
|
false,
|
249 |
|
|
false,
|
250 |
|
|
false,
|
251 |
|
|
false,
|
252 |
|
|
false,
|
253 |
|
|
false,
|
254 |
|
|
false
|
255 |
|
|
]);
|
256 |
|
|
break;
|
257 |
|
|
}
|
258 |
|
|
}
|
259 |
|
|
|
260 |
|
|
function setFilerVisibility(visibility) {
|
261 |
|
|
const id = [
|
262 |
|
|
"filter-case",
|
263 |
|
|
"filter-countability",
|
264 |
|
|
"filter-gender",
|
265 |
|
|
"filter-shape",
|
266 |
|
|
"filter-grade",
|
267 |
|
|
"filter-type",
|
268 |
|
|
"filter-mood",
|
269 |
|
|
"filter-person",
|
270 |
|
|
"filter-time",
|
271 |
|
|
"filter-vid",
|
272 |
|
|
"filter-v-type",
|
273 |
|
|
"filter-k-type"
|
274 |
|
|
];
|
275 |
|
|
|
276 |
|
|
for(let i = 0; i < id.length && i < visibility.length; i++){
|
277 |
|
|
document.getElementById(id[i]).style.display = visibility[i] === true ? "" : "none";
|
278 |
|
|
document.getElementById(id[i].replace("filter-", "")).value = "";
|
279 |
|
|
}
|
280 |
|
|
}
|
281 |
|
|
</script>
|
282 |
|
|
|
283 |
|
|
<!-- conditionaly rendered filters-->
|
284 |
|
|
<div class="mr-3" id="filter-case">
|
285 |
|
|
<label for="case" class="mr-2">Pád</label>
|
286 |
|
|
<select id="case">
|
287 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
288 |
|
|
<option value = "1">Nominativ</option>
|
289 |
|
|
<option value = "2">Genitiv</option>
|
290 |
|
|
<option value = "3">Dativ</option>
|
291 |
|
|
<option value = "4">Akuzativ</option>
|
292 |
|
|
<option value = "5">Vokativ</option>
|
293 |
|
|
<option value = "6">Lokál</option>
|
294 |
|
|
<option value = "7">Instrumentál</option>
|
295 |
|
|
</select>
|
296 |
|
|
</div>
|
297 |
|
|
<div class="mr-3" id="filter-countability">
|
298 |
|
|
<label for="countability" class="mr-2">Číslo</label>
|
299 |
|
|
<select id="countability">
|
300 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
301 |
a908ef13
|
Anděl Ondřej
|
<option value = "S">Singulár</option>
|
302 |
|
|
<option value = "P">Plurál</option>
|
303 |
|
|
<option value = "D">Duál</option>
|
304 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
305 |
|
|
</div>
|
306 |
|
|
<div class="mr-3" id="filter-gender">
|
307 |
|
|
<label for="gender" class="mr-2">Rod</label>
|
308 |
|
|
<select id="gender">
|
309 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
310 |
a908ef13
|
Anděl Ondřej
|
<option value = "M">Maskulinum</option>
|
311 |
|
|
<option value = "F">Femininum</option>
|
312 |
|
|
<option value = "N">Neutrum</option>
|
313 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
314 |
|
|
</div>
|
315 |
|
|
<div class="mr-3" id="filter-shape">
|
316 |
|
|
<label for="shape" class="mr-2">Tvar</label>
|
317 |
|
|
<select id="shape">
|
318 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
319 |
a908ef13
|
Anděl Ondřej
|
<option value = "C">Složený</option>
|
320 |
|
|
<option value = "N">Jmenný</option>
|
321 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
322 |
|
|
</div>
|
323 |
|
|
<div class="mr-3" id="filter-grade">
|
324 |
|
|
<label for="grade" class="mr-2">Stupeň</label>
|
325 |
|
|
<select id="grade">
|
326 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
327 |
|
|
<option value = "1">Pozitiv</option>
|
328 |
|
|
<option value = "2">Komparativ</option>
|
329 |
|
|
<option value = "3">Superlativ</option>
|
330 |
|
|
</select>
|
331 |
|
|
</div>
|
332 |
|
|
<div class="mr-3" id="filter-type">
|
333 |
|
|
<label for="type" class="mr-2">Druh</label>
|
334 |
|
|
<select id="type">
|
335 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
336 |
a908ef13
|
Anděl Ondřej
|
<option value = "P">Personalia</option>
|
337 |
|
|
<option value = "S">Posesiva</option>
|
338 |
|
|
<option value = "D">Demonstrativa</option>
|
339 |
|
|
<option value = "Q">Interogativa</option>
|
340 |
|
|
<option value = "J">Relativa</option>
|
341 |
|
|
<option value = "Z">Indefinita</option>
|
342 |
|
|
<option value = "L">Limitativa</option>
|
343 |
|
|
<option value = "W">Negativa</option>
|
344 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
345 |
|
|
</div>
|
346 |
|
|
<div class="mr-3" id="filter-mood">
|
347 |
a908ef13
|
Anděl Ondřej
|
<label for="mood" class="mr-2">Způsob</label>
|
348 |
e278dcbf
|
Ondřej Anděl
|
<select id="mood">
|
349 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
350 |
a908ef13
|
Anděl Ondřej
|
<option value = "f">Infinitiv</option>
|
351 |
|
|
<option value = "d">Indikativ</option>
|
352 |
|
|
<option value = "i">Imperativ</option>
|
353 |
|
|
<option value = "c">Kondicionál</option>
|
354 |
|
|
<option value = "S">Supinum</option>
|
355 |
|
|
<option value = "e">Přech. přítomný</option>
|
356 |
|
|
<option value = "m">Přech. minulý</option>
|
357 |
|
|
<option value = "A">Part. perf. akt.</option>
|
358 |
|
|
<option value = "P">Part. perf. pas.</option>
|
359 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
360 |
|
|
</div>
|
361 |
|
|
<div class="mr-3" id="filter-person">
|
362 |
|
|
<label for="person" class="mr-2">Osoba</label>
|
363 |
|
|
<select id="person">
|
364 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
365 |
|
|
<option value = "1">1.</option>
|
366 |
|
|
<option value = "2">2.</option>
|
367 |
|
|
<option value = "3">3.</option>
|
368 |
|
|
</select>
|
369 |
|
|
</div>
|
370 |
|
|
<div class="mr-3" id="filter-time">
|
371 |
|
|
<label for="time" class="mr-2">Čas</label>
|
372 |
|
|
<select id="time">
|
373 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
374 |
a908ef13
|
Anděl Ondřej
|
<option value = "P">Prézens</option>
|
375 |
|
|
<option value = "A">Aorist</option>
|
376 |
|
|
<option value = "R">Préteritum</option>
|
377 |
|
|
<option value = "I">Imperfektum</option>
|
378 |
|
|
<option value = "H">Plusquamperfektum</option>
|
379 |
|
|
<option value = "F">Futurum</option>
|
380 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
381 |
|
|
</div>
|
382 |
|
|
<div class="mr-3" id="filter-vid">
|
383 |
a908ef13
|
Anděl Ondřej
|
<label for="vid" class="mr-2">Vid</label>
|
384 |
e278dcbf
|
Ondřej Anděl
|
<select id="vid">
|
385 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
386 |
a908ef13
|
Anděl Ondřej
|
<option value = "P">Perfektivum</option>
|
387 |
|
|
<option value = "I">Imperfektivum </option>
|
388 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
389 |
|
|
</div>
|
390 |
|
|
<div class="mr-3" id="filter-v-type">
|
391 |
a908ef13
|
Anděl Ondřej
|
<label for="v-type" class="mr-2">Slovesný rod</label>
|
392 |
e278dcbf
|
Ondřej Anděl
|
<select id="v-type">
|
393 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
394 |
a908ef13
|
Anděl Ondřej
|
<option value = "A">Aktivum</option>
|
395 |
|
|
<option value = "P">Pasivum</option>
|
396 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
397 |
|
|
</div>
|
398 |
|
|
<div class="mr-3" id="filter-k-type">
|
399 |
|
|
<label for="k-type" class="mr-2">Typ</label>
|
400 |
|
|
<select id="k-type">
|
401 |
|
|
<option selected="selected" value = "">Nevybráno</option>
|
402 |
a908ef13
|
Anděl Ondřej
|
<option value = "V">Větná</option>
|
403 |
|
|
<option value = "C">Členská</option>
|
404 |
|
|
<option value = "N">Navazovací</option>
|
405 |
|
|
<option value = "P">Spojení s přechodníkem</option>
|
406 |
e278dcbf
|
Ondřej Anděl
|
</select>
|
407 |
|
|
</div>
|
408 |
a908ef13
|
Anděl Ondřej
|
|
409 |
|
|
<!-- send button-->
|
410 |
31a2bb94
|
Anděl Ondřej
|
<button class="ml-auto btn" onclick="callFilter()">
|
411 |
a908ef13
|
Anděl Ondřej
|
Filtrovat
|
412 |
|
|
</button>
|
413 |
9a7b1f4c
|
Ondřej Anděl
|
</div>
|
414 |
|
|
</div>
|
415 |
|
|
|
416 |
|
|
<div class="search-results my-4">
|
417 |
|
|
<table class="table table-striped">
|
418 |
|
|
<thead>
|
419 |
|
|
<tr>
|
420 |
a908ef13
|
Anděl Ondřej
|
<th scope="col">Slovo</th>
|
421 |
9a7b1f4c
|
Ondřej Anděl
|
<th scope="col">Lemma</th>
|
422 |
e278dcbf
|
Ondřej Anděl
|
<th scope="col">Rukopisy</th>
|
423 |
|
|
<th scope="col">Pozice</th>
|
424 |
9a7b1f4c
|
Ondřej Anděl
|
<th scope="col"></th>
|
425 |
|
|
</tr>
|
426 |
|
|
</thead>
|
427 |
|
|
<tbody id="search-table">
|
428 |
|
|
<script>
|
429 |
a908ef13
|
Anděl Ondřej
|
let data;
|
430 |
31a2bb94
|
Anděl Ondřej
|
function callFilter() {
|
431 |
|
|
pageIndex = 0;
|
432 |
|
|
fetchData(true)
|
433 |
|
|
}
|
434 |
|
|
|
435 |
fb32f0e8
|
Anděl Ondřej
|
function filterData (formData) {
|
436 |
|
|
//regular
|
437 |
|
|
formData.append("lemma", document.getElementById("lemma").value);
|
438 |
|
|
formData.append("word", document.getElementById("wordshape").value);
|
439 |
|
|
|
440 |
|
|
//positions
|
441 |
|
|
const positionSplit = document.getElementById("location").value.split("/");
|
442 |
|
|
formData.append("position1", positionSplit[0] !== undefined ? positionSplit[0] : "");
|
443 |
|
|
formData.append("position2", positionSplit[1] !== undefined ? positionSplit[1] : "");
|
444 |
|
|
formData.append("positiondetail", positionSplit[2] !== undefined ? positionSplit[2] : "");
|
445 |
a908ef13
|
Anděl Ondřej
|
|
446 |
fb32f0e8
|
Anděl Ondřej
|
//multiselect
|
447 |
|
|
formData.append("manuscript", getValues("source"));
|
448 |
|
|
|
449 |
|
|
const pos = document.getElementById("wordclass").value;
|
450 |
|
|
formData.append("tag_pos", pos);
|
451 |
|
|
//those upcoming are dynamic based on the previous field
|
452 |
|
|
formData.append("tag_case", document.getElementById("case").value);
|
453 |
|
|
formData.append("tag_number", document.getElementById("countability").value);
|
454 |
|
|
formData.append("tag_gender", document.getElementById("gender").value);
|
455 |
|
|
formData.append("tag_degree", document.getElementById("grade").value);
|
456 |
|
|
formData.append("tag_shape", document.getElementById("shape").value);
|
457 |
|
|
formData.append("tag_num", "");//THIS ONE IS WORTHLESS
|
458 |
|
|
|
459 |
|
|
if(pos === "P"){
|
460 |
|
|
formData.append("tag_sentence", document.getElementById("type").value);
|
461 |
|
|
} else if(pos === "V"){
|
462 |
|
|
formData.append("tag_sentence", document.getElementById("mood").value);
|
463 |
|
|
} else if(pos === "J"){
|
464 |
|
|
formData.append("tag_sentence", document.getElementById("k-type").value);
|
465 |
|
|
}
|
466 |
|
|
|
467 |
|
|
formData.append("tag_verb_person", document.getElementById("person").value);
|
468 |
|
|
formData.append("tag_verb_time", document.getElementById("time").value);
|
469 |
|
|
formData.append("tag_verb_degree", document.getElementById("vid").value);
|
470 |
|
|
formData.append("tag_verb_aspect", document.getElementById("v-type").value);
|
471 |
|
|
}
|
472 |
|
|
|
473 |
|
|
function fetchData (filter = true) {
|
474 |
a908ef13
|
Anděl Ondřej
|
// (A1) GET SEARCH TERM
|
475 |
|
|
const formData = new FormData();
|
476 |
31a2bb94
|
Anděl Ondřej
|
formData.append("page", ""+pageIndex);
|
477 |
|
|
formData.append("items_per_page", ""+itemPerPage);
|
478 |
a908ef13
|
Anděl Ondřej
|
formData.append("finished", "true");//TODO ADMIN
|
479 |
fb32f0e8
|
Anděl Ondřej
|
if(filter){
|
480 |
|
|
filterData(formData);
|
481 |
|
|
}
|
482 |
|
|
|
483 |
a908ef13
|
Anděl Ondřej
|
// (A2) AJAX - USE HTTP:// NOT FILE://
|
484 |
|
|
let xhr = new XMLHttpRequest();
|
485 |
|
|
xhr.open("POST", "./controller/TableController.php");
|
486 |
|
|
xhr.onload = function(){
|
487 |
|
|
let search = this.response;
|
488 |
|
|
let parsedJSON = JSON.parse(search);
|
489 |
fb32f0e8
|
Anděl Ondřej
|
if(parsedJSON.count === 0){
|
490 |
|
|
document.getElementById("no-data-label").style.display = "";
|
491 |
31a2bb94
|
Anděl Ondřej
|
document.getElementById("paging-control").style.display = "none";
|
492 |
fb32f0e8
|
Anděl Ondřej
|
} else {
|
493 |
|
|
document.getElementById("no-data-label").style.display = "none";
|
494 |
31a2bb94
|
Anděl Ondřej
|
document.getElementById("paging-control").style.display = "";
|
495 |
fb32f0e8
|
Anděl Ondřej
|
}
|
496 |
31a2bb94
|
Anděl Ondřej
|
itemCount = parsedJSON.count;
|
497 |
|
|
pageCount = Math.ceil(itemCount / itemPerPage);
|
498 |
|
|
document.getElementById("page-label").value = (pageIndex + 1) + " / " + pageCount;
|
499 |
a908ef13
|
Anděl Ondřej
|
data = parsedJSON.data;
|
500 |
|
|
renderData(parsedJSON.data);
|
501 |
|
|
};
|
502 |
|
|
xhr.send(formData);
|
503 |
|
|
}
|
504 |
|
|
|
505 |
|
|
function renderManuscript(manuscripts, shorten=true) {
|
506 |
|
|
let output = "";
|
507 |
|
|
for(let i = 0; i < manuscripts.length; i++){
|
508 |
56235f0a
|
Anděl Ondřej
|
if(shorten)
|
509 |
|
|
output += codeToManuscriptShort[manuscripts[i]];
|
510 |
|
|
else
|
511 |
|
|
output += codeToManuscript[manuscripts[i]];
|
512 |
a908ef13
|
Anděl Ondřej
|
|
513 |
|
|
if(i < manuscripts.length - 1){
|
514 |
56235f0a
|
Anděl Ondřej
|
if(shorten)
|
515 |
|
|
output += ", ";
|
516 |
|
|
else
|
517 |
|
|
output += "; ";
|
518 |
a908ef13
|
Anděl Ondřej
|
}
|
519 |
|
|
}
|
520 |
|
|
return output;
|
521 |
|
|
}
|
522 |
|
|
|
523 |
|
|
function renderData(data) {
|
524 |
|
|
let result = "";
|
525 |
|
|
data.forEach((item,id) => {
|
526 |
|
|
result += "<tr>";
|
527 |
|
|
result += "<td>" + item.word + "</td>";
|
528 |
|
|
result += "<td>" + item.lemma.lemma + "</td>";
|
529 |
|
|
result += "<td>" + renderManuscript(item.manuscript) + "</td>";
|
530 |
|
|
result += "<td>" + item.position1 + (item.position2 ? ("/" + item.position2 + (item.positiondetail ? "/" + item.positiondetail : "")) : "") + "</td>";
|
531 |
|
|
result += "<td class=\"action-td\">" +
|
532 |
|
|
"<button class=\"btn\" title=\"Detail\" data-toggle=\"modal\" data-target=\"#detail-modal\" data-pseudo-id='" + id + "'><i class=\"fa fa-search\"></i></button>" +
|
533 |
|
|
"</td>";
|
534 |
|
|
result += "</tr>";
|
535 |
|
|
});
|
536 |
|
|
document.getElementById("search-table").innerHTML = result;
|
537 |
|
|
}
|
538 |
9a7b1f4c
|
Ondřej Anděl
|
</script>
|
539 |
|
|
</tbody>
|
540 |
|
|
</table>
|
541 |
fb32f0e8
|
Anděl Ondřej
|
|
542 |
|
|
<h3 id="no-data-label" class="mx-auto text-center font-italic">Žádná data nebyla nalezena</h3>
|
543 |
31a2bb94
|
Anděl Ondřej
|
|
544 |
|
|
<script>
|
545 |
7a7b805f
|
Ondrej Drtina
|
function checkValidItemsPerPage(){
|
546 |
d845d95d
|
Ondrej Drtina
|
var visibleItemCount = document.getElementById("itemsPerPage");
|
547 |
7a7b805f
|
Ondrej Drtina
|
if(!isNaN(visibleItemCount.value) && visibleItemCount.value % 1 === 0 && parseInt(visibleItemCount.value) >= 1 && parseInt(visibleItemCount.value) <= 500){
|
548 |
|
|
return true;
|
549 |
|
|
}else{
|
550 |
|
|
alert("Zadaný počet není validní, zkuste to znovu.\nPlatný rozsah: 1 - 500 položek na stránku.");
|
551 |
|
|
visibleItemCount.value = itemPerPage;
|
552 |
|
|
return false;
|
553 |
|
|
}
|
554 |
d845d95d
|
Ondrej Drtina
|
}
|
555 |
|
|
|
556 |
|
|
function changeItemsPerPage(){
|
557 |
7a7b805f
|
Ondrej Drtina
|
//if there is no valid input, return and dont save
|
558 |
|
|
if(checkValidItemsPerPage() === false){
|
559 |
|
|
return;
|
560 |
|
|
}
|
561 |
d845d95d
|
Ondrej Drtina
|
|
562 |
7a7b805f
|
Ondrej Drtina
|
pageIndex = 0;
|
563 |
d845d95d
|
Ondrej Drtina
|
var visibleItemCount = document.getElementById("itemsPerPage").value;
|
564 |
|
|
itemPerPage = visibleItemCount;
|
565 |
|
|
fetchData(true);
|
566 |
|
|
}
|
567 |
|
|
|
568 |
31a2bb94
|
Anděl Ondřej
|
function moveToFirst(){
|
569 |
|
|
pageIndex = 0;
|
570 |
|
|
fetchData(true);
|
571 |
|
|
}
|
572 |
|
|
|
573 |
|
|
function moveToPrevious(){
|
574 |
|
|
pageIndex = (pageIndex - 1 > 0) ? (pageIndex - 1) : (0);
|
575 |
|
|
fetchData(true);
|
576 |
|
|
}
|
577 |
|
|
|
578 |
|
|
function moveToNext(){
|
579 |
|
|
pageIndex = (pageIndex + 1 < pageCount) ? (pageIndex + 1) : (pageCount - 1);
|
580 |
|
|
fetchData(true);
|
581 |
|
|
}
|
582 |
|
|
|
583 |
|
|
function moveToLast(){
|
584 |
|
|
pageIndex = pageCount - 1;
|
585 |
|
|
fetchData(true);
|
586 |
|
|
}
|
587 |
|
|
|
588 |
|
|
function onManualPageStart(element){
|
589 |
|
|
element.value = '';
|
590 |
|
|
}
|
591 |
|
|
|
592 |
|
|
function onManualPageEnd(element) {
|
593 |
|
|
const value = Number(element.value) - 1;
|
594 |
|
|
if(Number.isInteger(value) && value >= 0 && value < pageCount){
|
595 |
|
|
pageIndex = value;
|
596 |
|
|
fetchData(true);
|
597 |
|
|
} else {
|
598 |
|
|
element.value = (pageIndex + 1) + " / " + pageCount;
|
599 |
|
|
}
|
600 |
|
|
|
601 |
|
|
}
|
602 |
|
|
</script>
|
603 |
|
|
<div id="paging-control" class="mx-auto text-center" style="display: none">
|
604 |
|
|
<button class="border-0 shadow-none bg-transparent" onclick="moveToFirst()"><b><<</b></button>
|
605 |
|
|
<button class="border-0 shadow-none bg-transparent" onclick="moveToPrevious()"><b><</b></button>
|
606 |
|
|
<input class="border-0 shadow-none bg-transparent text-center font-weight-bold"
|
607 |
|
|
id="page-label"
|
608 |
|
|
onfocus="onManualPageStart(this)"
|
609 |
|
|
onblur="onManualPageEnd(this)"
|
610 |
|
|
/>
|
611 |
|
|
<button class="border-0 shadow-none bg-transparent" onclick="moveToNext()"><b>></b></button>
|
612 |
|
|
<button class="border-0 shadow-none bg-transparent" onclick="moveToLast()"><b>>></b></button>
|
613 |
|
|
</div>
|
614 |
9a7b1f4c
|
Ondřej Anděl
|
</div>
|
615 |
|
|
|