PageSourceSearch

https://xn--80aa1cdf.xn--p1ai/media/js/script.js?v=1791587409

js xn--80aa1cdf.xn--p1ai collected 2026-10-09 23:10:49 UTC 7,468 bytes, 251 lines download raw bytes

1$(function() {
2
3    compareWidget()
4    cartWidget()
5    wishlistWidget()
6
7    const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
8    const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
9
10    $('.change-mail').bind('copy', function () {
11        if(typeof ym === 'function'){
12            ym(96021684,'reachGoal', 'email_copy')
13        }
14        return true;
15    });
16    
17    // minus qty
18    $('body').on('click', '.js-btn-minus', function(e) {
19        e.preventDefault();
20
21        let input = $(this).next('.js-input-qty');
22        input.val(parseInt(input.val()) - 1);
23        input.trigger('change');
24    });
25
26    // plus qty
27    $('body').on('click', '.js-btn-plus', function(e) {
28        e.preventDefault();
29
30        let input = $(this).prev('.js-input-qty');
31        input.val(parseInt(input.val()) + 1);
32        input.trigger('change');
33    });
34
35    // change qty
36    $('body').on('change', '.js-input-qty', function(e) {
37        e.preventDefault();
38
39        let qty = parseInt($(this).val());
40
41        if (isNaN(qty) || qty < 1) {
42            return $(this).val(1);
43        }
44
45        $(this).val(qty);
46    });
47
48    $('.product-card, .navbottom').on('click', '[data-type="cart-add"]', function(e){
49        e.preventDefault()
50        
51        const that  = $(this)
52        const id    = that.data('id')
53        const qty   = 1 
54        
55        addToCart(that, id, qty)
56    })
57
58    $('.product-page').on('click', '[data-type="product-cart-add"]', function(e){
59        e.preventDefault()
60        
61        const that  = $(this)
62        const id    = that.data('id')
63        const qty   = $('.product-page').find('.js-input-qty').val()
64        
65        addToCart(that, id, qty)
66    })
67    
68    // change qty in cart and product
69    $('.product-page, .cart-qty').on('change', '.js-input-qty', function(e) {
70        e.preventDefault();
71
72        let id = $(this).data('id');
73        let qty = parseInt($(this).val());
74
75        if (isNaN(qty) || qty < 1) {
76            updateCart(id, 1)
77            return $(this).val(1);
78        }
79
80        $(this).val(qty);
81        updateCart(id, qty)
82    });
83    
84    $('.product-card, .product-page .first-screen, .navbottom').on('click', '[data-type="compare"]', function(e){
85        e.preventDefault()
86        
87        const that = $(this)
88        const id = that.data('id')
89        const action = that.hasClass('active') ? 'delete' : 'add'
90        
91        addToCompare(that, id, action)
92    })
93    
94    $('.compare-table').on('click', '.btn-compare-delete', function(e) {
95        e.preventDefault()
96
97        const id = $(this).data('id')
98        
99        $.get('/compare/delete/' + id, function(res){
100            compareTable(id, res.count)
101            compareWidget()
102        }, 'json')
103    })
104    
105    $('.product-card, .product-page .first-screen, .navbottom').on('click', '[data-type="wishlist"]', function(e){
106        e.preventDefault()
107        
108        const that = $(this)
109        const id = that.data('id')
110        const action = that.hasClass('active') ? 'delete' : 'add'
111        
112        addToWishlist(that, id, action)
113    })
114    
115    
116    
117    
118    
119    // global ajax
120    $(document).ajaxStart(function(){
121        $("#loader").show();
122    });
123    $(document).ajaxComplete(function(){
124        $("#loader").hide();
125    });
126    $(document).ajaxStop(function() {
127        $("#loader").hide();
128    });
129    $(document).ajaxError(function() {
130        $("#loader").hide();
131    });
132});
133
134async function cartWidget() {
135    let response = await fetch('/cart/widget', {method: 'POST'})
136    let cart = await response.json()
137    $('.cart-box').html(cart)
138}
139
140async function compareWidget() {
141    let response = await fetch('/compare/widget', {method: 'POST'})
142    let compare = await response.json()
143    $('.compare-box').html(compare)
144}
145
146async function wishlistWidget() {
147    let response = await fetch('/wishlist/widget', {method: 'POST'})
148    let compare = await response.json()
149    $('.wishlist-box').html(compare)
150}
151
152const addToCompare = (that, id, action) => {
153    $.get('/compare/' + action + '/' + id, function(res){
154        if (res.errors) {
155            showMsg(res.errors, 'danger')
156        }
157        else{
158            $('[data-id="'+id+'"][data-type="compare"]').toggleClass('active')
159            showMsg(res.success, 'success')
160            $('#compare-count-nav').text(res.count)
161            compareWidget()
162        }
163    }, 'json')
164}
165
166const compareTable = (id, count) => {
167    if ( ! count) {
168        $('.compare-page').html('<div class="compare-empty"><img src="/media/svg/compare.svg" alt="compare" class="compare-empty-icon"><p class="compare-empty-text">Нет товаров к сравнению</p><a href="/" class="compare-catalog-link">В каталог</a></div>');
169    }
170    else {
171        $('.compare-table td[data-id="' + id + '"], .compare-table th[data-id="' + id + '"]').hide(600, function(){
172            $(this).remove();
173        });
174    }
175}
176
177const addToWishlist = (that, id, action) => {
178    $.get('/wishlist/' + action + '/' + id, function(res){
179        if (res.errors) {
180            showMsg(res.errors, 'danger')
181        }
182        else{
183            $('[data-id="'+id+'"][data-type="wishlist"]').toggleClass('active')
184            showMsg(res.success, 'success')
185            wishlistWidget()
186            
187            $('#wish-count-nav').text(res.count)
188            
189            if ($(that).parents('.wishlist-page').length && action === 'delete') {
190                $(that).parents('.grid-products-item').hide(600, function(){
191                    $(this).remove()
192                    if ( ! res.count) {
193                        $('.wishlist-container').html('<div class="wishlist-empty"><img src="/media/svg/heart.svg" alt="wishlist" class="wishlist-empty-icon"><p class="wishlist-empty-text">Вы еще не добавили товары в Избранное</p><a href="/" class="wishlist-catalog-link">В каталог</a></div>');
194                    }
195                })
196            }
197        }
198    }, 'json')
199}
200
201const addToCart = (that, id, qty) => {
202    $.post('/cart/add', {
203        id, qty
204    }, function(res){
205        if (res.errors) {
206            showMsg(res.errors, 'danger')
207        }
208        else{
209            showMsg(res.success, 'success')
210            $('.cart-box i').attr('data-cart', res.qty)
211            $('.cart-box i').text(res.qty)
212            $('#cart-count-nav').text(res.qty)
213        }
214    }, 'json')
215}
216
217const updateCart = (id, qty) => {
218    $.post('/cart/update', {
219        id, qty
220    }, function(res){
221        if (res.errors) {
222            showMsg(res.errors, 'danger')
223        }
224        else{
225            $('.sum-prod' + id).text(res.sum_prod)
226            
227            $('.cart-total-qty').text(res.qty)
228            $('.cart-sum').text(res.sum)
229            $('#cart-count-nav').text(res.qty)
230        }
231        cartWidget()
232    }, 'json')
233}
234
235const showMsg = (msg, type) => {
236    $('.alert-danger').remove()
237
238    let msgStr = ''
239
240    $.each(msg, function(i, el){
241        msgStr += '<div>' + el + '</div>'
242    })
243
244    $('body').append('<div class="alert alert-js alert-' + type + ' alert-dismissible fade show mt-3" role="alert">
244' + msgStr + '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>');
245
246    setTimeout(function(){
247        $('.alert').eq(0).fadeOut('slow', function(){
248            $(this).remove()
249        })
250    }, 5000)
251}

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.