commented new vote function
This commit is contained in:
@@ -553,7 +553,6 @@ function deleteContribution(contributionId) {
|
||||
});
|
||||
}
|
||||
|
||||
// VOTE: Like or Dislike existing Contributions
|
||||
// VOTE: Like or Dislike existing Contributions
|
||||
function voteContribution(contributionId, voteType) {
|
||||
if (!currentUser) {
|
||||
@@ -571,14 +570,14 @@ function voteContribution(contributionId, voteType) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update local Vote State
|
||||
// Updates local Vote State
|
||||
var likeBtn = document.getElementById('vote-like-' + contributionId);
|
||||
var dislikeBtn = document.getElementById('vote-dislike-' + contributionId);
|
||||
var likesSpan = document.getElementById('likes-' + contributionId);
|
||||
var dislikesSpan = document.getElementById('dislikes-' + contributionId);
|
||||
|
||||
if (response.action === 'created') {
|
||||
// New Vote — highlight the Button, update Count
|
||||
// New Vote — Highlights Button and updates Count
|
||||
userVotes[contributionId] = voteType;
|
||||
if (voteType === 'like') {
|
||||
likeBtn.classList.add('liked');
|
||||
@@ -588,7 +587,7 @@ function voteContribution(contributionId, voteType) {
|
||||
dislikesSpan.textContent = parseInt(dislikesSpan.textContent) + 1;
|
||||
}
|
||||
} else if (response.action === 'removed') {
|
||||
// Vote removed (Toggle off) — remove Highlight, update Count
|
||||
// Vote removed — Removes Button Highlight and updates Count
|
||||
delete userVotes[contributionId];
|
||||
if (voteType === 'like') {
|
||||
likeBtn.classList.remove('liked');
|
||||
@@ -598,7 +597,7 @@ function voteContribution(contributionId, voteType) {
|
||||
dislikesSpan.textContent = Math.max(0, parseInt(dislikesSpan.textContent) - 1);
|
||||
}
|
||||
} else if (response.action === 'changed') {
|
||||
// Vote changed (e.g. Like → Dislike) — switch Highlights, update both Counts
|
||||
// Vote changed — Switches Highlights and updates both Counts
|
||||
userVotes[contributionId] = voteType;
|
||||
if (voteType === 'like') {
|
||||
likeBtn.classList.add('liked');
|
||||
|
||||
Reference in New Issue
Block a user