Projekt

Obecné

Profil

« Předchozí | Další » 

Revize fb32f0e8

Přidáno uživatelem Ondřej Anděl před více než 3 roky(ů)

Feature #8349: Napojení metod serveru

Zobrazit rozdíly:

application/view/searchContent.php
2 2
    window.onload = function() {
3 3
        let sourceSelect = new vanillaSelectBox("#source");
4 4
        filtersChange();
5
        fetchData();
5
        fetchData(false);
6 6
    };
7 7
</script>
8 8

  
9 9
<div class="search-filters container" onload="filtersChange()">
10 10
    <div class="row">
11
        <div class="mr-3">
12
            <label for="lemma" class="mr-2">Lemma</label>
13
            <input type="text" id="lemma">
14
        </div>
15 11
        <div class="mr-3">
16 12
            <label for="wordshape" class="mr-2">Slovo</label>
17 13
            <input type="text" id="wordshape">
18 14
        </div>
15
        <div class="mr-3">
16
            <label for="lemma" class="mr-2">Lemma</label>
17
            <input type="text" id="lemma">
18
        </div>
19 19
        <div class="mr-3">
20 20
            <label for="source" class="mr-2">Rukopisný pramen</label>
21 21
            <select id="source" multiple>
22
                <option value = "1">C</option>
23
                <option value = "2">Cr</option>
24
                <option value = "3">F</option>
25
                <option value = "4">Fs</option>
26
                <option value = "5">H</option>
27
                <option value = "6">Hr</option>
28
                <option value = "7">Jš</option>
29
                <option value = "8">K</option>
30
                <option value = "9">L</option>
31
                <option value = "10">M</option>
32
                <option value = "11">O</option>
33
                <option value = "12">P</option>
34
                <option value = "13">S</option>
35
                <option value = "14">V</option>
36
                <option value = "15">Z</option>
22
                <option value = "0">rukopis Vídeňský</option>
23
                <option value = "1">zlomky Hanušovy</option>
24
                <option value = "2">zlomky Hradecké</option>
25
                <option value = "3">rukopis Cambridžský</option>
26
                <option value = "4">rukopis Františkánský</option>
27
                <option value = "5">zlomek Olomoucký</option>
28
                <option value = "6">fragment Strahovský</option>
29
                <option value = "7">zlomky Klementinsko-Křižovnické</option>
30
                <option value = "8">zlomky Mnichovské</option>
31
                <option value = "9">rukopis Lobkovický</option>
32
                <option value = "10">rukopis Pelclův</option>
33
                <option value = "11">rukopis Cerronský</option>
34
                <option value = "12">rukopis Fürstenberský</option>
35
                <option value = "13">rukopis Zebererův</option>
36
                <option value = "14">vydání Pavla Ješína z Bezdězi, Praha 1620</option>
37
                <option value = "15">básně připsané při Pulkavově kronice v rukopisu Litoměřickém</option>
37 38
            </select>
38 39
        </div>
39 40
        <div class="mr-3">
......
46 47
            <label for="wordclass" class="mr-2">Slovní druh</label>
47 48
            <select onchange="filtersChange()"  id="wordclass">
48 49
                <option selected="selected" value = "">Nevybráno</option>
49
                <option value = "1">Substantiva</option>
50
                <option value = "2">Adjektiva</option>
51
                <option value = "3">Pronomina</option>
52
                <option value = "4">Numeralia</option>
53
                <option value = "5">Verba</option>
54
                <option value = "6">Adverbia</option>
55
                <option value = "7">Prepozice</option>
56
                <option value = "8">Konjunkce</option>
57
                <option value = "9">Interjekce</option>
58
                <option value = "10">Partikule</option>
50
                <option value = "N">Substantiva</option>
51
                <option value = "A">Adjektiva</option>
52
                <option value = "P">Pronomina</option>
53
                <option value = "C">Numeralia</option>
54
                <option value = "V">Verba</option>
55
                <option value = "D">Adverbia</option>
56
                <option value = "R">Prepozice</option>
57
                <option value = "J">Konjunkce</option>
58
                <option value = "I">Interjekce</option>
59
                <option value = "T">Partikule</option>
59 60
            </select>
60 61
        </div>
61 62

  
......
63 64
            function filtersChange() {
64 65
                const value = document.getElementById("wordclass").value;
65 66
                switch (value) {
66
                    case "1":
67
                    case "N":
67 68
                        setFilerVisibility([
68 69
                            true,
69 70
                            true,
......
79 80
                            false
80 81
                        ]);
81 82
                        break;
82
                    case "2":
83
                    case "A":
83 84
                        setFilerVisibility([
84 85
                            true,
85 86
                            true,
......
95 96
                            false
96 97
                        ]);
97 98
                        break;
98
                    case "3":
99
                    case "P":
99 100
                        setFilerVisibility([
100 101
                            true,
101 102
                            true,
......
111 112
                            false
112 113
                        ]);
113 114
                        break;
114
                    case "4":
115
                    case "C":
115 116
                        setFilerVisibility([
116 117
                            true,
117 118
                            true,
......
127 128
                            false
128 129
                        ]);
129 130
                        break;
130
                    case "5":
131
                    case "V":
131 132
                        setFilerVisibility([
132 133
                            true,
133 134
                            true,
......
143 144
                            false
144 145
                        ]);
145 146
                        break;
146
                    case "6":
147
                    case "D":
147 148
                        setFilerVisibility([
148 149
                            false,
149 150
                            false,
......
159 160
                            false
160 161
                        ]);
161 162
                        break;
162
                    case "7":
163
                    case "R":
163 164
                        setFilerVisibility([
164 165
                            true,
165 166
                            false,
......
175 176
                            false
176 177
                        ]);
177 178
                        break;
178
                    case "8":
179
                    case "J":
179 180
                        setFilerVisibility([
180 181
                            false,
181 182
                            false,
......
191 192
                            true
192 193
                        ]);
193 194
                        break;
194
                    case "9":
195
                    case "I":
195 196
                        setFilerVisibility([
196 197
                            false,
197 198
                            false,
......
207 208
                            false
208 209
                        ]);
209 210
                        break;
210
                    case "10":
211
                    case "T":
211 212
                        setFilerVisibility([
212 213
                            false,
213 214
                            false,
......
392 393
        </div>
393 394

  
394 395
        <!-- send button-->
395
        <button class="ml-auto btn" onclick="filterData()">
396
        <button class="ml-auto btn" onclick="fetchData(true)">
396 397
            Filtrovat
397 398
        </button>
398 399
    </div>
......
411 412
        </thead>
412 413
        <tbody id="search-table">
413 414
            <script>
414
                function filterData () {
415
                    //TODO
416
                }
417

  
418 415
                let data;
416
                function filterData (formData) {
417
                    //regular
418
                    formData.append("lemma", document.getElementById("lemma").value);
419
                    formData.append("word", document.getElementById("wordshape").value);
420

  
421
                    //positions
422
                    const positionSplit = document.getElementById("location").value.split("/");
423
                    formData.append("position1", positionSplit[0] !== undefined ? positionSplit[0] : "");
424
                    formData.append("position2", positionSplit[1] !== undefined ? positionSplit[1] : "");
425
                    formData.append("positiondetail", positionSplit[2] !== undefined ? positionSplit[2] : "");
419 426

  
420
                function fetchData () {
427
                    //multiselect
428
                    formData.append("manuscript", getValues("source"));
429

  
430
                    const pos = document.getElementById("wordclass").value;
431
                    formData.append("tag_pos", pos);
432
                    //those upcoming are dynamic based on the previous field
433
                    formData.append("tag_case", document.getElementById("case").value);
434
                    formData.append("tag_number", document.getElementById("countability").value);
435
                    formData.append("tag_gender", document.getElementById("gender").value);
436
                    formData.append("tag_degree", document.getElementById("grade").value);
437
                    formData.append("tag_shape", document.getElementById("shape").value);
438
                    formData.append("tag_num", "");//THIS ONE IS WORTHLESS
439

  
440
                    if(pos === "P"){
441
                        formData.append("tag_sentence", document.getElementById("type").value);
442
                    } else if(pos === "V"){
443
                        formData.append("tag_sentence", document.getElementById("mood").value);
444
                    } else if(pos === "J"){
445
                        formData.append("tag_sentence", document.getElementById("k-type").value);
446
                    }
447

  
448
                    formData.append("tag_verb_person", document.getElementById("person").value);
449
                    formData.append("tag_verb_time", document.getElementById("time").value);
450
                    formData.append("tag_verb_degree", document.getElementById("vid").value);
451
                    formData.append("tag_verb_aspect", document.getElementById("v-type").value);
452
                }
453

  
454
                function fetchData (filter = true) {
421 455
                    // (A1) GET SEARCH TERM
422 456
                    const formData = new FormData();
423 457
                    formData.append("page", "0");//TODO PAGING
424 458
                    formData.append("items_per_page", "50");//TODO PAGING
425 459
                    formData.append("finished", "true");//TODO ADMIN
426 460

  
461
                    if(filter){
462
                        filterData(formData);
463
                    }
464

  
427 465
                    // (A2) AJAX - USE HTTP:// NOT FILE://
428 466
                    let xhr = new XMLHttpRequest();
429 467
                    xhr.open("POST", "./controller/TableController.php");
430 468
                    xhr.onload = function(){
431 469
                        let search = this.response;
432 470
                        let parsedJSON = JSON.parse(search);
471
                        if(parsedJSON.count === 0){
472
                            document.getElementById("no-data-label").style.display = "";
473
                        } else {
474
                            document.getElementById("no-data-label").style.display = "none";
475
                        }
433 476
                        data = parsedJSON.data;
434 477
                        renderData(parsedJSON.data);
435 478
                    };
......
489 532
            </script>
490 533
        </tbody>
491 534
    </table>
535

  
536
    <h3 id="no-data-label" class="mx-auto text-center font-italic">Žádná data nebyla nalezena</h3>
492 537
</div>
493 538

  
494 539

  

Také k dispozici: Unified diff