Skip to content

Commit

Permalink
display the original score in a gray, small text.
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Jan 16, 2015
1 parent 44d122f commit 55eff93
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions myscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,34 @@ function patch(){
honest = 1.0;
}

console.log("Original score: " + score + ", Honest score: " + honest);
console.log("Original score: " + score.toFixed(2) + ", Honest score: " + honest);
return honest;
};

$('[rel="v:rating"], .rate .score').each(function(index, element) {
var el = $(element);
var score = parseFloat(el.text());
$('.rate .score').each(function(index, element) {
var score = parseFloat($(element).text());
if (isNaN(score)) return;

var honest = honestify(score);
var image = "http://image1-3.tabelog.k-img.com/images/restaurant/star/star_ll" + (honest * 10) + ".gif";
el.text(honest.toFixed(1));
el.parent().find("img").attr("src", image);
$(element).html(honest.toFixed(1) + ' <span class="tabelog-score">(' + score.toFixed(2) + ")</span>");
$(element).parent().find("img")
.attr("src", "http://image1-3.tabelog.k-img.com/images/restaurant/star/star_ll" + (honest * 10) + ".gif");
});

$(".info .score-overall").each(function(index, element) {
var score = parseFloat($(element).find(".score").text());
if (isNaN(score)) return;

var honest = honestify(score);
$(element).find(".score").text(honest.toFixed(1));
$(element).find(".score").html(honest.toFixed(1) + ' <span class="tabelog-score">(' + score.toFixed(2) + ")</span>");
$(element).find(".star").removeClass().addClass("star star" + honest * 10);
});
}

var style = document.createElement('style');
style.appendChild(document.createTextNode('.tabelog-score { font-weight: normal; font-size: 60%; color: #bbb }'));
document.body.appendChild(style);

var script = document.createElement('script');
script.appendChild(document.createTextNode('('+patch+')();'));
document.body.appendChild(script);

0 comments on commit 55eff93

Please # to comment.