diff --git a/html/poketube.ejs b/html/poketube.ejs index ae1f7bf0..a2060c50 100644 --- a/html/poketube.ejs +++ b/html/poketube.ejs @@ -1377,19 +1377,18 @@ WIP!
Rating : <%=engagement.rating.toLocaleString()%> (<%=engagement.dislikes.toLocaleString()%>/<%=engagement.likes.toLocaleString()%> LTDR)
- <% + <% const likes = parseInt(engagement.likes) || 0; const dislikes = parseInt(engagement.dislikes) || 0; const total = likes + dislikes; - const likePercentage = total > 0 ? ((likes / total) * 100).toFixed(2) + '%' : '0%'; - const dislikePercentage = total > 0 ? ((dislikes / total) * 100).toFixed(2) + '%' : '0%'; + const likePercentage = total > 0 ? ((likes / total) * 100).toFixed(2) : 0; + const dislikePercentage = total > 0 ? ((dislikes / total) * 100).toFixed(2) : 0; const getLikePercentageColor = (percentage) => { - const num = parseFloat(percentage); - if (num >= 80) { + if (percentage >= 80) { return 'green'; - } else if (num >= 50) { + } else if (percentage >= 50) { return 'orange'; } else { return 'red'; @@ -1397,10 +1396,9 @@ WIP! }; const getDislikePercentageColor = (percentage) => { - const num = parseFloat(percentage); - if (num >= 50) { + if (percentage >= 50) { return 'red'; - } else if (num >= 20) { + } else if (percentage >= 20) { return 'orange'; } else { return 'green'; @@ -1410,11 +1408,31 @@ WIP! const likeColor = getLikePercentageColor(likePercentage); const dislikeColor = getDislikePercentageColor(dislikePercentage); - %> - - <%= likePercentage %> of the users lieked the video!!
- <%= dislikePercentage %> of the users dislieked the video!!
+ const userScore = (parseFloat(likePercentage) - parseFloat(dislikePercentage) / 2).toFixed(2); + const getUserScoreLabel = (score) => { + if (score >= 80) { + return 'Overwhelmingly Positive'; + } else if (score >= 60) { + return 'Positive'; + } else if (score >= 40) { + return 'Mixed'; + } else if (score >= 20) { + return 'Negative'; + } else { + return 'Overwhelmingly Negative'; + } + }; + + const userScoreLabel = getUserScoreLabel(userScore); + const userScoreColor = userScore >= 80 ? 'green' : userScore >= 50 ? 'orange' : 'red'; + %> + + + +
<%= likePercentage %> of the users lieked the video!!
+ <%= dislikePercentage %> of the users dislieked the video!!

+ User score: <%= userScore %>/100 - <%= userScoreLabel %>
RYD date created : <%=engagement.dateCreated.toLocaleString()%>
See in json