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"
{self.author.sig_html}" diff --git a/files/classes/submission.py b/files/classes/submission.py index abec40b0d..44d780b20 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -355,9 +355,9 @@ class Submission(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=post-" + str(curr[0].id) else: curr = '' - body += f'' + body += f'' for o in self.options: if o.exclusive == 2: @@ -373,19 +373,20 @@ class Submission(Base): if v and v.admin_level > 2: body += f'''''' body += "" - - elif o.exclusive == 1: - body += f'''
' + input_type = 'radio' if o.exclusive else 'checkbox' + body += f'
''' diff --git a/files/templates/util/assetcache.html b/files/templates/util/assetcache.html index 936f9c9da..02e196f98 100644 --- a/files/templates/util/assetcache.html +++ b/files/templates/util/assetcache.html @@ -18,7 +18,7 @@ set CACHE_VER = { 'js/award_modal.js': 4000, 'js/bootstrap.js': 4000, 'js/category_modal.js': 4000, - 'js/comments+submission_listing.js': 4006, + 'js/comments+submission_listing.js': 4007, 'js/comments_admin.js': 4000, 'js/comments_v.js': 4000, 'js/submission_listing.js': 4000,