diff --git a/files/assets/js/comments+submission_listing.js b/files/assets/js/comments+submission_listing.js index 144166eb6..2b8e0ab68 100644 --- a/files/assets/js/comments+submission_listing.js +++ b/files/assets/js/comments+submission_listing.js @@ -81,43 +81,46 @@ function post(url) { xhr.send(form); }; -function poll_vote(cid, kind) { - var type = document.getElementById(cid).checked; - var scoretext = document.getElementById('option-' + cid); - var score = Number(scoretext.textContent); +function poll_vote_0(oid, parentid, kind) { + const full_oid = kind + '-' + oid + const type = document.getElementById(full_oid).checked; + const scoretext = document.getElementById('score-' + full_oid); + const score = Number(scoretext.textContent); if (type == true) scoretext.textContent = score + 1; else scoretext.textContent = score - 1; - post(`/vote/${kind}/option/${cid}`); + post(`/vote/${kind}/option/${oid}`); } -function choice_vote(cid, parentid, kind) { - let curr = document.getElementById(`current-${parentid}`) +function poll_vote_1(oid, parentid, kind) { + const full_oid = kind + '-' + oid + let curr = document.getElementById(`current-${kind}-${parentid}`) if (curr && curr.value) { - var scoretext = document.getElementById('option-' + curr.value); - var score = Number(scoretext.textContent); + console.log(curr.value) + const scoretext = document.getElementById('score-' + curr.value); + const score = Number(scoretext.textContent); scoretext.textContent = score - 1; } - var scoretext = document.getElementById('option-' + cid); + const scoretext = document.getElementById('score-' + full_oid); - var score = Number(scoretext.textContent); + const score = Number(scoretext.textContent); scoretext.textContent = score + 1; - post(`/vote/${kind}/option/${cid}`); - curr.value = cid + post(`/vote/${kind}/option/${oid}`); + curr.value = full_oid } -function bet_vote(cid) { +function bet_vote(oid) { for(let el of document.getElementsByClassName('bet')) { el.disabled = true; } for(let el of document.getElementsByClassName('cost')) { el.classList.add('d-none') } - var scoretext = document.getElementById('option-' + cid); + var scoretext = document.getElementById('option-' + oid); var score = Number(scoretext.textContent); scoretext.textContent = score + 1; - post(`/vote/post/option/${cid}`); + post(`/vote/post/option/${oid}`); document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - 200; } \ No newline at end of file diff --git a/files/classes/comment.py b/files/classes/comment.py index 317ae03dd..dc0a43927 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -365,24 +365,24 @@ class Comment(Base): if self.options: curr = [x for x in self.options if x.exclusive and x.voted(v)] - if curr: curr = " value=" + str(curr[0].id) + if curr: curr = " value=comment-" + str(curr[0].id) else: curr = '' - body += f'' + body += f'' for o in self.options: - if o.exclusive: - body += f'''
' + body += f''' onchange="poll_vote_{o.exclusive}('{o.id}', '{self.id}', 'comment')"''' + else: + body += f''' onchange="poll_vote_no_v()"''' + + body += f'''>''' if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and (v.sigs_disabled or v.poor)))): body += f"