PageSourceSearch

https://kopalnia-zdrowia.pl/public_html/js/pink/filter.js

js kopalnia-zdrowia.pl collected 2026-09-26 17:51:25 UTC 8,503 bytes, 236 lines download raw bytes

1$(document).ready(function () {
2    if (productFilters['producer_id_list'] != undefined) {
3        var productIdList = productFilters['producer_id_list'].split(',');
4        for (i = 0; i < productIdList.length; i++) {
5            producerFilter[productIdList[i]] = productIdList[i];
6        }
7    }
8    if (productFilters['category_id_list'] != undefined) {
9        var categoryIdList = productFilters['category_id_list'].split(',');
10        for (i = 0; i < categoryIdList.length; i++) {
11            categoryFilter[categoryIdList[i]] = categoryIdList[i];
12//            $('input[name="category-' + categoryIdList[i] + '"]').attr("checked", true);
13//            $('input[name="category-' + categoryIdList[i] + '"]').parents(".filterSubCategoryBox").show();
14//            var objList = $('input[name="category-' + categoryIdList[i] + '"]').nextAll(".filterSubCategoryBox").find(".filterCategoryCheckbox");
15//            objList.each(function () {
16//                $(this).attr("checked", true);
17//            });
18        }
19    }
20
21    $(".manufaktuterCheckbox").on('change', function () {
22        var input = jQuery(this);
23        var name = jQuery(this).attr('data-name');
24        var input_name = jQuery(this).attr('name');
25        var unselect = prepareUnselectFilterElement(input_name, name);
26        jQuery('.active_filter_list').find('*[data-active-filter-off][data-input="' + input_name + '"]').off().remove();
27
28        if (jQuery(this).is(':checked')) {
29            jQuery('.active_filter_list').append(unselect);
30            setClickActionOnFilter(input, input_name);
31        }
32
33        producerFilter = {};
34        setProducerFilterValue();
35        check_list();
36    });
37    
38    $(".categoryCheckbox").on('change', function () {
39        var input = jQuery(this);
40        var name = jQuery(this).attr('data-name');
41        var input_name = jQuery(this).attr('name');
42        var unselect = prepareUnselectFilterElement(input_name, name);
43        jQuery('.active_filter_list').find('*[data-active-filter-off][data-input="' + input_name + '"]').off().remove();
44
45        if (jQuery(this).is(':checked')) {
46            jQuery('.active_filter_list').append(unselect);
47            setClickActionOnFilter(input, input_name);
48        }
49
50        setCategoryFilterValue();
51        check_list();
52    });
53
54//    $(".filterCategoryCheckbox").click(function () {
55//        if ($(this).is(':checked')) {
56//            categoryFilter[$(this).val()] = $(this).val();
57//            var objList = $(this).nextAll(".filterSubCategoryBox").find(".filterCategoryCheckbox");
58//            objList.each(function () {
59//                $(this).attr("checked", true);
60//            });
61//        } else {
62//            delete categoryFilter[$(this).val()];
63//            var objList = $(this).nextAll(".filterSubCategoryBox").find(".filterCategoryCheckbox");
64//            objList.each(function () {
65//                $(this).attr("checked", false);
66//            });
67//        }
68//    });
69
70    $("input[type='radio'][name='product_sorting']").change(function () {
71        productFilters['product_sorting'] = $(this).val();
72        reloadProductListAfterFilterChange(baseProductListUrl);
73        ;
74
75        return false;
76    });
77
78    $("#filterSubmit").click(function () {
79        setPriceFilterValue();
80        reloadProductListAfterFilterChange(baseProductListUrl);
81        return false;
82    });
83
84    $(".hasChildInd").click(function () {
85        if ($(this).hasClass("fa-plus")) {
86            $(this).next('.filterSubCategoryBox').slideDown('slow');
87            $(this).removeClass("fa-plus");
88            $(this).addClass("fa-minus");
89        } else {
90            $(this).next('.filterSubCategoryBox').slideUp('slow');
91            $(this).removeClass("fa-minus");
92            $(this).addClass("fa-plus");
93        }
94    });
95    
96    restoreActiveFilterList();
97});
98
99// ----------- FILTER FUNCTIONS -------
100function setProducerFilterValue() {
101    producerFilter = {};
102    $(".manufaktuterCheckbox").each(function () {
103        if ($(this).is(":checked")) {
104            producerFilter[$(this).val()] = $(this).val();
105        }
106    });
107}
108function setCategoryFilterValue() {
109    categoryFilter = {};
110    $(".categoryCheckbox").each(function () {
111        if ($(this).is(":checked")) {
112            categoryFilter[$(this).val()] = $(this).val();
113        }
114    });
115}
116
117function prepareUnselectFilterElement(input_name, name) {
118    var unselect = '<a href="#" data-active-filter-off data-input="' + input_name + '"><i class="fas fa-times"></i>' + name + '</a>';
119    return unselect;
120}
121
122function setPriceFilterValue() {
123    var range = $("#pricerange").val();
124    var rangeData = range.split('-');
125    productFilters['price_min'] = rangeData[0];
126    productFilters['price_max'] = rangeData[1];
127}
128function convertFilterToUrl() {
129    var producer = converProducerParameter();
130
131    if (producer !== "") {
132        productFilters['producer_id_list'] = converProducerParameter();
133    } else {
134        delete productFilters['producer_id_list'];
135    }
136
137    var category = convertCategoryParameter();
138    if (category !== "") {
139        productFilters['category_id_list'] = convertCategoryParameter();
140    } else {
141        delete productFilters['category_id_list'];
142    }
143
144    var urlString = "";
145    for (var key in productFilters) {
146        var row = "&" + key + "=" + productFilters[key];
147        urlString = urlString + row;
148    }
149    return urlString;
150}
151
152function converProducerParameter() {
153    var producerParam = "";
154    for (var key in producerFilter) {
155        var row = producerFilter[key] + ",";
156        producerParam = producerParam + row;
157    }
158    if (producerParam.length > 0) {
159        producerParam = producerParam.substring(0, producerParam.length - 1);
160    }
161    return producerParam;
162}
163
164function convertCategoryParameter() {
165    var categoryParam = "";
166    for (var key in categoryFilter) {
167        var row = categoryFilter[key] + ",";
168        categoryParam = categoryParam + row;
169    }
170    if (categoryParam.length > 0) {
171        categoryParam = categoryParam.substring(0, categoryParam.length - 1);
172    }
173    return categoryParam;
174}
175
176function reloadProductList(url) {
177    window.location.href = url;
178}
179
180function reloadProductListAfterFilterChange(baseProductListUrl) {
181    ;
182    var url = baseProductListUrl;
183    url = baseProductListUrl + convertFilterToUrl();
184
185    reloadProductList(url);
186}
187
188function check_list() {
189    if (jQuery('.active_filter_list').is(':empty'))
190        jQuery('.filter_list').stop(true, true).slideUp();
191    else
192        jQuery('.filter_list').slideDown();
193}
194
195function setClickActionOnFilter (input, input_name) {
196    jQuery('.active_filter_list').find('*[data-active-filter-off][data-input="'+input_name+'"]').on('click', function(e){
197            e.preventDefault();
198            input.parent().parent().parent().parent().parent().parent().children('.control-checkbox').find('input[type=checkbox]').prop('checked', false).trigger('change');
199            input.parent().parent().parent().find('.submenu input[type=checkbox]').prop('checked', false).trigger('change');
200            input.prop('checked', false).trigger('change');
201            jQuery('.active_filter_list').find('*[data-active-filter-off][data-input="'+input_name+'"]').off().remove();
202            setProducerFilterValue();
203            setCategoryFilterValue();
204            check_list();
205    });
206}
207
208function restoreActiveFilterList () {
209    for (var key in producerFilter) {
210        var row = producerFilter[key];
211        var input_name = 'manufacturer['+row+']';
212        
213        var input = jQuery('.manufaktuterCheckbox[name="'+input_name+'"]');
214        if(input) {
215            jQuery(input).prop('checked', true);
216            var name = jQuery(input).attr('data-name');
217            var unselect = prepareUnselectFilterElement(input_name, name);
218            jQuery('.active_filter_list').append(unselect);
219            setClickActionOnFilter(input,input_name);
220        }
221    }
222    for (var key in categoryFilter) {
223        var row = categoryFilter[key];
224        var input_name = 'category['+row+']';
225        
226        var input = jQuery('.categoryCheckbox[name="'+input_name+'"]');
227        if(input) {
228            jQuery(input).prop('checked', true);
229            var name = jQuery(input).attr('data-name');
230            var unselect = prepareUnselectFilterElement(input_name, name);
231            jQuery('.active_filter_list').append(unselect);
232            setClickActionOnFilter(input,input_name);
233        }
234    }
235    check_list();
236}

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.