add user score!!

This commit is contained in:
ashley 2024-06-10 22:24:47 +00:00
parent 038b1f610f
commit 8b1e2bc26b

View file

@ -1377,19 +1377,18 @@ WIP! </a>
<hr style="clear: both;display: none;border: none;border-bottom: 0.5px solid #2f2f2f;/*! width: 4.5em; */height: 0;"> <hr style="clear: both;display: none;border: none;border-bottom: 0.5px solid #2f2f2f;/*! width: 4.5em; */height: 0;">
Rating : <%=engagement.rating.toLocaleString()%> (<%=engagement.dislikes.toLocaleString()%>/<%=engagement.likes.toLocaleString()%> <abbr title="Like To dislike ratio - the number to the left is dislike count and the one to the right is like count :3">LTDR</abbr>) <br> Rating : <%=engagement.rating.toLocaleString()%> (<%=engagement.dislikes.toLocaleString()%>/<%=engagement.likes.toLocaleString()%> <abbr title="Like To dislike ratio - the number to the left is dislike count and the one to the right is like count :3">LTDR</abbr>) <br>
<% <%
const likes = parseInt(engagement.likes) || 0; const likes = parseInt(engagement.likes) || 0;
const dislikes = parseInt(engagement.dislikes) || 0; const dislikes = parseInt(engagement.dislikes) || 0;
const total = likes + dislikes; const total = likes + dislikes;
const likePercentage = total > 0 ? ((likes / 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 dislikePercentage = total > 0 ? ((dislikes / total) * 100).toFixed(2) : 0;
const getLikePercentageColor = (percentage) => { const getLikePercentageColor = (percentage) => {
const num = parseFloat(percentage); if (percentage >= 80) {
if (num >= 80) {
return 'green'; return 'green';
} else if (num >= 50) { } else if (percentage >= 50) {
return 'orange'; return 'orange';
} else { } else {
return 'red'; return 'red';
@ -1397,10 +1396,9 @@ WIP! </a>
}; };
const getDislikePercentageColor = (percentage) => { const getDislikePercentageColor = (percentage) => {
const num = parseFloat(percentage); if (percentage >= 50) {
if (num >= 50) {
return 'red'; return 'red';
} else if (num >= 20) { } else if (percentage >= 20) {
return 'orange'; return 'orange';
} else { } else {
return 'green'; return 'green';
@ -1410,11 +1408,31 @@ WIP! </a>
const likeColor = getLikePercentageColor(likePercentage); const likeColor = getLikePercentageColor(likePercentage);
const dislikeColor = getDislikePercentageColor(dislikePercentage); const dislikeColor = getDislikePercentageColor(dislikePercentage);
%> const userScore = (parseFloat(likePercentage) - parseFloat(dislikePercentage) / 2).toFixed(2);
<span style="color: <%= likeColor %>;"><%= likePercentage %></span> of the users lieked the video!! <br>
<span style="color: <%= dislikeColor %>;"><%= dislikePercentage %></span> of the users dislieked the video!! <br>
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';
%>
<br><span style="color: <%= likeColor %>;"><%= likePercentage %></span> of the users lieked the video!! <br>
<span style="color: <%= dislikeColor %>;"><%= dislikePercentage %></span> of the users dislieked the video!! <br><br>
User score: <span style="color: <%= userScoreColor %>;"><%= userScore %></span>/100 - <%= userScoreLabel %><br>
RYD date created : <%=engagement.dateCreated.toLocaleString()%> <br> RYD date created : <%=engagement.dateCreated.toLocaleString()%> <br>
<a href="https://returnyoutubedislikeapi.com/votes?videoId=<%=inv_vid.videoId%>">See in json</a> <a href="https://returnyoutubedislikeapi.com/votes?videoId=<%=inv_vid.videoId%>">See in json</a>