PageSourceSearch

https://luxebazar.ru/bitrix/templates/aspro_optimus/js/_google_helper.js

js luxebazar.ru collected 2026-10-06 00:09:06 UTC 13,146 bytes, 500 lines download raw bytes

1var selector_array = [];
2var selector_array_name = [];
3var need_scroll_event = false;
4var default_list_name = "ГЛАВНАЯ / НОВИНКИ";
5var category_list_name = "";
6var selector = ".tab.NEW_wrapp .catalog_item.item_wrap";
7
8window.dataLayer = window.dataLayer || [];
9
10
11jQuery(document).ready(function() {
12
13	//by client custom
14	setSelectorToVisible(".tab.NEW_wrapp.cur .catalog_item.item_wrap[googleadd!='y']", "ГЛАВНАЯ / НОВИНКИ");
15	setSelectorToVisible(".tab.HIT_wrapp.cur .catalog_item.item_wrap[googleadd!='y']", "ГЛАВНАЯ / ХИТ ПРОДАЖ");
16	setSelectorToVisible(".tab.STOCK_wrapp.cur .catalog_item.item_wrap[googleadd!='y']", "ГЛАВНАЯ / АКЦИЯ");
17	
18	setSelectorToVisible(".novinki_page .google_item[googleadd!='y']", "НОВИНКИ");
19	setSelectorToVisible(".sale_page .google_item[googleadd!='y']", "АКЦИИ");
20	
21	setSelectorToVisible(".common_catalog .google_item[googleadd!='y']", "Каталог");
22
23	setSelectorToVisible(".ASSOCIATED_wrapp.cur .google_item[googleadd!='y']", "Другие продукты этой линии");
24	setSelectorToVisible(".RECOMENDATION_wrapp.cur .google_item[googleadd!='y']", "Персональные рекомендации");
25	
26	setSelectorToVisible(".articles_selector .google_item[googleadd!='y']", "Статья");
27	
28	setSelectorToVisible(".similar_products_wrapp .google_item[googleadd!='y']", "");
29	
30	setTimeout(checkElementsToVisible, 200);
31
32	$(window).scroll(function() {
33		if (need_scroll_event)
34		{
35			checkElementsToVisible();
36		}
37		
38	});
39	
40	_init_onclick_action();
41	_init_orderStatistic();
42
43});
44
45function _init_orderStatistic()
46{
47	$('#bx-soa-total a.btn-order-save').bind('click', function(e){
48		e.preventDefault();
49		FullOrderStatistic(1);
50	});
51	
52
53	$('#final_step_full_order_button').bind('click', function(e){
54		e.preventDefault();
55		FullOrderStatistic(1);
56	});
57	
58}
59
60
61$(document).on("click", ".large_basket_remove", function () {
62		removeItemFromBasket($(this))
63});
64
65
66
67
68function removeItemFromBasket(data_selector)
69{
70	
71	var itemid = $(data_selector).data("itemid");
72	var brand = $(data_selector).data("brand");
73	var price = $(data_selector).data("price");
74	var name = $(data_selector).data("name");
75	
76	var quantity_selector = $(data_selector).data("quantityselector");
77	var q = $(quantity_selector).val();
78	
79	window.dataLayer = window.dataLayer || [];
80		dataLayer.push({
81		 'ecommerce': {
82		   'currencyCode': 'RUB',
83		   'remove': {
84			 'products': [{
85			   'name': name,
86			   'id': itemid,
87			   'price': price,
88			   'brand': brand,
89			   'quantity': q
90			  }]
91		   }
92		 },
93			'event': 'gtm-ee-event',
94			'gtm-ee-event-category': 'Enhanced Ecommerce',
95			'gtm-ee-event-action': 'Removing a Product to a Shopping Cart',
96			'gtm-ee-event-non-interaction': 'False',
97		});
98	
99	
100}
101
102
103
104function _init_onclick_action()
105{
106	var selector = ".google_item a.thumb";
107	selector += ", .google_item .item-title a";
108	selector += ", .google_item .button_block a";
109	
110	selector += ", .google_item td.item-name-cell a";
111	selector += ", .google_item .image_wrapper_block a";
112	
113	//console.log(selector);
114	
115	$(document).on("click", selector, function () {
116		//event.preventDefault();
117		
118		var obj = $(this).closest(".google_item")
119		var itemid = $(obj).data("itemid");
120		
121		var list_name = default_list_name;
122		if (category_list_name!="")
123			list_name = category_list_name;
124		
125		//console.log("click! GoogleAddVisited list_name="+list_name);
126		GoogleAddVisited(obj, list_name);
127		
128		return true;
129		
130    });
131	
132	//главная страница ТАБЫ
133	$(document).on("click", "li[data-code='NEW']", function () {
134		category_list_name = "ГЛАВНАЯ / НОВИНКИ";
135		checkElementsToVisible();
136    });
137	
138	$(document).on("click", "li[data-code='HIT']", function () {
139		category_list_name = "ГЛАВНАЯ / ХИТ ПРОДАЖ";
140		checkElementsToVisible();
141    });
142	
143	$(document).on("click", "li[data-code='STOCK']", function () {
144		category_list_name = "ГЛАВНАЯ / АКЦИЯ";
145		checkElementsToVisible();
146    });
147	
148	$(document).on("click", "li[data-code='RECOMENDATION'], li[data-code='ASSOCIATED']", function () {
149		//console.log("flex-next");
150		checkElementsToVisible();
151    });
152	
153	$(document).on("click", "a.flex-next, a.flex-prev", function () {
154		//console.log("flex-next");
155		setTimeout(function(){checkElementsToVisible();},1000);
156		
157    });
158	
159	
160	
161	
162	
163}
164
165function GoogleAddBasket(elem)
166{
167	var obj = $(elem).closest(".item_main_info");
168	
169	var itemid = "";
170	var brand = "";
171	var name = "";
172	var q = "";
173	var price = 0;
174	var toAdd = false;
175	
176	if ($(elem).closest(".google_item").length)
177	{
178		var list_obj = $(elem).closest(".google_item");
179		
180		itemid = $(list_obj).data("itemid");
181		brand = $(list_obj).data("brand");
182		name = $(list_obj).data("name");
183		q = 1;
184		
185		if ($(list_obj).find("input[name='quantity']").length>0)
186			q = $(list_obj).find("input[name='quantity']").val();
187		
188		price = $(list_obj).data("price");
189		toAdd = true;
190	}
191	else if (obj)
192	{
193		
194		itemid = $(obj).data("id");
195		brand = $(obj).data("brand");
196		name = $(obj).data("name");
197		
198		q = $(obj).data("quantity");
199		if ($(".counter_block input[name='quantity']").length)
200			q = $(".counter_block input[name='quantity']").val();
201		
202		if ($(".prices_block div.price").length)
203		{
204			var rawPrice = $(".prices_block div.price").html();
205			rawPrice = rawPrice.replace("<span>цена</span>", "");
206			rawPrice = rawPrice.replace("руб.", "");
207			rawPrice = rawPrice.replace(" ", "");
208			rawPrice = rawPrice.trim();		
209			price = rawPrice+".00";
210		}
211		
212		
213		toAdd = true;
214		
215	}
216	
217	if (toAdd)
218	{
219		
220		
221		window.dataLayer = window.dataLayer || [];
222		dataLayer.push({
223		 'ecommerce': {
224		   'currencyCode': 'RUB',
225		   'add': {
226			 'products': [{
227			   'name': name,
228			   'id': itemid,
229			   'price': price,
230			   'brand': brand,
231			   'quantity': q
232			  }]
233		   }
234		 },
235		 'event': 'gtm-ee-event',
236		 'gtm-ee-event-category': 'Enhanced Ecommerce',
237		 'gtm-ee-event-action': 'Adding a Product to a Shopping Cart',
238		 'gtm-ee-event-non-interaction': 'False',
239		});
240	}
241	
242	
243}
244
245function GoogleAddVisited(elem, list_name)
246{
247	var name = $(elem).data("name");
248	var id = $(elem).data("id");
249	var price = $(elem).data("price");
250	var brand = $(elem).data("brand");
251	var position = $(elem).data("position");
252	
253	if ($(elem).data("listname")!="" && typeof $(elem).data("listname") != 'undefined')
254		list_name = $(elem).data("listname");
255	
256	//console.log("VISITED name="+name+" id="+id+" price="+price+" brand="+brand+" brand="+brand+" position="+position+" list_name="+list_name);
257	
258	
259	dataLayer.push({
260	   'ecommerce': {
261	   'currencyCode': 'RUB',
262	   'click': {
263		 'actionField': {'list': list_name},
264		 'products': [{
265		  'name': name,
266		  'id': id,
267		  'price': price,
268		  'brand': brand,
269		  'position': position
270		 }]
271	   }
272	 },
273	 'event': 'gtm-ee-event',
274	 'gtm-ee-event-category': 'Enhanced Ecommerce',
275	 'gtm-ee-event-action': 'Product Clicks',
276	 'gtm-ee-event-non-interaction': 'False',
277	});
278}
279
280
281//добавляем селектор для элеметтов
282function setSelectorToVisible(selector, list_name)
283{
284	selector_array.push(selector);
285	selector_array_name.push(list_name);
286}
287
288function checkElementsToVisible()
289{
290	for (var i = 0; i < selector_array.length; i++) {
291		var list_name = selector_array_name[i];
292		
293		$(selector_array[i]).each(function(){
294			checkPosition($(this), list_name);
295		});
296		
297	}
298	need_scroll_event  = true;
299}
300
301
302function checkPosition(elem, list_name){
303    var div_position = $(elem).offset();
304	
305    // отступ сверху
306    var div_top = div_position.top;
307    // отступ слева
308    var div_left = div_position.left;
309    // ширина
310    var div_width = $(elem).width();
311    // высота
312    var div_height = $(elem).height();
313     
314    // проскроллено сверху 
315    var top_scroll = $(document).scrollTop();
316    // проскроллено слева
317    var left_scroll = $(document).scrollLeft();
318    // ширина видимой страницы
319    var screen_width = $(window).width();
320    // высота видимой страницы
321    var screen_height = $(window).height();
322	
323     
324    // координаты углов видимой области
325    var see_x1 = left_scroll;
326    var see_x2 = screen_width + left_scroll;
327    var see_y1 = top_scroll;
328    var see_y2 = screen_height + top_scroll;
329     
330    // координаты углов искомого элемента
331    var div_x1 = div_left;
332    var div_x2 = div_left + div_width;
333    var div_y1 = div_top;
334    var div_y2 = div_top + div_height;
335
336     
337    // проверка - виден див полностью или нет
338    if( div_x1 >= see_x1 && div_x2 <= see_x2 && div_y1 >= see_y1 && div_y2 <= see_y2 ){
339        // если виден
340        $(elem).attr("googleadd", "y");
341		
342		//GoogleAdd($(elem).find(".footer_button"),list_name);
343		GoogleAddViewed($(elem).closest(".google_item"),list_name);
344    }else{
345        // если не виден
346        //$('.example_div').css({'background-color': 'red'});     
347		//console.log(" - ");
348    }
349}
350
351
352function GoogleAddViewed(elem,list_name)
353{
354	var name = $(elem).data("name");
355	var id = $(elem).data("itemid");
356	var price = $(elem).data("price");
357	var brand = $(elem).data("brand");
358	var position = $(elem).data("position");
359	
360	if ($(elem).data("listname")!="" && typeof $(elem).data("listname") != 'undefined')
361		list_name = $(elem).data("listname");
362	
363	console.log("VIEW name="+name+" id="+id+" price="+price+" brand="+brand+" brand="+brand+" position="+position+" list_name="+list_name);
364	
365	
366	dataLayer.push({
367	 'ecommerce': {
368	   'currencyCode': 'RUB',
369	   'impressions': [
370		{
371		  'name': name,
372		  'id': id,
373		  'price': price,
374		  'brand': brand,
375		  'list': list_name,
376		  'position': position
377		}]
378	 },
379	 'event': 'gtm-ee-event',
380	 'gtm-ee-event-category': 'Enhanced Ecommerce',
381	 'gtm-ee-event-action': 'Product Impressions',
382	 'gtm-ee-event-non-interaction': 'True',
383	});
384	
385
386	
387}
388
389function FastOrderStatistic(step)
390{
391	console.log('FastOrderStatistic '+step);
392	if ($("#one_click_buy_form input[name='BUY_TYPE']").length)
393	{
394		console.log("Покупаем всю корзину");
395		dataLayer.push({
396		 'ecommerce': {
397		   'currencyCode': 'RUB',
398		   'checkout': {
399			 'actionField': {'step': step, 'option': 'быстрый заказ'},
400			 'products': basketElements
401		   }
402		 },
403		 'event': 'gtm-ee-event',
404		 'gtm-ee-event-category': 'Enhanced Ecommerce',
405		 'gtm-ee-event-action': 'Checkout Step '+step,
406		 'gtm-ee-event-non-interaction': 'False',
407		});
408		
409		return true;
410	}
411	
412	console.log("Покупаем один элемент");
413	var price = "";
414	if ($(".middle_info .prices_block .price").length)
415	{
416		price = $(".middle_info .prices_block .price").text();
417		price = price.replace("цена","");
418		price = price.replace("руб.","");
419		price = price.replace(new RegExp("\\r?\\n", "g"), "")
420
421		price = price.replace(" ","").trim()+'.00';
422		
423		
424	}
425	
426	var brand = "";
427	if ($("a.brand_picture").length)
428		brand = $("a.brand_picture").data("name");
429	
430	var name = "";
431	if ($("#pagetitle").length)
432		name = $("#pagetitle").text();
433	
434	
435	
436	var element_id = "";
437	if ( $("#one_click_buy_form input[name='ELEMENT_ID']").length)
438		element_id = $("#one_click_buy_form input[name='ELEMENT_ID']").val();
439	
440	var quantity = "";
441	if ( $("#one_click_buy_form input[name='ELEMENT_QUANTITY']").length)
442		quantity = $("#one_click_buy_form input[name='ELEMENT_QUANTITY']").val();
443
444	
445	dataLayer.push({
446	 'ecommerce': {
447	   'currencyCode': 'RUB',
448	   'checkout': {
449		 'actionField': {'step': step, 'option': 'быстрый заказ'},
450		 'products': [{
451		   'name': name,
452		   'id': element_id,
453		   'price': price,
454		   'brand': brand,
455		   'quantity': element_id
456		  }]
457	   }
458	 },
459	 'event': 'gtm-ee-event',
460	 'gtm-ee-event-category': 'Enhanced Ecommerce',
461	 'gtm-ee-event-action': 'Checkout Step '+step,
462	 'gtm-ee-event-non-interaction': 'False',
463	});
464
465}
466
467
468function FullOrderStatistic(step)
469{
470	console.log('FullOrderStatistic step='+step);
471	
472	window.dataLayer = window.dataLayer || [];
473	dataLayer.push({
474	 'ecommerce': {
475	   'currencyCode': 'RUB',
476	   'checkout': {
477		 'actionField': {'step': step, 'option': 'долгий заказ'},
478		 'products': basketElements
479	   }
480	 },
481	 'event': 'gtm-ee-event',
482	 'gtm-ee-event-category': 'Enhanced Ecommerce',
483	 'gtm-ee-event-action': 'Checkout Step '+step,
484	 'gtm-ee-event-non-interaction': 'False',
485	});
486	
487}
488
489
490function UpdateMyQuantity()
491{
492	setTimeout(function(){
493		console.log("UpdateMyQuantity");
494		$('#temp').load('/ajax/google_basket.php?update=y');
495	}, 500);
496	
497	if (basketElements)
498		console.log(basketElements);
499	
500}

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.