{% load static %}
<!doctype html>

<html>
<head>
    <title>Jasmine Spec Runner</title>
    <link rel="stylesheet" type="text/css" href="http://cdn.rawgit.com/jasmine/jasmine/{{ version }}/lib/jasmine-core/jasmine.css">

    {% block jasmine_preload %}{% endblock %}
</head>
<body>

<script type="text/javascript">
    var failedJasmineFile = function () {
        var body = document.getElementsByTagName('BODY');
        body[0].innerHTML = '<h1 style="color: red;">An error occurred loading a Jasmine file.</h1><h1 style="color: red;">Are you sure you have a valid tag for Jasmine?</h1>'
    }
</script>

{# core files #}
<script type="text/javascript" src="http://cdn.rawgit.com/jasmine/jasmine/{{ version }}/lib/jasmine-core/jasmine.js" onerror="failedJasmineFile()"></script>
<script type="text/javascript" src="http://cdn.rawgit.com/jasmine/jasmine/{{ version }}/lib/jasmine-core/jasmine-html.js" onerror="failedJasmineFile()"></script>

<script type="text/javascript" src="http://cdn.rawgit.com/jasmine/jasmine/{{ version }}/lib/jasmine-core/boot/boot.js"></script>

{# source files #}
{% for url in suite.js_files %}
    <script src="{% static url %}"></script>
{% endfor %}

{# static files #}
{% for url in suite.static_files %}
    <script src="{% static url %}"></script>
{% endfor %}

{# spec files #}
{% for file in files %}
<script src="{% url 'jasmine_test' file %}"></script>
{% endfor %}

<script>
    {% block jasmine %}
    (function() {
        var jasmineEnv = jasmine.getEnv();
        jasmineEnv.updateInterval = 1000;

        var htmlReporter = new jasmine.HtmlReporter();

        jasmineEnv.addReporter(htmlReporter);

        jasmineEnv.specFilter = function(spec) {
            return htmlReporter.specFilter(spec);
        };

        // Additional configuration can be done in this block
        {% block jasmine_extra %}{% endblock %}

        var currentWindowOnload = window.onload;

        window.onload = function() {
            if (currentWindowOnload) {
                currentWindowOnload();
            }
            execJasmine();
        };

        function execJasmine() {
            jasmineEnv.execute();
        }

    })();
    {% endblock %}
</script>

</body>
</html>
