<!DOCTYPE html>
<!--
Copyright (C) 2016 Sebastian Pipping <sebastian@pipping.org>
Licensed under GNU GPL v3 or later

{% load static %}
-->
<html lang="en">
    <head>
        <title>jawanndenn: Vote!</title>

        <meta name="viewport" content="width=device-width, initial-scale=1">

        <script type="text/javascript" src="{% static '3rdparty/jquery-3.5.1/jquery-3.5.1.min.js' %}"></script>
        <script src="{% static '3rdparty/noty-2.4.1/js/noty/packaged/jquery.noty.packaged.min.js' %}"></script>

        <link rel="stylesheet" href="{% static '3rdparty/roboto-20/css/roboto.css' %}">
        <link rel="stylesheet" href="{% static '3rdparty/materialize-1.0.0/css/materialize.min.css' %}">
        <script src="{% static '3rdparty/materialize-1.0.0/js/materialize.min.js' %}"></script>

        <script type="text/javascript" src="{% static 'js/html.js' %}?sha1=c1fe4690fa614be0708cb5ecc74e82f5cb058084"></script>
        <script type="text/javascript" src="{% static 'js/poll.js' %}?sha1=954917ae1af0215991c93374d8e1decb7d587c24"></script>
        <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}?sha1=6a800a3f645fe42576b63a2e41e1461710cd0382">

        <script type="text/javascript">
            $( document ).ready(function() {
                var pollId = /[0-9a-fA-F]{64}/.exec(window.location.pathname)[0]
                var pollDataUrl = '{% url 'poll-data' poll_id='POLL_ID' %}'.replace( 'POLL_ID', pollId );
                var voteUrl = '{% url 'vote' poll_id='POLL_ID' %}'.replace( 'POLL_ID', pollId );

                $.get( pollDataUrl, function(data) {
                    var poll = $( '#poll' );
                    poll.html( createPollHtml( data.config, data.votes, Mode.LIVE, '{{ csrf_token }}' ) );
                    $( '#pollForm' ).attr( 'action', voteUrl );
                    if (data.config.equal_width) {
                        equalizeWidth( poll );
                    }
                    // NOTE: Browser auto-fill does not seem to fire any JS events,
                    //       so we start checking for changes ourselves, periodically;
                    //       200ms is a compromise in delay and CPU load.
                    setInterval(syncSaveButton, 200);
                }, 'json')
                .fail(function() {
                    var html = 'Error: Poll data could not be loaded.';
                    noty({text: html, type: 'error', timeout: null});
                });
            });
        </script>
    </head>
    <body>
        <div id='live'>
            <div id='poll'></div>
        </div>
        <footer>
            {% include 'html/footer.htm' %}
        </footer>
    </body>
</html>
