PageSourceSearch

https://sportnutra.ru/bitrix/components/aspro/catalog.viewed.max/templates/main_horizontal/script.js

js sportnutra.ru collected 2026-10-08 17:34:49 UTC 5,279 bytes, 124 lines download raw bytes

1/*BX.addCustomEvent('onSlideInit', function(eventdata) {
2	try{
3		ignoreResize.push(true);
4		if(eventdata){
5			var slider = eventdata.slider;
6			if(slider){
7				$('.viewed_block .rows_block .item .item-title').sliceHeight({'autoslicecount': false, 'slice': 5});
8				$('.viewed_block .rows_block .item').sliceHeight({'autoslicecount': false, 'slice': 5});
9			}
10		}
11	}
12	catch(e){}
13	finally{
14		ignoreResize.pop();
15	}
16});*/
17
18
19showViewedItems = function(lastViewedTime, bShowMeasure, $viewedSlider){
20
21	if($viewedSlider.length){
22	
23		// save $.cookie option
24		var bCookieJson = $.cookie.json;
25		$.cookie.json = true;
26
27		var arViewedLocal = {};
28		var arViewedCookie = {};
29
30		try{
31			if(typeof BX.localStorage !== 'undefined'){
32				var localKey = 'MAX_VIEWED_ITEMS_'+BX.message('SITE_ID');
33				var cookieParams = {path: '/', expires: 30};
34
35				arViewedLocal = BX.localStorage.get(localKey) ? BX.localStorage.get(localKey) : {};
36				arViewedCookie = $.cookie(localKey) ? $.cookie(localKey) : {};
37
38				var empty = '<div class="block-item bordered rounded3"><div class="item_wrap item block-item__wrapper"></div></div>';
39			
40				// remove different items
41				for(var itemKey in arViewedCookie) {
42					if(arViewedLocal[itemKey] == undefined) {
43						$viewedSlider.find('div[data-id=' + itemKey + ']').closest('.block-item').remove();
44						$viewedSlider.closest('.block-items').append(empty);
45						
46					}
47				}
48
49				for(var PRODUCT_ID in arViewedLocal){
50					var $item = $viewedSlider.find('div[data-id=' + PRODUCT_ID + ']');
51
52					if($item.length){
53						var item = arViewedLocal[PRODUCT_ID];
54						var picture = (typeof $item.attr('data-picture') !== 'undefined' ) ? JSON.parse($item.attr('data-picture')) : {ID: false, SRC: BX.message('SITE_TEMPLATE_PATH')+'/images/svg/noimage_product.svg', ALT: item.NAME, TITLE: item.NAME};
55						var bIsOffer = (typeof item.IS_OFFER !== 'undefined') ? (item.IS_OFFER === 'Y') : false;
56						var bWithOffers = (typeof item.WITH_OFFERS !== 'undefined') ? (item.WITH_OFFERS === 'Y') : false;
57						$item.html(
58							'<div class="block-item__inner flexbox flexbox--row">'+
59								'<div class="block-item__image block-item__image--wh90">'+
60									'<a href="' + item.DETAIL_PAGE_URL + '" class="thumb">'+
61										'<img border="0" src="' + picture.SRC + '" alt="' + (picture.ALT.length ? picture.ALT : item.NAME) + '" title="' + (picture.TITLE.length ? picture.TITLE : item.NAME) + '" />'+
62									'</a>'+
63								'</div>'+
64								'<div class="block-item__info item_info">'+
65									'<div class="block-item__title">'+
66										'<a class="dark-color font_xs" href="' + item.DETAIL_PAGE_URL + '"><span>' + item.NAME + '</span></a>'+
67									'</div>'+
68									'<div class="block-item__cost cost prices clearfix font_sm">'+
69										(item.MIN_PRICE && item.MIN_PRICE.PRINT_DISCOUNT_VALUE !== undefined ?
70											((((item.MIN_PRICE.VALUE * 1) > (item.MIN_PRICE.DISCOUNT_VALUE * 1))) ?
71												'<div class="price only_price">' + (bWithOffers ? BX.message('CATALOG_FROM_VIEWED')+' ' : '') + item.MIN_PRICE.PRINT_DISCOUNT_VALUE + (bShowMeasure && item.CATALOG_MEASURE_NAME.length ? '/' + item.CATALOG_MEASURE_NAME : '') + '</div>'
72											: '<div class="price only_price">' + (bWithOffers ? BX.message('CATALOG_FROM_VIEWED')+' ' : '') + item.MIN_PRICE.PRINT_DISCOUNT_VALUE + (bShowMeasure && item.CATALOG_MEASURE_NAME.length ? '/' + item.CATALOG_MEASURE_NAME : '') + '</div>')
73										: '')+
74									'</div>'+
75								'</div>'+
76							'</div>'
77						);
78					}
79					else{
80						// item not finded
81						// may be if it`s new item (it`s detail page), than ACTIVE_FROM > last viewed exists item
82						// or it`s old died item and quantity limit
83						var ACTIVE_FROM = (typeof arViewedLocal[PRODUCT_ID].ACTIVE_FROM !== 'undefined') ? arViewedLocal[PRODUCT_ID].ACTIVE_FROM : ((typeof arViewedCookie[PRODUCT_ID] !== 'undefined') ? arViewedCookie[PRODUCT_ID][0] : false);
84						if(!ACTIVE_FROM || ACTIVE_FROM < lastViewedTime){
85							// get actual for save
86							var _arViewedLocal = BX.localStorage.get(localKey) ? BX.localStorage.get(localKey) : {};
87							var _arViewedCookie = $.cookie(localKey) ? $.cookie(localKey) : {};
88							delete _arViewedLocal[PRODUCT_ID];
89							delete _arViewedCookie[PRODUCT_ID];
90							BX.localStorage.set(localKey, _arViewedLocal, 2592000);  // 30 days
91							$.cookie(localKey, _arViewedCookie, cookieParams);
92						}
93					}
94				}
95			}
96
97			//remove some items
98			$viewedSlider.find('>.item').each(function() {
99				var PRODUCT_ID = (typeof $(this).attr('data-id') !== 'undefined') ? $(this).attr('data-id') : false;
100				if(PRODUCT_ID && (typeof arViewedLocal[PRODUCT_ID] === 'undefined')){
101					$(this).removeClass('has-item').find('>.block-item__inner').remove();
102				}
103			});
104
105			// if no items than remove block
106			if(!$viewedSlider.find('>.item.has-item').length){
107				$viewedSlider.closest('.viewed-wrapper').remove();
108			}
109		}
110		catch(e){
111			console.error(e);
112		}
113		finally{
114			// restore $.cookie option
115			$.cookie.json = bCookieJson;
116		}
117	}
118}
119
120if (typeof window.frameCacheVars !== "undefined"){
121	BX.addCustomEvent("onFrameDataReceived", function (json){
122		InitOwlSlider();
123	})
124}

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.