PageSourceSearch

https://arctic-bear.ru/design/default/js/js.js?1791469189

js arctic-bear.ru collected 2026-10-08 14:20:02 UTC 39,750 bytes, 1,167 lines download raw bytes

1/*
2 * https://swiperjs.com/demos#responsive-breakpoints
3 * https://arcticlab.ru/arcticmodal/#desc
4 * https://russianblogs.com/article/46822548529/
5 * https://viivue.github.io/fancybox/#images
6 * https://codepen.io/fancyapps/pen/jwNNZJ
7 * http://zoltantothcom.github.io/vanilla-js-tabs/
8 *
9 *
10 */
11
12$(document).ready(function(){
13
14    var window_width = window.innerWidth;
15
16    $(document).on('click', '.js-specific-header', function(e){
17        e.preventDefault();
18        $(this).parents('.js-specific').toggleClass('open');
19    });
20    
21    $("a.js-scroll").click(function(){
22        let href = $(this).attr("href");
23        if (href.includes("#")) {
24            if($(href).length){
25                $('html, body').animate({
26                    scrollTop: $(href).offset().top
27                }, 1000);
28                return false;
29            }
30        }
31    });
32
33    $(".js-site-menu a").click(function(){
34        let href = $(this).attr("href");
35        if (href.includes("#")) {
36            if($(href).length){
37                $('html, body').animate({
38                    scrollTop: $(href).offset().top
39                }, 1000);
40                return false;
41            }
42        }
43    });
44
45    $(document).on('click', '.js-language-select', function(e){
46        e.preventDefault();
47        $(this).parents('.js-language').toggleClass('open');
48    });
49
50    if($("[data-fancybox]").length){
51        $("[data-fancybox]").fancybox({
52            protect: true
53        });
54    }
55    if($(".js-phone-mask").length){
56        $(".js-phone-mask").mask("+7 (999) 999-99-99");
57    }
58
59    $(".js-products-item-thumbs-nav > div").hover(function(){
60        
61        $(this).parents(".js-products-item-thumbs-nav").find("div").removeClass("active");
62        $(this).addClass("active");
63        
64        var image = $(this).data("image");
65        var number = $(this).data("number");
66        if(image){
67            if(number >= 0){
68                $(this).parents(".js-products-item-thumbs").find(".js-products-item-thumbs").find("div[class *= js-thumb-]").removeClass("active");
69                var d_image = $(this).parents(".js-products-item-thumbs").find(".js-products-item-thumbs").find(".js-thumb-"+number).find("img").attr("src");  
70                if(image != d_image){
71                    $(this).parents(".js-products-item-thumbs").find(".js-products-item-thumbs").find(".js-thumb-"+number).find("img").attr("src", image);
72                }
73                $(this).parents(".js-products-item-thumbs").find(".js-products-item-thumbs").find(".js-thumb-"+number).addClass("active");       
74            }
75        }
76        
77    });
78    
79    $(".js-product-item-variants input[name=variant]").change(function(){
80        
81        $(this).parents(".js-product-item-variants").find("label").removeClass("active");
82        $(this).parents("label").addClass("active");
83        
84        var sku = $(this).data("sku");
85        var price = $(this).data("price");
86        var old_price = $(this).data("old-price");
87        var stock = $(this).data("stock");
88        
89        $(this).parents(".js-product-item").find(".js-product-price").text(number_format(price, 0, '.', ' '));
90        
91        if(old_price != 0){
92            $(this).parents(".js-product-item").find(".js-product-old-price").text(number_format(old_price, 0, '.', ' '));
93            $(this).parents(".js-product-item").find(".js-product-old-price-wrap").show();
94            $(this).parents(".js-product-item").find(".js-product-sale").show();
95        }else{
96            $(this).parents(".js-product-item").find(".js-product-old-price-wrap").hide();
97            $(this).parents(".js-product-item").find(".js-product-sale").hide();
98        }
99        
100        $(this).parents(".js-product-item").find(".js-product-sku").text(sku);
101        
102        if(stock === "" || parseInt(stock) > 0){
103            $(this).parents(".js-product-item").find(".js-product-status").removeClass("status--green").removeClass("status--red").addClass("status--green");
104            $(this).parents(".js-product-item").find(".js-product-item-buy").show();
105            $(this).parents(".js-product-item").find(".js-product-item-learn").hide();
106            if(parseInt(stock) > 0){
107                $(this).parents(".js-product-item").find(".js-counter input[name=quantity]").attr("data-stock", stock);
108            }else{
109                $(this).parents(".js-product-item").find(".js-counter input[name=quantity]").attr("data-stock", "NULL");
110            }
111        }else{
112            $(this).parents(".js-product-item").find(".js-product-status").removeClass("status--green").removeClass("status--red").addClass("status--red");
113            $(this).parents(".js-product-item").find(".js-product-item-buy").hide();
114            $(this).parents(".js-product-item").find(".js-product-item-learn").show();
115            $(this).parents(".js-product-item").find(".js-counter input[name=quantity]").attr("data-stock", 0);
116        }
117        
118    });
119    
120    $(document).on('change', '.js-counter-cart input[name=quantity]', function(){
121        var amount = $(this).parents(".js-counter").find("input[name=quantity]").val()*1;
122        var stock = $(this).parents(".js-counter").find("input[name=quantity]").attr("data-stock");
123        
124        if(amount <= 0){amount = 1;}
125        
126        $(this).parents(".js-counter").find("input[name=quantity]").val(amount);
127        
128        var url = window.location.href;
129        if (url.indexOf("/cart/") >= 0){
130            var idv = $(this).parents(".js-counter").find("input[name=quantity]").data('idv');
131            if(idv){
132                $.ajax({
133                    url: "/ajax/ajax.php",
134                    type: "POST",
135                    data: {
136                        type: 'cart',
137                        action: 'upd',
138                        idv: idv,
139                        quantity: amount
140                    },
141                    success: function(answer){
142                        if(answer == 'true'){
143                            window.location.reload();
144                        }
145                    },
146                    error: function(){
147                        alert('error');
148                    }
149                });
150            }
151        }
152        
153    });
154    
155    $(document).on('click', '.js-counter .minus, .js-counter .plus', function(){
156        var amount = $(this).parents(".js-counter").find("input[name=quantity]").val()*1;
157        var stock = $(this).parents(".js-counter").find("input[name=quantity]").attr("data-stock");
158        var type = $(this).data("type");
159        
160        if(type == "plus"){
161            if(stock != "NULL"){
162                if(stock*1 < amount + 1){
163                    var n_amount = amount;
164                }else{
165                    var n_amount = amount + 1;
166                }
167            }else{
168                var n_amount = amount + 1;
169            }
170        }else if(type == "minus"){
171            n_amount = amount-1;
172            if(n_amount <= 0){n_amount = 1;}
173        }
174        
175        $(this).parents(".js-counter").find("input[name=quantity]").val(n_amount);
176        
177        var url = window.location.href;
178        if (url.indexOf("/cart/") >= 0){
179            var idv = $(this).parents(".js-counter").find("input[name=quantity]").data('idv');
180            if(idv){
181                $.ajax({
182                    url: "/ajax/ajax.php",
183                    type: "POST",
184                    data: {
185                        type: 'cart',
186                        action: 'upd',
187                        idv: idv,
188                        quantity: n_amount
189                    },
190                    success: function(answer){
191                        if(answer == 'true'){
192                            window.location.reload();
193                        }
194                    },
195                    error: function(){
196                        alert('error');
197                    }
198                });
199            }
200        }
201        
202    });
203
204    $("#js-header-burger").click(function(){
205        var d = $(".js-site-menu").css("display");
206        if(d == "none"){
207            $(".js-site-menu").show();
208        }else{
209            $(".js-site-menu").hide();
210        }
211        return false;
212    });
213
214    $("#js-filter-burger").click(function(){
215        $(".js-filter").addClass("open");
216        $("body").addClass("blackout");
217        return false;
218    });
219
220    $(".js-filter-close").click(function(){
221        $(".js-filter").removeClass("open");
222        $("body").removeClass("blackout");
223        return false;
224    });
225
226    $(".js-site-menu > li > a").click(function (){
227        if($(this).next("ul").length > 0){
228            var d = $(this).next("ul").css("display");
229            if(d == "none"){
230                $(this).next("ul").slideDown();
231            }else{
232                $(this).next("ul").slideUp();
233            }
234            return false;
235        }
236    });
237
238    $(".js-categories-btn").click(function (){
239        var d = $(".js-categories-dropdown").css("display");
240        if(d == "none"){
241            $(".js-categories-dropdown").slideDown();
242        }else{
243            $(".js-categories-dropdown").slideUp();
244        }
245        return false;
246    });
247
248    if(window_width < 992) {
249        $(".js-footer-data-menu .footer-data-h1").click(function () {
250            var d = $(this).next("ul").css("display");
251            if (d == "none") {
252                $(this).next("ul").slideDown();
253            } else {
254                $(this).next("ul").slideUp();
255            }
256        });
257    }
258
259    $("#sharing").click(function (){
260        $(this).parents(".js-sharing").toggleClass("active");
261    });
262
263    $(document).on('mouseenter', '.js-comment-rating-item', function(){
264		$(this).removeClass('rating--empty');
265		var	index = $(this).index();
266		var	message = $(this).data('text');
267
268		$(this).siblings().each(function(){
269			var svg = $(this);
270			$(this).index() < index ? svg.removeClass('rating--empty') : svg.addClass('rating--empty');
271		});
272		$(this).closest('.js-comment-rating').find('.js-rating-text').text(message);
273	});
274    $(document).on('mouseleave', '.js-comment-rating-item', function(){
275		var	index = $(this).data('rating');
276		var ratingText = $(this).closest('.js-comment-rating').find('.js-rating-text');
277		var message = ratingText.data('text');
278
279		$(this).find('.js-comment-rating-item').each(function(){
280			var svg = $(this);
281			$(this).index() < index ? svg.removeClass('rating--empty') : svg.addClass('rating--empty');
282		});
283		ratingText.text(message);
284	});
285    $(document).on('click', '.js-comment-rating-item', function(){
286		var	rating = $(this).closest('.js-comment-rating');
287		var	value = $(this).index() + 1;
288		var	message = $(this).data('text');
289		rating.data('rating', value).find('.js-rating-input').val(value);
290		rating.find('.js-rating-text').data('text', message);
291	});
292    
293    $('.js-faq-list').click(function(){
294        $(this).toggleClass('open');
295    });
296    
297    $(document).on('submit', '.js-coupon', function(e){
298        
299        e.preventDefault();
300        
301        var coupon = $(this).find('input[name=coupon]').val();
302        
303        if(coupon != ''){
304            $.ajax({
305                url: "/ajax/ajax.php",
306                type: "POST",
307                data: {
308                    type: 'coupon',
309                    action: 'add',
310                    coupon: coupon
311                },
312                success: function(answer){
313                    if(answer == 'true'){
314                        window.location.reload();
315                    }
316                },
317                error: function(){
318                    alert('error');
319                }
320            });
321        }
322        
323    });
324    
325    // WSort
326    $('.js-sort').change(function(){
327        var sort = $(this).val();
328        $.ajax({
329            url: "/ajax/ajax.php",
330            type: "POST",
331            data: {type: 'sort', sort: sort},
332            success: function(answer){
333                if(answer == 'true'){
334                    window.location.reload();
335                }
336            },
337            error: function(){
338                alert('error');
339            }
340        });
341    });
342    // ---------
343    
344    // WView
345    $('.js-view').click(function(){
346        var view = $(this).data('view');
347        $.ajax({
348            url: "/ajax/ajax.php",
349            type: "POST",
350            data: {type: 'view', view: view},
351            success: function(answer){
352                if(answer == 'true'){
353                    window.location.reload();
354                }
355            },
356            error: function(){
357                alert('error');
358            }
359        });
360    });
361    // ---------
362    
363    // WComments
364    $(document).on('click', '.js-comments-btn', function(){
365        $('body, html').animate({scrollTop: $('.js-comments-form').offset().top}, 1000);
366    });
367    $(document).on('submit', '.js-comments-form form', function(e){
368        
369        e.preventDefault();
370        
371        var form = $(this);
372        
373        form.prepend('<i class="loader"></i>');
374        
375        var json_arr = {};
376        json_arr['data'] = form.serializeArray();
377        
378        var json_string = JSON.stringify(json_arr);
379        
380        $('.js-comments-tree').append('<div class="js-comment-load"></div>').ready(function(){
381            $('.js-comments-tree .js-comment-load:last').load("/app/widgets/WComments.php", {dataType: "json", data: json_string}, function(){
382                $('body, html').animate({scrollTop: $(this).offset().top - 20}, 1000);
383                form.find("i.loader").remove();
384                form.find("[name=comment]").val("");
385            });
386        });
387        
388    });
389    $(document).on('click', '.js-comment-parent-btn', function(e){
390        
391        e.preventDefault();
392        
393        var parent = $(this).data("parent");
394        
395        $('.js-comments-clone').find('input[name=parent]').val(parent);
396        var clone = $('.js-comments-clone > div').clone(true);
397        
398        $(this).closest('.js-comment-footer').after(clone);
399        
400    });
401    $(document).on('submit', '.js-comments-parent-form form', function(e){
402        
403        e.preventDefault();
404        
405        var form = $(this);
406        
407        form.prepend('<i class="loader"></i>');
408        
409        var json_arr = {};
410        json_arr['data'] = form.serializeArray();
411        
412        var json_string = JSON.stringify(json_arr);
413        
414        form.closest('.js-comments-parent-form').prepend('<div class="js-comment-parent-load"></div>').ready(function(){
415            
416            form.closest('.js-comments-parent-form').find('.js-comment-parent-load:last').load("/app/widgets/WComments.php", {dataType: "json", data: json_string}, function(){
417                $('body, html').animate({scrollTop: $(this).offset().top - 20}, 1000);
418                form.find("i.loader").remove();
419                form.remove();
420            });
421            
422        });
423        
424    });
425    // ---------
426    
427    // WFilter
428    $(document).on('click', '.js-w-filter-item-header', function(){
429        var d = $(this).parents('.js-w-filter-item').find('.js-w-filter-item-body').css("display");
430        if (d == "none") {
431            $(this).parents('.js-w-filter-item').find('.js-w-filter-item-body').slideDown();
432        } else {
433            $(this).parents('.js-w-filter-item').find('.js-w-filter-item-body').slide
433Up();
434        }
435    });
436    
437    $(".js-filter input[type=checkbox]").change(function(){
438        $(this).parents(".js-filter").find("form").submit();
439    });
440    
441    if($(".js-filter").length){
442        if($(".js-filter input[type=checkbox]:checked").length){
443            $(".js-filter input[type=checkbox]:checked").each(function(){
444                var d = $(this).parents('.js-w-filter-item-body').css("display");
445                if (d == "none") {
446                    $(this).parents('.js-w-filter-item-body').slideDown();
447                }
448            });
449        }
450    }
451    
452    if($(".js-from-to").length){
453        $(".js-from-to").each(function(){
454           
455            var id = $(this).data("id");
456            var range = document.getElementById('js-range-from-to-'+id);
457            var inputMin = document.getElementById('js-min-from-to-'+id);
458            var inputMax = document.getElementById('js-max-from-to-'+id);
459            
460            var rangeMin = $(this).data("from");
461            var rangeMax = $(this).data("to");
462            
463            var rangeMinGet = $(this).data("from-get");
464            var rangeMaxGet = $(this).data("to-get");
465                        
466            const inputs = [inputMin, inputMax];
467            
468            noUiSlider.create(range, {
469                start: [rangeMinGet, rangeMaxGet],
470                connect: true,
471                range: {
472                    'min': rangeMin,
473                    'max': rangeMax
474                },
475                step: 1
476                }
477            )
478           
479            range.noUiSlider.on('update', function (values, handle) {
480                inputs[handle].value = parseInt(values[handle]);
481            });
482           
483            range.noUiSlider.on('change', function (values, handle) {
484                if(handle == 0) {
485                    if (rangeMin == inputs[handle].value) {
486                        inputs[handle].disabled = true;
487                    } else {
488                        inputs[handle].disabled = false;
489                    }
490                }else if(handle == 1) {
491                    if (rangeMax == inputs[handle].value) {
492                        inputs[handle].disabled = true;
493                    } else {
494                        inputs[handle].disabled = false;
495                    }
496                }
497                $(".js-filter").find("form").submit();
498            });
499            
500            inputMin.addEventListener('change', function () {
501                range.noUiSlider.set([this.value, null]);
502                $(".js-filter").find("form").submit();
503            });
504            
505            inputMax.addEventListener('change', function () {
506                range.noUiSlider.set([null, this.value]);
507                $(".js-filter").find("form").submit();
508            });
509           
510        });
511    }
512    
513    
514    $(document).on('submit', '.js-filter form', function(e){
515        e.preventDefault();
516        
517        var action = $('.js-filter form').attr("action");
518        
519        var result = {};
520    	var data = $('.js-filter form').serializeArray();
521    
522        $.each(data, function(i, feature) {
523            var name = feature.name.replace(/\[.*?\]/g, '');
524    		if(result[name] == undefined){
525    			result[name] = [];
526            }                
527    		result[name].push(feature.value);
528    	});
529    
530    
531    	var params = [];
532    	$.each(result, function(name, values) {
533    		var str = name+'-is-'+values.join('-or-');
534    		params.push(str);
535    	});
536        
537    	var url = params.length > 0 ? ''+params.join('-and-')+'/' : '';
538    	
539        window.location.href = action+url;
540        
541        return false;
542        
543    });
544    // ---------
545    
546    // WCompare
547    $(document).on('click', '.js-product-add-compare', function(e) {
548        
549        var id = $(this).data('product-id');
550        
551        var btn = $(this);
552        
553        $.ajax({
554            url: "/ajax/ajax.php",
555            type: "POST",
556            data: {
557                type: 'compare',
558                action: 'add',
559                id: id
560            },
561            success: function(answer){
562                if(answer == 'true'){
563                    if($("#notice").length == 0){
564                        $("body").append('<div id="notice"></div>')
565                    }
566                    if($("#notice").length > 0){
567                        
568                        var json_arr = {};
569                        json_arr['action'] = "notice";
570                        json_arr['id'] = id;
571                                                
572                        var json_string = JSON.stringify(json_arr);
573                        
574                        $("#notice").load("/app/widgets/WCompare.php", {dataType: "json", data: json_string}, function(){
575                            
576                            btn.removeClass("js-product-add-compare").addClass("js-product-del-compare").addClass("active");
577                            
578                            json_arr['action'] = "label";
579                            var json_string = JSON.stringify(json_arr);
580                            
581                            $(".js-compare-label").load("/app/widgets/WCompare.php", {dataType: "json", data: json_string});
582                            
583                        });
584                        
585                    }
586                }
587            },
588            error: function(){
589                alert('error');
590            }
591        });
592        
593    });
594    $(document).on('click', '.js-product-del-compare', function(e) {
595        
596        var id = $(this).data('product-id');
597        
598        var btn = $(this);
599        
600        $.ajax({
601            url: "/ajax/ajax.php",
602            type: "POST",
603            data: {
604                type: 'compare',
605                action: 'delete',
606                id: id
607            },
608            success: function(answer){
609                if(answer == 'true'){
610                    
611                    var json_arr = {};
612                    json_arr['action'] = "label";
613                                            
614                    var json_string = JSON.stringify(json_arr);
615                    
616                    $(".js-compare-label").load("/app/widgets/WCompare.php", {dataType: "json", data: json_string}, function(){
617                        
618                        btn.removeClass("js-product-del-compare").removeClass("active").addClass("js-product-add-compare");
619                        
620                        var url = window.location.href;
621                        if (url.indexOf("/compare/") >= 0){
622                            window.location.reload();
623                        }
624                        
625                    });
626                    
627                }
628            },
629            error: function(){
630                alert('error');
631            }
632        });
633        
634    });
635    // ---------
636    
637    // WWishlist
638    $(document).on('click', '.js-product-add-wishlist', function(e) {
639        
640        var id = $(this).data('product-id');
641        
642        var btn = $(this);
643        
644        $.ajax({
645            url: "/ajax/ajax.php",
646            type: "POST",
647            data: {
648                type: 'wishlist',
649                action: 'add',
650                id: id
651            },
652            success: function(answer){
653                if(answer == 'true'){
654                    if($("#notice").length == 0){
655                        $("body").append('<div id="notice"></div>')
656                    }
657                    if($("#notice").length > 0){
658                        
659                        var json_arr = {};
660                        json_arr['action'] = "notice";
661                        json_arr['id'] = id;
662                                                
663                        var json_string = JSON.stringify(json_arr);
664                        
665                        $("#notice").load("/app/widgets/WWishlist.php", {dataType: "json", data: json_string}, function(){
666                            
667                            btn.removeClass("js-product-add-wishlist").addClass("js-product-del-wishlist").addClass("active");
668                            
669                            json_arr['action'] = "label";
670                            var json_string = JSON.stringify(json_arr);
671                            
672                            $(".js-wishlist-label").load("/app/widgets/WWishlist.php", {dataType: "json", data: json_string});
673                            
674                        });
675                        
676                    }
677                }
678            },
679            error: function(){
680                alert('error');
681            }
682        });
683        
684    });
685    $(document).on('click', '.js-product-del-wishlist', function(e) {
686        
687        var id = $(this).data('product-id');
688        
689        var btn = $(this);
690        
691        $.ajax({
692            url: "/ajax/ajax.php",
693            type: "POST",
694            data: {
695                type: 'wishlist',
696                action: 'delete',
697                id: id
698            },
699            success: function(answer){
700                if(answer == 'true'){
701                    
702                    var json_arr = {};
703                    json_arr['action'] = "label";
704                                            
705                    var json_string = JSON.stringify(json_arr);
706                    
707                    $(".js-wishlist-label").load("/app/widgets/WWishlist.php", {dataType: "json", data: json_string}, function(){
708                        
709                        btn.removeClass("js-product-del-wishlist").removeClass("active").addClass("js-product-add-wishlist");
710                        
711                        var url = window.location.href;
712                        if (url.indexOf("/wishlist/") >= 0){
713                            window.location.reload();
714                        }
715                        
716                    });
717                    
718                }
719            },
720            error: function(){
721                alert('error');
722            }
723        });
724        
725    });    
726    $(document).on('click', '.js-notice-closer', function() {
727        $(this).closest("#notice").fadeOut(300, function(){
728            $(this).remove();
729        });
730    });
731    // ---------
732    
733    // WOffers
734    $(document).on('click', '.js-offers-btn', function() {
735        
736        var offers = $(this).data("offers");
737        
738        $('.js-offers-btn').removeClass('btn-active');
739        $(this).addClass('btn-active');
740        
741        $('.js-index-offers-products').removeClass('active');
742        $('.js-index-offers-'+offers).addClass('active');
743        
744    });
745    // ---------
746    
747    // WKp
748    $(document).on('click', '.js-kp-request', function(e) {
749        
750        e.preventDefault();
751        
752        var btn = $(this);
753        var lang = $('body').data('lang');
754        
755        var json_arr = {};
756        json_arr['action'] = "view";
757        json_arr['idv'] = btn.data("idv");
758        
759        var json_string = JSON.stringify(json_arr);
760        
761        $("#js-kp-modal").arcticmodal({
762            afterOpen: function() {
763                $("#js-kp-modal").find(".js-phone-mask").mask("+7 (999) 999-99-99");
764            }
765        }).find(".js-box-modal-load").load("/app/widgets/WKp.php", {dataType: "json", data: json_string, lang: lang});
766        
767    });
768    $(document).on('submit', '.js-kp-form form', function(e) {
769        
770        e.preventDefault();
771        
772        var iss = 0;
773        
774        var form = $(this);
775        var lang = $('body').data('lang');
776        
777        var json_arr = {};
778        json_arr['data'] = form.serializeArray();
779        json_arr['action'] = "send";
780        
781        var idv = form.find('input[name=idv]').val();
782        var inn = form.find('input[name=inn]').val();
783        
784        if(inn){
785            checkInnByDadata(inn).then(company => {
786              if (company) {
787                //console.log('Найдено:', company.value);
788                //console.log('ИНН:', company.data.inn);
789                
790                json_arr['data'].push({
791                  name: 'company',
792                  value: company.value.replace(/"/g, '')
793                });
794                
795                var json_string = JSON.stringify(json_arr);
796                
797                form.parents('.js-kp-form').find('.js-kp-load').html('<i class="loader"></i>').load("/app/widgets/WKp.php", {dataType: "json", data: json_string, lang: lang}, function(){
798                    if(form.parents('.js-kp-form').find('.js-kp-load').find("div[class*=-success]").length > 0){
799                        setTimeout(function () {
800                            window.open('/api/pdf.php?idv='+idv, '_blank');
801                        }, 1000);
802                    }
803                    form.parents('.js-kp-form').find("form").trigger('reset');
804                });
805              } else {
806                alert('Компания не найдена');
807              }
808            }).catch(err => {
809              alert('Ошибка при проверке ИНН');
810            });
811        }else{
812            
813            var json_string = JSON.stringify(json_arr);
814            
815            form.parents('.js-kp-form').find('.js-kp-load').html('<i class="loader"></i>').load("/app/widgets/WKp.php", {dataType: "json", data: json_string, lang: lang}, function(){
816                if(form.parents('.js-kp-form').find('.js-kp-load').find("div[class*=-success]").length > 0){
817                    setTimeout(function () {
818                        window.open('/api/pdf.php?idv='+idv, '_blank');
819                    }, 1000);
820                }
821                form.parents('.js-kp-form').find("form").trigger('reset');
822            });
823        }
824        
825    });
826    
827    async function checkInnByDadata(inn) {
828      const API_KEY = '0aa3065e9576b69b63d5ce572d963203b29bd68e'; // ← ваш ключ
829    
830      const response = await fetch('https://suggestions.dadata.ru/suggestions/api/4_1/rs/findById/party', {
831        method: 'POST',
832        mode: 'cors',
833        headers: {
834          'Content-Type': 'application/json; charset=utf-8',
835          'Accept': 'application/json',
836          'Authorization': `Token ${API_KEY}`
837        },
838        body: JSON.stringify({
839          query: inn
840        })
841      });
842    
843      if (!response.ok) {
844        throw new Error(`HTTP error! status: ${response.status}`);
845      }
846    
847      const result = await response.json();
848      return result.suggestions[0] || null;
849    }
850            
851    // WFeedback
852    $(document).on('click', '.js-feedback-btn', function(e) {
853        
854        e.preventDefault();
855        
856        var btn = $(this);
857        var lang = $('body').data('lang');
858        
859        var json_arr = {};
860        json_arr['action'] = "view";
861        json_arr['template'] = btn.data("template");
862        json_arr['title'] = btn.data("title");
863        
864        var json_string = JSON.stringify(json_arr);
865        
866        $("#js-feedback-modal").arcticmodal({
867            afterOpen: function() {
868                $("#js-feedback-modal").find(".js-phone-mask").mask("+7 (999) 999-99-99");
869            }
870        }).find(".js-box-modal-load").load("/app/widgets/WFeedback.php", {dataType: "json", data: json_string, lang: lang});
871        
872    });
873    $(document).on('submit', '.js-feedback-form form', function(e) {
874        
875        e.preventDefault();
876        
877        var form = $(this);
878        var lang = $('body').data('lang');
879        
880        var json_arr = {};
881        json_arr['data'] = form.serializeArray();
882        json_arr['action'] = "send";
883        
884        var json_string = JSON.stringify(json_arr);
885        
886        form.parents('.js-feedback-form').find('.js-feedback-load').html('<i class="loader"></i>').load("/app/widgets/WFeedback.php", {dataType: "json", data: json_string, lang: lang}, function(){
887            setTimeout(function () {
888                form.parents('.js-feedback-form').find('.js-feedback-load').find("div[class*=alert-]").fadeOut(500);
889            }, 3000);
890            form.parents('.js-feedback-form').find("form").trigger('reset');
891        });
892        
893    });
894    // ---------
895    
896    // WForm
897    $(document).on('submit', '.js-contact-form form', function(e) {
898        
899        e.preventDefault();
900        
901        var form = $(this);
902        
903   
903     var json_arr = {};
904        json_arr['data'] = form.serializeArray();
905        json_arr['action'] = "send";
906        
907        var json_string = JSON.stringify(json_arr);
908        
909        form.parents('.js-contact-form').find('.js-contact-load').html('<i class="loader"></i>').load("/app/widgets/WForm.php", {dataType: "json", data: json_string}, function(){
910            setTimeout(function () {
911                form.parents('.js-contact-form').find('.js-contact-load').find("div[class*=alert-]").fadeOut(500);
912            }, 3000);
913            form.parents('.js-contact-form').find("form").trigger('reset');
914        });
915        
916    });
917    // ---------
918    
919    // WSubscriber
920    $(document).on('submit', '.js-subscription form', function(e) {
921        
922        e.preventDefault();
923        
924        var form = $(this);
925        
926        var json_arr = {};
927        json_arr['email'] = form.find("input[name=email]").val();
928        
929        var json_string = JSON.stringify(json_arr);
930        
931        form.parents('.js-subscription').addClass("sending-data");
932        form.parents('.js-subscription').find('.js-subscriber-load').load("/app/widgets/WSubscriber.php", {dataType: "json", data: json_string}, function(){
933            setTimeout(function () {
934                form.parents(".js-subscription").find(".js-subscriber-load").find("div[class*=alert-]").fadeOut(500);
935            }, 3000);
936            form.parents('.js-subscription').removeClass("sending-data");
937            form.parents('.js-subscription').find("form").trigger('reset');
938        });
939        
940        
941    });
942    // ---------
943    
944    // WMenu
945    $(document).on('click', '.js-multi-accordion li > a', function (event) {
946    	
947        var $this = $(this), $next = $this.next();
948        
949        $('.js-multi-accordion li > a').removeClass('active');
950        
951        if ($next.length) {
952            if ($next.is(':visible')) {
953                $next.slideToggle(function () {
954                    $next.find('ul').toggle(false);
955                });
956            } else {
957                $next.slideToggle().parent().siblings().find('ul').filter(':visible').slideToggle();
958                $this.addClass('active');
959            }
960            
961            event.preventDefault();
962        }
963        
964    });
965    // ---------
966    
967    // WCart
968    $(document).on('submit', '.js-add-cart', function(e) {
969        e.preventDefault();
970        
971        var idv = $(this).find('input[type="radio"][name *= variant]:checked').val();
972        var quantity = $(this).find('input[type="text"][name *= quantity]').val();
973        if(isNaN(quantity)){quantity = 1;}
974        
975        $.ajax({
976            url: "/ajax/ajax.php",
977            type: "POST",
978            data: {
979                type: 'cart',
980                action: 'add',
981                idv: idv,
982                quantity: quantity
983            },
984            success: function(answer){
985                if(answer == 'true'){
986                    if($("#notice").length == 0){
987                        $("body").append('<div id="notice"></div>')
988                    }
989                    if($("#notice").length > 0){
990                        
991                        var json_arr = {};
992                        json_arr['action'] = "notice";
993                        json_arr['idv'] = idv;
994                                                
995                        var json_string = JSON.stringify(json_arr);
996                        
997                        $("#notice").load("/app/widgets/WCart.php", {dataType: "json", data: json_string}, function(){
998                            
999                            json_arr['action'] = "label";
1000                            var json_string = JSON.stringify(json_arr);
1001                            
1002                            $(".js-basket-label").load("/app/widgets/WCart.php", {dataType: "json", data: json_string}, function(){
1003                                $(".js-basket-mobile-label").load("/app/widgets/WCart.php", {dataType: "json", data: json_string});
1004                            });
1005                            
1006                        });
1007                        
1008                    }
1009                }
1010            },
1011            error: function(){
1012                alert('error');
1013            }
1014        });
1015        
1016    });
1017    // ---------
1018
1019    // WDelivery
1020    $('.js-delivery').change(function(){
1021        var id = $(this).val();
1022        $.ajax({
1023            url: "/ajax/ajax.php",
1024            type: "POST",
1025            data: {type: 'delivery', action: 'add', id: id},
1026            success: function(answer){
1027                if(answer == 'true'){
1028                    window.location.reload();
1029                }
1030            },
1031            error: function(){
1032                alert('error');
1033            }
1034        });
1035    });
1036    // ---------
1037    
1038    // WPayments
1039    $('.js-payment').change(function(){
1040        var id = $(this).val();
1041        $.ajax({
1042            url: "/ajax/ajax.php",
1043            type: "POST",
1044            data: {type: 'payment', action: 'add', id: id},
1045            success: function(answer){
1046                
1047            },
1048            error: function(){
1049                alert('error');
1050            }
1051        });
1052    });
1053    // ---------
1054    
1055    // WOneClick
1056    $(document).on('click', '.js-one-click-btn', function(e) {
1057        
1058        e.preventDefault();
1059        
1060        var idv = $(this).parents('form').find('input[type="radio"][name *= variant]:checked').val();
1061
1062        var json_arr = {};
1063        json_arr['action'] = "view";
1064        json_arr['idv'] = $(this).parents('form').find('input[type="radio"][name *= variant]:checked').val();
1065        
1066        var json_string = JSON.stringify(json_arr);
1067        
1068        $("#js-one-click-modal").arcticmodal({
1069            afterOpen: function() {
1070                $("#js-one-click-modal").find(".js-phone-mask").mask("+7 (999) 999-99-99");
1071            }
1072        }).find(".js-box-modal-load").load("/app/widgets/WOneClick.php", {dataType: "json", data: json_string});
1073        
1074    });
1075    $(document).on('submit', '.js-one-click-form form', function(e) {
1076        
1077        e.preventDefault();
1078        
1079        var form = $(this);
1080        
1081        var json_arr = {};
1082        json_arr['data'] = form.serializeArray();
1083        json_arr['action'] = "send";
1084        
1085        var json_string = JSON.stringify(json_arr);
1086        
1087        form.parents('.js-one-click-form').find('.js-one-click-load').html('<i class="loader"></i>').load("/app/widgets/WOneClick.php", {dataType: "json", data: json_string}, function(){
1088            setTimeout(function () {
1089                if(form.parents('.js-one-click-form').find('.js-one-click-load').find(".alert-danger").length){
1090                    form.parents('.js-one-click-form').find('.js-one-click-load').find(".alert-danger").fadeOut(500);
1091                }
1092            }, 3000);
1093            form.parents('.js-one-click-form').find("form").trigger('reset');
1094        });
1095        
1096    });
1097    // ---------
1098    
1099    
1100    
1101    
1102    
1103    
1104    
1105
1106});
1107
1108
1109function number_format (number, decimals, dec_point, thousands_sep) {
1110    // Strip all characters but numerical ones.
1111    number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
1112    var n = !isFinite(+number) ? 0 : +number,
1113        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
1114        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
1115        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
1116        s = '',
1117        toFixedFix = function (n, prec) {
1118            var k = Math.pow(10, prec);
1119            return '' + Math.round(n * k) / k;
1120        };
1121    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
1122    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
1123    if (s[0].length > 3) {
1124        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
1125    }
1126    if ((s[1] || '').length < prec) {
1127        s[1] = s[1] || '';
1128        s[1] += new Array(prec - s[1].length + 1).join('0');
1129    }
1130    return s.join(dec);
1131}
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167

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.