Subversion Repositories SmartDukaan

Rev

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

Rev 5323 Rev 5329
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');
-
 
14
		$.ajax({
13
		$.ajax({
15
			url: '/feedback-url',
14
			url: '/feedback-url',
16
			type: 'GET',
15
			type: 'GET',
-
 
16
			dataType: 'html',
-
 
17
			
17
			success: function(data){
18
			success: function(dataString){
-
 
19
				var data = eval('(' + dataString + ')');
18
				console.log(data);
20
				//console.log(dataString, data);
19
				
21
				
20
				$.each(data, function(entityId, sourceData){
22
				$.each(data, function(entityId, sourceData){
21
					console.log(entityId, sourceData);
23
					//console.log(entityId, sourceData);
22
					
24
					
23
					$.each(sourceData, function(source, productData){
25
					$.each(sourceData, function(source, productData){
24
						console.log(entityId, source, productData);
26
						//console.log(source, productData);
25
						
27
						
26
						var tr = $('#' + entityId);
28
						var tr = $('#' + entityId);
27
						var td = $(tr).children('td[source=' + source +']')[0];
29
						var td = $(tr).children('td[source=' + source +']')[0];
28
						var anchor = $(td).children('a')[0];
30
						var anchor = $(td).children('a')[0];
29
						console.log(anchor);
31
						//console.log(anchor);
30
						
32
						
31
						$(anchor).attr('href', productData['product_url']);
33
						$(anchor).attr('href', productData['product_url']);
32
						$(anchor).html(productData['price']);
34
						$(anchor).html(productData['price']);
33
						
35
						
34
						$(td).children('span.url-feedback-link').addClass('url-saved');
36
						$(td).children('span.url-feedback-link').addClass('url-saved');
Line 54... Line 56...
54
						
56
						
55
						if($(td).hasClass('conflict'))	updateCellWithFeedback(td, feedback_instruction);
57
						if($(td).hasClass('conflict'))	updateCellWithFeedback(td, feedback_instruction);
56
					});
58
					});
57
					markBestPrice(tr);
59
					markBestPrice(tr);
58
				});
60
				});
59
				console.log('updateWithSecondaryCrawledData');
-
 
60
				updateWithSecondaryCrawledData();
61
				updateWithSecondaryCrawledData();
61
			}
62
			}
62
		})
63
		})
63
	}
64
	}
64
	
65
	
Line 390... Line 391...
390
			get: function()	{
391
			get: function()	{
391
				$.ajax({
392
				$.ajax({
392
					type: 'GET',
393
					type: 'GET',
393
					url: '/watchlist',
394
					url: '/watchlist',
394
					
395
					
-
 
396
					
395
					error: function(jqXHR, textStatus, errorThrown)	{
397
					error: function(jqXHR, textStatus, errorThrown)	{
-
 
398
						console.log(jqXHR, textStatus, errorThrown);
396
						alert('Could not get WatchList. Try again later.');
399
						alert('Could not get WatchList. Try again later.');
397
					},
400
					},
398
					success: function(data, textStatus, jqXHR)	{
401
					success: function(data, textStatus, jqXHR)	{
-
 
402
						console.log(data, textStatus, jqXHR);
399
						entities = eval('(' + data + ')');
403
						entities = eval('(' + data + ')');
400
						
404
						
401
						$.each(entities, function(index, entity)	{
405
						$.each(entities, function(index, entity)	{
402
							var elementId = '#' + entity;
406
							var elementId = '#' + entity;
403
							var tr = $(elementId);
407
							var tr = $(elementId);