PageSourceSearch

https://cortex.ooo/bitrix/components/aspro/marketing.popup/templates/.default/js/script.js

js cortex.ooo collected 2026-10-04 02:01:17 UTC 5,998 bytes, 238 lines download raw bytes

1window.appAspro = window.appAspro || {}
2
3if (!window.appAspro.marketing) {
4	window.appAspro.marketing = {
5		inited: false,
6		showPopup: function () {
7			if($('.dyn_mp_jqm').length)
8			{
9				var allDelays = [];
10				$('.dyn_mp_jqm').each(function(i, el) {
11					var jqmBlock = $(el),
12						delay = 0;
13		
14					if(!jqmBlock.hasClass('initied')) // first load
15					{
16						jqmBlock.addClass('initied');
17						
18						if(jqmBlock.data('param-delay'))
19							delay = jqmBlock.data('param-delay')*1000;
20		
21						while(allDelays.indexOf(delay) !== -1) {
22							delay += 100;
23						}
24		
25						allDelays.push(delay);
26		
27						if(typeof localStorage !== 'undefined')
28						{
29							let lsKey = jqmBlock.data('ls');
30							var dataLS = localStorage.getItem(lsKey),
31								ls = '';
32							try{
33								ls = JSON.parse(dataLS);
34							}
35							catch(e){
36								ls = dataLS
37							}
38		
39							let bShowOnCurrentDevice = true;
40							try {
41								let mediaSelector = jqmBlock.data('media-query');
42								if (mediaSelector) {
43									if (!matchMedia(mediaSelector).matches) { 
44										bShowOnCurrentDevice = false;
45									}
46								}
47							} catch (error) {
48							}
49		
50							if(bShowOnCurrentDevice && (!ls || (ls && (ls.SHOW_ALWAYS === 'Y' || (ls.TIMESTAMP < Date.now() && ls.TIMESTAMP)))))
51							{
52								timeoutID = setTimeout(function(){
53									jqmBlock.click();
54								}, delay);
55							}
56							if (ls && (ls.SHOW_ALWAYS === 'N' && (ls.TIMESTAMP < Date.now() && ls.TIMESTAMP))) { 
57								ls.SHOW_ALWAYS = 'Y';
58								localStorage.setItem(lsKey, JSON.stringify(ls));
59							}
60						}
61						else
62						{
63							var ls = $.cookie(jqmBlock.data('ls'));
64							if(!ls)
65							{
66								timeoutID = setTimeout(function(){
67									jqmBlock.click();
68								}, delay);
69							}
70						}
71		
72					}
73					else // ajax popup
74					{
75						
76					}
77		
78				});
79			}
80		},
81		
82		stopShowAlways: function (lsKey) { 
83			if(typeof localStorage !== 'undefined')
84			{
85				let dataLS = localStorage.getItem(lsKey),
86					ls = '';
87				try{
88					ls = JSON.parse(dataLS);
89				}
90				catch(e){
91					ls = dataLS
92				}
93				if(ls)
94				{
95					ls.SHOW_ALWAYS = 'N';
96					localStorage.setItem(lsKey, JSON.stringify(ls));
97				}
98			}
99		
100		},
101		
102		checkStopAction: function (lsKey, action) {
103			let allStopActions = $('.dyn_mp_jqm[data-ls=' + lsKey + ']').data('stop-actions');
104			let bNeedStopShow = false;
105		
106			if (allStopActions) {
107				let arStopActions = allStopActions.split(',');
108				bNeedStopShow = arStopActions.indexOf(action) !== -1;
109			}
110		
111			return bNeedStopShow;
112		}
113	}
114}
115
116
117if (!appAspro.marketing.inited) { 
118	appAspro.marketing.inited = true;
119	
120
121	$(document).ready(function () {
122		BX.addCustomEvent("onMarketingPopupClose", function (eventdata) {
123			if (eventdata) {
124				let mpFrame = eventdata.hash.w,
125					popupWrap = mpFrame.find('.marketing-popup'),
126					lsKey = popupWrap.data('ls');
127					
128				if (lsKey) {
129					let bNeedStopShow = appAspro.marketing.checkStopAction(lsKey, 'close');
130	
131					if (bNeedStopShow) {
132						appAspro.marketing.stopShowAlways(lsKey);
133					}
134				}
135			}
136		});
137	
138		BX.addCustomEvent("onMarketingPopupShow", function (eventdata) {
139			if (eventdata) {
140				let hash = eventdata.hash;
141				if (typeof $(hash.t).data("ls") !== " undefined" && $(hash.t).data("ls")) {
142					var ls = $(hash.t).data("ls"),
143						ls_timeout = 0,
144						v = "";
145			
146					if ($(hash.t).data("ls_timeout")) ls_timeout = $(hash.t).data("ls_timeout");
147			
148					ls_timeout = ls_timeout ? Date.now() + ls_timeout * 1000 : "";
149			
150					if (typeof localStorage !== "undefined") {
151						var val = localStorage.getItem(ls);
152						try {
153							v = JSON.parse(val);
154						} catch (e) {
155							v = val;
156						}
157						if (v != null) {
158							localStorage.removeItem(ls);
159						}
160						v = {};
161						v["VALUE"] = "Y";
162						v["TIMESTAMP"] = ls_timeout; // default: seconds for 1 day
163						
164						if ($(hash.t).data("show_always"))
165							v["SHOW_ALWAYS"] = $(hash.t).data("show_always");
166			
167						localStorage.setItem(ls, JSON.stringify(v));
168					} else {
169						var val = $.cookie(ls);
170						if (!val) $.cookie(ls, "Y", { expires: ls_timeout }); // default: seconds for 1 day
171					}
172	
173					var dopClasses = hash.w.find(".marketing-popup").data("classes");
174					if (dopClasses) {
175						hash.w.addClass(dopClasses);
176					}
177				}
178			}
179		});
180
181		appAspro.marketing.showPopup();
182		
183		if(typeof window.frameCacheVars !== "undefined"){
184			BX.addCustomEvent("onFrameDataReceived", function (json){
185				appAspro.marketing.showPopup();
186			});
187		}
188	})
189
190	$(document).on('click', '.dyn_mp_jqm_frame [data-marketing-action]', function (e) {
191		let mpFrame = $(this).closest('.dyn_mp_jqm_frame'),
192			popupWrap = $(this).closest('.marketing-popup'),
193			lsKey = popupWrap.data('ls'),
194			bNeedStopShow = false,
195			btnAction = $(this).attr('data-marketing-action'),
196			bLockClose = mpFrame.hasClass('jqm-lock-close');
197			
198		bNeedStopShow = appAspro.marketing.checkStopAction(lsKey, btnAction);
199
200		if (btnAction === 'btn1') {
201			if (bLockClose) {
202				mpFrame.removeClass('jqm-lock-close');
203				bNeedStopShow = true;
204			}
205		} else {
206			let disagreePopup = mpFrame.find('.marketing-popup-disagree');
207
208			if (bLockClose) {
209				if (popupWrap.length) { 
210					popupWrap.hide();
211				}
212				if (disagreePopup.length) { 
213					disagreePopup.removeClass('hidden');
214				}
215				bNeedStopShow = false;
216			}
217		}
218
219		if (bNeedStopShow) { 
220			appAspro.marketing.stopShowAlways(lsKey);
221		}
222
223		mpFrame.jqmHide();
224	});
225
226	$(document).on('click', '.coupon-block', function (e) {
227		let couponText = this.querySelector('.coupon-block__text').textContent.trim();
228
229		if(navigator.clipboard){
230			navigator.clipboard.writeText(couponText).then(() => {
231				// console.log('ok');
232			}).catch(() => {
233				console.log('error copy');
234			});
235		}
236	});
237	
238}

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.