hide poll scores until the user votes
parent
0796a17422
commit
f81205a427
|
@ -77,6 +77,9 @@ function post(url) {
|
|||
};
|
||||
|
||||
function poll_vote_0(oid, parentid, kind) {
|
||||
for(let el of document.getElementsByClassName('presult-'+parentid)) {
|
||||
el.classList.remove('d-none');
|
||||
}
|
||||
const full_oid = kind + '-' + oid
|
||||
const type = document.getElementById(full_oid).checked;
|
||||
const scoretext = document.getElementById('score-' + full_oid);
|
||||
|
@ -87,6 +90,9 @@ function poll_vote_0(oid, parentid, kind) {
|
|||
}
|
||||
|
||||
function poll_vote_1(oid, parentid, kind) {
|
||||
for(let el of document.getElementsByClassName('presult-'+parentid)) {
|
||||
el.classList.remove('d-none');
|
||||
}
|
||||
const full_oid = kind + '-' + oid
|
||||
let curr = document.getElementById(`current-${kind}-${parentid}`)
|
||||
if (curr && curr.value)
|
||||
|
|
|
@ -260,6 +260,13 @@ class Comment(Base):
|
|||
|
||||
return data
|
||||
|
||||
@lazy
|
||||
def total_poll_voted(self, v):
|
||||
if v:
|
||||
for o in self.options:
|
||||
if o.voted(v): return True
|
||||
return False
|
||||
|
||||
@lazy
|
||||
def realbody(self, v):
|
||||
if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id] or (self.parent_comment and v.id == self.parent_comment.author_id))):
|
||||
|
@ -319,8 +326,9 @@ class Comment(Base):
|
|||
else:
|
||||
body += f''' onchange="poll_vote_no_v()"'''
|
||||
|
||||
body += f'''><label class="custom-control-label" for="comment-{o.id}">{o.body_html} -
|
||||
<a href="/votes/comment/option/{o.id}"><span id="score-comment-{o.id}">{o.upvotes}</span> votes</a></label></div>'''
|
||||
body += f'''><label class="custom-control-label" for="comment-{o.id}">{o.body_html}<span class="presult-{self.id}'''
|
||||
if not self.total_poll_voted(v): body += ' d-none'
|
||||
body += f'"> - <a href="/votes/comment/option/{o.id}"><span id="score-comment-{o.id}">{o.upvotes}</span> votes</a></label></div>'''
|
||||
|
||||
if not self.ghost and self.author.show_sig(v):
|
||||
body += f"<hr>{self.author.sig_html}"
|
||||
|
|
|
@ -277,6 +277,13 @@ class Submission(Base):
|
|||
if o.exclusive == 2 and o.voted(v): return True
|
||||
return False
|
||||
|
||||
@lazy
|
||||
def total_poll_voted(self, v):
|
||||
if v:
|
||||
for o in self.options:
|
||||
if o.voted(v): return True
|
||||
return False
|
||||
|
||||
@lazy
|
||||
def realbody(self, v, listing=False):
|
||||
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{CC} ONLY</p>"
|
||||
|
@ -338,8 +345,9 @@ class Submission(Base):
|
|||
else:
|
||||
body += f''' onchange="poll_vote_no_v()"'''
|
||||
|
||||
body += f'''><label class="custom-control-label" for="post-{o.id}">{o.body_html} -
|
||||
<a href="/votes/post/option/{o.id}"><span id="score-post-{o.id}">{o.upvotes}</span> votes</a></label></div>'''
|
||||
body += f'''><label class="custom-control-label" for="post-{o.id}">{o.body_html}<span class="presult-{self.id}'''
|
||||
if not self.total_poll_voted(v): body += ' d-none'
|
||||
body += f'"> - <a href="/votes/post/option/{o.id}"><span id="score-post-{o.id}">{o.upvotes}</span> votes</a></label></div>'''
|
||||
|
||||
|
||||
if not listing and not self.ghost and self.author.show_sig(v):
|
||||
|
|
Loading…
Reference in New Issue