PageSourceSearch

https://www.kupele-skleneteplice.sk/templates/sklene/js/analytics.js

js kupele-skleneteplice.sk collected 2026-10-02 21:46:55 UTC 15,062 bytes, 670 lines download raw bytes

1var currency = "EUR";
2
3$(document).ready(function() {
4
5	/*** TRIGGER EVENTS ***/
6
7
8
9	/* ESHOP ADD TO CART */
10	$(document).on("click", ".track-product-to-cart", function(){
11		let items = [];
12
13		let price;
14		let pid = $(this).data("track-pid");
15		let name = $(this).data("track-name");
16		let qty = parseInt($(this).parent().parent().find("input").val());
17		let variant = false;
18
19		//if variant or not
20		if($(this).data("variant-options")){
21			price = parseFloat($(this).parent().parent().parent().siblings(".price-wrapper").find("> div:not(.hidden)").data("price"));
22			variant = true;
23		}else{
24			price = parseFloat($(this).data("track-price"));
25		}
26
27		items.push({item_id:pid, item_name:name, quantity:qty, price:price});
28		
29		ga_add_to_cart(price,items);
30		fb_product_to_cart(pid,name,price,variant);
31	});
32	/* END */
33
34
35	/* SIMPLE ADD TO CART */
36	$(document).on("click", ".track-add-to-cart", function(){
37		process_track_add_to_cart($(this));
38	});
39	/* END */
40
41
42
43
44
45	/* ADD TO CART RESERVATION */
46	$(document).on("click",".addtobasket",function(){
47		if($(this).attr("id") != 'edit-searcher'){
48			
49			var items = [];
50			var value = 0;
51
52			var parent = $(this).parent().parent().parent();
53			var elements = parent.find(".book-room-item");
54
55			elements.each(function(index){
56				var qty = 1;
57				var pid = $(this).data("room");
58				var ctg = "room";
59				var name = $('[data-item="'+pid+'"]').find(".fw-item-main-desc .title-big").html();
60				var price = parseFloat($(this).find(".book-price").data("newprice"));
61
62				var package_id = parseInt($(this).data("package"));
63				if(package_id>0){
64					pid = package_id;
65					ctg = "package";
66					name = $('#p'+pid).find(".fw-item-main-desc .title-big").html();
67				}
68
69				var adults = parseInt($(this).find(".book-adults .adults_input").val());
70				var kids = 0;
71	        	var els_kids = $(this).find(".kids-row .child:visible .form-select");
72	        	els_kids.each(function(index){
73	        		if($(this).val()!='deleteP' && $(this).val()!=''){
74	        			kids++;
75	        		}
76	        	});
77
78	        	var variant = 'adults (' +adults+'x), kids ('+kids+'x)';
79
80				items.push({'id':pid, 'category':ctg, 'name':name, 'quantity':qty, 'price':price, 'variant': variant});
81				value += price;
82			});
83
84	        //console.log(items);
85			ga_add_to_cart(value,items);
86
87		}
88	});
89	/* END ADD TO CART */
90
91	/* REMOVE FROM CART */
92	$(document).on("click", ".track-remove-from-cart", function(){
93		process_track_remove_from_cart($(this));
94		
95		// if removing room/package from maincart -> remove also services
96		if($(this).hasClass("track-remove-main-services")){
97			let id = $(this).data("cart-product");
98			let els = $(".main-cartitems [data-track-pid='"+id+"'] .extra-items > .item");
99			let items = [];
100			let value = 0;
101
102			els.each(function(index){
103				var quantity = parseInt($(this).find(".counter input").val());
104
105				if(quantity > 0){
106					var pid = $(this).find(".counter input").data("track-pid");
107					var name = $(this).find(".extra-title b").html();
108					var price = parseFloat($(this).find(".counter input").data("track-price"));
109					
110					items.push({item_id:pid, item_name:name, price:price, quantity:quantity});
111					value += price*quantity;
112				}
113			});
114
115			if(items.length){
116				ga_remove_from_cart(value,items);
117			}
118		}
119
120		// if removing rental from maincart -> remove also additions
121		if($(this).hasClass("track-remove-rental-services")){
122			let els = $(this).parent().parent().parent().find(".extra-items .track-rental-addition:checked");
123			let items = [];
124			let value = 0;
125
126			els.each(function(index){
127				var pid = $(this).data("track-pid");
128				var quantity = parseInt($(this).data("track-qty"));
129				var name = $(this).data("track-name");
130				var price = parseFloat($(this).data("track-price"));
131				
132				items.push({item_id:pid, item_name:name, price:price, quantity:quantity});
133				value += price*quantity;
134			});
135
136			if(items.length){
137				ga_remove_from_cart(value,items);
138			}
139		}
140
141		// if removing room/package from smallcart -> remove also services
142		if($(this).hasClass("track-remove-small-services")){
143			let els = $(this).parent().parent().find(".services .wrapper .track-remove-from-cart");
144			let items = [];
145			let value = 0;
146
147			els.each(function(index){
148				var pid = $(this).data("track-pid");
149				var quantity = parseInt($(this).data("track-qty"));
150				var name = $(this).data("track-name");
151				var price = parseFloat($(this).data("track-price"));
152				
153				items.push({item_id:pid, item_name:name, price:price, quantity:quantity});
154				value += price*quantity;
155			});
156
157			if(items.length){
158				ga_remove_from_cart(value,items);
159			}
160		}
161	});
162	/* END */
163
164
165
166
167	/* VIEW CHECKOUT */
168	if($(".track-checkout").length>0){
169		var ga_items = [];
170		var fb_items = [];
171		var elements = $(".track-checkout .col-summary .items .item");
172		var services = $(".track-checkout .col-summary .items .item .track-service");
173		var value = 0;
174
175		elements.each(function(index){
176			var pid = $(this).data("track-pid");
177			var name = $(this).data("track-name");
178			var price = parseFloat($(this).data("track-price"));
179			var quantity = parseInt($(this).data("track-qty"));
180
181			let ga_obj = {item_name:name, price:price, quantity:quantity};
182
183			if($(this).data("track-ctg")){ga_obj.item_category = $(this).data("track-ctg");}
184
185
186			let fb_obj = {quantity:quantity, name:name};
187			if(pid){
188				ga_obj.item_id = pid;
189				fb_obj.id = pid;
190			}
191			
192			ga_items.push(ga_obj);
193			fb_items.push(fb_obj);
194
195			value += price*quantity;
196		});
197
198		services.each(function(index){
199			var pid = $(this).data("track-pid");
200			var name = $(this).data("track-name");
201			var price = parseFloat($(this).data("track-price"));
202			var quantity = parseInt($(this).data("track-qty"));
203
204			let ga_obj = {item_name:name, price:price, quantity:quantity};
205			let fb_obj = {quantity:quantity, name:name};
206			if(pid){
207				ga_obj.item_id = pid;
208				fb_obj.id = pid;
209			}
210			
211			ga_items.push(ga_obj);
212			fb_items.push(fb_obj);
213
214			value += price*quantity;
215		});
216
217		ga_begin_checkout(value,ga_items);
218		fb_begin_checkout(value,elements.length,fb_items);
219	}
220	/* END VIEW ITEM LIST */
221
222
223
224
225	/* VIEW ITEM */
226	if($(".track-view-item").length>0){
227		process_track_view_item($(".track-view-item"));
228	}
229	/* END VIEW ITEM */
230
231
232	/* VIEW PRODUCT VARIANT */
233	if($(".track-view-variant-group").length>0){
234		let ga_items = [];
235		let fb_items = [];
236		let fb_ids = [];
237		let item = {};
238		let value = 0;
239		
240		let el = $(".track-view-variant-group");
241		let els = el.find(".track-view-variant-item");
242
243		els.each(function(index){
244			item = {};
245
246			item.item_id = el.data("track-pid");
247			item.item_name = el.data("track-name");
248			item.item_variant = $(this).data("track-variant");
249			item.price = parseFloat($(this).data("track-price"));
250			if(el.data("track-ctg")){item.item_category = el.data("track-ctg");}
251
252			ga_items.push(item);
253			fb_items.push({id: item.item_id, quantity: 1, name: item.item_name});
254			fb_ids.push(item.item_id);
255			value += item.price;
256		});		
257
258		ga_view_item(value,ga_items);
259		fb_view_item(item.item_name,fb_ids,value,fb_items);
260	}
261	/* END VIEW ITEM */
262
263
264	/* VIEW ITEM LIST */
265	process_track_view_items($(".track-view-items:not(.on-call)"));
266	/* END VIEW ITEM LIST */
267
268});
269
270
271
272
273
274
275
276
277
278
279
280function process_track_cart(){
281	var items = [];
282	var main_elements = $(".track-cart .track-remove-from-cart");
283	var extra_elements = $(".track-cart .main-cartitems .extra-items:not(.rental) > .item");
284	var rental_extra_elements = $(".track-cart .main-cartitems .extra-items .track-rental-addition:checked");
285	var value = 0;
286
287	main_elements.each(function(index){
288		var pid = $(this).data("track-pid");
289		var name = $(this).data("track-name");
290		var price = parseFloat($(this).data("track-price"));
291
292		var quantity = 1;
293
294		//has to be single unit price
295		if(quantity > 1){
296			price = price/quantity;
297		}
298
299		let obj = {item_name:name, price:price, quantity:quantity};
300		if(pid){obj.item_id = pid;}
301
302		items.push(obj);
303		value += price*quantity;
304	});
305
306	extra_elements.each(function(index){
307		var quantity = parseInt($(this).find(".counter input").val());
308
309		if(quantity > 0){
310			var pid = $(this).find(".counter input").data("track-pid");
311			var name = $(this).find(".extra-title b").html();
312			var price = parseFloat($(this).find(".counter input").data("track-price"));
313			
314			
315			//has to be single unit price
316			if(quantity > 1){
317				price = price/quantity;
318			}
319
320			items.push({item_id:pid, item_name:name, price:price, quantity:quantity});
321			value += price*quantity;
322		}
323	});
324
325	rental_extra_elements.each(function(index){
326		let el = $(this);
327		let pid = el.data("track-pid");
328		let qty = el.data("track-qty");
329		let name = el.data("track-name");
330		let price = parseFloat(el.data("track-price"));
331		
332		items.push({item_id:pid, item_name:name, price:price, quantity:qty});
333		value += price*qty;
334	});
335
336	ga_view_cart(value,items);
337}
338
339function process_track_add_to_cart(el){
340	if(!el.attr("disabled")){
341		let items = [];
342		
343		let pid = el.data("track-pid");
344		let name = el.data("track-name");
345		let qty = parseInt(el.data("track-qty"));
346		let price = parseFloat(el.data("track-price"));
347
348		let obj = {item_name:name};
349		if(pid){obj.item_id = pid;}
350		if(qty){obj.quantity = qty;}
351		if(price){obj.price = price;}
352
353		items.push(obj);
354
355		ga_add_to_cart(price,items);
356		fb_add_to_cart(pid,name,price);
357	}
358}
359
360function process_track_remove_from_cart(el){
361	let items = [];
362
363	let pid = el.data("track-pid");
364	let name = el.data("track-name");
365	let qty = parseInt(el.data("track-qty"));
366	let price = parseFloat(el.data("track-price"));
367
368	let obj = {item_name:name, quantity:qty, price:price};
369	if(pid){
370		obj.item_id = pid;
371	}
372
373	if(el.data("track-ctg")){obj.item_category = el.data("track-ctg");}
374
375	items.push(obj);
376
377	ga_remove_from_cart(price*qty,items);
378}
379
380function process_track_view_item(el){
381	var items = [];
382	var item = {};
383
384	item.item_id = el.data("track-pid");
385	item.item_name = el.data("track-name");
386	if(el.data("track-price")){item.price = el.data("track-price");}
387	if(el.data("track-ctg")){item.item_category = el.data("track-ctg");}
388
389	items.push(item);
390
391	ga_view_item(item.price,items);
392	fb_view_item(item.item_name,item.item_id,item.price,null);
393}
394
395function process_track_view_items(parent){
396	if(parent.length>0){
397		let els_group = parent;
398		els_group.each(function(index){
399			let el_group = $(this);
400			let els_items = el_group.find(".track-data");
401
402			let list_id = el_group.data("track-list-id");
403			let list_name = el_group.data("track-list-name");
404
405			let items = [];
406			els_items.each(function(index){
407				var item = {};
408				item.item_id = $(this).data("track-pid");
409				item.item_name = $(this).data("track-name");
410				if($(this).data("track-price")){item.price = $(this).data("track-price");}
411				if($(this).data("track-ctg")){item.item_category = $(this).data("track-ctg");}
412
413				items.push(item);
414			});
415
416			ga_view_item_list(list_id, list_name, items);
417		});
418	}
419}
420
421function process_track_bikes_to_cart(){
422	let ga_items = [];
423	let fb_items = [];
424	let fb_content_ids = [];
425	let value = 0;
426
427	let bikes = $("#rental-response .track-data:checked");
428	bikes.each(function(index) {
429		var pid = $(this).attr("data-track-pid");
430		var name = $(this).attr("data-track-name");
431		var price = parseFloat($(this).attr("data-track-price"));
432		ga_items.push({item_id:pid, item_name:name, quantity:1, price:price});
433		fb_items.push({id:pid, quantity:1});
434		fb_content_ids.push(pid);
435		value += price;
436	});
437
438	ga_add_to_cart(value,ga_items);
439	fb_multiple_to_cart(value,fb_content_ids,fb_items);
440}
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463/*** GA FUNCTIONS ***/
464function ga_add_to_cart(value,items){
465	if(ga_ready()){
466		gtag('event', 'add_to_cart', {
467			currency: currency,
468			value: value,
469			items: items
470		});
471	}
472}
473
474function ga_remove_from_cart(value,items){
475	if(ga_ready()){
476		gtag('event', 'remove_from_cart', {
477			currency: currency,
478			value: value,
479			items: items
480		});
481	}
482}
483
484function ga_view_cart(value,items){
485	if(ga_ready()){
486		console.log("cart");
487		gtag('event', 'view_cart', {
488			currency: currency,
489			value: value,
490			items: items
491		});
492	}
493}
494
495function ga_begin_checkout(value,items){
496	if(ga_ready()){
497		gtag('event', 'begin_checkout', {
498			currency: currency,
499			value: value,
500			items: items
501		});
502	}
503}
504
505function ga_view_item(value,items){
506	let obj = {items: items};
507	if(value){
508		obj.value = value;
509		obj.currency = currency;
510	}
511
512	if(ga_ready()){
513		gtag('event', 'view_item', obj);
514	}
515	console.log("view-item");
516}
517
518function ga_view_item_list(list_id,list_name,items){
519	let obj = {items: items};
520
521	if(list_id){obj.list_id = list_id;}
522	if(list_name){obj.list_name = list_name;}
523
524	if(ga_ready()){
525		gtag('event', 'view_item_list', obj);
526	}
527}
528
529function ga_add_payment_info(value,payment_type,items){
530	if(ga_ready()){
531		gtag('event', 'add_payment_info', {
532			currency: currency,
533			value: value,
534			payment_type: payment_type,
535		  	items: items
536		});
537	}
538}
539
540function ga_add_shipping_info(value,shipping_tier,items){
541	if(ga_ready()){
542		gtag('event', 'add_shipping_info', {
543			currency: currency,
544			value: value,
545			shipping_tier: shipping_tier,
546		  	items: items
547		});
548	}
549}
550
551
552
553
554
555
556
557
558
559
560
561/*** FB FUNCTIONS ***/
562function fb_add_to_cart(pid,name,price){
563	let obj = {content_name: name, content_type: "product", currency: currency};
564	if(pid){obj.content_ids=[pid];}
565	if(price){obj.value=price;}
566
567	if(fb_ready()){
568		fbq('track', 'AddToCart', obj);
569	}
570}
571
572function fb_product_to_cart(pid,name,price,variant){
573	let content_type = "product";
574	if(variant){
575		content_type = "product_group";
576	}
577
578	if(fb_ready()){
579		fbq('track', 'AddToCart', {
580	    	content_name: name, 
581	    	content_ids: [pid],
582	    	content_type: content_type,
583	    	value: price,
584	    	currency: currency
585	    });
586	}
587}
588
589function fb_multiple_to_cart(value,ids,items){
590	if(fb_ready()){
591		fbq('track', 'AddToCart', {
592	    	content_ids: ids,
593	    	content_type: "product",
594	    	value: value,
595	    	currency: currency,
596	    	contents: items
597	    });
598	}
599}
600
601function fb_begin_checkout(value,count,items){
602	if(fb_ready()){
603		fbq('track', 'InitiateCheckout', {
604			contents: items,
605			currency: currency,
606			num_items: count,
607			value: value
608		});
609	}
610}
611
612function fb_view_item(name,id,price,items){
613	let obj = {content_name: name, content_ids: [id], content_type: 'product'};
614	if($.isArray(id)){
615		obj.content_ids = id;
616	}else{
617		obj.content_ids = [id];
618	}
619
620	if(price){
621		obj.value = price;
622		obj.currency = currency;
623	}
624
625	if(items){
626		obj.contents = items;
627		obj.content_type = 'product_group';
628	}else{
629		obj.content_type = 'product';
630	}
631
632	if(fb_ready()){
633		fbq('track', 'ViewContent', obj);
634	}
635}
636
637function fb_add_payment_info(value,items){
638	if(fb_ready()){
639		fbq('track', 'AddPaymentInfo', {
640			currency: currency,
641			value: value,
642		  	contents: items
643		});
644	}
645}
646
647
648
649function ga_ready(){
650	if(typeof gtag == 'function'){
651		return true;
652	}else{
653		return false;
654	}
655}
656function fb_ready(){
657	if(typeof fbq == 'function'){
658		return true;
659	}else{
660		return false;
661	}
662}
663function currencyFormatNum(num) {
664    return (
665        num
666        .toFixed(2)
667        .replace('.', '.')
668        .replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 ')
669    )
670}

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.