PageSourceSearch

https://akkond.ru/bitrix/js/yandex.metrika/script.js?17804758866724

js akkond.ru collected 2026-10-02 06:27:00 UTC 6,724 bytes, 191 lines download raw bytes

1(function (){
2
3    if (typeof BX === 'undefined' || typeof BX.ajax === 'undefined' || window.ymecInited) {
4        return;
5    }
6
7    window.ymecInited = true;
8
9    let hasActiveRequest = false;
10
11
12    BX.ready(function(){
13        requestEcommerceActions(true);
14
15        if (typeof jQuery === 'function') {
16            jQuery(document).on('ajaxSuccess', function(r){
17                if (hasActions()) {
18                    requestEcommerceActions();
19                }
20            });
21        }
22
23
24
25        BX.addCustomEvent('onAjaxSuccess', function(oResponse, r2, r3){
26            //if (typeof oResponse !== 'undefined' && oResponse && !oResponse.ecActions && oResponse.status !== 'error') {
27                if (hasActions()) {
28                    if (typeof r2 !== 'undefined' && r2.url.indexOf('yandex_metrika') < 1) {
29                        requestEcommerceActions();
30                    }
31                }
32            //}
33        });
34
35        document.addEventListener("DOMContentLoaded", function() {
36            if (typeof jQuery === 'function') {
37                jQuery(document).on('shown.bs.modal', function (e) {
38                    let form = e.target.querySelector('form');
39
40                    if ((form !== undefined) && (form !== null)) {
41                        let counters = window.counters;
42                        for (var key in counters) {
43                            ym(counters[key], 'reachGoal', 'ym-open-leadform');
44                        }
45                    }
46                });
47            }
48
49            if (typeof $.magnificPopup === "object") {
50                $.magnificPopup.instance.open = function (data) {
51                    $.magnificPopup.proto.open.call(this, data);
52
53                    let form = $.magnificPopup.instance.wrap[0].querySelector('form');
54                    if ((form !== undefined) && (form !== null)) {
55                        let counters = window.counters;
56                        for (var key in counters) {
57                            ym(counters[key], 'reachGoal', 'ym-open-leadform');
58                        }
59                    }
60                };
61            }
62
63            if (typeof $.fancybox === 'object') {
64                $.fancybox.defaults.afterShow = function (fancy) {
65                    let form = fancy.$refs.container[0].querySelector('form');
66
67                    if ((form !== undefined) && (form !== null)) {
68                        let counters = window.counters;
69                        for (var key in counters) {
70                            ym(counters[key], 'reachGoal', 'ym-open-leadform');
71                        }
72                    }
73                };
74            }
75
76            if (typeof Fancybox === 'function') {
77                Fancybox.bind('[data-fancybox]', {
78                        on: {
79                            done: (fancybox, slide) => {
80                                let form = slide.$content.querySelector('form');
81
82                                if ((form !== undefined) && (form !== null)) {
83                                    let counters = window.counters;
84                                    for (var key in counters) {
85                                        ym(counters[key], 'reachGoal', 'ym-open-leadform');
86                                    }
87                                }
88                            }
89                        }
90                    }
91                );
92            };
93
94        });
95    });
96
97    function requestEcommerceActions(processInstant){
98        if (hasActiveRequest) {
99            return;
100        }
101
102        hasActiveRequest = true;
103        BX.ajax.runAction('yandex:metrika.yandex_metrika.Ajax.getEcommerceActions')
104            .then(function(oResponse) {
105                if (oResponse.status === 'success') {
106                    if (typeof oResponse.data.actions !== 'undefined') {
107                        const actions = oResponse.data.actions;
108                        const actionsIds = Object.keys(actions);
109                        if (processInstant) {
110                            processActions(actions);
111                            removeSentActions(actionsIds);
112                            hasActiveRequest = false;
113                        } else {
114                            setTimeout(function () {
115                                processActions(actions);
116                                removeSentActions(actionsIds);
117                                hasActiveRequest = false;
118                            }, 2000);
119                        }
120                    }
121                }
122
123                oResponse.ecActions = true;
124                return oResponse;
125            }, function (oResponse) {
126                oResponse.ecActions = true;
127                hasActiveRequest = false;
128                return oResponse;
129            });
130    }
131
132    function processActions(actions){
133        let formSended = false;
134
135        for (let id in actions) {
136
137            let action = actions[id];
138            if(Object.hasOwn(action, 'ecommerce'))
139                window[window.dataLayerName].push(action);
140            else {
141                if(formSended == false) {
142                    let counters = window.counters;
143                    for (var key in counters) {
144                        ym(counters[key], 'reachGoal', actions[id][0]);
145                    }
146                    formSended = true;
147                }
148            }
149        }
150    }
151
152    function removeSentActions(actionsIds){
153        BX.ajax.runAction('yandex:metrika.yandex_metrika.Ajax.removeEcommerceActions', {
154            data: {
155                'actionsIds': actionsIds
156            }
157        })
158            .then(function(oResponse) {
159                oResponse.ecActions = true;
160                return oResponse;
161            }, function (oResponse) {
162                oResponse.ecActions = true;
163                return oResponse;
164            });
165
166        BX.setCookie('ym_has_actions', '', {
167            expires: -1000,
168            path: '/'
169        });
170    }
171
172    function addAction(type){
173        BX.ajax.runAction('yandex:metrika.yandex_metrika.Ajax.addEcommerceActions', {
174            data: {
175                'type': type
176            }
177        })
178            .then(function(oResponse) {
179                oResponse.ecActions = true;
180                return oResponse;
181            }, function (oResponse) {
182                oResponse.ecActions = true;
183                return oResponse;
184            });
185    }
186
187    function hasActions(){
188        return BX.getCookie('ym_has_actions');
189    }
190
191})();

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.