mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 17:57:52 +01:00
add user score!!
This commit is contained in:
parent
038b1f610f
commit
8b1e2bc26b
1 changed files with 31 additions and 13 deletions
|
@ -1382,14 +1382,13 @@ WIP! </a>
|
||||||
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);
|
||||||
|
|
||||||
|
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';
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<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><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>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue