PageSourceSearch

https://lab-iq.ru/wp-content/themes/miniapp/js/loads.js?ver=47.9.5

js lab-iq.ru collected 2026-10-04 19:31:06 UTC 3,794 bytes, 82 lines download raw bytes

1/*Поиск*/
2jQuery(document).ready(function($) {
3    function initializeSearch(formSelector, inputSelector, resultsSelector) {
4        var searchForm = $(formSelector);
5        var searchInput = searchForm.find(inputSelector);
6        var searchResults = searchForm.find(resultsSelector);
7
8        searchInput.on('input', function() {
9            var query = $(this).val();
10            if (query.length > 2) {
11                $.ajax({
12                    url: search_params.ajax_url,
13                    type: 'POST',
14                    data: {
15                        action: 'ajax_product_search',
16                        query: query
17                    },
18                    success: function(response) {
19                        var resultsHTML = '';
20
21                        // Отображение категорий
22                        if (response.categories && response.categories.length > 0) {
23                            response.categories.forEach(function(category) {
24								resultsHTML += '<a href="' + category.link + '" class="search-category">' +
25									'<img class="search-icons" src="' + category.icon + '">' +
26									'<div class="search-product__info-name">' + category.name + '</div>' +
27									'<img class="search-arrow" src="' + category.arrov + '">' +
28								'</a>';
29                            });
30                        }
31
32                        // Отображение товаров
33                        if (response.products && response.products.length > 0) {
34                            response.products.forEach(function(product) {
35                                var price = $('<div>').html(product.price).find('ins .woocommerce-Price-amount').text() ||
36								$('<div>').html(product.price).find('.woocommerce-Price-amount').text();
37								resultsHTML += '<a href="' + product.link + '" class="search-product">' +
38									'<img class="search-thumb" src="' + product.image + '">' +
39									'<div class="search-product__info">' +
40										'<div class="search-product__info-name">' + product.name + '</div>' +
41										'<span class="product-price' + (product.is_on_sale ? ' sale-price' : '') + '">' + product.price + '</span>' + 
42									'</div>' + 
43									'<img class="search-arrow" src="' + product.arrov + '">' +
44								'</a>';
45                            });
46                        }
47
48                        // Если нет результатов
49                        if (!response.products || response.products.length === 0) {
50                            resultsHTML += '<div class="search-no-results">Ничего не нашли</div>';
51                        }
52
53                        // Ссылка на все результаты
54                        if (response.total_results > 0) {
55                            resultsHTML += '<div class="search-all-results">' +
56                                '<a href="/?s=' + query + '&post_type=product">Все результаты поиска (' + response.total_results + ')</a>' +
57                                '</div>';
58                        }
59
60                        searchResults.html(resultsHTML).css('display', 'flex').show();
61                    }
62                });
63            } else {
64                searchResults.html('').hide(); 
65            }
66        });
67
68        // Скрываем результаты поиска при клике вне формы
69        $(document).on('click', function(e) {
70            if (!$(e.target).closest(searchForm).length) {
71                searchResults.hide();
72            }
73        });
74    }
75
76	// Инициализация для обеих форм
77	initializeSearch('#searchform-pc', '#s-pc', '.search-results-box');
78	initializeSearch('#searchform-mobile', '#s-mobile', '.search-results-box');
79
80});
81
82

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.