Subversion Repositories SmartDukaan

Rev

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

Rev 3462 Rev 3551
Line 3... Line 3...
3
	
3
	
4
	function getPriceAsInt(priceString)	{
4
	function getPriceAsInt(priceString)	{
5
		return parseInt(priceString.replace('Rs.', '').replace(',', ''));
5
		return parseInt(priceString.replace('Rs.', '').replace(',', ''));
6
	}
6
	}
7
	
7
	
-
 
8
	function roundNumber(num, dec) {
-
 
9
		return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
-
 
10
	}
-
 
11
	
8
	function updateWithFeedback()	{
12
	function updateWithFeedback()	{
9
		$.ajax({
13
		$.ajax({
10
			url: '/feedback',
14
			url: '/feedback',
11
			type: 'GET',
15
			type: 'GET',
12
			success: function(data){
16
			success: function(data){
Line 68... Line 72...
68
	function markBestPrice(trNode)	{
72
	function markBestPrice(trNode)	{
69
		$(trNode).children().removeClass('best');
73
		$(trNode).children().removeClass('best');
70
		var tdBestPrice = $(trNode).children('td')[1];
74
		var tdBestPrice = $(trNode).children('td')[1];
71
		var saholicPrice = parseInt(tdBestPrice.innerHTML);
75
		var saholicPrice = parseInt(tdBestPrice.innerHTML);
72
		var bestPrice = saholicPrice;
76
		var bestPrice = saholicPrice;
-
 
77
		var maxPrice = saholicPrice;
73
		
78
		
74
		$(trNode).find('a[href!="#"]').each(function(index, a){
79
		$(trNode).find('a[href!="#"]').each(function(index, a){
75
			var price = getPriceAsInt(a.innerHTML);
80
			var price = getPriceAsInt(a.innerHTML);
76
 
81
 
77
			if (price < bestPrice)	{
82
			if (price < bestPrice)	{
78
				bestPrice = price;
83
				bestPrice = price;
79
				tdBestPrice = $(a).parent();
84
				tdBestPrice = $(a).parent();
80
			}
85
			}
-
 
86
			
-
 
87
			if(price > maxPrice)	maxPrice = price;
81
		});
88
		});
-
 
89
		var maxMinDiff = roundNumber((maxPrice - bestPrice) * 100 / maxPrice, 2);
-
 
90
		
82
		$(tdBestPrice).addClass('best');
91
		$(tdBestPrice).addClass('best');
83
		
92
		
84
		if (bestPrice < saholicPrice)	$($(trNode).children()[0]).addClass('red');
93
		if (bestPrice < saholicPrice)	$($(trNode).children()[0]).addClass('red');
-
 
94
		var tds = $(trNode).children()
-
 
95
		
-
 
96
		if (tds.length == 7)	{
-
 
97
			tds[6].innerHTML = maxMinDiff + '%'
-
 
98
		} else	{
-
 
99
			$(trNode).append('<td class="diff" title="Max-Min price difference">' + maxMinDiff + '%</td>');
-
 
100
		}
85
	}
101
	}
86
 
102
 
87
	var baseUrl = {
103
	var baseUrl = {
88
		'flipkart': 'http://www.flipkart.com',
104
		'flipkart': 'http://www.flipkart.com',
89
		'homeshop18': '',
105
		'homeshop18': '',