PageSourceSearch

https://kolesa-kzn.ru/wp-content/mu-plugins/modules/cookie-consent/assets/promo/promo.js?ver=0.7.235

js kolesa-kzn.ru collected 2026-10-08 12:19:56 UTC 2,892 bytes, 102 lines download raw bytes

1/* global jQuery */
2(function ($) {
3    'use strict';
4
5    $(document).ready(function () {
6        const modal = $('#mu-promo-modal');
7        if (!modal.length) {
8            return;
9        }
10
11        const closeBtn = modal.find('.mu-promo-modal__close');
12        const copyBtn = modal.find('.promo-code-text');
13
14        /**
15         * Проверяем, нужно ли показывать промо
16         */
17        function shouldShowPromo() {
18            const urlParams = new URLSearchParams(window.location.search);
19
20            if (urlParams.get('utm_source') === 'promo') {
21                return true;
22            }
23
24            try {
25                return sessionStorage.getItem('utm_sourceCode') === 'promo';
26            } catch (e) {
27                return false;
28            }
29        }
30
31        if (!shouldShowPromo()) {
32            return;
33        }
34
35        /**
36         * Показ модалки с задержкой
37         */
38        setTimeout(function () {
39            modal.fadeIn(300);
40        }, 1000);
41
42        /**
43         * Закрытие по клику
44         */
45        closeBtn.on('click', function () {
46            modal.fadeOut(300);
47        });
48
49        /**
50         * Закрытие по ESC
51         */
52        $(document).on('keydown', function (e) {
53            if (e.key === 'Escape' && modal.is(':visible')) {
54                modal.fadeOut(300);
55            }
56        });
57
58        /**
59         * Копирование промокода
60         */
61        copyBtn.on('click', function () {
62            const $this = $(this);
63            const promoCode = $this.data('code');
64            const originalText = $this.text();
65
66            function showCopied() {
67                $this.text('скопировано');
68                setTimeout(function () {
69                    $this.text(originalText);
70                }, 1000);
71            }
72
73            if (navigator.clipboard && navigator.clipboard.writeText) {
74                navigator.clipboard.writeText(promoCode)
75                    .then(showCopied)
76                    .catch(fallbackCopy);
77            } else {
78                fallbackCopy();
79            }
80
81            function fallbackCopy() {
82                const textArea = document.createElement('textarea');
83                textArea.value = promoCode;
84                document.body.appendChild(textArea);
85                textArea.select();
86
87                try {
88                    document.execCommand('copy');
89                    showCopied();
90                } catch (err) {
91                    alert(
92                        'Не удалось скопировать промокод. ' +
93                        'Скопируйте вручную: ' + promoCode
94                    );
95                }
96
97                document.body.removeChild(textArea);
98            }
99        });
100    });
101
102})(jQuery);

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.