Subversion Repositories SmartDukaan

Rev

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

Rev 3551 Rev 4198
Line 40... Line 40...
40
		if(feedback.type == 'reject')	{
40
		if(feedback.type == 'reject')	{
41
			$(td).html('Not Found ' + $('<a>').append($(anchor).clone()).remove().html()).addClass('with-feedback');
41
			$(td).html('Not Found ' + $('<a>').append($(anchor).clone()).remove().html()).addClass('with-feedback');
42
			
42
			
43
		} else	{
43
		} else	{
44
			var itemInfo = lookupInfoForItem(eval($(td).attr('data')), feedback.selected_item);
44
			var itemInfo = lookupInfoForItem(eval($(td).attr('data')), feedback.selected_item);
-
 
45
			
-
 
46
			if (itemInfo != null)	{
-
 
47
				$(td).html(
45
			$(td).html('<a href="' + baseUrl[source] + itemInfo.url + '">' + itemInfo.price + '</a> ' + $('<a>').append($(anchor).clone()).remove().html()).addClass('with-feedback');
48
					'<a href="' + baseUrl[source] + itemInfo.url + '">' + itemInfo.price + '</a> ' + 
-
 
49
					$('<a>').append($(anchor).clone()).remove().html()
-
 
50
				).addClass('with-feedback');
-
 
51
			}
46
		}
52
		}
47
	}
53
	}
48
	
54
	
49
	function lookupInfoForItem(data, itemName)	{
55
	function lookupInfoForItem(data, itemName)	{
50
		var info = null;
56
		var info = null;
Line 60... Line 66...
60
 
66
 
61
	$('tbody tr').each(function(index, e)	{
67
	$('tbody tr').each(function(index, e)	{
62
 		var class_tr = index % 2 == 0 ? 'even' : 'odd';
68
 		var class_tr = index % 2 == 0 ? 'even' : 'odd';
63
 		$(e).addClass(class_tr);
69
 		$(e).addClass(class_tr);
64
 		markBestPrice(this);
70
 		markBestPrice(this);
-
 
71
 		
65
 		$(this).find('td').each(function(){
72
 		$(this).find('td').each(function(){
66
 			if($(this).hasClass('conflict'))	$(this).children('a').addClass('link-conflict');
73
 			if($(this).hasClass('conflict'))	$(this).children('a').addClass('link-conflict');
-
 
74
 			
-
 
75
 			if(! $(this).hasClass('diff') && ! $(this).hasClass('name') && ! $(this).hasClass('saholic'))	{
-
 
76
 				$(this).append('<span class="url-feedback-link" title="Click to map a product page URL">U</span>');
-
 
77
 			}
67
 		});
78
 		});
68
	});
79
	});
69
	
80
	
70
	updateWithFeedback();
81
	updateWithFeedback();
71
	
82
	
72
	function markBestPrice(trNode)	{
83
	function markBestPrice(trNode)	{
73
		$(trNode).children().removeClass('best');
84
		$(trNode).children().removeClass('best');
74
		var tdBestPrice = $(trNode).children('td')[1];
85
		var tdBestPrice = $(trNode).children('.saholic').html();
75
		var saholicPrice = parseInt(tdBestPrice.innerHTML);
86
		var saholicPrice = parseInt(tdBestPrice);
76
		var bestPrice = saholicPrice;
87
		var bestPrice = saholicPrice;
77
		var maxPrice = saholicPrice;
88
		var maxPrice = saholicPrice;
78
		
89
		
79
		$(trNode).find('a[href!="#"]').each(function(index, a){
90
		$(trNode).find('a[href!="#"]').each(function(index, a){
80
			var price = getPriceAsInt(a.innerHTML);
91
			var price = getPriceAsInt(a.innerHTML);
Line 93... Line 104...
93
		if (bestPrice < saholicPrice)	$($(trNode).children()[0]).addClass('red');
104
		if (bestPrice < saholicPrice)	$($(trNode).children()[0]).addClass('red');
94
		var tds = $(trNode).children()
105
		var tds = $(trNode).children()
95
		
106
		
96
		if (tds.length == 7)	{
107
		if (tds.length == 7)	{
97
			tds[6].innerHTML = maxMinDiff + '%'
108
			tds[6].innerHTML = maxMinDiff + '%'
-
 
109
		} else	{var diffCssClass = '';
-
 
110
		
-
 
111
		if(maxMinDiff >= 25.0)	{
-
 
112
			diffCssClass = 'dark-orange';
-
 
113
		} else if(maxMinDiff >= 10.0)	{
-
 
114
			diffCssClass = 'orange';
98
		} else	{
115
		}
99
			$(trNode).append('<td class="diff" title="Max-Min price difference">' + maxMinDiff + '%</td>');
116
		$(trNode).append('<td class="diff ' + diffCssClass + '" title="Max-Min price difference">' + maxMinDiff + '%</td>');
100
		}
117
		}
101
	}
118
	}
102
 
119
 
103
	var baseUrl = {
120
	var baseUrl = {
104
		'flipkart': 'http://www.flipkart.com',
121
		'flipkart': 'http://www.flipkart.com',
Line 216... Line 233...
216
		} else	{
233
		} else	{
217
			$(table).before('<div class="msg">' + msg + '</div>');
234
			$(table).before('<div class="msg">' + msg + '</div>');
218
		}
235
		}
219
	}
236
	}
220
	
237
	
-
 
238
	$('.url-feedback-link').live('click', function(){
-
 
239
		var source = $(this).parent().attr('source');
-
 
240
		var entity = $(this).parent().parent().attr('id');
-
 
241
//		console.log(source, entity);
-
 
242
		var html = '<div class="form-url-feedback">\n';
-
 
243
		var html = 'Enter the URL you want to be crawled for this product<br>\n';
-
 
244
		html += '<input type="text" id="url-feedback" size="40"><br />\n';
-
 
245
		html += '<input type="hidden" id="entity-url-feedback" value="' + entity + '">\n';
-
 
246
		html += '<input type="hidden" id="source-url-feedback" value="' + source + '">\n';
-
 
247
		html += '<input type="button" id="submit-url-feedback" value="Save">\n';
-
 
248
		html += '</div>';
-
 
249
		$.facebox(html);
-
 
250
	});
-
 
251
	
-
 
252
	$('#submit-url-feedback').live('click', function(){
-
 
253
		$.ajax({
-
 
254
			url: '/feedback-url',
-
 
255
			type: 'POST',
-
 
256
			data: {
-
 
257
				entity: $('#entity-url-feedback').val(), 
-
 
258
				source: $('#source-url-feedback').val(), 
-
 
259
				url: $('#url-feedback').val()
-
 
260
			},
-
 
261
			beforeSend: function(){
-
 
262
				$('#url-feedback, #submit-url-feedback').attr('disabled', 'disabled');
-
 
263
				$('#submit-url-feedback').val('Saving...').after('<img src="/static/images/loading.gif" width="24" />');
-
 
264
			},
-
 
265
			success: function(data){
-
 
266
				console.log(data);
-
 
267
				var html = '<table>';
-
 
268
				html += '<tr><td class="msg" colspan="2" align="center">The URL is saved and will be crawled next time</td></tr>';
-
 
269
				html += '<tr><td align="center">' + data.name + '</td><td align="center">Rs.' + data.price + '</td></tr>';
-
 
270
				html += '<tr><td colspan="2" align="center">Please refresh the page to see the changes</td></tr>';
-
 
271
				html += '</table>';
-
 
272
				var form = $('#facebox').find('.content').html(html);
-
 
273
			}
-
 
274
		});
-
 
275
	});
-
 
276
	
-
 
277
	$('#howTo').click(function(){
-
 
278
		html = '<ul>\n\
-
 
279
			<li class="first">The price data is crawled directly from competitor websites at 8:00 AM everyday</li>\n\
-
 
280
			<li class="first">All price figures are linked to their respective product pages</li>\n\
-
 
281
			<li class="first">Cells showing "Not Found" are linked to search result page of relevant website.</li>\n\
-
 
282
			<li class="first">Cells showing "Conflict" are linked to set of products which are conflicting to match with\n\
-
 
283
			the product. You can either select one of them or reject all depending on the case. The selection \n\
-
 
284
			will be taken into account when showing the dashboard next time.</li>\n\
-
 
285
			<li class="first">Clicking on "U" (present in all price cells) will pop up a form where you can submit a URL \n\
-
 
286
			pointing to the product page of the product. After submission this URL will be crawled and indexed \n\
-
 
287
			in real-time and saved in the list of URLs for scheduled crawling in future.</li>\n\
-
 
288
			<li class="first">In each row, right most cell shows the percentage difference between the minimum and maximum \n\
-
 
289
			price of that product. Color coding:\n\
-
 
290
				<ul>\n\
-
 
291
					<li>Yellow: 10 - 24.99% difference</li>\n\
-
 
292
					<li>Orange: Above 24.99%</li>\n\
-
 
293
				</ul></li>\n\
-
 
294
			<li class="first">In case of further clarification, email your query at varun.gupta@shop2020.in</li>\n\
-
 
295
			</ul>';
-
 
296
		$.facebox(html);
-
 
297
	});
-
 
298
	
221
	$('#facebox .close').live('click', function(){});
299
	$('#facebox .close').live('click', function(){});
222
});
300
});
223
301