Subversion Repositories SmartDukaan

Rev

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

Rev 3232 Rev 3313
Line 1... Line 1...
1
$(function(){
1
$(function(){
2
	
2
	
-
 
3
	function markBestPrice(trNode)	{
-
 
4
		var tdBestPrice = $(trNode).children('td')[1];
-
 
5
		var saholicPrice = parseInt(tdBestPrice.innerHTML);
-
 
6
		var bestPrice = saholicPrice;
-
 
7
 
-
 
8
		$(trNode).find('a[href!="#"]').each(function(index, a){
-
 
9
			var price = parseInt(a.innerHTML);
-
 
10
			
-
 
11
			if (price < bestPrice)	{
-
 
12
				bestPrice = price;
-
 
13
				tdBestPrice = $(a).parent();
-
 
14
			}
-
 
15
		});
-
 
16
		$(tdBestPrice).addClass('best');
-
 
17
		
-
 
18
		if (bestPrice < saholicPrice)	$($(trNode).children()[0]).addClass('red');
-
 
19
	}
-
 
20
 
3
	$('tbody tr').each(function(index, e)	{
21
	$('tbody tr').each(function(index, e)	{
4
 		var class_tr = index % 2 == 0 ? 'even' : 'odd';
22
 		var class_tr = index % 2 == 0 ? 'even' : 'odd';
5
 		$(e).addClass(class_tr);
23
 		$(e).addClass(class_tr);
6
 
-
 
7
 		var tdSaholic = $(this).children()[1];
24
 		markBestPrice(this);
8
 		var tdFlipkart = $(this).children()[2];
-
 
9
 		
-
 
10
 		if (! $(tdFlipkart).hasClass('conflict'))	{
-
 
11
 			var priceSaholic = parseInt($(tdSaholic).html());
-
 
12
 			var priceFlipkart = parseInt($(tdFlipkart).children('a').html());
-
 
13
 			
-
 
14
 			if (priceSaholic < priceFlipkart)	{
-
 
15
 				$(tdSaholic).addClass('best');
-
 
16
 			}
-
 
17
 			else if (priceSaholic > priceFlipkart)	{
-
 
18
 				$(tdFlipkart).addClass('best');
-
 
19
 				$($(this).children()[0]).addClass('red');
-
 
20
 			}
-
 
21
 		}
-
 
22
	});
25
	});
23
 
26
 
-
 
27
	var baseUrl = {
-
 
28
		'flipkart': 'http://www.flipkart.com',
-
 
29
		'homeshop18': '',
-
 
30
		'infibeam': 'http://www.infibeam.com',
-
 
31
		'letsbuy': ''
-
 
32
	};
-
 
33
	
24
	$('.conflict').click(function(){
34
	$('.conflict').click(function(){
25
		$(this).children('a')
35
		$(this).children('a')
26
			.removeAttr('href')
36
			.removeAttr('href')
27
			.css({'text-decoration': 'underline', 'cursor': 'pointer'});
37
			.css({'text-decoration': 'underline', 'cursor': 'pointer'});
28
		var data = eval("{results: " + $(this).attr('data') + "}");
38
		var data = eval("{results: " + $(this).attr('data') + "}");
29
		var text = '<table>';
39
		var text = '<table>';
30
		
40
		
31
		for (i in data)	{
41
		for (i in data)	{
32
			text += '<tr>';
42
			text += '<tr>';
33
			text += '<td>' + data[i]['name'] + '</td>';
43
			text += '<td>' + data[i]['name'] + '</td>';
34
			text += '<td><a target="_blank" href="http://www.flipkart.com' + data[i]['url'] + '">' + data[i]['price'] + '</a></td>';
44
			text += '<td><a target="_blank" href="' + baseUrl[data[i]['source']] + data[i]['url'] + '">' + data[i]['price'] + '</a></td>';
35
			text += '</tr>';
45
			text += '</tr>';
36
		}
46
		}
37
		text += '</table>';
47
		text += '</table>';
38
		$.facebox(text);
48
		$.facebox(text);
39
	});
49
	});