aboutsummaryrefslogtreecommitdiffstats
path: root/templates/poll.html.j2
blob: c09f089a8ee5501e5dd6c3c09a14e83b35835acd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{% extends "base.html.j2" %}

{% block content %}

<h2><span class="contrast">{{ poll.title }}</span> by <i>{{ poll.author_name }}</i></h2>
{% if poll.description %}
  <pre class="poll-description">{{ poll.description }}</pre>
{% endif %}

{% if poll.choices | length  == 0 %}
<p style="margin-top: 20px;">No options available.</p>
{% else %}

<div class="display-mode-section">
  <form action="/options/toggle_display_mode" method="post">
    <input type="hidden" name="poll_id" value="{{ poll.id }}">
    <label>
      Display mode:
      <input type="submit" value="{{ display_mode }}">
    </label>
  </form>
</div>


{% if display_mode == "table" %}
{% include "poll_vote_table.html.j2" %}
{% else %}
{% include "poll_vote_list.html.j2" %}
{% endif %}

<script>
  const query = new URLSearchParams(window.location.search);
  const prefill_voter_name = query.get("prefill_voter_name");
  if (prefill_voter_name !== null) {
    document.querySelector("input[name=voter_name]").focus()
    document.querySelector("input[name=voter_name]").select();
    query.delete("prefill_voter_name");
    history.replaceState(null, "", window.location.pathname + (query.toString() ? "?" + query.toString() : ""));
  }
  </script>

{% endif %}
{% endblock %}