aboutsummaryrefslogtreecommitdiffstats
path: root/templates/poll.html.j2
blob: 14601fbf3393df530ed7d494d64a8dcf57ab7a22 (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
44
45
46
47
48
49
50
51
52
53
{% extends "base.html.j2" %}

{% block head_meta %}
<title>{{ poll.title }} - diddle 👉👈</title>
<meta name="description" content="{{ poll.description }}">
<meta property="og:title" content="{{ poll.title }} by {{ poll.author_name }}">
<meta property="og:description" content="{{ poll.description }}">
<meta property="og:url" content="{{ poll.share_url() }}">
<meta property="og:site_name" content="diddle">
<meta property="og:type" content="website">
{% endblock %}

{% 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 %}