From 55eff9329a6409838ff1de4ac7be2aabef6fe125 Mon Sep 17 00:00:00 2001 From: Tatsuhiko Miyagawa Date: Thu, 15 Jan 2015 20:43:46 -0800 Subject: [PATCH] display the original score in a gray, small text. --- myscript.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/myscript.js b/myscript.js index a3f35f2..c38e12a 100644 --- a/myscript.js +++ b/myscript.js @@ -17,19 +17,18 @@ 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) + ' (' + score.toFixed(2) + ")"); + $(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) { @@ -37,11 +36,15 @@ function patch(){ if (isNaN(score)) return; var honest = honestify(score); - $(element).find(".score").text(honest.toFixed(1)); + $(element).find(".score").html(honest.toFixed(1) + ' (' + score.toFixed(2) + ")"); $(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);