{% extends 'layouts/layout.html' %}

{% block body %}
    <div id="container-not-an-ad" class="media">
        <div class="media-left pull-left" href="#">
                    <!-- REPLACE THE LOGO HERE WITH YOUR  UNIVERSITY, LAB, or COMPANY -->
                    <img id="adlogo" src="/static/images/university.png" alt="Lab Logo" />
        </div>
        <div class="media-body">
                <h1>Debugging task complete!</h1>
                <hr />
                <div class="alert alert-warning">
                    If this was a real hit, the data would be saved now and the HIT submitted to AMT.
                </div>
                {% if allow_repeats %}
                    <h3>Repeat experiment?</h3>
                    <a class='btn btn-primary' id='ad-href' href='#'>Repeat</a>
                {% endif %}
        </div>
    </div>
        <script>
            {% if allow_repeats %}
                function makeid() {
                    var text = "";
                    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

                    for( var i=0; i < 5; i++ )
                        text += possible.charAt(Math.floor(Math.random() * possible.length));

                    return text;
                }

                var assignmentId = "debug" + makeid();
                var hitId = "debug" + makeid();
                var href = "/ad?assignmentId=" + assignmentId + "&hitId=" + hitId + "&workerId={{worker_id}}" + "&mode=debug"

                document.getElementById('ad-href').href = href;
            {% endif %}
        </script>
{% endblock %}
