diff options
author | ubq323 <ubq323> | 2021-07-17 23:27:37 +0000 |
---|---|---|
committer | ubq323 <ubq323> | 2021-07-17 23:27:37 +0000 |
commit | a2c82ca4f96420234460ea5fdea5df37078117d7 (patch) | |
tree | b12848493c3630cb2aab445fc20542736b304ea9 /apioforum/templates | |
parent | 2eae97d6a08da4b832ccc69ce66bd15009001737 (diff) |
vote meters idk
Diffstat (limited to 'apioforum/templates')
-rw-r--r-- | apioforum/templates/view_forum.html | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/apioforum/templates/view_forum.html b/apioforum/templates/view_forum.html index b27088d..017d9f0 100644 --- a/apioforum/templates/view_forum.html +++ b/apioforum/templates/view_forum.html @@ -43,6 +43,46 @@ </span> </div> {% endif %} + {% if thread_polls[thread.id] %} + {% set poll = thread_polls[thread.id] %} + {% set total_votes = poll.total_votes %} + {% set n = namespace() %} + {% set n.runningtotal = 0 %} + + <div class="thread-vote-summary"> + <svg width="100%" height="15px" xmlns="http://www.w3.org/2000/svg"> + {% if total_votes == 0 %} + <text text-anchor="middle" dominant-baseline="middle" x="11%" y="55%" fill="black" style="font-size:15px">no votes</text> + {% else %} + {% for opt in poll.options %} + {% set opt_count = opt.num or 0 %} + {% set colour = (loop.count|string + opt.text)|gen_colour %} + {% if opt_count != 0 %} + {% set percentage = 100*(opt_count/total_votes) %} + {# todo: do this in css somehow #} + {% if opt.text|length > 10 %} + {% set opt_text = opt.text[:7] + "..." %} + {% else %} + {% set opt_text = opt.text %} + {% endif %} + <rect y="0" height="100%" x="{{n.runningtotal}}%" width="{{percentage}}%" stroke="black" fill="{{colour}}" /> + <text text-anchor="middle" dominant-baseline="middle" y="55%" fill="black" style="font-size:15px" x="{{n.runningtotal+(percentage/2)}}%"> + {{opt_text}}: {{opt_count}} + </text> + {% set n.runningtotal = n.runningtotal + percentage %} + {% endif %} + {% endfor %} + {% endif %} + <desc> + poll: {{poll.title}} + {% for opt in poll.options %} + option "{{opt.text}}": {{opt.num}} votes + {% endfor %} + total votes: {{total_votes}} + </desc> + </svg> + </div> + {% endif %} </div> {%endfor%} </div> |