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("");