Skip to content

Commit

Permalink
Updated to handle Pending Inspection
Browse files Browse the repository at this point in the history
Tweaked filter range to treat Pending Inspection and No Data as zero
score so they are filtered properly.
  • Loading branch information
dutts committed Mar 24, 2015
1 parent 06007c9 commit 33eeeb1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions addon/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ function ApplyFilter(ratingFilterRange, restaurantEntries, excludeNoData) {
var ratingElement = $("div#nomorvom[data-rating]", this);
if (ratingElement.length) {
var rating = $("div#nomorvom[data-rating]", this).attr("data-rating");
if ( ((rating == -1) && excludeNoData) || (rating < ratingFilterRange[0]) || (rating > ratingFilterRange[1]) ) {
//if ( ((rating == -1) && excludeNoData) || (rating < ratingFilterRange[0]) || (rating > ratingFilterRange[1]) ) {
if ( (rating < ratingFilterRange[0]) || (rating > ratingFilterRange[1]) ) {
$(this).hide();
}
else { $(this).show(); }
}
else { $(this).show(); }
});
Expand Down Expand Up @@ -122,7 +124,7 @@ restaurantEntries.each(function () {

_this.append(scorePlaceholder);

var rating = -1;
var rating = 0;

$.ajax({
url: url,
Expand All @@ -133,7 +135,7 @@ restaurantEntries.each(function () {
if (data.establishments.length > 0) {
scorePlaceholder.removeChild(loadingText);
scorePlaceholder.removeChild(loaderImg);
rating = data.establishments[0].RatingValue;
rating = data.establishments[0].RatingValue;
for (var i = 0; i < rating; i++) {
AppendImg(scorePlaceholder, '48-fork-and-knife-icon.png');
}
Expand All @@ -144,8 +146,15 @@ restaurantEntries.each(function () {
resultText.id = "hygieneScore"
resultText.style.fontWeight = "bold";
resultText.style.margin = "0px 5px";
$(resultText).text("Hygiene Score : " + rating + "/5");



if (rating == "AwaitingInspection") {
$(resultText).text("This takeaway is awaiting inspection");
rating = 0;
}
else {
$(resultText).text("Hygiene Score : " + rating + "/5");
}
scorePlaceholder.appendChild(resultText);

$(scorePlaceholder).attr("data-rating", rating);
Expand All @@ -167,8 +176,9 @@ restaurantEntries.each(function () {
}

var ratingFilterRange = $(scoreFilterSlider).slider("values");
var excludeNoData = $(excludeNoDataCheckbox).prop('checked');
if ( ((rating == -1) && excludeNoData) || (rating < ratingFilterRange[0]) || (rating > ratingFilterRange[1]) ) {
//var excludeNoData = $(excludeNoDataCheckbox).prop('checked');
//if ( ((rating == -1) && excludeNoData) || (rating < ratingFilterRange[0]) || (rating > ratingFilterRange[1]) ) {
if ((rating < ratingFilterRange[0]) || (rating > ratingFilterRange[1])) {
_this.hide();
}
else
Expand Down
Binary file modified addon/nomorvom.xpi
Binary file not shown.
2 changes: 1 addition & 1 deletion addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"description": "Never eat from a dodgy takeaway again. Display food.gov.uk food hygiene scores in your Just Eat search results.",
"author": "Richard Dutton",
"license": "MPL 2.0",
"version": "0.12"
"version": "0.13"
}

0 comments on commit 33eeeb1

Please sign in to comment.