PageSourceSearch

https://snoufa.ru/public/assets/js/compare.js?v=6ac7164059ad9

js snoufa.ru collected 2026-10-09 18:34:59 UTC 6,122 bytes, 170 lines download raw bytes

1"use strict";
2
3function getArrayFromCookieByName(a, b) {
4    var c = new RegExp("".concat(a, "\\=(.*)")),
5        d = c.exec(document.cookie);
6    return null != d && 0 < d[1].length && (d = d[1].split(";"), void 0 !== d[0]) ? d[0].split(b) : []
7}
8
9$(document).ready(function() {
10    initCompareButtons();
11    setCompareCount();
12    SetHeightCompareBlock();
13    SetHeightComparePartBlock();
14    $(window).on('resize', function(){
15        SetHeightCompareBlock();
16        SetHeightComparePartBlock();
17    });
18    var slideCount = $('.slick-slide').length;
19    var slideHideCount = 0;
20    $(".delete-compare").click(function(){
21        $('#compareslider').slick('slickRemove', $(this).closest(".slick-slide").hide());
22        $(this).closest(".slick-slide").addClass('d-none-slider');
23        $('#compareslider').slick('slickRemove', $(this).closest(".slick-slide").index(this) - 1);
24        slideHideCount = $('.d-none-slider').length;
25        compareClick(this);
26        if (slideCount == slideHideCount) {
27            window.location.href = "/compare/";
28        }
29    });
30    $("#clearCompare").click(function(){
31        $.cookie("compare_offers", null);
32        window.location.href = "/compare/";
33    });
34    $('.showdiff').click(function() {
35        if(this.checked){
36            //ShowCompareDiff();
37            $(document).find(".notEqual").each(function() {
38                $(this).hide();
39            });
40            SetHeightComparePartBlock();
41            $('#pill1').prop('checked', true);
42            $('#pill2').prop('checked', true);
43        } 
44        
45        else{
46            $(document).find(".notEqual").each(function() {
47                $(this).show();
48            });
49            SetHeightComparePartBlock();
50            $('#pill1').prop('checked', false);
51            $('#pill2').prop('checked', false);
52        }
53    });
54});
55
56
57//
58function initCompareButtons() {
59    var a = getArrayFromCookieByName("compare_offers", "%2C");
60    $("*[data-button=\"compare\"]").each(function() {
61        a.includes($(this).attr("data-product-id")) ? $(this).find(".compare-text").text("В сравнении").addClass('in-compare').closest('.btn-add-compare').find('i').addClass('in-compare-i') : $(this).find(".compare-text").text("Добавить в сравнение").removeClass('in-compare').closest('.btn-add-compare').find('i').removeClass('in-compare-i'), $(this).unbind("click"), $(this).bind("click", function() {
62            return compareClick(this);
63        }), $(this).unbind("focusout"), $(this).bind("focusout", function() {
64            return $(this).tooltip("hide");
65        })
66    })
67}
68//
69function compareClick(a) {
70    var b = $(a).attr("data-product-id");
71    return $.ajax({
72        url: "/json.php?compare=toogle",
73        method: "POST",
74        dataType: "json",
75        data: "product_id=" + b,
76        beforeSend: function beforeSend() {
77            $("*[data-toggle-custom=\"tooltip\"]").each(function() {
78                $(this).tooltip("dispose")
79            })
80        },
81        success: function success(b) {
82            1 == b.code && ("undefined" != typeof window.ym, $(a).attr("data-toggle", "tooltip"), $(a).attr("data-toggle-custom", "tooltip"), $(a).attr("data-template", "<div class=\"tooltip tooltip-white\" role=\"tooltip\"><div class=\"arrow arrow-white\"></div><div class=\"tooltip-inner tooltip-inner-white\"></div></div>"), $(a).attr("data-trigger", "focus"), $(a).attr("data-placement", "bottom"), $(a).attr("data-html", "true"), $(a).attr("title", b.message), $(a).tooltip("show"))
83            setCompareCount();
84            if ($(a).attr('data-original-title').indexOf('Товар добавлен')!==-1)
85            {
86                $(a).find(".compare-text").text("В сравнении");
87                $(a).find(".compare-text").addClass('in-compare');
88                $(a).find("i").addClass('in-compare');
89            }
90            else
91            {
92                $(a).find(".compare-text").text("Добавить в сравнение");
93            }
94            if($('.d-none-slider').length === $(".slick-slide").length)window.location.href = '/compare/';
95        },
96        error: function error(a) {
97            console.error(a.responseText)
98        },
99        complete: function complete() {
100            initCompareButtons()
101        }
102    }), !1
103}
104function setCompareCount()
105{
106    var a = getArrayFromCookieByName("compare_offers", "%2C");
107    if(a.length<=0)$("#compare_count").hide();
108    if(a.length<=0)$("#mobile-compare-count").hide();
109    else {
110        $("#compare_count").show();
111        $("#compare_count").html(a.length);
112        $("#mobile-compare-count").html(a.length);
113        $("#mobile-compare-count").show();
114    }
115}
116
117function SetHeightCompareBlock()
118{
119    var column = 0;
120    $(".tovar-block").removeAttr('style');
121    $('.tovar-block').each(function(){
122        var h = $(this).height();
123        if (h > column) {
124            column = h;
125        }
126    });
127    $('.tovar-block').each(function(){$(this).height(column);});
128}
129function SetHeightComparePartBlock()
130{
131    var column = 0;
132    $(".part").removeAttr('style');
133    $('.part').each(function(){
134        var h = $(this).height();
135        if (h > column) {
136            column = h;
137        }
138    });
139}
140function ShowCompareDiff()
141{
142    var diff_prop = [];
143    $(".part").each(function (e){
144        var buff=[];
145        $(this).find(".mat-text").each(function() {
146            buff.push($(this).text())
147        });
148        diff_prop.push(buff);
149    });
150    if(diff_prop.length<=1)return;
151    for(var prop=0;prop<diff_prop[0].length;prop++)
152    {
153        var is_hide=false;
154        var comp="";
155        for(var tovar=0;tovar<diff_prop.length;tovar++)
156        {
157            if(comp.length === 0) comp = diff_prop[tovar][prop].trim();
158            else
159            {
160                if(comp.trim() !== diff_prop[tovar][prop].trim())
161                {
162                    is_hide=true;
163                    break;
164                }
165            }
166        }
167        if(!is_hide)$( "div[ data-prop-index='" + prop + "']" ).hide();
168    }
169    $(".showdiff").attr('checked','checked');
170}

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.