1PowerReviewsCustom = { 2 3 renderCategorySnippet : function () { 4 5 jQuery.each(jQuery('.pr-stars-snippet'), function (key, value) { 6 reviews = jQuery(value).data('reviews'); 7 reviewsText = reviews == '1' ? 'Review' : 'Reviews'; 8 starsContainer = jQuery(value).children(); 9 rating = jQuery(starsContainer).data('rating'); 10 11 PowerReviewsCustom.renderStarsCategorySnippet(rating, starsContainer); 12 jQuery(value).append('<div class="pr-total-reviews">' + reviews + ' ' + reviewsText + '</div>'); 13 14 }); 15 16 }, 17 18 renderStarsCategorySnippet : function (rating, starsContainer) { 19 20 if (!rating){ 21 22 for (index = 0; index < 5; index++) { 23 jQuery(starsContainer).append('<div class="pr-star pr-star-0-filled"></div>'); 24 } 25 26 } else { 27 28 if (rating == 0) { 29 30 for (index = 0; index < 5; index++){ 31 jQuery(starsContainer).append('<div class="pr-star pr-star-0-filled"></div>'); 32 } 33 34 } else if (rating <= 5) { 35 36 int_rating = parseInt(rating); 37 empty_starts = parseInt(5 - rating); 38 39 for (index = 0; index < int_rating; index++) { 40 jQuery(starsContainer).append('<div class="pr-star pr-star-100-filled"></div>'); 41 } 42 43 decimal_residual = rating - int_rating; 44 45 if (decimal_residual > 0.25 && decimal_residual < 0.50) { 46 jQuery(starsContainer).append('<div class="pr-star pr-star-25-filled"></div>'); 47 } else if (decimal_residual >= 0.50 && decimal_residual < 0.75) { 48 jQuery(starsContainer).append('<div class="pr-star pr-star-50-filled"></div>'); 49 } else if (decimal_residual >= 0.75 && decimal_residual < 1) { 50 jQuery(starsContainer).append('<div class="pr-star pr-star-75-filled"></div>'); 51 } 52 53 54 if (empty_starts >= 1) { 55 for (index = 0; index < empty_starts; index++) { 56 jQuery(starsContainer).append('<div class="pr-star pr-star-0-filled"></div>'); 57 } 58 } 59 60 } 61 62 } 63 64 }, 65 // Return HTML String only Stars Category Snippet 66 printStarsCategorySnippet : function (rating) { 67 var divContainer = ""; 68 69 if (!rating) { 70 for (index = 0; index < 5; index++) { 71 divContainer += '<div class="pr-star pr-star-0-filled"></div>'; 72 } 73 } else { 74 if (rating == 0) { 75 for (index = 0; index < 5; index++) { 76 divContainer += '<div class="pr-star pr-star-0-filled"></div>'; 77 } 78 } else if (rating <= 5) { 79 int_rating = parseInt(rating); 80 empty_starts = parseInt(5 - rating); 81 82 for (index = 0; index < int_rating; index++) { 83 divContainer += '<div class="pr-star pr-star-100-filled"></div>'; 84 } 85 86 decimal_residual = rating - int_rating; 87 88 if (decimal_residual > 0.25 && decimal_residual < 0.50) { 89 divContainer += '<div class="pr-star pr-star-25-filled"></div>'; 90 } else if (decimal_residual >= 0.50 && decimal_residual < 0.75) { 91 divContainer += '<div class="pr-star pr-star-50-filled"></div>'; 92 } else if (decimal_residual >= 0.75 && decimal_residual < 1) { 93 divContainer += '<div class="pr-star pr-star-75-filled"></div>'; 94 } 95 96 if (empty_starts >= 1) { 97 for (index = 0; index < empty_starts; index++) { 98 divContainer += '<div class="pr-star pr-star-0-filled"></div>'; 99 } 100 } 101 } 102 } 103 104 return divContainer; 105 }, 106 init: function () { 107 PowerReviewsCustom.renderCategorySnippet(); 108 } 109 110}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.