PageSourceSearch

https://intriganail.ru/mg-templates/mg-friend-mod/mg-plugins/p6-chd-show-more/js/script.js?rev=1767301493

js intriganail.ru collected 2026-09-24 12:54:27 UTC 6,492 bytes, 131 lines download raw bytes

1$(document).ready(function () {
2  $('body').on('click', '#chd-show-more-button', function(){
3    let page = location.search.match(/page=\d+/) ? location.search.match(/page=\d+/)[0].match(/\d+/) : 1;
4    getShowMoreItems(Number(page) + 1);
5   })
6})
7
8function getShowMoreItems(page) {
9    let pathName = $('form.filter-form').attr('action') ? $('form.filter-form').attr('action')  :location.pathname;
10    let locationParams = window.location.search.replace('?','').split('&')
11    .reduce(
12        function(p,e){
13            let a = e.split('=');
14            p[ decodeURIComponent(a[0])] = decodeURIComponent(a[1]);
15            return p;
16        },
17        {}
18    );
19
20    let uri = '';
21    if (location.origin) {
22      uri = location.origin + pathName;
23    } else {
24      uri = location.protocol + '//' + location.hostname + pathName;
25    }
26    
27    if(locationParams.type){
28      const type = locationParams.type;
29      uri+='?type=' + type + '&page=' + page;
30    }
31    let packedData = '';
32    if ($('#chd-show-more-button').data('filter') == true ) {
33      packedData = $('.filter-form').serialize();
34      packedData += '&filter=1&';
35    }
36    history.pushState({page: page}, null, uri + '?' + packedData + 'page=' + page);
37      $.ajax({
38        type: "GET",
39        url: uri,
40        data: packedData + 'page='+page,
41        dataType: 'html',
42        success: function(response) {
43          var showmore = $(response).find('#chd-show-more-button').html();
44          var paginator = $(response).find('.catalog__pagination .mg-pager').html();
45          var curclass = document.getElementById('chd-show-more-button').getAttribute('data-curclass');
46            var arrCurclasses = curclass.split(" ");
47            var curclasses = arrCurclasses.join(".");
48            var parentBlockClass = document.getElementById('chd-show-more-button').getAttribute('data-parent-class');
49            let addedProducts = $(response).find('.' + parentBlockClass + ' .' + curclasses);
50            $('.catalog__pagination .mg-pager').html(paginator);
51            if (addedProducts.length != 0) {
52              
53              addedProducts.each(function(i, elem) {
54                    // снова вешаем обработчики на варианты
55                    $(this).find('.c-variant__selected').on('click', function() {
56                      var $this = $(this).closest('.c-variant');
57                        $($this).toggleClass('c-variant--toggle');
58                        $($this).closest('.j-goods__item').siblings().find('.c-variant').removeClass('c-variant--toggle')
59                    });
60                    $(this).find('.c-variant__row').on('click', function() {
61                      var $this = $(this);
62                        var text = $(this).find('.c-variant__text').text();
63                        var selected = $(this).closest('.c-variant').find('.c-variant__selected__text');
64                        $(selected).empty();
65                        $(selected).text(text);
66                        $($this).closest('.c-variant').removeClass('c-variant--toggle');
67                        $($this).addClass('c-variant__row--active').siblings().removeClass('c-variant__row--active')
68                    });
69                    $(this).find('.c-variant__row').on('click', function() {
70                      var $this = $(this).closest('.c-variant').siblings('.buy-container');
71                        if ($(this).hasClass('c-variant__none')) {
72                            $($this).hide();
73                            $('.j-product__message').show()
74                        } else {
75                            $($this).show();
76                            $('.j-product__message').hide()
77                        }
78                    });
79                    $(this).find('.c-variant tr:not(.c-variant__none)').on('click', function() {
80                        $(response).find('.j-product__stock--out').addClass('j-product__stock--in').removeClass('j-product__stock--out').text('Есть в наличии')
81                    });
82                    $(this).find('.c-variant tr.c-variant__none').on('click', function() {
83                        $(response).find('.j-product__stock--in').addClass('j-product__stock--out').removeClass('j-product__stock--in').text('Нет в наличии')
84                    });
85                    $('.' + parentBlockClass + ' .' + curclasses + ':last').after($(this));
86                    clickOnVariants(elem);
87                });
88                
89            } else if ($('.' + parentBlockClass + ' .' + curclasses).length > 0) {
90              addedProducts.each(function(i, elem) {
91                    $('.' + parentBlockClass + ' .' + curclasses + ':last').after($(this));
92                    clickOnVariants(elem);
93                })
94                
95            }
96            const rating = $(".rateit");
97            if (rating.length > 0) {
98              rating.rateit();
99            }
100            if ($('.j-button').length > 0) {
101                $('.addToCart, .product-info, .refreshFilter, .filter-btn').addClass('j-button');
102            }
103
104
105          if (showmore) {
106            $('#chd-show-more-button').text(showmore);
107            $('#chd-show-more-button').data('page',page+1);
108            if (typeof mgrate != "undefined"){
109            mgrate.init();
110
111            }
112          } else {
113            $('.chd-show-more-button-wrapper').hide();
114          }
115        },
116      });
117    
118    // Функция кликает по цветам и размерам после добавления элемента на страницу
119    function clickOnVariants(elem) {
120      if (!elem.querySelector('.sizeMap-row')) return; // Если элемент не содержит цвето-размерной сетки, выходим из функции
121      if (elem.querySelector('.color.active')) return; // Если элемент уже имеет цвет, выходим из функции
122      const color = elem.querySelector('.color'); // находим первый цвет в вариантах элемента
123      const size = elem.querySelector('.size'); // находим первый размер в вариантах элемента
124      if (color !== null) {
125        color.classList.add('active'); // если есть цвет, окрашиваем его
126      }
127      if (size !== null) {
128        size.classList.add('active'); // если есть размер, окрашиваем его
129      }
130    }
131  }

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.