1
|
<script>
|
2
|
let pageIndex = 0;
|
3
|
let itemPerPage = 50;
|
4
|
let itemCount = 0;
|
5
|
let pageCount = 0;
|
6
|
|
7
|
//what to do when page renders
|
8
|
window.onload = function() {
|
9
|
let sourceSelect = new vanillaSelectBox("#source");
|
10
|
filtersChange();
|
11
|
fetchData(false);
|
12
|
|
13
|
//page-label listener
|
14
|
document.getElementById('page-label').addEventListener('keyup',function(e){
|
15
|
if (e.key === 'Enter' || e.keyCode === 13) {
|
16
|
this.blur();
|
17
|
}
|
18
|
});
|
19
|
};
|
20
|
</script>
|
21
|
|
22
|
<div class="search-filters container" onload="filtersChange()">
|
23
|
<div class="row">
|
24
|
<div class="mr-3">
|
25
|
<label for="lemma" class="mr-2">Lemma</label>
|
26
|
<input type="text" id="lemma">
|
27
|
</div>
|
28
|
<div class="mr-3">
|
29
|
<label for="wordshape" class="mr-2">Slovní tvar</label>
|
30
|
<input type="text" id="wordshape">
|
31
|
</div>
|
32
|
<div class="mr-3">
|
33
|
<label for="source" class="mr-2">Rukopisný pramen</label>
|
34
|
<select id="source" multiple>
|
35
|
<option value = "0">rukopis Vídeňský</option>
|
36
|
<option value = "1">zlomky Hanušovy</option>
|
37
|
<option value = "2">zlomky Hradecké</option>
|
38
|
<option value = "3">rukopis Cambridžský</option>
|
39
|
<option value = "4">rukopis Františkánský</option>
|
40
|
<option value = "5">zlomek Olomoucký</option>
|
41
|
<option value = "6">fragment Strahovský</option>
|
42
|
<option value = "7">zlomky Klementinsko-Křižovnické</option>
|
43
|
<option value = "8">zlomky Mnichovské</option>
|
44
|
<option value = "9">rukopis Lobkovický</option>
|
45
|
<option value = "10">rukopis Pelclův</option>
|
46
|
<option value = "11">rukopis Cerronský</option>
|
47
|
<option value = "12">rukopis Fürstenberský</option>
|
48
|
<option value = "13">rukopis Zebererův</option>
|
49
|
<option value = "14">vydání Pavla Ješína z Bezdězi, Praha 1620</option>
|
50
|
<option value = "15">básně připsané při Pulkavově kronice v rukopisu Litoměřickém</option>
|
51
|
</select>
|
52
|
</div>
|
53
|
<div class="mr-3">
|
54
|
<label for="location" class="mr-2">Pozice</label>
|
55
|
<input type="text" id="location">
|
56
|
</div>
|
57
|
<div class="mr-3">
|
58
|
<label for="description2" class="mr-2">Doplňující údaj</label>
|
59
|
<input type="text" id="description2" />
|
60
|
</div>
|
61
|
|
62
|
<div class="mr-3">
|
63
|
<label for="wordclass" class="mr-2">Slovní druh</label>
|
64
|
<select onchange="filtersChange()" id="wordclass">
|
65
|
<option selected="selected" value = "">nevybráno</option>
|
66
|
<option value = "N">substantivum</option>
|
67
|
<option value = "A">adjektivum</option>
|
68
|
<option value = "P">pronomen</option>
|
69
|
<option value = "C">numerále</option>
|
70
|
<option value = "V">verbum</option>
|
71
|
<option value = "D">adverbium</option>
|
72
|
<option value = "R">prepozice</option>
|
73
|
<option value = "J">konjunkce</option>
|
74
|
<option value = "T">partikule</option>
|
75
|
<option value = "I">interjekce</option>
|
76
|
</select>
|
77
|
</div>
|
78
|
|
79
|
<!-- conditionaly rendered filters-->
|
80
|
<div class="mr-3" id="filter-person">
|
81
|
<label for="person" class="mr-2">Osoba</label>
|
82
|
<select id="person">
|
83
|
<option selected="selected" value = "">nevybráno</option>
|
84
|
<option value = "1">1.</option>
|
85
|
<option value = "2">2.</option>
|
86
|
<option value = "3">3.</option>
|
87
|
</select>
|
88
|
</div>
|
89
|
<div class="mr-3" id="filter-case">
|
90
|
<label for="case" class="mr-2">Pád</label>
|
91
|
<select id="case">
|
92
|
<option selected="selected" value = "">nevybráno</option>
|
93
|
<option value = "1">nominativ</option>
|
94
|
<option value = "2">genitiv</option>
|
95
|
<option value = "3">dativ</option>
|
96
|
<option value = "4">akuzativ</option>
|
97
|
<option value = "5">vokativ</option>
|
98
|
<option value = "6">lokál</option>
|
99
|
<option value = "7">instrumentál</option>
|
100
|
</select>
|
101
|
</div>
|
102
|
<div class="mr-3" id="filter-countability">
|
103
|
<label for="countability" class="mr-2">Číslo</label>
|
104
|
<select id="countability">
|
105
|
<option selected="selected" value = "">nevybráno</option>
|
106
|
<option value = "S">singulár</option>
|
107
|
<option value = "P">plurál</option>
|
108
|
<option value = "D">duál</option>
|
109
|
</select>
|
110
|
</div>
|
111
|
<div class="mr-3" id="filter-mood">
|
112
|
<label for="mood" class="mr-2">Způsob</label>
|
113
|
<select id="mood" onchange="moodChange()">
|
114
|
<option selected="selected" value = "">nevybráno</option>
|
115
|
<option value = "d">indikativ</option>
|
116
|
<option value = "i">imperativ</option>
|
117
|
<option value = "c">kondicionál</option>
|
118
|
</select>
|
119
|
</div>
|
120
|
<div class="mr-3" id="filter-time">
|
121
|
<label for="time" class="mr-2">Čas</label>
|
122
|
<select id="time">
|
123
|
<option selected="selected" value = "">nevybráno</option>
|
124
|
<option value = "P">prézens</option>
|
125
|
<option value = "A">aorist</option>
|
126
|
<option value = "R">préteritum</option>
|
127
|
<option value = "I">imperfektum</option>
|
128
|
<option value = "H">plusquamperfektum</option>
|
129
|
<option value = "F">futurum</option>
|
130
|
</select>
|
131
|
</div>
|
132
|
<div class="mr-3" id="filter-v-type">
|
133
|
<label for="v-type" class="mr-2">Slovesný rod</label>
|
134
|
<select id="v-type">
|
135
|
<option selected="selected" value = "">nevybráno</option>
|
136
|
<option value = "A">aktivum</option>
|
137
|
<option value = "P">pasivum</option>
|
138
|
</select>
|
139
|
</div>
|
140
|
<div class="mr-3" id="filter-vid">
|
141
|
<label for="vid" class="mr-2">Vid</label>
|
142
|
<select id="vid">
|
143
|
<option selected="selected" value = "">nevybráno</option>
|
144
|
<option value = "P">perfektivum</option>
|
145
|
<option value = "I">imperfektivum </option>
|
146
|
</select>
|
147
|
</div>
|
148
|
<div class="mr-3" id="filter-irregular">
|
149
|
<label for="irregular" class="mr-2">Neurčitý slovesný tvar</label>
|
150
|
<select id="irregular" onchange="irregularChange()">
|
151
|
<option selected="selected" value = "">nevybráno</option>
|
152
|
<option value = "f">infinitiv</option>
|
153
|
<option value = "S">supinum</option>
|
154
|
<option value = "e">přech. přítomný</option>
|
155
|
<option value = "m">přech. minulý</option>
|
156
|
<option value = "A">part. perf. akt.</option>
|
157
|
<option value = "P">part. perf. pas.</option>
|
158
|
</select>
|
159
|
</div>
|
160
|
<div class="mr-3" id="filter-gender">
|
161
|
<label for="gender" class="mr-2">Rod</label>
|
162
|
<select id="gender">
|
163
|
<option selected="selected" value = "">nevybráno</option>
|
164
|
<option value = "M">maskulinum</option>
|
165
|
<option value = "F">femininum</option>
|
166
|
<option value = "N">neutrum</option>
|
167
|
</select>
|
168
|
</div>
|
169
|
<div class="mr-3" id="filter-shape">
|
170
|
<label for="shape" class="mr-2">Tvar</label>
|
171
|
<select id="shape">
|
172
|
<option selected="selected" value = "">nevybráno</option>
|
173
|
<option value = "C">složený</option>
|
174
|
<option value = "N">jmenný</option>
|
175
|
</select>
|
176
|
</div>
|
177
|
<div class="mr-3" id="filter-grade">
|
178
|
<label for="grade" class="mr-2">Stupeň</label>
|
179
|
<select id="grade">
|
180
|
<option selected="selected" value = "">nevybráno</option>
|
181
|
<option value = "1">pozitiv</option>
|
182
|
<option value = "2">komparativ</option>
|
183
|
<option value = "3">superlativ</option>
|
184
|
</select>
|
185
|
</div>
|
186
|
<div class="mr-3" id="filter-type">
|
187
|
<label for="type" class="mr-2">Druh</label>
|
188
|
<select id="type">
|
189
|
<option selected="selected" value = "">nevybráno</option>
|
190
|
<option value = "P">personalia</option>
|
191
|
<option value = "S">posesiva</option>
|
192
|
<option value = "D">demonstrativa</option>
|
193
|
<option value = "Q">interogativa</option>
|
194
|
<option value = "J">relativa</option>
|
195
|
<option value = "Z">indefinita</option>
|
196
|
<option value = "L">limitativa</option>
|
197
|
<option value = "W">negativa</option>
|
198
|
</select>
|
199
|
</div>
|
200
|
<div class="mr-3" id="filter-k-type">
|
201
|
<label for="k-type" class="mr-2">Typ</label>
|
202
|
<select id="k-type">
|
203
|
<option selected="selected" value = "">nevybráno</option>
|
204
|
<option value = "V">větná</option>
|
205
|
<option value = "C">členská</option>
|
206
|
<option value = "N">navazovací</option>
|
207
|
<option value = "P">spojení s přechodníkem</option>
|
208
|
</select>
|
209
|
</div>
|
210
|
|
211
|
<!-- send button-->
|
212
|
<div class="ml-auto" id="filter-control-div">
|
213
|
<i class="mr-1 my-auto" id="hit-count">0 záznamů</i>
|
214
|
<button class="btn" id="filter-but" onclick="callFilter()">
|
215
|
Filtrovat
|
216
|
</button>
|
217
|
<button class="btn" data-toggle="modal" data-target="#settings-modal" title="Nastavení">
|
218
|
<i class="fa fa-cogs"></i>
|
219
|
</button>
|
220
|
|
221
|
<?php if(isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) {?>
|
222
|
<button class="btn" data-toggle="modal" data-target="#edit-modal" data-title="Nový záznam" title="Nový záznam">
|
223
|
<i class="fa fa-plus"></i>
|
224
|
</button>
|
225
|
<?php }?>
|
226
|
</div>
|
227
|
</div>
|
228
|
</div>
|
229
|
|
230
|
<div class="search-results mt-4">
|
231
|
<table class="table table-striped">
|
232
|
<thead>
|
233
|
<tr>
|
234
|
<?php if(isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) {?>
|
235
|
<th scope="col">Vydáno</th>
|
236
|
<?php }?>
|
237
|
<th scope="col">Lemma</th>
|
238
|
<th scope="col">Slovní tvar</th>
|
239
|
<th scope="col">Morfologie</th>
|
240
|
<th scope="col">Rukopisy</th>
|
241
|
<th scope="col">Pozice</th>
|
242
|
<th scope="col">Doplňující údaj</th>
|
243
|
<th scope="col"></th>
|
244
|
</tr>
|
245
|
</thead>
|
246
|
<tbody id="search-table">
|
247
|
<script>
|
248
|
let data;
|
249
|
function fetchData (filter = true) {
|
250
|
// (A1) GET SEARCH TERM
|
251
|
const formData = new FormData();
|
252
|
formData.append("page", ""+pageIndex);
|
253
|
formData.append("items_per_page", ""+itemPerPage);
|
254
|
if(filter){
|
255
|
filterData(formData);
|
256
|
}
|
257
|
|
258
|
// (A2) AJAX - USE HTTP:// NOT FILE:/
|
259
|
let xhr = new XMLHttpRequest();
|
260
|
xhr.open("POST", "./controller/TableController.php");
|
261
|
xhr.onload = function(){
|
262
|
let search = this.response;
|
263
|
//console.log(search);
|
264
|
let parsedJSON = JSON.parse(search);
|
265
|
if(parsedJSON.count === 0){
|
266
|
document.getElementById("no-data-label").textContent = "Žádná data nebyla nalezena";
|
267
|
document.getElementById("no-data-label").style.display = "";
|
268
|
document.getElementById("paging-control").style.display = "none";
|
269
|
} else {
|
270
|
document.getElementById("no-data-label").style.display = "none";
|
271
|
document.getElementById("paging-control").style.display = "";
|
272
|
}
|
273
|
|
274
|
if(parsedJSON.count === 1){
|
275
|
document.getElementById("hit-count").innerText = "1 záznamů";
|
276
|
} else if(parsedJSON.count < 5){
|
277
|
document.getElementById("hit-count").innerText = parsedJSON.count +" záznamů";
|
278
|
} else {
|
279
|
document.getElementById("hit-count").innerText = parsedJSON.count +" záznamů";
|
280
|
}
|
281
|
|
282
|
itemCount = parsedJSON.count;
|
283
|
pageCount = Math.ceil(itemCount / itemPerPage);
|
284
|
document.getElementById("page-label").value = (pageIndex + 1) + " / " + pageCount;
|
285
|
data = parsedJSON.data;
|
286
|
renderData(parsedJSON.data);
|
287
|
};
|
288
|
xhr.send(formData);
|
289
|
}
|
290
|
|
291
|
function publishItem(id, index){
|
292
|
let item = data[index];
|
293
|
const finishedChecked = document.getElementById("check-"+id).checked;
|
294
|
|
295
|
const formData = new FormData();
|
296
|
formData.append("finished", finishedChecked);
|
297
|
|
298
|
formData.append("id", item.id);
|
299
|
formData.append("ending", item.ending);
|
300
|
formData.append("prefix", item.prefix);
|
301
|
formData.append("suffix", item.suffix);
|
302
|
|
303
|
formData.append("namedentity", item.namedentity);
|
304
|
formData.append("position1", item.position1);
|
305
|
formData.append("position2", item.position2);
|
306
|
formData.append("positiondetail", item.positiondetail);
|
307
|
formData.append("word", item.word);
|
308
|
formData.append("lemma", item.lemma.lemma);
|
309
|
formData.append("manuscript", item.manuscript);
|
310
|
formData.append("context", item.context);
|
311
|
formData.append("description", item.description);
|
312
|
formData.append("description2", item.description2);
|
313
|
formData.append("description3", item.description3);
|
314
|
formData.append("tag", item.tag.tag);
|
315
|
formData.append("pos", item.lemma.pos);
|
316
|
formData.append("date", item.date);
|
317
|
|
318
|
var xhr = new XMLHttpRequest();
|
319
|
xhr.open("POST", "./controller/UpdateController.php");
|
320
|
xhr.send(formData);
|
321
|
setTimeout(function(){
|
322
|
location.reload();
|
323
|
}, 500);
|
324
|
}
|
325
|
|
326
|
function renderData(data) {
|
327
|
let result = "";
|
328
|
data.forEach((item,id) => {
|
329
|
result += "<tr>";
|
330
|
<?php if(isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) {?>
|
331
|
result += "<td><input type='checkbox' id='check-"+item.id+"' onchange='publishItem("+item.id+", "+ id+ ")' "+ ((item.finished === true) ? 'checked' : '') +" /></td>";
|
332
|
<?php }?>
|
333
|
result += "<td>" + item.lemma.lemma + "</td>";
|
334
|
result += "<td>" + item.word + "</td>";
|
335
|
result += "<td>" + renderTag(item.tag.tag) + "</td>";
|
336
|
result += "<td>" + renderManuscript(item.manuscript) + "</td>";
|
337
|
result += "<td>" + item.position1 + (item.position2 ? ("/" + item.position2 + (item.positiondetail ? "/" + item.positiondetail : "")) : "") + "</td>";
|
338
|
result += "<td>" + ((item.description2 !== null && item.description2.trim().length > 0) ? (normalizeDescription(item.description2)) : "-") + "</td>";
|
339
|
result += "<td class=\"action-td\">" +
|
340
|
"<button class=\"btn mr-1\" title=\"Upravit\" data-toggle=\"modal\" data-target=\"#edit-modal\" data-pseudo-id='" + id + "' data-title=\"Upravit záznam\"><i class=\"fa fa-pencil\"></i></button>" +
|
341
|
"<button class=\"btn\" title=\"Detail\" data-toggle=\"modal\" data-target=\"#detail-modal\" data-pseudo-id='" + id + "'><i class=\"fa fa-search\"></i></button>";
|
342
|
<?php if(isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) { ?> //show remove only if logged in
|
343
|
result += "<button class=\"btn ml-1\" title=\"Odstranit\" data-toggle=\"modal\" data-target=\"#remove-modal\" data-pseudo-id='" + id + "'><i class=\"fa fa-trash\"></i></button>";
|
344
|
<?php }?>
|
345
|
result += "</td>";
|
346
|
result += "</tr>";
|
347
|
});
|
348
|
document.getElementById("search-table").innerHTML = result;
|
349
|
}
|
350
|
|
351
|
function removeSelectedItem(idToDelete){
|
352
|
const data = new FormData(); //to pass ids, which we want to delete from DB
|
353
|
data.append("id", ""+idToDelete); //id to delete from table dd_wordform
|
354
|
|
355
|
let xhr = new XMLHttpRequest();
|
356
|
xhr.open("POST", "./controller/RemoveController.php");
|
357
|
xhr.send(data);
|
358
|
fetchData(true); //reload data after item delete
|
359
|
}
|
360
|
</script>
|
361
|
</tbody>
|
362
|
</table>
|
363
|
|
364
|
<h3 id="no-data-label" class="mx-auto text-center font-italic">Probíhá načítání dat</h3>
|
365
|
|
366
|
<div id="paging-control" class="mx-auto text-center" style="display: none">
|
367
|
<button class="border-0 shadow-none bg-transparent" onclick="moveToFirst()"><b><<</b></button>
|
368
|
<button class="border-0 shadow-none bg-transparent" onclick="moveToPrevious()"><b><</b></button>
|
369
|
<input class="border-0 shadow-none bg-transparent text-center font-weight-bold"
|
370
|
id="page-label"
|
371
|
onfocus="onManualPageStart(this)"
|
372
|
onblur="onManualPageEnd(this)"
|
373
|
/>
|
374
|
<button class="border-0 shadow-none bg-transparent" onclick="moveToNext()"><b>></b></button>
|
375
|
<button class="border-0 shadow-none bg-transparent" onclick="moveToLast()"><b>>></b></button>
|
376
|
</div>
|
377
|
</div>
|