PageSourceSearch

https://www.vse.cz/wp-content/plugins/es-vse/frontend/js/es-vse-frontend.js?ver=1

js vse.cz collected 2026-10-01 08:43:40 UTC 5,629 bytes, 141 lines download raw bytes

1(function( $ ) {
2	'use strict';
3
4    var esVSEsearch = {
5        vars: {
6            formSelector: '.es-vse-search__form',
7            inputSelector: '.es-vse-search-input',
8            autocompleteSelector: '.es-vse-search-autocomplete',
9            contextSelector: '.es-vse-search-context',
10            crossSelector: '.es-vse-search__cross',
11            tabSelector: '.es-vse-search__tab',
12            activeTabSelector: '.es-vse-search__tab.active',
13            submitSelector: '.es-vse-search__submit',
14            menuItemSelector: '.es-vse-autocomplete .ui-menu-item',
15            getMoreSelector: '.es-vse-get-more',
16            resultsSelector: '.es-vse-results',
17            loaderSelector: '.es-vse-loader'
18        },
19        init: function () {
20
21            esVSEsearch.crossVisibility();
22            $(esVSEsearch.vars.getMoreSelector).on('click', function () {
23                esVSEsearch.ajaxSearch();
24            });
25
26            $(esVSEsearch.vars.autocompleteSelector).autocomplete({
27                source: function( request, response ) {
28                    $.ajax({
29                        url: es_vse_ajax_url.ajaxurl,
30                        data: {
31                            q: request.term,
32                            action: 'es_vse_suggesting',
33                        },
34                        success: function( data ) {
35                            response( data );
36                        }
37                    });
38                },
39                select: function (event, ui) {
40                    $(this).val(ui.item.value);
41                    $(this).closest('form').submit();
42                },
43                minLength: 2,
44                delay: 200
45            });
46
47
48            $(esVSEsearch.vars.inputSelector).on('keyup', function (event) {
49                if (event.keyCode === 13) {
50                    esVSEsearch.submitForm();
51                }
52                esVSEsearch.crossVisibility();
53
54            });
55
56
57            $(esVSEsearch.vars.crossSelector).on('click', function () {
58                $(esVSEsearch.vars.inputSelector).val('');
59                esVSEsearch.crossVisibility();
60            });
61
62            $(esVSEsearch.vars.tabSelector).on('click', function (e) {
63                e.preventDefault();
64                if (!($(this).hasClass('active'))) {
65                    $(esVSEsearch.vars.tabSelector).removeClass('active');
66                    $(this).addClass('active');
67                    $(esVSEsearch.vars.contextSelector).val($(this).attr('data-context'));
68                    esVSEsearch.submitForm();
69                }
70            });
71            $(esVSEsearch.vars.menuItemSelector).on('click', function () {
72                esVSEsearch.submitForm();
73            });
74            $(esVSEsearch.vars.tabSelector).on('click', function () {
75                if (!($(this).hasClass('active'))) {
76                    $(esVSEsearch.vars.tabSelector).removeClass('active');
77                    $(this).addClass('active');
78                    esVSEsearch.submitForm();
79                }
80            });
81        },
82
83        crossVisibility: function () {
84            if ($(esVSEsearch.vars.inputSelector).length > 0 && $(esVSEsearch.vars.inputSelector).val()) {
85                $(esVSEsearch.vars.crossSelector).css('display','block');
86            } else {
87
88                $(esVSEsearch.vars.crossSelector).css('display','none');
89            }
90        },
91
92        submitForm: function () {
93          $(esVSEsearch.vars.formSelector).submit();
94        },
95
96        ajaxSearch: function () {
97            var context = $(esVSEsearch.vars.contextSelector).val();
98            var offset = $(esVSEsearch.vars.formSelector).attr('data-offset');
99            var query = $(esVSEsearch.vars.formSelector).attr('data-query');
100
101            $(esVSEsearch.vars.loaderSelector).show();
102            $(esVSEsearch.vars.getMoreSelector)[0].disabled = true;
103            $.ajax({
104                url: es_vse_ajax_url.ajaxurl,
105                type: 'POST',
106                data: {
107                    action: 'es_vse_search',
108                    offset: offset,
109                    query: query,
110                    context: context
111                },
112                success: function (response){
113                    $(esVSEsearch.vars.getMoreSelector)[0].disabled = false ;
114
115                    $(esVSEsearch.vars.loaderSelector).hide();
116                    if (response.results.length > 0) {
117                        var offset = $(esVSEsearch.vars.formSelector).attr('data-offset');
118                        var limit = $(esVSEsearch.vars.formSelector).attr('data-limit');
119                        var totalCount = $(esVSEsearch.vars.formSelector).attr('data-total-count');
120                        var newOffset = parseInt(offset) + parseInt(limit);
121                        $(esVSEsearch.vars.formSelector).attr('data-offset', newOffset);
122                        if (newOffset >= totalCount) {
123                            $(esVSEsearch.vars.getMoreSelector).hide();
124                        }
125                        $(esVSEsearch.vars.resultsSelector).append(response.results)
126                    }
127                },
128                error: function () {
129                    $(esVSEsearch.vars.getMoreSelector)[0].disabled = false ;
130                    $(esVSEsearch.vars.loaderSelector).hide();
131                }
132            });
133        }
134
135    };
136
137    jQuery(document).ready( function(){
138        esVSEsearch.init();
139    });
140
141})( jQuery );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.