Update meme voting

This commit is contained in:
2024-04-27 11:23:42 +02:00
parent f251d18bcb
commit 7b5f418344
5 changed files with 98 additions and 11 deletions

View File

@@ -625,13 +625,45 @@ async function getMemeImages() {
async function reloadMemeVotes(memeID) {
let memeVoteCounterElement = document.getElementById(`meme_votes_counter_${memeID}`);
let memeVoteUpvoteElement = document.getElementById(`meme_votes_upvote_${memeID}`);
let memeVoteDownvoteElement = document.getElementById(`meme_votes_downvote_${memeID}`);
let memeVoteResponse = await doAction('/meme', {
action: "getMemeVotes",
meme_id: memeID
}, "Počet hlasov k meme-u bol stiahnutý", "Nastala chyba pri sťahovaní počtu hlasov k meme-u", true);
memeVoteCounterElement.innerText = memeVoteResponse.NetVotes;
let memeVotes = memeVoteResponse.NetVotes;
let userVote = memeVoteResponse.UserVote;
memeVoteCounterElement.innerText = memeVotes;
memeVoteCounterElement.classList.remove("positive", "negative", "neutral");
if (memeVotes > 0) {
memeVoteCounterElement.classList.add("positive");
}
else if (memeVotes < 0) {
memeVoteCounterElement.classList.add("negative");
}
else {
memeVoteCounterElement.classList.add("neutral");
}
if (userVote > 0) {
memeUpvoteVariant = "fill";
memeDownvoteVariant = "line";
}
else if (userVote < 0) {
memeUpvoteVariant = "line";
memeDownvoteVariant = "fill";
}
else {
memeUpvoteVariant = "line";
memeDownvoteVariant = "line";
}
memeVoteUpvoteElement.classList = [`ri-arrow-up-circle-${memeUpvoteVariant}`];
memeVoteDownvoteElement.classList = [`ri-arrow-up-circle-${memeDownvoteVariant}`];
}
async function voteMeme(memeID, isUpvote){

View File

@@ -351,7 +351,7 @@ div#articleslist>article{
.meme_image {
max-width: 500px;
max-height: 500px;
max-height: 300px;
width: auto;
height: auto;
}
@@ -371,6 +371,18 @@ div#articleslist>article{
flex-direction: column;
}
.positive {
color: green;
}
.negative {
color: red;
}
.neutral {
color: var(--pico-color);
}
@media (max-width: 1050px) {
div#articleslist {