mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 12:17:52 +01:00
add user score!!
This commit is contained in:
parent
038b1f610f
commit
8b1e2bc26b
1 changed files with 31 additions and 13 deletions
|
@ -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;">
|
||||
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 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! </a>
|
|||
};
|
||||
|
||||
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! </a>
|
|||
const likeColor = getLikePercentageColor(likePercentage);
|
||||
const dislikeColor = getDislikePercentageColor(dislikePercentage);
|
||||
|
||||
%>
|
||||
|
||||
<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 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';
|
||||
%>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
<a href="https://returnyoutubedislikeapi.com/votes?videoId=<%=inv_vid.videoId%>">See in json</a>
|
||||
|
||||
|
|
Loading…
Reference in a new issue