PageSourceSearch

https://cvetochka.ru/local/templates/2018/js/custom.js?16088900844858

js cvetochka.ru collected 2026-09-26 11:31:03 UTC 4,858 bytes, 145 lines download raw bytes

1function refreshBasket(urlParams) {
2    if (!urlParams) {
3        urlParams = {};
4    }
5
6    var queryString = '';
7
8    $.each(urlParams, function (key, value) {
9        if (queryString.length > 0) {
10            queryString += '&';
11        }
12
13        queryString += key + '=' + value;
14    });
15
16    $("article[data-role='cart']").load('/.ajax/refreshBasket.php?' + queryString, function () {
17        var count = parseInt($(this).find('#topTotalCount').text());
18
19        if (count > 0) {
20            $('#basketCount').show().text(count);
21        } else {
22            $('#basketCount').hide();
23        }
24    });
25}
26
27function refreshBasketCount() {
28    //ajax-запрос для получения данных корзины
29    $.ajax({
30        url: "/.ajax/getBasket.php",
31        dataType: 'json',
32        success: function (response) {
33            //обновляем количество
34
35            //десктоп шапка
36            response.COUNT > 0 ? $('#basketCount').show().text(response.COUNT) : $('#basketCount').hide();
37            //десктоп плавающая шапка
38            //$('#filterBasketCount').text(response.COUNT);
39            //корзина в сайдбаре
40            $('#topTotalCount').text(response.COUNT);
41            $('#topTotalSum').text(response.TOTAL_SUM);
42            $('#bottomTotalSum').text(response.TOTAL_SUM);
43            //оформление заказа
44            //$('#orderTopBasketCount').text(response.COUNT);
45            //$('#orderTopBasketSum').text(response.TOTAL_SUM);
46        }
47    });
48}
49
50function getOrderPayment(order_id, callback = function() {} ) {
51    if (typeof order_id != "undefined") {
52        $.ajax({
53            url: "/.ajax/orderPayment.php",
54            dataType: 'html',
55            data: {ORDER_ID: order_id},
56            success: function (response) {
57                $("article[data-role='pay-order'] .payment-form").append(response);
58                $("article .overlay-submit .btn").prop("disabled", false);
59
60                if( callback ) {
61                    callback();
62                }
63            }
64        });
65    }
66}
67
68$(document).ready(function () {
69    //функция - обновление количества и суммы в корзине
70    //refreshBasketCount();
71
72    $("article[data-role='cart']")
73        .on('click', '.ordercart-remove', function () {
74            var parent = $(this).parents('[data-role="cart-item"]');
75
76            dataLayer.push({
77                'event': 'removeFromCart',
78                'products': [{
79                    'id': parent.data('id'),
80                    'name': parent.data('name')
81                    //'sku': id,
82                }]
83            });
84
85            parent.addClass('-out');
86            //parent.trigger('cve.sendCartEvent', [$(this).data('href')]);
87            refreshBasket({'action': 'delete', 'id': parent.data('id')});
88        })
89        .on('click', '.count-btn', function () {
90            var parent = $(this).parents('[data-role="cart-item"]'),
91                itemId = parent.data('id'),
92                delta = $(this).hasClass('-add') ? 1 : -1,
93                currentQuantity = parseInt(parent.find('[data-count]').data('count')),
94                newQuantity = currentQuantity + delta,
95                params = {'BasketRefresh': 'Y'};
96
97            params['QUANTITY_' + itemId] = newQuantity;
98
99            if (newQuantity <= 0) {
100                return;
101            }
102
103            parent.find('[data-count]').text(newQuantity).attr('data-count', newQuantity);
104            //parent.trigger('cve.sendCartEvent', [window.location.pathname + '?QUANTITY_' + itemId + '=' + newQuantity]);
105            refreshBasket(params);
106        })
107    /*.on('cve.sendCartEvent', function(event, href, callback) {
108        if (!href) {
109            return;
110        }
111
112        $.ajax({
113            url: href,
114            dataType: 'json',
115            complete: function(response) {
116                //обновляем количество
117                refreshBasket();
118            }
119        });
120    })*/;
121
122    $('#select_category').on('change', function() {
123        let value = $(this).find('option:selected').val();
124        let path = document.location.pathname;
125        let get = document.location.search;
126        let getCat = get.split('category=');
127        if(getCat.length>1) {
128            getCat = getCat[1];
129            if(getCat.indexOf('&')>-1) {
130                getCat = getCat.split('&')[0];
131            }
132            get = get.replace('category='+getCat, '');
133            if(get == '?') get ='';
134            if(get[get.length-1]=='&')
135                get = get.substr(0, get.length-1);
136        }
137        if(value)
138            path = path+(get?get+"&category="+value:'?category='+value);
139        else 
140            path = path;
141        document.location.href = path;
142    });
143});
144
145

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.