diff --git a/html/poketube.ejs b/html/poketube.ejs index 1c63cb0f..b31a3063 100644 --- a/html/poketube.ejs +++ b/html/poketube.ejs @@ -2664,24 +2664,73 @@ font-size: 13px;margin:0;padding:0;white-space: nowrap;
- + <% + 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 getLikePercentageColor = (percentage) => { + if (percentage >= 80) { + return 'green'; + } else if (percentage >= 50) { + return 'orange'; + } else { + return 'red'; + } + }; + + const getDislikePercentageColor = (percentage) => { + if (percentage >= 50) { + return 'red'; + } else if (percentage >= 20) { + return 'orange'; + } else { + return 'green'; + } + }; + + const likeColor = getLikePercentageColor(likePercentage); + const dislikeColor = getDislikePercentageColor(dislikePercentage); + + 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'; + %>
<%-String(channelurlfixer(inv_vid.descriptionHtml)).replace(/\n/g, "
").replace(/twitter\.com/g, "twitter.com").replace(/reddit\.com/g, "redlib.matthew.science") %> - - - - -
- - +
Rating! :3

<%= likePercentage %>% of the users lieked the video!!
<%= dislikePercentage %>% of the users dislieked the video!!
User score: <%= userScore %>- <%= userScoreLabel %>

+ + + +
+ +