PageSourceSearch

https://www.landrover-saudi.com/shop/public/frontend_assets//js/save_vehicle/save_vehicle.js?1791406722

js landrover-saudi.com collected 2026-10-07 20:59:40 UTC 20,909 bytes, 595 lines download raw bytes

1
2var save_btn_cliked = false;
3
4function save_check_vehicle(current_object,checkbox)
5{
6    if(checkbox === undefined){checkbox = '';}
7    //console.log(saved_cnt);
8    var product_id = $(current_object).attr('data-product_id');
9    var ext_colour_code = $(current_object).attr('data-ext_colour_code');
10    var vin_no = $(current_object).attr('data-vin_no');
11    var order_status = $(current_object).attr('data-order_status');
12    var vehicle_type = $(current_object).attr('data-vehicle_type');
13    var dlrid = $(current_object).attr('data-dlrid');
14    var spl_offer = $(current_object).attr('data-spl_offer');
15    var check_flag = $(current_object).attr('data-check_flag');
16    var flag = $(current_object).attr('data-flag');
17    //alert('product_id:'+product_id+',ext_colour_code:'+ext_colour_code+',vin_no:'+vin_no+',order_status:'+order_status+',vehicle_type:'+vehicle_type+',dlrid:'+dlrid+',spl_offer:'+spl_offer+',check_flag:'+check_flag);
18    //console.log(check_saved_count);
19    var action_url = '';
20    
21    if(check_flag === 'true')
22    {
23        action_url = 'save_vehicle/unsave_vehicle';
24        $(current_object).attr('data-check_flag',false);
25        /*$(current_object).addClass('btn-primary');
26        $(current_object).removeClass('btn-success');*/
27//        $(current_object).html(save_btn_label);
28        //$(current_object).css({'pointer-events':'none'}); 
29        //$(current_object).blur();
30    }
31    else if(Number(check_saved_count) < Number(10))
32    {
33        action_url = 'save_vehicle/save';
34        $(current_object).attr('data-check_flag',true);
35       /* $(current_object).removeClass('btn-primary');
36        $(current_object).addClass('btn-success');*/
37    //    $(current_object).html(unsave_btn_label);
38        //$(current_object).css({'pointer-events':'none'}); 
39        //$(current_object).blur();
40    }
41    
42    if(action_url !== '')
43    {
44        save_btn_cliked = true;
45     $.ajax({
46		type:"POST",
47		url:Const.URL+action_url,
48		dataType:"json",
49		async : true,
50		data:{
51		      product_id:product_id,
52		      ext_colour_code:ext_colour_code,
53		      vin_no:vin_no,
54		      order_status:order_status,
55		      vehicle_type:vehicle_type,
56		      dlrid : dlrid,
57		      spl_offer : spl_offer,
58		      checkbox : checkbox,
59              flag:flag,
60              csrf_token : csrf.token
61		     },
62
63		success:function(response)
64		{
65		    update_csrf_token();
66		    //$(current_object).css({'pointer-events':'unset'}); 
67		    var list = window.location.href.split('/');
68		    save_count();
69        	if($(current_object).parent('div').hasClass('stock_page') === true)
70            {
71                 if(list.indexOf("new_vehicle") > -1 && !list.indexOf("details") > -1)
72                 {
73                    get_recently_view('grid');
74                 }
75                 if(list.indexOf("approved") > -1 && !list.indexOf("details") > -1)
76                 {
77                    get_recently_view('grid');
78                 }
79            }
80            if($(current_object).parent('div').hasClass('recently') === true)
81            {
82                 if(list.indexOf("new_vehicle") > -1 && !list.indexOf("details") > -1)
83                 {
84                    fetch_nv_submodel_data();
85                 }
86                 if(list.indexOf("approved") > -1 && !list.indexOf("details") > -1)
87                 {
88                    fetch_appr_submodel_data();
89                 }
90            }
91    		    /*if(response.msg === 'success')
92    		    {
93    			    $(current_object).parent('div').html(response.html);
94    		    }
95    		    else
96    		    {
97    		        //alert(response.error_msg);
98    		        $(current_object).css({'pointer-events':'auto'}); 
99    		    }*/
100    		    
101		},
102		error : function(request,status)
103    	{
104    	    if(check_flag === 'false')
105            {
106                $(current_object).attr('data-check_flag',false);
107                //$(current_object).addClass('btn-primary');
108                //$(current_object).removeClass('btn-success');
109//                $(current_object).html(save_btn_label);
110                //$(current_object).css({'pointer-events':'none'}); 
111                //$(current_object).blur();
112            }
113            else
114            {
115                $(current_object).attr('data-check_flag',true);
116                //$(current_object).removeClass('btn-primary');
117                //$(current_object).addClass('btn-success');
118        //        $(current_object).html(unsave_btn_label);
119                //$(current_object).css({'pointer-events':'none'}); 
120                //$(current_object).blur();
121            }
122    	},
123    	timeout : 6000
124	});
125	
126    }
127}
128
129
130function save_check_vehicle1(current_object,checkbox)
131{
132    if(checkbox === undefined){checkbox = '';}
133    //console.log(saved_cnt);
134    var product_id = $(current_object).attr('data-product_id');
135    var ext_colour_code = $(current_object).attr('data-ext_colour_code');
136    var vin_no = $(current_object).attr('data-vin_no');
137    var order_status = $(current_object).attr('data-order_status');
138    var vehicle_type = $(current_object).attr('data-vehicle_type');
139    var dlrid = $(current_object).attr('data-dlrid');
140    var spl_offer = $(current_object).attr('data-spl_offer');
141    var check_flag = $(current_object).attr('data-check_flag');
142    var flag = $(current_object).attr('data-flag');
143    //alert('product_id:'+product_id+',ext_colour_code:'+ext_colour_code+',vin_no:'+vin_no+',order_status:'+order_status+',vehicle_type:'+vehicle_type+',dlrid:'+dlrid+',spl_offer:'+spl_offer+',check_flag:'+check_flag);
144    //console.log(check_saved_count);
145    var action_url = '';
146    
147    if(check_flag === 'true')
148    {
149        action_url = 'save_vehicle/unsave_vehicle';
150        $(current_object).attr('data-check_flag',false);
151        /*$(current_object).addClass('btn-primary');
152        $(current_object).removeClass('btn-success');*/
153       $(current_object).html(save_btn_label);
154        //$(current_object).css({'pointer-events':'none'}); 
155        //$(current_object).blur();
156    }
157    else if(Number(check_saved_count) < Number(10))
158    {
159        action_url = 'save_vehicle/save';
160        $(current_object).attr('data-check_flag',true);
161       /* $(current_object).removeClass('btn-primary');
162        $(current_object).addClass('btn-success');*/
163        $(current_object).html(unsave_btn_label);
164        //$(current_object).css({'pointer-events':'none'}); 
165        //$(current_object).blur();
166    }
167    
168    if(action_url !== '')
169    {
170        save_btn_cliked = true;
171     $.ajax({
172		type:"POST",
173		url:Const.URL+action_url,
174		dataType:"json",
175		async : true,
176		data:{
177		      product_id:product_id,
178		      ext_colour_code:ext_colour_code,
179		      vin_no:vin_no,
180		      order_status:order_status,
181		      vehicle_type:vehicle_type,
182		      dlrid : dlrid,
183		      spl_offer : spl_offer,
184		      checkbox : checkbox,
185              flag:flag,
186              csrf_token : csrf.token
187		     },
188
189		success:function(response)
190		{
191		    update_csrf_token();
192		    //$(current_object).css({'pointer-events':'unset'}); 
193		    var list = window.location.href.split('/');
194		    save_count();
195        	if($(current_object).parent('div').hasClass('stock_page') === true)
196            {
197                 if(list.indexOf("new_vehicle") > -1 && !list.indexOf("details") > -1)
198                 {
199                    get_recently_view('grid');
200                 }
201                 if(list.indexOf("approved") > -1 && !list.indexOf("details") > -1)
202                 {
203                    get_recently_view('grid');
204                 }
205            }
206            if($(current_object).parent('div').hasClass('recently') === true)
207            {
208                 if(list.indexOf("new_vehicle") > -1 && !list.indexOf("details") > -1)
209                 {
210                    fetch_nv_submodel_data();
211                 }
212                 if(list.indexOf("approved") > -1 && !list.indexOf("details") > -1)
213                 {
214                    fetch_appr_submodel_data();
215                 }
216            }
217    		    /*if(response.msg === 'success')
218    		    {
219    			    $(current_object).parent('div').html(response.html);
220    		    }
221    		    else
222    		    {
223    		        //alert(response.error_msg);
224    		        $(current_object).css({'pointer-events':'auto'}); 
225    		    }*/
226    		    
227		},
228		error : function(request,status)
229    	{
230    	    if(check_flag === 'false')
231            {
232                $(current_object).attr('data-check_flag',false);
233                //$(current_object).addClass('btn-primary');
234                //$(current_object).removeClass('btn-success');
235               $(current_object).html(save_btn_label);
236                //$(current_object).css({'pointer-events':'none'}); 
237                //$(current_object).blur();
238            }
239            else
240            {
241                $(current_object).attr('data-check_flag',true);
242                //$(current_object).removeClass('btn-primary');
243                //$(current_object).addClass('btn-success');
244               $(current_object).html(unsave_btn_label);
245                //$(current_object).css({'pointer-events':'none'}); 
246                //$(current_object).blur();
247            }
248    	},
249    	timeout : 6000
250	});
251	
252    }
253}
254
255function save_check_vehicle2(current_object,checkbox)
256{
257    if(checkbox === undefined){checkbox = '';}
258    //console.log(saved_cnt);
259    var product_id = $(current_object).attr('data-product_id');
260    var ext_colour_code = $(current_object).attr('data-ext_colour_code');
261    var vin_no = $(current_object).attr('data-vin_no');
262    var order_status = $(current_object).attr('data-order_status');
263    var vehicle_type = $(current_object).attr('data-vehicle_type');
264    var dlrid = $(current_object).attr('data-dlrid');
265    var spl_offer = $(current_object).attr('data-spl_offer');
266    var check_flag = $(current_object).attr('data-check_flag');
267    var flag = $(current_object).attr('data-flag');
268    //alert('product_id:'+product_id+',ext_colour_code:'+ext_colour_code+',vin_no:'+vin_no+',order_status:'+order_status+',vehicle_type:'+vehicle_type+',dlrid:'+dlrid+',spl_offer:'+spl_offer+',check_flag:'+check_flag);
269    //console.log(check_saved_count);
270    var action_url = '';
271    
272    if(check_flag === 'true')
273    {
274        action_url = 'save_vehicle/unsave_vehicle';
275        $(current_object).attr('data-check_flag',false);
276        /*$(current_object).addClass('btn-primary');
277        $(current_object).removeClass('btn-success');*/
278       $(current_object).html(save_btn_label_2);
279        //$(current_object).css({'pointer-events':'none'}); 
280        //$(current_object).blur();
281    }
282    else if(Number(check_saved_count) < Number(10))
283    {
284        action_url = 'save_vehicle/save';
285        $(current_object).attr('data-check_flag',true);
286       /* $(current_object).removeClass('btn-primary');
287        $(current_object).addClass('btn-success');*/
288        $(current_object).html(unsave_btn_label_2);
289        //$(current_object).css({'pointer-events':'none'}); 
290        //$(current_object).blur();
291    }
292    
293    if(action_url !== '')
294    {
295        save_btn_cliked = true;
296     $.ajax({
297		type:"POST",
298		url:Const.URL+action_url,
299		dataType:"json",
300		async : true,
301		data:{
302		      product_id:product_id,
303		      ext_colour_code:ext_colour_code,
304		      vin_no:vin_no,
305		      order_status:order_status,
306		      vehicle_type:vehicle_type,
307		      dlrid : dlrid,
308		      spl_offer : spl_offer,
309		      checkbox : checkbox,
310              flag:flag,
311              csrf_token : csrf.token
312		     },
313
314		success:function(response)
315		{
316		    update_csrf_token();
317		    //$(current_object).css({'pointer-events':'unset'}); 
318		    var list = window.location.href.split('/');
319		    save_count();
320        	if($(current_object).parent('div').hasClass('stock_page') === true)
321            {
322                 if(list.indexOf("new_vehicle") > -1 && !list.indexOf("details") > -1)
323                 {
324                    get_recently_view('grid');
325                 }
326                 if(list.indexOf("approved") > -1 && !list.indexOf("details") > -1)
327                 {
328                    get_recently_view('grid');
329                 }
330            }
331            if($(current_object).parent('div').hasClass('recently') === true)
332            {
333                 if(list.indexOf("new_vehicle") > -1 && !list.indexOf("details") > -1)
334                 {
335                    fetch_nv_submodel_data();
336                 }
337                 if(list.indexOf("approved") > -1 && !list.indexOf("details") > -1)
338                 {
339                    fetch_appr_submodel_data();
340                 }
341            }
342    		    /*if(response.msg === 'success')
343    		    {
344    			    $(current_object).parent('div').html(response.html);
345    		    }
346    		    else
347    		    {
348    		        //alert(response.error_msg);
349    		        $(current_object).css({'pointer-events':'auto'}); 
350    		    }*/
351    		    
352		},
353		error : function(request,status)
354    	{
355    	    if(check_flag === 'false')
356            {
357                $(current_object).attr('data-check_flag',false);
358                //$(current_object).addClass('btn-primary');
359                //$(current_object).removeClass('btn-success');
360               $(current_object).html(save_btn_label_2);
361                //$(current_object).css({'pointer-events':'none'}); 
362                //$(current_object).blur();
363            }
364            else
365            {
366                $(current_object).attr('data-check_flag',true);
367                //$(current_object).removeClass('btn-primary');
368                //$(current_object).addClass('btn-success');
369               $(current_object).html(unsave_btn_label_2);
370                //$(current_object).css({'pointer-events':'none'}); 
371                //$(current_object).blur();
372            }
373    	},
374    	timeout : 6000
375	});
376	
377    }
378}
379
380function get_save_data()
381{
382    var event_action = 'view saved quotes';
383    var event_category = 'account';
384    $.ajax({
385		type:"POST",
386		url:Const.URL+'save_vehicle/get_saved_data',
387		dataType:"json",
388		data:{csrf_token : csrf.token},
389        async : false,
390		success:function(response)
391        {
392            update_csrf_token();
393           // console.log(response);
394    		//$("#compare_count").html(response.count);
395		    if(response.count === 0)
396		    {
397		       //$("#compare_count").html('');  
398		       
399		    }
400		    google_analytics(event_action,event_category);
401    		$("#saved_response_data").html(response.data);
402		}
403	});
404}
405
406function save_count()
407{
408    $.ajax({
409		type:"POST",
410		url:Const.URL+'save_vehicle/get_save_count',
411		dataType:"json",
412		data:{csrf_token : csrf.token},
413        async : false,
414		success:function(response)
415		{
416		    update_csrf_token();
417            //console.log(response);
418    		$(".saved_count").html(response.count);
419    		check_saved_count = response.count;
420		    if(response.count === 0)
421		    {
422		      $(".saved_count").html('');  
423		      $(".saved_count_link").css({"display":"none"});
424		      if(window.location.href.indexOf("save_vehicle") !=-1 || window.location.href.indexOf("saved") !=-1) history.back();
425		    }
426		    else
427		    {
428		        $(".saved_count_link").css({"display":"inline-block"});
429		    }
430		}
431	});
432}
433
434function remove_saved2(current_object,explore_url,reload)
435{
436    if(reload === undefined){reload = false;}
437    $(current_object).css({'pointer-events':'none'}); 
438    if(check_saved_count !== 0)
439    {
440        check_saved_count = check_saved_count - 1;
441        $(".saved_count").html(check_saved_count);
442        if(check_saved_count === 0) $(".saved_count").html('');
443    }
444    if(check_saved_count === 0)
445    {
446        $(".saved_count").html('');
447    }
448    
449    $(current_object).parentsUntil(".car-box").parent().css({"display":"none"});
450    
451    var product_id = $(current_object).attr('data-product_id');
452    var ext_colour_code = $(current_object).attr('data-ext_colour_code');
453    var vin_no = $(current_object).attr('data-vin_no');
454    var order_status = $(current_object).attr('data-order_status');
455    var dlrid = $(current_object).attr('data-dlrid');
456    var vehicle_type = $(current_object).attr('data-vehicle_type');
457    var spl_offer = '';
458    $.ajax({
459		type:"POST",
460		url:Const.URL+'save_vehicle/remove_saved_data2',
461		dataType:"json",
462		async : false,
463		data:{
464		      product_id:product_id,
465		      ext_colour_code:ext_colour_code,
466		      vin_no:vin_no,
467		      order_status:order_status,
468		      dlrid:dlrid,
469		      vehicle_type:vehicle_type,
470		      spl_offer:spl_offer
471		      ,csrf_token : csrf.token
472		     },
473
474		success:function(response)
475		{
476		    update_csrf_token();
477    		 if(check_saved_count === 0)
478            {
479                window.location.href = explore_url;
480            }
481            else
482            {
483                window.location.reload();
484            }
485    	}
486	});
487    
488}
489
490/////////////function for header save count is zero
491
492function check_save_count()
493{
494    if(check_saved_count === 0)
495    {
496       $("#save_count_zero_popup").modal('show'); 
497    }
498    else
499    {
500        if(window.location.href.indexOf("save_vehicle") ===-1 || window.location.href.indexOf("saved") ===-1) window.location.href = Const.URL+site_lang+'/saved'  + window.location.search;
501    }
502}
503
504
505/* Google Analytics */
506    function save_google_anylytics(product_id,vin_no,model,dlrid,event_action,event_category)
507    {
508        window.dataLayer = window.dataLayer || [];
509        window.dataLayer.push({
510          event: 'pushedEvent',
511          eventCateogry: event_category,
512          eventAction: event_action,
513          eventLabel: model,//market can determine naming convention
514              vehicle: 
515              {
516                id: product_id,
517                nameplate: vin_no,
518                bodystyle: model
519              },
520              dealer: 
521              {
522                id: dlrid,
523                name: model
524              }
525          });
526    }
527
528function google_analytics(event_action,event_category)
529    {
530        window.dataLayer = window.dataLayer || [];
531        window.dataLayer.push({
532          event: 'pushedEvent',
533          eventCateogry: event_category,
534          eventAction: event_action,
535          eventLabel: '',
536          eventNonInteraction: ''
537          });
538    }
539function filter_google_analytics(event_action,event_category,event_label)
540    {
541        window.dataLayer = window.dataLayer || [];
542        window.dataLayer.push({
543          event: 'pushedEvent',
544          eventCateogry: event_category,
545          eventAction: event_action,
546          eventLabel: event_label,
547          eventNonInteraction: '',
548          });
549    }
550
551    function add_vehicle_details(current_object){
552       
553         var product_id = $(current_object).attr('data-product_id');
554         var ext_colour_code = $(current_object).attr('data-ext_colour_code');
555         var order_status = $(current_object).attr('data-order_status');
556         var spl_offer = $(current_object).attr('data-spl_offer');
557         var vehicle_type = $(current_object).attr('data-vehicle_type');
558         var model = $(current_object).attr('data-model');
559         var submodel = $(current_object).attr('data-submodel');
560         var engine = $(current_object).attr('data-engine');
561        
562          $.ajax({
563             type:"POST",
564             url:Const.URL+'build_your_own/set_vehicle_1',
565             dataType:"json",
566             data:{
567                   product_id:product_id,
568                   ext_colour_code:ext_colour_code,
569                   order_status:order_status,
570                   spl_offer:spl_offer,
571                   vehicle_type:vehicle_type,
572                //   csrf_token:csrf.token,
573                   model:model,
574                   submodel:submodel,
575                   engine:engine,
576                   csrf_token : csrf.token
577                  },
578     
579             success:function(response)
580             { 
581                update_csrf_token();
582                 if(response.msg == 'success')
583                 {
584                      //window.location.href = response.redirect_url;
585                      window.location.href = Const.URL+'en/build/vehicle_summary'+'/'+model.toLowerCase().replace(/ /g, "_");
586                 }
587                 else
588                 {
589                     alert('Please try again!');
590                 }
591                         
592             }
593         });
594     }
595     

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.