Subversion Repositories SmartDukaan

Rev

Rev 19887 | Rev 20671 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19887 Rev 20504
Line 464... Line 464...
464
            for(var i in livePriceCalls){
464
            for(var i in livePriceCalls){
465
                livePriceCalls[i].abort();
465
                livePriceCalls[i].abort();
466
            }
466
            }
467
        }
467
        }
468
        $('#loadingModal').modal();
468
        $('#loadingModal').modal();
469
        if($(this).data('source')==2){
-
 
470
            //in case of flipkart, close popup after 5 seconds
-
 
471
            setTimeout(function(){ $('#loadingModal').modal('hide');$('#customMessageModal').modal('hide'); }, 1000*10);            
-
 
472
        }
-
 
473
        var store = $(this).data('source');
469
        var store = $(this).data('source');
474
        var url = apihost+"clicks/add/"+me+"/"+$(this).data('id')+'/'+$(this).data('source')+'/?url='+encodeURIComponent($(this).data('url'))+'&price='+$(this).data('price');
470
        var url = apihost+"clicks/add/"+me+"/"+$(this).data('id')+'/'+$(this).data('source')+'/?url='+encodeURIComponent($(this).data('url'))+'&price='+$(this).data('price');
475
        $.ajax({
471
        $.ajax({
476
            url: url,
472
            url: url,
477
            // The name of the callback parameter, as specified by the YQL service
473
            // The name of the callback parameter, as specified by the YQL service
Line 483... Line 479...
483
                format: "json"
479
                format: "json"
484
            },
480
            },
485
            // Work with the response
481
            // Work with the response
486
            success: function( response ) {
482
            success: function( response ) {
487
                if(response.success && response.type=='redirect'){
483
                if(response.success && response.type=='redirect'){
488
                    //console.log(store);
-
 
489
                    if(store == 5) {
484
                    if(store == 5) {
490
                        //check if shopclues is active or not
485
                        //check if shopclues is active or not
491
                        active = getCookie('shopcluesActive',1);
486
                        active = getCookie('shopcluesActive',1);
492
                        response.url = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
487
                        response.url = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
493
                        if(active && active == 'true'){                         
488
                        if(active && active == 'true'){                         
Line 497... Line 492...
497
                            pma.send('apk','shopclues','inactive',me,null);
492
                            pma.send('apk','shopclues','inactive',me,null);
498
                            $('#loadingModal').modal('hide');
493
                            $('#loadingModal').modal('hide');
499
                            showShopcluesPopup(response.url);
494
                            showShopcluesPopup(response.url);
500
                        }
495
                        }
501
                    } else if(store == 6 ) {
496
                    } else if(store == 6 ) {
502
                        //display paytm help
-
 
503
//                      if(needToDisplayPaytmPopup(me)){
-
 
504
//                          showPaytmHelpPopup();
-
 
505
//                          $('#oktatabyebye').on('click',function(){
-
 
506
//                              redirectToPaytm(response.url);  
-
 
507
//                          }); 
-
 
508
//                      }else{
-
 
509
                            redirectToPaytm(response.url);  
497
                    	redirectToPaytm(response.url);
510
//                      }
-
 
511
 
-
 
512
                    } 
-
 
513
                      //for homeshop 18
498
                    }//for homeshop 18
514
                      else if(store == 7)
499
                    else if(store == 7){
515
                      {
-
 
516
                            redirectTohomeShop18(response.url); 
500
                    	redirectTohomeShop18(response.url);
517
                        
-
 
518
                      }
-
 
519
                      else if (store == 3 || store == 2) {
501
                    } else if (store == 3 || store == 2) {
520
                        if (store == 2){
502
                        if (store == 2){
521
                            response.url = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
503
                            response.url = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
522
                        }
504
                        }
523
                        if (store == 3){
505
                        if (store == 3){
524
                            response.url = '/r.html?'+Base64.encode(response.url);
506
                            response.url = '/r.html?'+Base64.encode(response.url);
525
                        }
507
                        }
526
                        if(response.showmessage == 1) {
-
 
527
                            $('#loadingModal').modal('hide');
-
 
528
                            $('#customMessage').html(response.message);
-
 
529
                            $('#customMessageModal').modal('show');                         
-
 
530
                            setTimeout(function(){ document.location = response.url;}, 1000*3);         
-
 
531
                        } else{
-
 
532
                            document.location = response.url;   
-
 
533
                        }
-
 
534
                    } else if (store == 4) {
508
                    } else if (store == 4) {
535
                        var urll = apihost+"categories/saholicdeal/"+proid;
509
                        var urll = apihost+"categories/saholicdeal/"+proid;
536
                        $.ajax({
510
                        $.ajax({
537
                            method: "GET",
511
                            method: "GET",
538
                            url:  urll,
512
                            url:  urll,
Line 542... Line 516...
542
                                localStorage.removeItem("productdetail");
516
                                localStorage.removeItem("productdetail");
543
                                localStorage.setItem("productdetail",msg);
517
                                localStorage.setItem("productdetail",msg);
544
                                document.location = apihost+"categories/dealdetail/"+identifier;
518
                                document.location = apihost+"categories/dealdetail/"+identifier;
545
                            }
519
                            }
546
                        });
520
                        });
547
                        
-
 
548
//                        response.url = '/r.html?'+Base64.encode(response.url);
521
                        response.url = '/r.html?'+Base64.encode(response.url);
549
 
-
 
550
//                        document.location = response.url;
-
 
551
                    } 
522
                    }
552
                    
-
 
553
                    else{
523
                    else{
554
                        response.url = '/r.html?'+Base64.encode(response.url);
524
                        response.url = '/r.html?'+Base64.encode(response.url);
-
 
525
                    }
-
 
526
                    if(response.showmessage == 1) {
-
 
527
                    	$('#loadingModal').modal('hide');
-
 
528
                    	$('#customMessage').html(response.message);
-
 
529
                    	$('#customMessageModal').modal('show');
-
 
530
                    	setTimeout(function(){ document.location = response.url;}, 1000*3);
555
 
-
 
-
 
531
                    } else{
556
                      document.location = response.url;
532
                    	document.location = response.url;   
557
                    }
533
                    }
558
                }
534
                }
559
            },
535
            },
560
            error: function() {
536
            error: function() {
561
                document.location = url;
537
                document.location = url;
Line 924... Line 900...
924
    var brandnames = [];
900
    var brandnames = [];
925
    var subcategories = [];
901
    var subcategories = [];
926
    var subcatnames = [];
902
    var subcatnames = [];
927
    
903
    
928
    if($("#brandselecter").length == 0 && urldet['brands'] != undefined && urldet['brands'] != ''){
904
    if($("#brandselecter").length == 0 && urldet['brands'] != undefined && urldet['brands'] != ''){
929
//      brands = urldet['brands'];
-
 
930
        brands = urldet['brands'].split("^");
905
        brands = urldet['brands'].split("^");
931
    }
906
    }
932
    if($("#subcategoryselecter").length == 0 && urldet['subcategories'] != undefined && urldet['subcategories'] != ''){
907
    if($("#subcategoryselecter").length == 0 && urldet['subcategories'] != undefined && urldet['subcategories'] != ''){
933
        subcategories = urldet['subcategories'].split("^");;
908
        subcategories = urldet['subcategories'].split("^");;
934
    }
909
    }
Line 957... Line 932...
957
	        url = $('#subcategoryselecter').prop('action'); 
932
	        url = $('#subcategoryselecter').prop('action'); 
958
	    }
933
	    }
959
 
934
 
960
        if(brands.length==0 && subcategories.length==0){
935
        if(brands.length==0 && subcategories.length==0){
961
            $('#loadingModal').modal('hide');
936
            $('#loadingModal').modal('hide');
962
//          $('clearfilters').click();
-
 
963
//          setCookie('brandschosen', '', -1, true);
-
 
964
//            setCookie('subcategorieschosen','',-1, true); 
-
 
965
            var url = '';
937
            var url = '';
966
            document.location = url; 
938
            document.location = url; 
967
            
939
            
968
//            $('#message').html('Please choose a few brands/subcategories first').removeClass('hidden');
-
 
969
//            setTimeout(function(){ $('#message').addClass('hidden'); }, 3000);
-
 
970
//            $(this).prop('disabled',false);
-
 
971
//            return false;
-
 
972
        }else if(brands.length==0 && subcategories.length>0 ){
940
        }else if(brands.length==0 && subcategories.length>0 ){
973
//            setCookie('subcategorieschosen', subcategories, 0.25, true);
-
 
974
//            var url = $('#subcategoryselecter').prop('action');
-
 
975
            ga('send', 'event', 'filter', 'subcategory', subcatnames.join('|'));
941
            ga('send', 'event', 'filter', 'subcategory', subcatnames.join('|'));
976
            properties = {};
942
            properties = {};
977
            for(var i in subcatnames){
943
            for(var i in subcatnames){
978
                properties['subcategories_'+i] = subcatnames[i];
944
                properties['subcategories_'+i] = subcatnames[i];
979
            }
945
            }
Line 983... Line 949...
983
                $('#loadingModal').modal('hide');
949
                $('#loadingModal').modal('hide');
984
                $(this).prop('disabled',false);
950
                $(this).prop('disabled',false);
985
                document.location = url.split("?")[0]+'?filter=subcategory&subcategories='+subcategories.join('^')+"&whatfirst=subCategory";
951
                document.location = url.split("?")[0]+'?filter=subcategory&subcategories='+subcategories.join('^')+"&whatfirst=subCategory";
986
            }); 
952
            }); 
987
        }else if(brands.length>0 && subcategories.length==0 ){
953
        }else if(brands.length>0 && subcategories.length==0 ){
988
//            setCookie('brandschosen', brands, 0.25, true);
-
 
989
//            var url = $('#brandselecter').prop('action');
-
 
990
        	
-
 
991
            ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
954
            ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
992
            properties = {};
955
            properties = {};
993
            for(var i in brandnames){
956
            for(var i in brandnames){
994
                properties['brand_'+i] = brandnames[i];
957
                properties['brand_'+i] = brandnames[i];
995
            }
958
            }
Line 1001... Line 964...
1001
                document.location = url.split("?")[0]+'?filter=brand&brands='+brands.join('^')+"&whatfirst=brand";
964
                document.location = url.split("?")[0]+'?filter=brand&brands='+brands.join('^')+"&whatfirst=brand";
1002
            });     
965
            });     
1003
        }else if(brands.length>0 && subcategories.length>0 ){
966
        }else if(brands.length>0 && subcategories.length>0 ){
1004
            setCookie('brandschosen', brands, 0.25, true);
967
            setCookie('brandschosen', brands, 0.25, true);
1005
            setCookie('subcategorieschosen', subcategories, 0.25, true);
968
            setCookie('subcategorieschosen', subcategories, 0.25, true);
1006
//            var url = $('#brandselecter').prop('action');
-
 
1007
            ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
969
            ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
1008
            ga('send', 'event', 'filter', 'subcategory', subcatnames.join('|'));
970
            ga('send', 'event', 'filter', 'subcategory', subcatnames.join('|'));
1009
            properties = {};
971
            properties = {};
1010
            for(var i in brandnames){
972
            for(var i in brandnames){
1011
                properties['brand_'+i] = brandnames[i];
973
                properties['brand_'+i] = brandnames[i];
Line 1020... Line 982...
1020
            $.post( "/user_filters/add", postdata, function( data ) {
982
            $.post( "/user_filters/add", postdata, function( data ) {
1021
                $('#loadingModal').modal('hide');
983
                $('#loadingModal').modal('hide');
1022
                $(this).prop('disabled',false);
984
                $(this).prop('disabled',false);
1023
                if($("#brandselecter").length == 0 && urldet['brands'] != undefined && urldet['brands'] != ''){
985
                if($("#brandselecter").length == 0 && urldet['brands'] != undefined && urldet['brands'] != ''){
1024
                    url = $("#subcategoryselecter").prop('action');
986
                    url = $("#subcategoryselecter").prop('action');
1025
//                    brands = urldet['brands'];
-
 
1026
                    document.location = url.split('?')[0]+'?brands='+brands.join('^')+"&subcategories="+subcategories.join("^")+"&whatfirst="+whatfirst;
987
                    document.location = url.split('?')[0]+'?brands='+brands.join('^')+"&subcategories="+subcategories.join("^")+"&whatfirst="+whatfirst;
1027
                }
988
                }
1028
                else if($("#subcategoryselecter").length == 0 && urldet['subcategories'] != undefined && urldet['subcategories'] != ''){
989
                else if($("#subcategoryselecter").length == 0 && urldet['subcategories'] != undefined && urldet['subcategories'] != ''){
1029
                    url = $('#brandselecter').prop('action');
990
                    url = $('#brandselecter').prop('action');
1030
//                    subcategories = urldet['subcategories'];
-
 
1031
                    document.location = url.split('?')[0]+'?brands='+brands.join('^')+"&subcategories="+subcategories.join('^')+"&whatfirst="+whatfirst;
991
                    document.location = url.split('?')[0]+'?brands='+brands.join('^')+"&subcategories="+subcategories.join('^')+"&whatfirst="+whatfirst;
1032
                }
992
                }
1033
//                document.location = url+'&brands='+brands.join('^')+"&subcategories="+subcategories.join("^");
-
 
1034
            });
993
            });
1035
        }
994
        }
1036
//    }
-
 
1037
 
995
 
1038
 
996
 
1039
    /*if(brands.length==0){
-
 
1040
        $('#loadingModal').modal('hide');
-
 
1041
        $('#message').html('Please choose a few brands first').removeClass('hidden');
-
 
1042
        setTimeout(function(){ $('#message').addClass('hidden'); }, 3000);
-
 
1043
        $(this).prop('disabled',false);
-
 
1044
        return false;
-
 
1045
    }else{
-
 
1046
        setCookie('brandschosen', brands, 0.25, true);
-
 
1047
        var url = $('#brandselecter').prop('action');
-
 
1048
        ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
-
 
1049
        properties = {};
-
 
1050
        for(var i in brandnames){
-
 
1051
            properties['brand_'+i] = brandnames[i];
-
 
1052
        }
-
 
1053
        pma.send('filters','brands','addfilter',me,properties);
-
 
1054
        var postdata = {'user_id':me,'type':'brand','filters':brandnames.join('|')};
-
 
1055
        $.post( "/user_filters/add", postdata, function( data ) {
-
 
1056
            $('#loadingModal').modal('hide');
-
 
1057
            $(this).prop('disabled',false);
-
 
1058
            document.location = url+'&brands='+brands.join('^');
-
 
1059
        });     
-
 
1060
    }
-
 
1061
 
-
 
1062
    if(subcategories.length==0){
-
 
1063
        $('#loadingModal').modal('hide');
-
 
1064
        $('#message').html('Please choose a few Sub-categories first').removeClass('hidden');
-
 
1065
        setTimeout(function(){ $('#message').addClass('hidden'); }, 3000);
-
 
1066
        $(this).prop('disabled',false);
-
 
1067
        return false;
-
 
1068
    }else{
-
 
1069
        setCookie('subcategorieschosen', subcategories, 0.25, true);
-
 
1070
        var url = $('#subcategoryselecter').prop('action');
-
 
1071
        ga('send', 'event', 'filter', 'subcategory', brandnames.join('|'));
-
 
1072
        properties = {};
-
 
1073
        for(var i in brandnames){
-
 
1074
            properties['brand_'+i] = brandnames[i];
-
 
1075
        }
-
 
1076
        pma.send('filters','subcategories','addfilter',me,properties);
-
 
1077
        var postdata = {'user_id':me,'type':'subcategory','filters':subcatnames.join('|')};
-
 
1078
        $.post( "/user_filters/add", postdata, function( data ) {
-
 
1079
            $('#loadingModal').modal('hide');
-
 
1080
            $(this).prop('disabled',false);
-
 
1081
            document.location = url+'&brands='+brands.join('^');
-
 
1082
        });     
-
 
1083
    }*/ 
-
 
1084
});
997
});
1085
 
998
 
1086
 
999
 
1087
$(document).on('click','#showallbrands',function(){ 
1000
$(document).on('click','#showallbrands',function(){ 
1088
    $('.brand').removeClass('hidden');
1001
    $('.brand').removeClass('hidden');