Subversion Repositories SmartDukaan

Rev

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

Rev 5291 Rev 5323
Line 8... Line 8...
8
	function roundNumber(num, dec) {
8
	function roundNumber(num, dec) {
9
		return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
9
		return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
10
	}
10
	}
11
	
11
	
12
	function updateWithSecondaryCrawledData()	{
12
	function updateWithSecondaryCrawledData()	{
-
 
13
		console.log('updating With Secondary Crawled Data');
13
		$.ajax({
14
		$.ajax({
14
			url: '/feedback-url',
15
			url: '/feedback-url',
15
			type: 'GET',
16
			type: 'GET',
16
			success: function(data){
17
			success: function(data){
-
 
18
				console.log(data);
17
				
19
				
18
				$.each(data, function(entityId, sourceData){
20
				$.each(data, function(entityId, sourceData){
-
 
21
					console.log(entityId, sourceData);
19
					
22
					
20
					$.each(sourceData, function(source, productData){
23
					$.each(sourceData, function(source, productData){
-
 
24
						console.log(entityId, source, productData);
21
						
25
						
22
						var tr = $('#' + entityId);
26
						var tr = $('#' + entityId);
23
						var td = $(tr).children('td[source=' + source +']')[0];
27
						var td = $(tr).children('td[source=' + source +']')[0];
24
						var anchor = $(td).children('a')[0];
28
						var anchor = $(td).children('a')[0];
-
 
29
						console.log(anchor);
25
						
30
						
26
						$(anchor).attr('href', productData['product_url']);
31
						$(anchor).attr('href', productData['product_url']);
27
						$(anchor).html(productData['price']);
32
						$(anchor).html(productData['price']);
28
						
33
						
29
						$(td).children('span.url-feedback-link').addClass('url-saved');
34
						$(td).children('span.url-feedback-link').addClass('url-saved');
Line 49... Line 54...
49
						
54
						
50
						if($(td).hasClass('conflict'))	updateCellWithFeedback(td, feedback_instruction);
55
						if($(td).hasClass('conflict'))	updateCellWithFeedback(td, feedback_instruction);
51
					});
56
					});
52
					markBestPrice(tr);
57
					markBestPrice(tr);
53
				});
58
				});
-
 
59
				console.log('updateWithSecondaryCrawledData');
54
				updateWithSecondaryCrawledData();
60
				updateWithSecondaryCrawledData();
55
			}
61
			}
56
		})
62
		})
57
	}
63
	}
58
	
64
	
Line 385... Line 391...
385
				$.ajax({
391
				$.ajax({
386
					type: 'GET',
392
					type: 'GET',
387
					url: '/watchlist',
393
					url: '/watchlist',
388
					
394
					
389
					error: function(jqXHR, textStatus, errorThrown)	{
395
					error: function(jqXHR, textStatus, errorThrown)	{
390
						console.log(jqXHR, textStatus, errorThrown);
-
 
391
						alert('Could not get WatchList. Try again later.');
396
						alert('Could not get WatchList. Try again later.');
392
					},
397
					},
393
					success: function(data, textStatus, jqXHR)	{
398
					success: function(data, textStatus, jqXHR)	{
394
						console.log(data, textStatus, jqXHR);
-
 
395
						entities = eval('(' + data + ')');
399
						entities = eval('(' + data + ')');
396
						
400
						
397
						$.each(entities, function(index, entity)	{
401
						$.each(entities, function(index, entity)	{
398
							var elementId = '#' + entity;
402
							var elementId = '#' + entity;
399
							var tr = $(elementId);
403
							var tr = $(elementId);