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