PageSourceSearch

https://www.lakshmimusicshop.com/public/js/cart.js

js lakshmimusicshop.com collected 2026-10-03 18:29:11 UTC 14,653 bytes, 827 lines download raw bytes

1  $(document).ready(function(){   
2
3   
4
5   var mURL = window.location.origin+"/";
6   
7   var rURL = window.location.origin+"/index/";
8
9  	 	    
10
11    var cartTotal = 0; 
12
13    var country = "";
14
15    var zone = "";
16
17    var district = "";
18
19    var currencyCode = "";
20
21    var currencyValue = "";
22
23    var currencySymbol = "";
24
25    var currencyValue = "";
26    
27
28     if(typeof $.cookie('CURC') === 'undefined')
29      {
30          getIPAddress();
31       }
32       else {
33          
34          showPosition();  
35
36       } 
37
38    
39    // getIPAddress();
40    function getIPAddress(){
41      $.ajax({
42        url:rURL+'xhrGetMyIp', 
43        type:'POST',
44        processData:false,
45        contentType:false,
46        success:function(result){
47          //alert(result);
48          var settings = {
49          "async": false,
50          "crossDomain": true,
51          "dataType":"json",
52          "url": "https://ip-geo-location.p.rapidapi.com/ip/"+result+"?format=json",
53          "method": "GET",
54          "headers": {
55            "x-rapidapi-host": "ip-geo-location.p.rapidapi.com",
56            "x-rapidapi-key": "11bd3098fcmsh74b46a82ffed141p1a721ejsne24edae423d4"
57          }
58        }
59
60	
61
62        $.ajax(settings).done(function (response) 
63        {
64	
65       // var result = response.currency;
66
67        var currencys = response.currency.code;  
68	
69          var sorts = response.country.code;
70
71             var sd = response.area.code;
72
73               sds = sd.split("-");
74
75           var snames = sds[1];
76   
77
78         $.cookie("Countrys", sorts,{ path: "/" });  
79     
80         //alert($.cookie("Countrys"));
81
82         $.cookie("States", snames,{ path: "/" }); 
83
84         //alert($.cookie("States"));
85
86        
87         $.cookie("CURC", currencys,{ path: "/" }); 
88        
89          // alert($.cookie("CURC"));
90
91	        getCartTotal();
92        });
93
94       }
95
96    });
97
98    }
99 
100
101
102function showPosition() {
103
104    var content = "";
105
106   currencyCode = $.cookie("CURC");
107
108    if(currencyCode == ""){
109
110      currencyValue = 1;
111
112
113
114        getCartTotal();
115
116
117         return;
118
119    }
120
121    $.ajax({
122
123        url:'https://openexchangerates.org/api/currencies.json',
124
125        dataType:'json',
126
127        success:function(result)
128
129        {  
130
131
132
133          if(currencyCode == ""){
134
135           currencyValue = 1;
136
137
138
139              getCartTotal();
140
141
142
143            return;  
144
145           }
146
147        }
148
149    })
150
151
152
153    $.ajax({
154
155      url:'https://api.exchangerate-api.com/v4/latest/'+currencyCode,
156
157      dataType:'json',
158
159      success:function(result)
160
161      {   
162
163
164
165        item = result.rates;
166
167        i = 0;
168
169        currencyValue = item.INR;
170
171       
172
173        var cURL = mURL+"/cart/xhrGetCurrencySymbol";
174
175        data = {currency:currencyCode};
176
177        $.ajax({
178
179          url:cURL,
180
181          type:'POST',
182
183          data:data,
184
185          
186
187          success:function(result){
188
189            currencySymbol = result;
190
191
192
193             getCartTotal();
194
195          
196
197          }
198
199        }); 
200
201          
202
203        }
204
205    });
206
207
208
209  } 
210
211          
212
213
214
215function formatNumber(num) {
216
217  return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
218
219}
220
221
222
223function getCartTotal()
224
225{      
226
227     
228
229            var qty = $.cookie("QTY");
230
231          var price = $.cookie("PRICE");
232
233
234
235          if(typeof $.cookie('QTY') === 'undefined')
236
237         {
238
239
240
241              $('.top').html(currencySymbol+ " 0.00"); 
242
243
244
245            }
246
247     else
248
249        {   
250
251                qty = qty.split(",");
252
253              price = price.split(",");
254
255            var cartTotal = 0;
256
257          for (i = 0; i < qty.length; i++) 
258
259               {
260
261                 cartTotal += parseInt(qty[i]) * parseFloat(price[i]);
262
263               }     
264
265              
266
267               $('.top').html(currencySymbol+ formatNumber(cartTotal.toFixed(2)));
268
269
270
271              }   
272
273}
274
275
276
277$('.carts').click(function(){ 
278
279             $("div#divLoading").addClass('show');
280
281         var urls = mURL+'/item/xhrSessioncheck';
282
283  cartTotal = 0;
284  var content=""; 
285        if(typeof $.cookie('NAME') === 'undefined')
286           {
287              content += "<div class='dropdown-item dropd'>Your cart is empty</div>"; 
288           }
289          else {   
290        content += "<div class='responsive d-none'>";
291        content += "<table class='table table-responsive' id='shoping'>";
292        content += "<thead>";
293        content += "<tr>";
294        content += "<th> </th>";
295        content += "<th>
295Name</th>";
296        content += "<th>Quantity</th>";
297        content += "<th class='prs'>Price</th>";
298        content += "<th>Total</th>";
299        content += "</tr>";
300        content += "</thead>";
301        
302          var name = $.cookie("NAME"); 
303          var id = $.cookie("ID");
304          var qty = $.cookie("QTY");
305          var price = $.cookie("PRICE");
306          var qtys = $.cookie("QTYS"); 
307          var cwt = $.cookie("CWT"); 
308
309          name = name.split(",");
310          id = id.split(",");
311          qty = qty.split(",");
312          price = price.split(",");
313          qtys  = qtys.split(",");
314          cwt = cwt.split(",");
315
316          var i=0;
317          content += "<tbody>"; 
318          $.each(name, function(index, element)
319          {
320          i++;
321          content += "<tr class='myRows'>"; 
322          content += "<td><a class='del' id="+id[index]+"><i class='fa fa-times'></i></a></td>";
323          content += "<td>"+name[index]+"</td>";
324          var myqtys = $('#iqty').attr('max');
325          content += "<td><input type='number' class='form-control qc' id='qc-"+i+"' min='1' max="+qtys[index]+" value ="+qty[index]+"></td>";
326          content += "<input type='hidden' id='maxqc' value ="+qty[index]+">";
327          content += '<input type="hidden" id="maxwc" value="'+cwt[index]+'">';
328          content += "<td id='pr"+i+"' class='text-right prs'>"+price[index]+"</td>";
329          total = parseInt(qty[index]*parseFloat(price[index]));
330          content += "<td id='adds"+i+"' class='text-right'>"+total+"</td>";
331          cartTotal += total;
332          content += "</tr>";
333            
334          }); 
335
336          totalRowCount = i;
337          content += "</tbody>";
338              
339        content += "</table>";
340        content += "</div>";
341        content +="<div class='row paddinglr15 d-none'>";
342        content +="<table class='table'>";
343        content +="<tr>";
344        content +="<th>Total</th>";
345        content +="<td class='text-center'><span id='over'>"+cartTotal+"</span></td>";
346        content +="</tr>";
347        content +="</table>";
348        content +="<div class='checkBtn'>";
349        content +="<button type='button'";
350        content +="class='btn btn-primary btn-lg btn-block ctp'>";
351        content +="Checkout</button></div>";
352        content +="<div class='checkBtn'>";
353        content += '<div id="alertss">Kindly enter a value less than or equal to 1000</div>';
354        content += '</div></div>';
355
356               
357                                       $.ajax({
358
359               url:urls,
360
361               type:'post',
362
363               processData:false,
364
365               contentType:false,
366
367               success:function(result){
368
369                 //alert(result);
370
371              if(result == 0){
372                
373         
374                 $("#exampleModalCenters").modal('hide');
375                 
376                 $("#exampleModalCenter").modal('show');
377                   
378
379              }
380
381              else{
382
383              
384
385                window.location.href = mURL+'cart';
386
387              }  
388
389
390
391          }
392
393      }); 
394
395  
396    setTimeout(function() {
397    $('#divLoading').removeClass('show');
398}, 300);
399
400
401
402            }
403            
404        $('.textbox').html(content);
405
406         getCartTotal();
407
408        
409});
410
411
412
413   $(document).on('click','.del',function(){ 
414
415        // $("div#divLoading").addClass('show');
416    
417         $("div#divLoading-spin").show(0);
418
419         var currentId = this.id;
420
421          var id = $.cookie("ID");
422
423           	id = id.split(",");
424
425           	var position = -1;
426
427           	for(i = 0; i < id.length; i++)
428
429            {
430
431           		if(id[i] == currentId)
432
433              {
434
435           		 	     position = i;
436
437           		 	     break;        
438
439           		}
440
441           	}
442
443
444
445            
446
447          ID = $.cookie("ID");
448
449          NAME = $.cookie("NAME");
450
451          PRICE = $.cookie("PRICE");
452
453          QTY = $.cookie("QTY");
454          
455          CWT = $.cookie("CWT");
456
457
458
459          ID = ID.split(",");
460
461          NAME = NAME.split(",");
462
463          PRICE = PRICE.split(",");
464
465          QTY = QTY.split(",");
466
467          CWT = CWT.split(",");
468
469
470
471          var newId = null;
472
473          var newName = null;
474
475          var newPrice = null;
476
477          var newQty = null;
478
479          var newCwt = null;
480
481
482
483          var cookieLength = ID.length;
484
485          
486
487          if(cookieLength > 1)
488
489          {
490
491                      for(i = 0 ; i < ID.length; i++)
492
493          {
494
495            if(position != i)
496
497            {
498
499                if(newId != null){
500
501                  newId += ","+ID[i];
502
503                }
504
505                else{
506
507                  newId = ID[i];
508
509                }
510
511            }
512
513          }
514
515
516
517          for(i = 0 ; i < NAME.length; i++){
518
519            if(position != i)
520
521            {
522
523                if(newName != null){
524
525                  newName += ","+NAME[i];
526
527                }
528
529                else{
530
531                  newName = NAME[i];
532
533                }
534
535            }
536
537          }
538
539
540
541          for(i = 0 ; i < PRICE.length; i++){
542
543            if(position != i)
544
545            {
546
547                if(newPrice != null){
548
549                  newPrice += ","+PRICE[i];
550
551                }
552
553                else{
554
555                  newPrice = PRICE[i];
556
557                }
558
559            }
560
561          }
562
563
564
565          for(i = 0 ; i < QTY.length; i++){
566
567            if(position != i)
568
569            {
570
571                if(newQty != null){
572
573                  newQty += ","+QTY[i];
574
575                }
576
577                else{
578
579                  newQty = QTY[i];
580
581                }
582
583            }
584
585          }
586
587         
588           for(i = 0 ; i < CWT.length; i++){
589
590            if(position != i)
591
592            {
593                if(newCwt != null){
594
595                  newCwt += ","+CWT[i];
596
597                }
598
599                else{
600
601                  newCwt = CWT[i];
602
603                }
604            }
605          }  
606
607
608
609             $.cookie("ID", newId,{ path: "/" });
610
611             $.cookie("NAME", newName,{ path: "/" });
612
613             $.cookie("PRICE", newPrice,{ path: "/" });
614
615             $.cookie("QTY", newQty,{ path: "/" });  
616             
617             $.cookie("CWT",newCwt,{path: "/"});
618             
619             $("#exampleModalCenters").modal('hide');
620
621          }
622
623          else{
624
625
626
627                $.removeCookie('ID',{ path: "/" });
628
629                $.removeCookie('NAME',{ path: "/" });
630
631                $.removeCookie('PRICE',{ path: "/" });
632
633                $.removeCookie('QTY',{ path: "/" });
634
635                $.removeCookie('CWT',{path: "/"}); 
636                
637                $("#exampleModalCenters").modal('hide');
638
639               }
640
641
642
643 setTimeout(function() {
644
645   // $('#divLoading').removeClass('show');
646
647   $("div#divLoading-spin").hide(0);
648
649
650}, 300);
651
652
653
654 getCartTotal();
655
656          }); 
657
658       
659
660$(document).on('change','.qc',function(){ 
661
662 // $("div#divLoading").addClass('show'); 
663    
664     $("div#divLoading-spin").show(0);
665
666          var id = this.id;
667          id = id.split("-");
668          var quanc = $(this).val();
669          var pric = $('#pr'+id[1]).html();
670
671          tot = parseInt(quanc) * parseFloat(pric);
672
673             $('td#adds'+id[1]).html(tot);
674
675
676                         var tots = 0;
677
678                       for(i = 1; i <= totalRowCount; i++)
679
680                       {
681
682                          tots += parseFloat($("td#adds"+i).html());    
683                         
684                       }
685                         
686                                          
687
688              var cookie_ID = $.cookie("ID");
689              cookie_ID = cookie_ID.split(",");
690              position = id[1]-1;
691              $("span#over").html(tots);
692    
693              var cookie_qty = $.cookie("QTY");
694              cookie_qty = cookie_qty.split(",");
695              cookie_qty[position] = quanc;
696              cookie_qty = cookie_qty.join(",");
697              $.cookie("QTY", cookie_qty,{ path: "/" });
698
699               setTimeout(function() {
700    //$('#divLoading').removeClass('show');
701     $("div#divLoading-spin").hide(0);
702}, 300);  
703  
704  getCartTotal();
705
706     }); 
707
708 $(document).on('keyup','.qc',function(){
709
710       var id = this.id;
711       var qid = id.split("-");
712       var quans = $(this).val();
713
714       var oldvalue = $('#maxqc').val();
715   
716    var itemMax = $('#'+id).attr('max');
717
718   if(parseInt(quans) > parseInt(itemMax)) 
719     {
720       toasts(itemMax)
721       $('.qc').val(oldvalue);
722     }
723});
724
725 function toasts(itemMax){
726  var message = "These items available on "+itemMax;
727  $.toast({
728               heading: 'Error',
729               text: message,
730               position: 'mid-center',
731               icon: 'error',
732               loaderBg: '#ffffff',
733               stack: false
734})
735 }
736
737
738$(document).on('click','.ctp',function(){ 
739
740  //$("div#divLoading").addClass('show'); 
741 
742   $("div#divLoading-spin").show(0);
743
744         var urls = mURL+'/item/xhrSessioncheck';
745
746         // alert(link);
747
748      $.ajax({
749
750               url:urls,
751
752               type:'post',
753
754               processData:false,
755
756               contentType:false,
757
758               success:function(result){
759
760                 //alert(result);
761
762              if(result == 0){
763                
764         
765                 $("#exampleModalCenters").modal('hide');
766                 
767                 $("#exampleModalCenter").modal('show');
768                   
769
770              }
771
772              else{
773
774              
775
776                window.location.href = mURL+'cart';
777
778              }  
779
780
781
782          }
783
784      }); 
785
786  
787    setTimeout(function() {
788   // $('#divLoading').removeClass('show');
789     $("div#divLoading-spin").hide(0);
790}, 300);
791
792   
793
794   }); 
795
796$(document).on('click','.searchMobile',function(){
797
798  // $("div#divLoading").addClass('show'); 
799   
800         $("div#divLoading-spin").show(0);
801          
802           $.removeCookie('Pagesets',{ path: "/" });
803       
804         window.location.href = mURL+'/search?key='+$('#inames').val();
805});
806
807
808
809$(document).on('click','.searchs',function(){ 
810
811  // $("div#divLoading").addClass('show'); 
812   
813         $("div#divLoading-spin").show(0);
814        
815          $.removeCookie('Pagesets',{ path: "/" });
816
817        window.location.href = mURL+'/search?key='+$('#iname').val();
818
819
820   
821
822   }); 
823
824
825
826 });
827

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.