PageSourceSearch

https://hcsochi.ru/local/templates/2021_sochihk_default/custom/im/custom.js

js hcsochi.ru collected 2026-10-02 05:30:59 UTC 9,558 bytes, 299 lines download raw bytes

1$(document).ready(function (){
2
3
4    $("input[name='ORDER_PROP_11']").on("blur", function () {
5        BX.Sale.OrderAjaxComponent.sendRequest();
6    })
7
8
9    // запрос на backend
10    function getRequest(data = {}, callback) {
11        response = false;
12        var result = {};
13        $.ajax({
14            method: "POST",
15            dataType: "json",
16            url: "/local/ajax/action.php",
17            data: {data}
18        })
19            .done(function (resp) {
20                response = resp;
21                if (response != false || response != undefined) {
22                    callback();
23                } else {
24                    alert("Произошла ошибка");
25                }
26            })
27            .fail(function () {
28                alert("Произошла ошибка");
29            });
30
31
32    }
33
34    $('.dropdown-toggle').dropdown();
35
36    $('.shop-product-item__dropdown-scu .dropdown-item').on("click", function (e) {
37        var dropdown_button = $(this).closest('.dropdown').find('.dropdown-toggle');
38
39        $(this).parent().children().removeClass("active").filter(this).addClass("active");
40        dropdown_button.html($(this).html());
41
42        dropdown_button.dropdown("toggle");
43    });
44
45    $(document).on('keyup', '.catalog-filter-search input', function () {
46        var text = $(this).val().toLowerCase();
47        var wr = $(this).parents('.catalog-filter-item__body').find('.catalog-filter-checkbox');
48        var btn = $(this).parents('.catalog-filter-item__body').find('.catalog-filter-search__btn');
49
50        if (text.length > 0) {
51            wr.find('.cf-checkbox').each(function (index) {
52                var checkbox_text = $(this).find('span').text().toLowerCase();
53                var res = checkbox_text.indexOf(text);
54                if (res >= 0) {
55                    wr.find('.cf-checkbox').eq(index).show();
56                } else {
57                    wr.find('.cf-checkbox').eq(index).hide();
58                }
59            });
60
61            $(this).parents('.catalog-filter-search').find('i').removeClass('icon-search').addClass('search-close');
62            btn.addClass('searched');
63        } else {
64            btn.find('i').removeClass('search-close').addClass('icon-search');
65            wr.find('.cf-checkbox').show();
66            btn.removeClass('searched');
67        }
68    });
69
70    $(document).on('click', '.catalog-filter-search__btn.searched', function (e) {
71        e.preventDefault();
72        var wr = $(this).parents('.catalog-filter-item__body').find('.catalog-filter-checkbox');
73
74        $(this).find('i').removeClass('search-close').addClass('icon-search');
75        $(this).parents('.catalog-filter-search').find('input').val('');
76        wr.find('.cf-checkbox').show();
77    });
78
79    // быстрый фильтр назначения
80    $(".fast-filter input").on("change", function (e) {
81        e.preventDefault();
82        var dataId = $(this).data("id");
83        $("#" + dataId).click();
84        //$("#modef a").click();
85        var parentLi = $(this).parent();
86        if (parentLi.hasClass("active")) {
87            parentLi.removeClass("active");
88        } else {
89            parentLi.addClass("active");
90        }
91        setTimeout(function () {
92            $("#set_filter").click();
93        }, 1500);
94    });
95
96    // смена сортировки
97    $(".change-sort-catalog a").on("click", function (e) {
98        e.preventDefault();
99        var request = {};
100        rAction = "change-sort";
101        rType = $(this).data("type");
102        rSort = $(this).data("sort");
103        rMobile = $(this).data("mobile");
104
105        request = {
106            action: rAction,
107            type: rType,
108            sort: rSort,
109            mobile: rMobile,
110        }
111        getRequest(request, function () {
112            if (response.result) {
113                console.log(response);
114                location.reload();
115            } else {
116                if (response.error_text != false) {
117                    alert(response.error_text);
118                } else {
119                    console.log("Что-то пошло не по плану :)");
120                }
121            }
122        });
123    });
124
125    // смена кол-ва элементов на странице
126    $(".change-page-size-catalog a").on("click", function (e) {
127        e.preventDefault();
128        var request = {};
129        rAction = "change-page-size";
130        rValue = $(this).data("value");
131
132        request = {
133            action: rAction,
134            value: rValue,
135        }
136        getRequest(request, function () {
137            if (response.result) {
138                console.log(response);
139                location.reload();
140            } else {
141                if (response.error_text != false) {
142                    alert(response.error_text);
143                } else {
144                    console.log("Что-то пошло не по плану :)");
145                }
146            }
147        });
148    });
149
150    // alert add to cart
151    function alertMsg(msg, status) {
152        var id = new Date().getTime();
153        $('.alert-div').append('<div id="alert' + id + '" class="alert alert-' + status + ' alert-dismissible" role="alert">' + msg + '</div>');
154
155        setTimeout(function () {
156            $('#alert' + id).remove();
157        }, 2000);
158    }
159
160    function animCart() {
161        alertMsg('Добавлено в корзину', 'success');
162    }
163
164    $("body").prepend('<div class="alert-div"></div>');
165
166    $(document).on('click', '.shop-product-item__btn', function () {
167        animCart();
168    });
169
170
171    if (jQuery.fn.inputmask) {
172        $('input[name="ORDER_PROP_3"]').inputmask({"mask": "+7 (999) 999-9999", showMaskOnHover: false,});
173    }
174
175
176    /*timer*/
177    function convertTZ(date, tzString) {
178        return new Date((typeof date === "string" ? new Date(date) : date).toLocaleString("en-US", {timeZone: tzString}));
179    }
180
181    function makeTimerMainPage(el) {
182
183        var attrDate = el.attr('data-date-time');
184        var endTime = new Date(attrDate);
185        var endTime = convertTZ(endTime, 'Europe/Moscow');
186        var endTime = (Date.parse(endTime)) / 1000;
187
188        var now = new Date();
189        var now = convertTZ(now, 'Europe/Moscow');
190        var now = (Date.parse(now) / 1000);
191
192        var timeLeft = endTime - now;
193
194        var days = Math.floor(timeLeft / 86400);
195        var hours = Math.floor((timeLeft - (days * 86400)) / 3600);
196
197        var minutes = Math.floor((timeLeft - (days * 86400) - (hours * 3600)) / 60);
198        var seconds = Math.floor((timeLeft - (days * 86400) - (hours * 3600) - (minutes * 60)));
199
200        if (days < "10") {
201            days = "0" + days;
202        }
203        if (hours < "10") {
204            hours = "0" + hours;
205        }
206        if (minutes < "10") {
207            minutes = "0" + minutes;
208        }
209        if (seconds < "10") {
210            seconds = "0" + seconds;
211        }
212
213        if (timeLeft < 0) {
214            days = '00';
215            hours = '00';
216            minutes = '00';
217            seconds = '00';
218        }
219
220        el.find('.htt-item__days .htt-num b').html(days);
221        el.find('.htt-item__hours .htt-num b').html(hours);
222        el.find('.htt-item__minutes .htt-num b').html(minutes);
223        el.find('.htt-item__seconds .htt-num b').html(seconds);
224
225        // $("#timer #days").html("<b>" + days + "</b>" + "<span>дней</span>");
226        // $("#timer #hours").html("<b>" + hours + "</b>" + "<span>часов</span>");
227        // $("#timer #minutes").html("<b>" + minutes + "</b>" +"<span>минут</span>");
228        // $("#timer #seconds").html("<b>" + seconds + "</b>" + "<span>секунд</span>");
229
230    }
231
232
233    function textTimer(el) {
234        var attrDate = el.attr('data-date-time');
235        var endTime = new Date(attrDate);
236        var endTime = convertTZ(endTime, 'Europe/Moscow');
237        var endTime = (Date.parse(endTime)) / 1000;
238
239        var now = new Date();
240        var now = convertTZ(now, 'Europe/Moscow');
241        var now = (Date.parse(now) / 1000);
242
243        var timeLeft = endTime - now;
244
245        // var hours = Math.floor(timeLeft / 3600);
246        // var minutes = Math.floor((timeLeft - (hours * 3600)) / 60);
247        // var seconds = Math.floor((timeLeft - (hours * 3600) - (minutes * 60)));
248
249        var days = Math.floor(timeLeft / 86400);
250        var hours = Math.floor((timeLeft - (days * 86400)) / 3600);
251
252        var minutes = Math.floor((timeLeft - (days * 86400) - (hours * 3600)) / 60);
253        var seconds = Math.floor((timeLeft - (days * 86400) - (hours * 3600) - (minutes * 60)));
254
255        // if (days < "10") {
256        // 	days = "0" + days;
257        // }
258        // if (hours < "10") {
259        // 	hours = "0" + hours;
260        // }
261        // if (minutes < "10") {
262        // 	minutes = "0" + minutes;
263        // }
264        // if (seconds < "10") {
265        // 	seconds = "0" + seconds;
266        // }
267
268        if (timeLeft < 0) {
269            days = '0'
270            hours = '0';
271            minutes = '0';
272            seconds = '0';
273        }
274
275        el.html(days + 'д. ' + hours + 'ч. ' + minutes + 'мин.');
276    }
277
278
279    // setInterval(function() {
280    // 	makeTimerMainPage();
281    // }, 1000);
282
283    setInterval(function () {
284        $('.hit-item-timer__timer .htt-item').each(function (index, el) {
285            console.log(el);
286            makeTimerMainPage($(el));
287        });
288    }, 1000);
289    setInterval(function () {
290        $('.lk-auc-timer__timer').each(function (index, el) {
291            textTimer($(el));
292        });
293    }, 1000);
294
295    /*endtimer*/
296
297
298});
299

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.