Subversion Repositories SmartDukaan

Rev

Rev 11110 | Blame | Compare with Previous | Last modification | View Log | RSS feed

function loadCompetitionDetails(getUrl){
        jQuery.ajax({
                type : "GET",
                url : getUrl,
                beforeSend: function(){
                        $('#ajax-spinner').show();
                },
                complete: function(){
                        $('#ajax-spinner').hide();
                },
                success : function(response) {
                        $('#' + 'competition-details').html(response);
                },
                error : function() {
                        alert("Unable to get competition history.Please try again.");
                },
        });  
}

function getNextItems(start,end,itemId){
        jQuery.ajax({
                type : "GET",
                url : "/Support/snapdeal-list!fetchCompetitionData?next="+end+"&itemId="+itemId,
                beforeSend: function(){
                        $('#ajax-spinner').show();
                },
                complete: function(){
                        $('#ajax-spinner').hide();
                },
                success : function(response) {
                        $('.valueEnd').text(+end + +10);
                        $('.valueStart').text(+start + +10);
                        var last = $('.valueEnd').text();
                        var temp = $('.totalItems').text();
                        if (parseInt(last) >= parseInt(temp)){
                                $(".next").css("display", "none");
                        }
                        $('#' + 'competition-details').html(response);
                        $(".previous").css("display", "");
                },
                error : function() {
                        alert("Unable to fetch items");
                },
        });  
}
function getPreviousItems(start,end,pre,itemId){
        jQuery.ajax({
                type : "GET",
                url : "/Support/snapdeal-list!fetchCompetitionData?next="+pre+"&itemId="+itemId,
                beforeSend: function(){
                        $('#ajax-spinner').show();
                },
                complete: function(){
                        $('#ajax-spinner').hide();
                },
                success : function(response) {
                        $('.valueEnd').text(+end - +10);
                        $('.valueStart').text(+start - +10);
                        $('#' + 'competition-details').html(response);
                        $(".next").css("display", "");  
                        if (parseInt(start)==11)
                        {
                                $(".previous").css("display", "none");  
                        }

                },
                error : function() {
                        alert("Unable to fetch items");
                },
        });
}

function getDuplicateRecords(startDate, endDate, itemId, row){
        jQuery.ajax({
                type : "GET",
                url : "/Support/snapdeal-list!fetchCompetitionDataTest?startDate="+startDate+"&endDate="+endDate+"&itemId="+itemId,
                beforeSend: function(){
                        $('#ajax-spinner').show();
                },
                complete: function(){
                        $('#ajax-spinner').hide();
                },
                success : function(response) {
                        $(response).insertAfter(row).slideDown("slow");
                        $('tr.diffColor').children('td').css('backgroundColor', '#7F98FA');
                        
                },
                error : function() {
                        alert("Unable to fetch items");
                        return false;
                },
        });
}

function showData(supc){
        jQuery.ajax({
                type : "GET",
                url : "/Support/snapdeal-scraper?supc="+supc,
                beforeSend: function(){
                        $('#ajax-spinner').show();
                },
                complete: function(){
                        $('#ajax-spinner').hide();
                },
                success : function(json) {
                        var parsedData = JSON.parse(json);
                        $('#scraping-data td').eq(0).html(parsedData.saholicSp);
                        $('#scraping-data td').eq(1).html(parsedData.saholicOfferPrice);
                        $('#scraping-data td').eq(2).html(parsedData.saholicRank);
                        $('#scraping-data td').eq(3).html(parsedData.saholicInventory);
                        $('#scraping-data td').eq(4).html(parsedData.competitorName);
                        $('#scraping-data td').eq(5).html(parsedData.competitorType);
                        $('#scraping-data td').eq(6).html(parsedData.competitorSp);
                        $('#scraping-data td').eq(7).html(parsedData.competitorOfferPrice);
                        $('#scraping-data td').eq(8).html(parsedData.competitorInventory);
                        $('#scraping-data td').eq(9).html(parsedData.totalSeller);
                        $('#hidden-data').show();
                },
                error : function() {
                        alert("Unable to fetch details.");
                        return false;
                },
        });
}