From aec6a9bfb66f1a4b71d47c03674120687f7c8f6c Mon Sep 17 00:00:00 2001 From: patrickzerhusen Date: Mon, 20 Apr 2026 15:21:58 +0200 Subject: [PATCH] commented new vote function --- public/js/app.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 0b2f91d..a1c1613 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -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');