From 75c21df5639443781b0ef28ab898e111c1b26b67 Mon Sep 17 00:00:00 2001 From: ludger Date: Sat, 6 Oct 2018 22:37:29 +0200 Subject: [PATCH] quick fix --- frontpage/js/main.js | 13 +++++++------ frontpage/rateables/js/main.js | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/frontpage/js/main.js b/frontpage/js/main.js index 75bf7e7..ca58052 100644 --- a/frontpage/js/main.js +++ b/frontpage/js/main.js @@ -37,7 +37,7 @@ $(function(){ }); closeReviewBtn.hide(); for(j=1; j<=5;j++){ - $("#star" + (j)).addClass("btn-default btn-grey").removeClass("btn-warning"); + $(".stars #star" + (j)).addClass("btn-default btn-grey").removeClass("btn-warning"); } }); @@ -51,8 +51,8 @@ $(function(){ // Set appropriate stars for each review $(".review-block-rate").each(function(){ - let avg = parseInt($(".rating-block").attr("data-rating")).toPrecision(1); - if(i>avg){ + alert($(this).attr("data-rating")); + if(i>$(this).attr("data-rating")){ $(this).append(""); @@ -64,7 +64,8 @@ $(function(){ }); ///Set the stars for the average - if(i>$(".rating-block").attr("data-rating")){ + let avg = parseInt($(".rating-block").attr("data-rating")).toPrecision(1); + if(i>avg){ $(".rating-block").append(""); @@ -80,9 +81,9 @@ $(function(){ $('#rating_input').val(this.value); for(j=1; j<=5;j++){ if(j>this.value){ - $("#star" + (j)).addClass("btn-default btn-grey").removeClass("btn-warning"); + $(".stars #star" + (j)).addClass("btn-default btn-grey").removeClass("btn-warning"); }else{ - $("#star" + j).removeClass("btn-default btn-grey").addClass("btn-warning"); + $(".stars #star" + j).removeClass("btn-default btn-grey").addClass("btn-warning"); } } diff --git a/frontpage/rateables/js/main.js b/frontpage/rateables/js/main.js index e50ff7b..ca58052 100644 --- a/frontpage/rateables/js/main.js +++ b/frontpage/rateables/js/main.js @@ -51,8 +51,8 @@ $(function(){ // Set appropriate stars for each review $(".review-block-rate").each(function(){ - let avg = parseInt($(".rating-block").attr("data-rating")).toPrecision(1); - if(i>avg){ + alert($(this).attr("data-rating")); + if(i>$(this).attr("data-rating")){ $(this).append(""); @@ -64,7 +64,8 @@ $(function(){ }); ///Set the stars for the average - if(i>$(".rating-block").attr("data-rating")){ + let avg = parseInt($(".rating-block").attr("data-rating")).toPrecision(1); + if(i>avg){ $(".rating-block").append("");