PageSourceSearch

https://rostec.ru/local/templates/rostec2/assets/local/jquery.add.js?171656577320201

js rostec.ru collected 2026-09-24 08:24:15 UTC 20,201 bytes, 622 lines download raw bytes

1var offersInBasket = new Array();
2// дебаг JS битрикса
3window.BXDEBUG = true;
4var sended_urls = [];
5sended_urls.push(window.location.pathname);
6
7/**
8 * Для работы с композитом
9 */
10if (window.frameCacheVars !== undefined) {
11    BX.addCustomEvent("onFrameDataReceived", function (json) {
12        Working();
13    });
14} else {
15    BX.ready(function () {
16        Working();
17    });
18}
19
20function Working() {
21    initSorted();
22    initGlobal();
23    initUserActions();
24    initCookie();
25}
26
27// предупреждение куки
28function initCookie() {
29    if ($('[data-use-cookies]').length) {
30        $(document).on('click', '[data-use-cookies] [data-close]', function () {
31            $.get("/local/tools/.ajax/empty.php?use-cookies=Y");
32            $('[data-use-cookies]').hide();
33        });
34    }
35}
36
37function initSorted() {
38    if (!$('[data-recycling-box]').length) {
39        return;
40    }
41
42    var currentDate = new Date(),
43        currentDateString = '',
44        sec = currentDate.getSeconds(),
45        min = currentDate.getMinutes(),
46        hours = currentDate.getHours(),
47        day = currentDate.getDate(),
48        month = currentDate.getMonth();
49
50    month ++;
51    if (day < 10) {
52        day = '0' + day;
53    }
54    if (month < 10) {
55        month = '0' + month;
56    }
57    if (hours < 10) {
58        hours = '0' + hours;
59    }
60    if (min < 10) {
61        min = '0' + min;
62    }
63    if (sec < 10) {
64        sec = '0' + sec;
65    }
66
67    currentDateString = day + "." + month + "." + currentDate.getFullYear() + " " + hours + ":" + min + ":" + sec + "";
68
69    var json = {
70        "start-date": "18.10.2019 12:00",
71        "calculate-date": "01.09.2020 00:00",
72        "current-date": currentDateString,
73        "sorted": {
74            "paper": "6000000",
75            "plastic": "18000000",
76            "metal": "5500000",
77            "glass": "9500000"
78        },
79        "performance": {
80            "paper": "0.46",
81            "plastic": "1.38",
82            "metal": "0.42",
83            "glass": "0.72"
84        },
85        "make": {
86            "paper": {
87                "toilet-paper": "4",
88                "notepads": "6"
89            },
90            "plastic": {
91                "benches": "1/80",
92                "t-shirts": "1/0.42",
93                "kid-s-playground": "1/100"
94            },
95            "metal": {
96                "bicycles": "1/15",
97                "aluminum-cans": "1/0.015"
98            },
99            "glass": {
100                "christmas-toy": "6",
101                "glass-wool": "1/28"
102            }
103        }
104    };
105    var $box = $('[data-recycling-box]'),
106        sorted = {
107            paper: Number(json['sorted']['paper']),
108            plastic: Number(json['sorted']['plastic']),
109            metal: Number(json['sorted']['metal']),
110            glass: Number(json['sorted']['glass'])
111        },
112        performance = {
113            paper: Number(json['performance']['paper']),
114            plastic: Number(json['performance']['plastic']),
115            metal: Number(json['performance']['metal']),
116            glass: Number(json['performance']['glass'])
117        },
118        make = {
119            paper: json['make']['paper'],
120            plastic: json['make']['plastic'],
121            metal: json['make']['metal'],
122            glass: json['make']['glass']
123        },
124        startDate = toTimeStamp(json['start-date']),
125        calculateDate = toTimeStamp(json['calculate-date']),
126        currentDate = toTimeStamp(json['current-date']);
127
128    $.each(sorted, function (key, value) {
129
130        $item = $box.find('[data-item-value][data-sorted="' + key + '"]');
131        value += parseInt((currentDate - calculateDate) / 1000) * performance[key]; // Отсортировано с последнего учёта
132        $item.text(formatInt(Math.round((value + 5 * performance[key])))); // 5 секунда анимации, после которой запустим таймер
133
134        $.each(make[key], function (subkey, subvalue) {
135            var valueArr = subvalue.split('/'),
136                v = 0;
137            if (valueArr.length === 2) {
138                v = value * (valueArr[0] / valueArr[1]);
139            } else {
140                v = value * valueArr[0];
141            }
142            $box.find('[data-recycling-product-list] [data-make="' + subkey + '"]').text(formatInt(Math.round(v)));
143        })
144    });
145
146    function toTimeStamp(str) {
147        var arr = str.split('.');
148        var date = {
149            year: arr[2].split(' ')[0],
150            month: addZero(arr[1]),
151            day: addZero(arr[0]),
152            time: arr[2].split(' ')[1] || '00:00'
153        }
154
155        function addZero(substr) {
156            if (substr.length < 2) {
157                substr = '0' + substr;
158            }
159            return substr
160        }
161
162        return Date.parse(date.year + '-' + date.month + '-' + date.day + 'T' + date.time);
163    }
164}
165
166function initGlobal() {
167
168    if ($('.c-tabs').length) {
169        $('.c-tabs__nav_toggle a').on('click', function (e) {
170            e.preventDefault();
171            $(this).parent().toggleClass('opened');
172            $('.c-tabs__list').toggleClass('minimized');
173        });
174
175        var tabsContainer = $('.c-tabs');
176        var nav = $('.c-tabs__nav_fx');
177        var wrap = $('.c-tabs__nav_wrap');
178
179        function fixSidebar() {
180            var scl = $(window).scrollTop();
181
182            if ($(window).scrollTop() >= $('.c-tabs__nav').offset().top - 70) {
183                nav.css({
184                    left: wrap.offset().left,
185                    width: wrap.width()
186                });
187                nav.addClass('fixed').toggleClass('bottom', scl >= tabsContainer.offset().top + tabsContainer.height() - nav.height() - 30);
188                wrap.css({
189                    height: nav.height()
190                });
191            } else {
192                nav.removeClass('fixed');
193                nav.css({
194                    left: '',
195                    width: ''
196                });
197                wrap.css({
198                    height: ''
199                });
200            }
201        }
202
203        $(window).on('scroll resize', fixSidebar);
204
205        // $('.c-tabs__list li').eq(0).addClass('active');
206        // $('.c-tabs__tab').eq(0).addClass('active');
207
208        // $('.c-tabs__list li a').on('click', function (e) {
209        //     e.preventDefault();
210        //
211        //     $('.c-tabs__nav_toggle .active_text').text($(this).text());
212        //
213        //     $('.c-tabs__list li.active').removeClass('active');
214        //     $(this).parent().addClass('active');
215        //
216        //     var id = $(this).attr('href');
217        //
218        //     $('.c-tabs__tab.active').removeClass('active');
219        //     $(id).addClass('active');
220        //
221        //     $('.c-tabs__nav_toggle a').trigger('click');
222        //
223        //     $('html, body').animate({
224        //         scrollTop: $('.c-tabs__nav').offset().top - 80
225        //     }, 500, 'swing');
226        // });
227    }
228
229
230    var $ajaxBox = $('body'), $boxAutoLoad = $('[data-end-load]'), $loadProcess = false;
231
232    $('.doc-list').owlCarousel({
233        nav: true,
234        dots: false,
235        loop: false,
236        autoplay: false,
237        mouseDrag: false,
238        touchDrag: true,
239        responsiveClass: true,
240        responsive: {
241            0: {
242                items: 1,
243            },
244            600: {
245                items: 2,
246            },
247            1000: {
248                items: 3,
249            }
250        }
251    });
252
253
254    if ($boxAutoLoad.length > 0) {
255        $(window).on('load', function () {
256            $boxAutoLoad.each(function () {
257                SetAutoLoadElement($(this));
258            });
259        });
260    }
261	
262	function initGalleryContentSlider() {
263		var galleryContentSlider = new Swiper(".js-gallery-content-slider", {
264		  slidesPerView: 1,
265		  effect: "fade",
266		  loop: true,
267		  spaceBetween: 30,
268		  speed: 800,
269		  autoplay: {
270			delay: 5000,
271			disableOnInteraction: false
272		  },
273		  navigation: {
274			nextEl: ".swiper-button-next",
275			prevEl: ".swiper-button-prev"
276		  },
277		  pagination: {
278			el: ".swiper-pagination",
279			clickable: true,
280			renderBullet: function renderBullet(index, className) {
281			  return '<span class="' + className + '">' + '<span></span>' + '</span>';
282			}
283		  }
284		});
285    }
286
287    function SetAutoLoadElement($el) {
288        var $endBlock = $el.offset().top + $el.actual('height');
289
290        $(window).scroll(function () {
291            var $scroll = $(window).scrollTop() + $(window).height();
292            if ($(window).scrollTop() >= $el.offset().top && $(window).scrollTop() < $endBlock && window.location.pathname != $el.data('this-url')) {
293                history.pushState('', '', $el.data('this-url'));
294
295                if (!sended_urls.includes($el.data('this-url'))) {
296                    sended_urls.push($el.data('this-url'));
297                    // google
298                    if (typeof ga === 'function') {
299                        ga('set', 'page', $el.data('this-url'));
300                        ga('send', 'pageview');
301                        setTimeout("ga('send', 'event', 'read', '15_seconds')", 15000);
302                    }
303                    // yandex
304                    if (typeof yaCounter22587163 != 'undefined' && yaCounter22587163 !== false) {
305                        yaCounter22587163.hit($el.data('this-url'));
306                    }
307                    // ym(22587163, 'hit', 'https://rostec.ru'+$el.data('this-url'));
308                }
309            }
310            if ($scroll >= $endBlock - 300 && $el.data('success') != 'Y' && !$loadProcess) {
311                var $cache = $el.data('cache-box'),
312                    _ajax = $ajaxBox.data('ajax')
313
314                if (_ajax) {
315                    _ajax.abort();
316                }
317                $loadProcess = true;
318                _ajax = $.ajax({
319                    url: $el.data("load-url"),
320                    type: "GET",
321                    data: {
322                        ajax: "Y",
323                    },
324                    beforeSend: function () {
325                        $('.media-news-detailed:last-child .result-search__preloader').css('opacity', '1');
326                    },
327                }).done(function (data) {
328                    $el.after(data).data("success", "Y");
329                    $loadProcess = false;
330                    SetAutoLoadElement($("[data-end-load]").last());
331                    if ($(".js-gallery-content-slider").length) {
332                        initGalleryContentSlider();
333                    }
334                    $('.media-news-detailed .result-search__preloader').css('opacity', '0');
335                    setTimeout(function () {
336                        var sScrollContainer =
337                            document.querySelectorAll(".ss-container");
338
339                        for (
340                            var i = 0, len = sScrollContainer.length;
341                            i < len;
342                            i++
343                        ) {
344                            SimpleScrollbar.initEl(sScrollContainer[i]);
345                        }
346                    }, 700);
347                    
348                });
349                $ajaxBox.data('ajax', _ajax);
350            }
351        });
352    }
353
354
355    $(document).on('click', '[data-link]', function () {
356        if ($(this).data('link') != '') {
357            document.location.href = $(this).data('link');
358        }
359    });
360
361    $(document).on('click', '[data-box-ajax] [data-btn-ajax-load]', function () {
362        var $url = $(this).data('url-load'), $params = $(this).data('params'), $loadBox = $(this).data('load-box'),
363            $page = $(this).data('page'), $thisBtn = $(this);
364
365        var _ajax = $ajaxBox.data('ajax');
366        if (_ajax) {
367            _ajax.abort();
368        }
369        _ajax = $.ajax({
370            url: $url, type: "GET", data: {
371                ajax: 'Y'
372            }
373        }).done(function (data) {
374            var $items = $(data).find('#' + $loadBox + ' [data-box-items]').html(),
375                $btn = $(data).find('#' + $loadBox + ' [data-btn-ajax-load]');
376            $('body').find('#' + $loadBox + ' [data-box-items]').append($items);
377            if ($btn.length > 0) {
378                $thisBtn.data('url-load', $btn.data('url-load'));
379            } else {
380                $thisBtn.parent().remove();
381            }
382            sliderCategory('.news-slider');
383        });
384        $ajaxBox.data('ajax', _ajax);
385
386        return false;
387    });
388}
389
390function initUserActions() {
391    var ajaxPath = '/local/tools/.ajax/user.php';
392    /**
393     * Подписка
394     */
395    $(document).on('click', '#form-subscribe .btn', function () {
396        var _ajax = $('#form-subscribe').data('ajax');
397        if (_ajax) {
398            _ajax.abort();
399        }
400        _ajax = $.ajax({
401            url: ajaxPath, type: "POST", data: {
402                mail: $('#form-subscribe input[name=EMAIL]').val(), action: 'addSubscribe'
403            }
404        }).done(function (data) {
405            if (data == 'ok') {
406                getMessage("Вы успешно подписаны на рассылку.", "message", 5000);
407            } else if (data == 'not') {
408                getMessage("Ошибка, подписаться на рассылку не удалось. Проверьте правильность ввода E-mail.", "error", 5000);
409            } else if (data == 'double') {
410                getMessage("Вы уже подписывались на рассылку ранее.", "message", 5000);
411            }
412        });
413        $('#form-subscribe').data('ajax', _ajax);
414        return false;
415    });
416}
417
418/**
419 * Склонение окончаний существительных
420 * @param $type
421 * @constructor
422 */
423function DeclensionEnding($type) {
424    var $countWord = $type.split(' ');
425    if ($countWord.length == 1 && ($type.substr($type.length - 1, 1) == "а")) {
426        $type = $type.substr(0, $type.length - 1) + 'у';
427    } else if ($countWord.length > 1) {
428        $.each($countWord, function (key, value) {
429            if ((value.substr(value.length - 1, 1) == "а")) {
430                $countWord[key] = value.substr(0, value.length - 1) + 'у';
431            } else if (value.substr(value.length - 2, 2) == "ая") {
432                $countWord[key] = value.substr(0, value.length - 2) + 'ую';
433            }
434        });
435        $type = $countWord.join(' ');
436    }
437    return $type;
438}
439
440/**
441 * Форматирование числа
442 * @param n
443 * @returns {string}
444 */
445function formatInt(n) {
446    return (n + "").split("").reverse().join("").replace(/(\d{3})/g, "$1 ").split("").reverse().join("").replace(/^ /, "");
447}
448
449/**
450 * Аналог функции in_array в PHP
451 * @param needle
452 * @param haystack
453 * @param strict
454 *
455 * @returns {boolean}
456 */
457function in_array(needle, haystack, strict) {   // Checks if a value exists in an array
458    var found = false, key, strict = !!strict;
459    for (key in haystack) {
460        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
461            found = true;
462            break;
463        }
464    }
465    return found;
466}
467
468/**
469 * Склонение слов
470 * @param num
471 * @param expressions
472 * @returns {*}
473 *
474 * Пример: declension(1, ['пользователь','пользователя','пользователей'])
475 */
476function declension(num, expressions) {
477    var result;
478    count = num % 100;
479    if (count >= 5 && count <= 20) {
480        result = expressions['2'];
481    } else {
482        count = count % 10;
483        if (count == 1) {
484            result = expressions['0'];
485        } else if (count >= 2 && count <= 4) {
486            result = expressions['1'];
487        } else {
488            result = expressions['2'];
489        }
490    }
491    return result;
492}
493
494/**
495 * Плагин склонения, пример
496 * @https://github.com/kalys/jquery.russian-declension
497 *
498 * $('.days').russian_declension();
499 * <div class="days" data-one="день" data-several="дня" data-many="дней">7</div>
500 * <div class="days" data-one="день" data-several="дня" data-many="дней">1</div>
501 * <div class="days" data-one="день" data-several="дня" data-many="дней">2</div
502 *
503 *
504 * $('span.guest').russian_declension({one: "гость", several:"гостя", many: "гостей"});
505 */
506(function ($, window, undefined) {
507
508    var pluginName = 'russian_declension', document = window.document, defaults = {
509        one: "", several: "", many: "", zero: ""
510    };
511
512    function Plugin(element, options) {
513        this.element = element;
514        this.options = $.extend({}, defaults, options);
515
516        this._defaults = defaults;
517        this._name = pluginName;
518
519        this.init();
520    }
521
522    Plugin.prototype.init = function () {
523        var title_keys = ['one', 'several', 'many'];
524        var titles = [];
525        for (i = 0; i <= 2; i++) {
526            if ($(this.element).data(title_keys[i])) {
527                titles.push($(this.element).data(title_keys[i]));
528            } else {
529                titles.push(this.options[title_keys[i]]);
530            }
531        }
532
533        var number = parseInt($(this.element).html());
534
535        if (!number) {
536            number = 0;
537        }
538
539        var zero_title = this.options['zero'] || $(this.element).data('zero');
540        var title = this.pluralize(number, titles);
541
542        if (number == 0 && zero_title) {
543            $(this.element).html(zero_title);
544        } else {
545            $(this.element).html(number + " " + title);
546        }
547    };
548
549    Plugin.prototype.pluralize = function (number, titles) {
550        var cases = [2, 0, 1, 1, 1, 2];
551        return titles[(number % 100 > 4 && number % 100 < 20) ? 2 : cases[(number % 10 < 5) ? number % 10 : 5]];
552    }
553
554    $.fn[pluginName] = function (options) {
555        return this.each(function () {
556            if (!$.data(this, 'plugin_' + pluginName)) {
557                $.data(this, 'plugin_' + pluginName, new Plugin(this, options));
558            }
559        });
560    };
561
562
563    $(window).on('load', function () {
564        $('[data-rudecle]').russian_declension()
565    });
566
567}(jQuery, window));
568
569
570Share = {
571    vkontakte: function (purl, ptitle, pimg, text) {
572        url = 'http://vkontakte.ru/share.php?';
573        url += 'url=' + encodeURIComponent(purl);
574        url += '&title=' + encodeURIComponent(ptitle);
575        url += '&description=' + encodeURIComponent(text);
576        url += '&image=' + encodeURIComponent(pimg);
577        url += '&noparse=true';
578        Share.popup(url);
579    }, odnoklassniki: function (purl, text) {
580        url = 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1';
581        url += '&st.comments=' + encodeURIComponent(text);
582        url += '&st._surl=' + encodeURIComponent(purl);
583        Share.popup(url);
584    }, facebook: function (purl, ptitle, pimg, text) {
585        url = 'http://www.facebook.com/sharer.php?s=100';
586        url += '&p[title]=' + encodeURIComponent(ptitle);
587        url += '&p[summary]=' + encodeURIComponent(text);
588        url += '&p[url]=' + encodeURIComponent(purl);
589        url += '&p[images][0]=' + encodeURIComponent(pimg);
590        Share.popup(url);
591    }, twitter: function (purl, ptitle) {
592        url = 'http://twitter.com/share?';
593        url += 'text=' + encodeURIComponent(ptitle);
594        url += '&url=' + encodeURIComponent(purl);
595        url += '&counturl=' + encodeURIComponent(purl);
596        Share.popup(url);
597    }, mailru: function (purl, ptitle, pimg, text) {
598        url = 'http://connect.mail.ru/share?';
599        url += 'url=' + encodeURIComponent(purl);
600        url += '&title=' + encodeURIComponent(ptitle);
601        url += '&description=' + encodeURIComponent(text);
602        url += '&imageurl=' + encodeURIComponent(pimg);
603        Share.popup(url)
604    },
605
606    popup: function (url) {
607        window.open(url, '', 'toolbar=0,status=0,width=626,height=436');
608    }
609};
610
611
612$.fn.toggleText = function () {
613    if (this.text() == $(this).data('before-text')) this.text($(this).data('after-text')); else this.text($(this).data('before-text'));
614    return this;
615};
616
617
618$.log = function (message) {
619    console.log(message);
620    // var $logger = $("#logger");
621    // $logger.html($logger.html() + "\n * " + message );
622}

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.