PageSourceSearch

https://grill-profi.ru/template_grill/js/basket.js?t=1791468733

js grill-profi.ru collected 2026-10-08 14:12:29 UTC 17,165 bytes, 442 lines download raw bytes

1function animate_picture(el,to){
2	var image=el.offset();
3	var cart=$(to).offset();
4	$('footer').before('<img src="'+el.attr('src')+'" id="tmp_image" style="position:absolute;top:'+image.top+'px;left:'+image.left+'px;width:'+el.width()+'px;z-index:999;"/>');
5	params={
6		top:cart.top+10+'px',
7		left:cart.left+80+'px',
8		opacity:0.1,
9		width:20
10	};
11	$('#tmp_image').animate(params,900,false,function(){
12		$('#tmp_image').remove();
13	});
14}
15function number_format(str){
16	return str.replace(/(\s)+/g,'').replace(/(\d{1,3})(?=(?:\d{3})+$)/g,'$1 ');
17}
18function add_to_card(el,form_data){
19	$.ajax({
20		type:'post',
21		url:'/ajax.php?type=basket&action=add',
22		data:form_data,
23		beforeSend:function(){
24			$('#cart_animation').css({'display':'block','opacity':'1'});
25		},
26		success:function(r){
27			var result=JSON.parse(r);
28			$('#cart').addClass('fixed');
29			$('#cart .icon span').html(result['products_count']);
30			$('#cart .text span').html('на '+result['global_price']+'р.');
31			$('#cart_animation').animate({opacity:0},1000,false,function(){$('#cart_animation').css({'display':'none'});});
32		}
33	});
34	animate_picture(el,'#cart');
35	return false;
36}
37function delete_from_cart(el,del_key){
38	$.ajax({
39		type:'post',
40		url:'/ajax.php?type=basket&action=delete&'+del_key+'=1',
41		success:function(r){
42			var result=JSON.parse(r);
43			products_count=result['products_count'];
44		}
45	});
46	el.css({'background-color':'#e03c42'});
47	el.find('.cart_delete').css({'border':'2px solid #ffffff'});
48	el.animate({opacity:0.1},900,false,function(){
49		var new_count=parseInt($('#products_count').html())-parseInt(el.find('.cart_delete').attr('p_count'));
50		var cart_global_price=parseInt($('#cart_global_price').val());
51		cart_global_price=cart_global_price-(parseInt(el.find('.cart_delete').attr('p_count'))*parseInt(el.find('.cart_delete').attr('p_price')));
52		var new_global_price=number_format(cart_global_price.toString());
53		if($('.cart_item').length>2){
54			$('#products_count').html(new_count);
55			$('#global_price').html(new_global_price);
56			el.remove();
57		}else{
58			el.parent().remove();
59			$('.cart_summary').remove();
60			$('.cart_form').remove();
61			$('.cart_title').html('В корзину не добавленно ни одного товара');
62		}
63		//$('#cart').html('Товаров: '+new_count+' на сумму: '+new_global_price+'р.<br/><a href="/basket.html">Оформить заказ</a>');
64		$('#cart').addClass('fixed');
65		$('#cart .icon span').html(new_count);
66		$('#cart .text span').html('на '+new_global_price+'р.');
67		$('#cart_animation').animate({opacity:0}
67,1000,false,function(){$('#cart_animation').css({'display':'none'});});
68		window.location.reload(false);
69	});
70}
71function calc(){
72	$('.delivery_details').show();
73	var cart_global_price=parseInt($('#cart_global_price').val());
74	var price_cidex=cart_global_price;
75	var current_promo=$('input[name=price_promo]').val();
76	if(current_promo>0){
77		price_cidex-=current_promo;
78	}
79	var delivery_type=$('input[name=delivery]:checked').val();
80	var price_delivery=price_after=price_delivery_base=price_delivery_pickup=price_delivery_courier=0;
81	var delivery_count=parseInt($('#global_weight').val())+1;
82	var delivery_spb=parseInt($('#delivery_spb').val());
83	$('.delivery_type_box label span').html('');
84	if($('select[name=city]').val()!='') {
85		price_delivery_pickup=parseInt($(':selected',$('select[name=city]')).attr("data-price_pickup"));
86		term_delivery_pickup=parseInt($(':selected',$('select[name=city]')).attr("data-term_pickup"))+1;
87		price_delivery_courier=parseInt($(':selected',$('select[name=city]')).attr("data-price_courier"));
88		term_delivery_courier=parseInt($(':selected',$('select[name=city]')).attr("data-term_courier"))+1;
89		price_after=parseInt($(':selected',$('select[name=city]')).attr("data-price_after"));
90		if(price_delivery_pickup>0){
91			if(delivery_count>2){
92				price_delivery_pickup=(price_delivery_pickup*1)+((price_after*(delivery_count*1-2))*1);
93			}
94			$('label[for=delivery_pickup] span').html(' ('+price_delivery_pickup+' руб. &mdash; '+term_delivery_pickup+' дн.)');
95		}
96		if(price_delivery_courier>0){
97			if(delivery_count>2){
98				price_delivery_courier=(price_delivery_courier*1)+((price_after*(delivery_count*1-2))*1);
99			}
100			$('label[for=delivery_courier] span').html(' ('+price_delivery_courier+' руб. &mdash; '+term_delivery_courier+' дн.)');
101		}
102		if(typeof delivery_type!='undefined'){
103			switch(delivery_type){
104				case 'pickup':
105					price_delivery_base=$(':selected',$('select[name=city]')).attr("data-price_pickup");
106				break;
107				case 'courier':
108					price_delivery_base=$(':selected',$('select[name=city]')).attr("data-price_courier");
109				break;
110				case 'pickup_cdek':
111					price_delivery_base=$('#price_delivery_pickup_cdek').val();
112				break;
113				case 'courier_cdek':
114					price_delivery_base=$('#price_delivery_courier_cdek').val();
115				break;
116			}
117			if(delivery_type=='pickup'||delivery_type=='courier'){
118				console.log('calc '+price_delivery_base);
119				price_after=$(':selected',$('select[name=city]')).attr("data-price_after");
120				if(price_delivery_base>0){
121					if(delivery_count<=2){
122						price_delivery=price_delivery_base;
123					}
124					else{
125						price_delivery=price_delivery_base*1+(price_after*(delivery_count*1-2));
126					}
127				}
128			}
129		}
130	}
131	var cost=price_cidex*1+price_delivery*1;
132	$('input[name=price_cidex]').val(price_cidex);
133	$('input[name=price_delivery]').val(price_delivery);
134	$('input[name=cost]').val(cost);
135	$('#price_cidex_text').html(price_cidex);
136	$('#price_delivery_text').html(price_delivery);
137	$('#cost_text').html(cost);
138	if(price_cidex>0&&price_delivery>0){
139		$('.result').show();
140	}
141	else{
142		$('.result').hide();
143	}
144}
145/*
146function cart_result(price_cidex){
147	var delivery_type=$('input[name=delivery]:checked').val();
148	var current_promo=$('input[name=price_promo]').val();
149	if(current_promo>0){
150		price_cidex-=current_promo;
151	}
152	if(typeof delivery_type!='undefined'&&(delivery_type=='pickup_cdek'||delivery_type=='courier_cdek')){
153		var price_delivery=$('input[name=price_delivery_'+delivery_type+']').val();
154		var price_delivery_orig=$('input[name=price_delivery_'+delivery_type+'_orig]').val();
155		//alert('input[name=price_delivery_'+delivery_type+']');
156		console.log('cart_result: '+delivery_type+' '+price_delivery);
157		var cost=price_cidex*1+price_delivery*1;
158		$('input[name=price_delivery]').val(price_delivery);
159		$('input[name=price_delivery_orig]').val(price_delivery_orig);
160		$('input[name=price_cidex]').val(price_cidex);
161		$('input[name=cost]').val(cost);
162		$('#price_cidex_text').html(price_cidex);
163		$('#price_delivery_text').html(price_delivery);
164		$('#cost_text').html(cost);
165		if(price_cidex>0&&price_delivery>0){
166			$('.result').show();
167		}
168		else{
169			$('.result').hide();
170		}
171	}
172}
173*/
174function cart_result(price_cidex){
175	var delivery_type=$('input[name=delivery]:checked').val();
176	var current_promo=$('input[name=price_promo]').val();
177	if(current_promo>0){
178		price_cidex-=current_promo;
179	}
180	if(typeof delivery_type!='undefined'&&(delivery_type=='pickup_cdek'||delivery_type=='courier_cdek'||delivery_type=='pickup_yandex'||delivery_type=='pickup_boxberry')){
181		var price_delivery=$('input[name=price_delivery_'+delivery_type+']').val();
182		var price_delivery_orig=$('input[name=price_delivery_'+delivery_type+'_orig]').val();
183		//alert('input[name=price_delivery_'+delivery_type+']');
184		console.log('cart_result: '+delivery_type+' '+price_delivery);
185		var cost=price_cidex*1+price_delivery*1;
186		$('input[name=price_delivery]').val(price_delivery);
187		$('input[name=price_delivery_orig]').val(price_delivery_orig);
188		$('input[name=price_cidex]').val(price_cidex);
189		$('input[name=cost]').val(cost);
190		$('#price_cidex_text').html(price_cidex);
191		$('#price_delivery_text').html(price_delivery);
192		$('#cost_text').html(cost);
193		if(delivery_type=='pickup_cdek'){
194			if($("select[name=pvz]").val()!=''){
195				var pvz=$(':selected',$("select[name=pvz]"));
196				var pvz_info='<p><strong>Выбран пункт:</strong> '+pvz.data('name')+'</p><p><strong>Адрес:</strong> '+pvz.data('address')+'</p><p><strong>Телефон:</strong> '+pvz.data('phone')+'</p><p><strong>Режим работы:</strong> '+pvz.data('hours')+'</p><p><strong>Как найти:</strong> '+pvz.data('comment')+'</p>';
197				$('.pvz_map_info').html(pvz_info);
198			}
199			else{
200				$('.pvz_map_info').html('');
201			}
202		}
203		if(delivery_type=='pickup_yandex'){
204			if($("select[name=pvz_yandex]").val()!=''){
205				var pvz_yandex=$(':selected',$("select[name=pvz_yandex]"));
206				var pvz_info='<p><strong>Выбран пункт:</strong> '+pvz_yandex.data('address')+'</p><p><strong>Телефон:</strong> '+pvz_yandex.data('phone')+'</p><p><strong>Как найти:</strong> '+pvz_yandex.data('comment')+'</p>';
207				$('.pvz_map_info').html(pvz_info);
208			}
209			else{
210				$('.pvz_map_info').html('');
211			}
212		}
213		if(delivery_type=='pickup_boxberry'){
214			if($("select[name=pvz_boxberry]").val()!=''){
215				var pvz_boxberry=$(':selected',$("select[name=pvz_boxberry]"));
216				var pvz_info='<p><strong>Выбран пункт:</strong> '+pvz_boxberry.data('name')+'</p><p><strong>Адрес:</strong> '+pvz_boxberry.data('address')+'</p><p><strong>Телефон:</strong> '+pvz_boxberry.data('phone')+'</p><p><strong>Режим работы:</strong> '+pvz_boxberry.data('hours')+'</p><p><strong>Как найти:</strong> '+pvz_boxberry.data('comment')+'</p>';
217				$('.pvz_map_info').html(pvz_info);
218			}
219			else{
220				$('.pvz_map_info').html('');
221			}
222		}
223		if(price_cidex>0&&price_delivery>0){
224			$('.result').show();
225		}
226		else{
227			$('.result').hide();
228		}
229	}
230}
231function update_cart(form){
232	$.ajax({
233		url			:	'/ajax.php?type=basket&action=update',
234		type		:	form.attr('method'),
235		data		:	form.serialize(),
236		beforeSend	:	function(){$.fancybox.showLoading();},
237		success		:	function(r){
238							var result=JSON.parse(r);
239							var current_promo=$('input[name=price_promo]').val();
240							$('#products_count').html(result['products_count']);
241							$('#cart_global_price').val(result['global_price']);
242							if(result['global_price']<700){
243								$('.min_order').show();
244								$('.min_current').html(result['global_price']);
245								$('.min_minus').html(parseInt(700-result['global_price']));
246								$('.main_form input[type=submit]').attr('disabled','disabled');
247							}
248							else{
249								$('.min_order').hide();
250								$('.main_form input[type=submit]').removeAttr('disabled');
251							}
252							if(current_promo>0){
253								$('#global_price').html('<strike>'+number_format((result['global_price']).toString())+'</strike> '+number_format((result['global_price']-current_promo).toString()));
254							}
255							else{
256								$('#global_price').html(number_format((result['global_price']).toString()));
257							}
258						//	$('#cart').html(result['products_count']+'шт. / '+number_format(result['global_price'].toString())+' руб.');
259							$('#cart .icon span').html(result['products_count']);
260							$('#cart .text span').html('на '+result['global_price']+'р.');
261							$('input[name=delivery]:checked').change();
262						},
263		complete	:	function(){
264							$.fancybox.hideLoading();
265						}
266	});
267}
268$(document).ready(function(){
269	$('.catalog_form,.details_form,#form_order').on('submit',function(){
270		var yandex_id=$(this).data('counter');
271		var yandex_goal=$(this).data('goal')
272		console.log(yandex_id+'_'+yandex_goal);
273		if(yandex_id!=''&&yandex_goal!=''){
274			//window['yaCounter'+yandex_id].reachGoal(yandex_goal);
275			ym(yandex_id,'reachGoal',yandex_goal);
276			//ga('send','event','cart',yandex_goal);
277			//gtag('event',yandex_goal);
278		}
279	});
280	$('.catalog_form, .details_form').submit(function(){
281		var catalog_colors_count=$('#color_changer').length;
282		var catalog_sizes_count=($('#select_size').find($("option")).length)-1;
283		if(($('#cart_color').val()==0&&catalog_colors_count>0)||($('#cart_size').val()==0&&catalog_sizes_count>0)){
284			var message='';
285			if($('#cart_color').val()==0&&catalog_colors_count>0){
286				$('.item_colors_title').css('color','#e03c42');
287				message+="Выберите цвет товара\n";
288			}
289			else{
290				$('.item_colors_title').css('color','#212121');
291			}
292			if($('#cart_size').val()==0&&catalog_sizes_count>0) {
293				$('.item_sizes_title').css('color','#e03c42');
294				message+="Выберите размер товара\n";
295			}
296			else{
297				$('.item_sizes_title').css('color','#212121');
298			}
299			alert(message);
300			return false;
301		}
302		else{
303			$('.item_colors_title').css('color','#212121');
304			$('.item_sizes_title').css('color','#212121');
305		}
306		if($(this).attr('class')=='details_form'){
307			add_to_card($('#detail_photo'),$(this).serialize());
308		}
309		else{
310			add_to_card($('#image_'+$(this).attr('rel')),$(this).serialize());
311		}
312		return false;
313	});
314	$('input[name=n]').bind("change keyup input click",function(){
315		if(this.value.match(/[^0-9]/g)){
316			this.value=this.value.replace(/[^0-9]/g,'');
317		}
318	});
319	/*
320	$('.btnplus').live('click',function(){
321		var on=$(this).prev("input").val()*1;
322		var n=on+1;
323		$(this).prev("input").val(n);
324	});
325	$('.btnminus').live('click',function(){
326		var on=$(this).next("input").val()*1;
327		var n=on-1;
328		n=n<0?0:n;
329		$(this).next("input").val(n);
330	});
331	*/
332	$('.btnplus').live('click',function(){
333		var on=$(this).prev("input").val()*1;
334		var n=on+1;
335		$(this).prev("input").val(n);
336		$(this).closest('li').find('.summ').html(number_format(($(this).closest('li').find('a.cart_delete').attr('p_price')*n).toString())+' руб.');
337		$(this).closest('li').find('.cart_delete').attr('p_count',n);
338		update_cart($(this).closest('form'));
339		if($(this).closest('div').hasClass('cart_item_count')){
340			window.location.reload();
341		}
342	});
343	$('.btnminus').live('click',function(){
344		var on=$(this).next("input").val()*1;
345		var n=on-1;
346		n=n<1?1:n;
347		$(this).next("input").val(n);
348		$(this).closest('li').find('.summ').html(number_format(($(this).closest('li').find('a.cart_delete').attr('p_price')*n).toString())+' руб.');
349		$(this).closest('li').find('.cart_delete').attr('p_count',n);
350		update_cart($(this).closest('form'));
351		if($(this).closest('div').hasClass('cart_item_count')){
352			window.location.reload();
353		}
354	});
355
356
357
358
359
360	$('.cart_delete').click(function(){
361		del_key=$(this).attr('rel');
362		delete_from_cart($(this).parent().parent(),del_key);
363		return false;
364	});
365	$('#radio_individual').click(function(){
366		$('.tr_legal').hide();
367		$('.tr_individual').show();
368	});
369	$('#radio_legal').click(function(){
370		$('.tr_individual').hide();
371		$('.tr_legal').show();
372	});
373	$('.tr_individual_delivery input').change(function(){
374		if($(this).val()=='Доставка курьером'){
375			$('.tr_individual_address').removeClass('hide');
376		}
377		else{
378			$('.tr_individual_address').addClass('hide');
379		}
380	});
381	$('label[for=delivery_courier]').live('click',function(){
382		$('input[name=pickup]').prop('checked',false);
383		$('input[name=post]').prop('checked',false);
384		$('#pickup_info').html('');
385	});
386	$('.delivery_details_pickup_box input[name=pickup]').live('change',function(){
387		$('#delivery_pickup').click();
388	});
389	$('.delivery_details_pickup_cdek input[name=pickup]').live('change',function(){
390		//$('#delivery_pickup_cdek').attr('checked','checked');
391		$('#delivery_pickup_cdek').click();
392	});
393	$('input[name=pickup]').live('change',function(){
394		var pickup_info='';
395		pickup_info+='Телефон: '+$(this).attr('data-phone')+'<br/>';
396		pickup_info+='График работы: '+$(this).attr('data-schedule')+'<br/>';
397		//pickup_info+='Описание проезда: '+$(this).attr('data-directions')+'<br/>';
398		$('#pickup_info').html(pickup_info);
399	});
400	$('#form_order').on('submit',function(){
401		var err=0;
402		if (!$("input[name=delivery]").is(':checked')){
403			alert('Пожалуйста выберите способ доставки');
404			err=1;
405			return false;
406		}
407		else{
408			var delivery_type=$('input[name=delivery]:checked').val();
409			if((delivery_type=='courier')&&($('input[name=address_street]').val()=='')){
410				alert('Пожалуйста укажите адрес доставки');
411				err=1;
412				return false;
413			}
414			else if((delivery_type=='courier_cdek')&&($('input[name=address_street_cdek]').val()=='')){
415				alert('Пожалуйста укажите адрес доставки');
416				err=1;
417				return false;
418			}
419			else if((delivery_type=='pickup'||delivery_type=='pickup_cdek')&&(!$("input[name=pickup]").is(':checked')&&$('select[name=pvz]').val()=='')){
420				alert('Пожалуйста выберите пункт самовывоза');
421				err=1;
422				return false;
423			}
424			else if((delivery_type=='post')&&($('textarea[name=post]').val()==''||$('input[name=zip]').val()=='')){
425				alert('Пожалуйста укажите индекс и адрес доставки ');
426				err=1;
427				return false;
428			}
429		}
430		if(err==0){
431			$.fancybox.showLoading();
432			$(this).find('input[type=submit]').attr('disabled','disabled');
433		}
434	});
435	$('input[name=zip],textarea[name=post]').bind("change keyup input click",function(){
436		$('#delivery_post').attr('checked','checked');
437	});
438	$('input[name=gift]').on('change',function(){
439		var gift=$('input[name=gift]:checked').val();
440		$('input[name=gift_m]').val(gift);
441	});
442});

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.