Blame | Last modification | View Log | RSS feed
$(function(){function getPriceAsInt(priceString) {return parseInt(priceString.replace('Rs.', '').replace(',', ''));}function roundNumber(num, dec) {return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);}$('tbody tr').each(function(index, e) {var class_tr = index % 2 == 0 ? 'even' : 'odd';$(e).addClass(class_tr);markBestPrice(this);});function markBestPrice(trNode) {var tdBestPrice = $(trNode).children('td')[1];var saholicPrice = getPriceAsInt(tdBestPrice.innerHTML);var bestPrice = saholicPrice;var maxPrice = saholicPrice;$(trNode).find('a[href!="#"]').each(function(index, a){var price = getPriceAsInt(a.innerHTML);if (price < bestPrice) {bestPrice = price;tdBestPrice = $(a).parent();}if(price > maxPrice) maxPrice = price;});var maxMinDiff = roundNumber((maxPrice - bestPrice) * 100 / maxPrice, 2);$(tdBestPrice).addClass('best');if (bestPrice < saholicPrice) $($(trNode).children()[0]).addClass('red');var tds = $(trNode).children();var diffCssClass = '';if(maxMinDiff >= 25.0) {diffCssClass = 'dark-orange';} else if(maxMinDiff >= 10.0) {diffCssClass = 'orange';}$(trNode).append('<td class="diff ' + diffCssClass + '" title="Max-Min price difference">' + maxMinDiff + '%</td>');}});