PageSourceSearch

https://sportmen.ru/local/templates/sportmen/assets/js/shop_scripts.js?17425593118499

js sportmen.ru collected 2026-10-06 08:10:32 UTC 8,499 bytes, 313 lines download raw bytes

1BX.ready(function(){
2
3	//Обработчик добавления в избранное
4	BX.bindDelegate(
5		document.body, 'click', {className: 'js-favorites'},
6		function(e){
7			if(!e) {
8				e = window.event;
9			}
10			item = $(this);
11			PRODUCT_ID = item.attr('data-id');
12			ACTION = item.hasClass('delete') ? 'deleteFromFavorits' : 'add2Favorits';
13			IN_FAVORITE = item.closest('.js-vitrine-favorites').length ? true : false;
14			BX.ajax({
15				method: 'POST',
16				dataType: 'json',
17				data: {
18					'ACTION': ACTION,
19					'PRODUCT_ID': PRODUCT_ID,
20				},
21				url: '/include/ajax.php',
22				onsuccess: function(data) {
23					if (data.STATUS == 'OK') {
24						if (ACTION == 'deleteFromFavorits') {
25							item.removeClass('active');
26							item.removeClass('delete');
27							if (IN_FAVORITE) {
28								item.closest('[data-entity="item"]').remove();
29
30								let parent = document.querySelector('.js-vitrine-favorites');
31								if (parent.children.length == 0) {
32									parent.textContent = 'Товары не найдены';
33								}
34							}
35						} else {
36							item.addClass('active');
37							item.addClass('delete');
38						}
39					}
40
41					BX.ajax({
42						method: 'POST',
43						dataType: 'json',
44						data: {
45							'ACTION': 'getFavoritesIds',
46						},
47						url: '/include/ajax.php',
48						onsuccess: function(data) {
49							// console.log(data);
50							if (data.STATUS == 'OK' && Object.keys(data.ITEMS).length) {
51								$('.js-all-favorites-count').text(Object.keys(data.ITEMS).length);
52							} else {
53								$('.js-all-favorites-count').text(0);
54							}
55						}
56					});
57
58				}
59			});
60			return BX.PreventDefault(e);
61		}
62	);
63
64	//Проставляем кол-во избранного в шапке + у всех товаров на странице.
65	BX.ajax({
66		method: 'POST',
67		dataType: 'json',
68		data: {
69			'ACTION': 'getFavoritesIds',
70		},
71		url: '/include/ajax.php',
72		onsuccess: function(data) {
73			if (data.STATUS == 'OK' && Object.keys(data.ITEMS).length) {
74				Object.values(data.ITEMS).forEach(value => {
75					$('.js-favorites[data-id=' + value + ']').addClass('delete').addClass('active');
76				});
77
78				$('.js-all-favorites-count').text(Object.keys(data.ITEMS).length);
79			} else {
80				$('.js-all-favorites-count').text(0);
81			}
82		}
83	});
84
85	const ymEventsMap = [
86		{
87			// warrantyCallback: {
88			// 	url: '/include/ajax_warranty-callback.php',
89			// 	counterNum: 32144179,
90			// 	event: 'reachGoal',
91			// 	targetName: 'garant-submit'
92			// },
93			// callback: {
94			// 	url: '/include/ajax_callback.php',
95			// 	counterNum: 32144179,
96			// 	event: 'reachGoal',
97			// 	targetName: 'callback_submit'
98			// },
99			// specailcCallback: {
100			// 	url: '/include/ajax_special-callback.php',
101			// 	counterNum: 32144179,
102			// 	event: 'reachGoal',
103			// 	targetName: 'special_callback'
104			// },
105			buy_oneclick: {
106				url: '/include/buy_oneclick.php',
107				counterNum: 32144179,
108				event: 'reachGoal',
109				targetName: 'buy_oneclick'
110			}
111
112		}
113	];
114	function findEventByUrl(url) {
115		for (const event of ymEventsMap) {
116			for (const key in event) {
117				if (event[key].url === url) {
118					return event[key];
119				}
120			}
121		}
122		return null;
123	}
124	const js__phone__1 = document.querySelectorAll('.js-phone-1');
125	if(js__phone__1){
126		js__phone__1.forEach(function(item) {
127			item.addEventListener('click', function() {
128				console.log('Элемент был кликнут!');
129			});
130		});
131	}
132	
133	const js__phone__2 = document.querySelectorAll('.js-phone-2');
134	if(js__phone__2){
135		js__phone__2.forEach(function(item) {
136			item.addEventListener('click', function() {
137				console.log('Элемент был кликнут!');
138			});
139		});
140	}
141	
142	const js__phone__3 = document.querySelector('.js-phone-3');
143	if(js__phone__3){
144		js__phone__3.addEventListener('click', function() {
145			console.log('Элемент был кликнут!');
146		});
147	}
148	
149	const footer__download = document.querySelector('.footer__download-requisites');
150	if(footer__download){
151		footer__download.addEventListener('click', function() {
152			console.log('Элемент был кликнут!');
153		});
154	}
155	
156	const footer__email = document.querySelectorAll('.footer__email');
157	if(footer__email){
158		footer__email.forEach(function(item) {
159			item.addEventListener('click', function() {
160				console.log('Элемент был кликнут!');
161			});
162		});
163	}
164	
165	const product__buy = document.querySelectorAll('.product__buy-btn');
166	if(product__buy){
167		product__buy.forEach(function(item) {
168			item.addEventListener('click', function() {
169				ym(32144179,'reachGoal','add_to_cart_plus')
170				console.log('Элемент был кликнут!');
171			});
172		});
173	};
174
175	const card__form = document.querySelectorAll('.card__form-submit-btn');
176	if(card__form){
177		card__form.forEach(function(item) {
178			item.addEventListener('click', function() {
179				ym(32144179,'reachGoal','add_to_cart')
180				console.log('Элемент был кликнут!');
181			});
182		});
183	}
184
185
186	const order__final = document.querySelectorAll('.order-ym-final');
187	if (order__final){
188		order__final.forEach(function(item) {
189			item.addEventListener('click', function() {
190				// ym(32144179,'reachGoal','order-final')
191			});
192		});
193	}
194
195
196
197	//кнопки оформить заказ и отправить заказ имеют одинаковые классы разделить нужно логику
198	// document.querySelectorAll('.order-page__submit-btn').forEach(function(item) {
199	// 	item.addEventListener('click', function() {
200	// 		console.log('Элемент был кликнут!');
201	// 	});
202	// });
203
204
205
206	
207	const card__form_buy_one = document.querySelectorAll('.card__form-buy-one-click-btn');
208	if(card__form_buy_one){
209		card__form_buy_one.forEach(function(item) {
210			item.addEventListener('click', function() {
211				ym(32144179,'reachGoal','one_click')
212				console.log('Элемент был кликнут!');
213			});
214		});
215	}
216
217	//чет придумать с переходом в корзину нужно
218	const black__submit = document.querySelectorAll('.submit-btn submit.arrow--btn.btn.black-btn');
219	if(black__submit){	
220		black__submit.forEach(function(item) {
221			item.addEventListener('click', function() {
222				console.log('Элемент был кликнут!');
223			});
224		});
225	}
226
227	const footer__callback = document.querySelector('.footer__callback');
228	if(footer__callback){
229		footer__callback.addEventListener('click', function() {
230			ym(32144179,'reachGoal','calback')
231		});
232	}
233
234	const individual__link = document.querySelector('.individual__link .js-overlay');
235	if(individual__link){
236		individual__link.addEventListener('click', function() {
237			ym(32144179,'reachGoal','calback')
238		});
239	}
240	const header__callback = document.querySelector('.header__callback');
241	if(header__callback){
242		header__callback.addEventListener('click', function() {
243			ym(32144179,'reachGoal','calback')
244		});
245	}
246	const header__action = document.querySelector('.header__action');
247	if(header__action){
248		header__action.addEventListener('click', function() {
249			ym(32144179,'reachGoal','garant-open')
250		});
251	}
252	
253	const condition__form__submit = document.querySelector('.condition__form-submit');
254	if(condition__form__submit){
255		condition__form__submit.addEventListener('click', function() {
256			ym(32144179,'reachGoal','special_callback')
257		});
258	}
259
260
261	const oneclick = document.querySelector('.callback-form');
262	if (oneclick){
263		$(document).on('submit', oneclick, function() {
264			var $form = $(this);
265			let event = findEventByUrl($form.attr('action'))
266			if (event){
267				ym(event.counterNum, event.event, event.targetName)
268				console.log(event)
269			}
270		});
271	}
272	
273	$(document).on('submit', '.js-callback-form', function() {
274		var $form = $(this);
275
276		var data = new FormData(this);
277
278		let files;
279		if ($form.find('.js-form-file').length > 0) {
280			files = $form.find('.js-form-file').prop('files');
281
282			$.each( files, function( key, value ){
283				data.append( key, value );
284			});
285
286			data.append( 'files_uploaded', 1 );
287		}
288
289		$.ajax({
290			url         : $form.attr('action'),
291			type        : 'POST',
292			data        : data,
293			cache       : false,
294			dataType    : 'html',
295			processData : false,
296			contentType : false,
297		}).done(function(data){
298			$form.parent().html(data);
299			let event = findEventByUrl($form.attr('action'))
300
301			if (event){
302				// ym(event.counterNum, event.event, event.targetName)
303				console.log(event)
304			}
305		});
306
307	
308		// $.post($form.attr('action'), $form.serialize(), function(data){
309		// 	$form.parent().html(data);
310		// }, 'html');
311		return false;
312	});
313});

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.