<!DOCTYPE html>
<html>
<head>
<title>Test Results</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/testfile.css" />
</head>
<body>
<h1>Test Results
{% if builder or test_type or name %}
- {{ builder }} {{test_type }} {{ name }}
{% endif %}
</h1>
<div>
    <table>
        <tr>
            <th>Master</th>
            <th>Builder</th>
            <th>Test Type</th>
            <th>Build Number</th>
            <th>File</th>
            <th>Date</th>
            {% if admin %}
            <th></th>
            {% endif %}
        {% for file in files %}
        <tr>{% if file.builder and file.name %}
            <td><a href="/testfile?master={{ file.master }}" >
                {{ file.master }}
                </a>
            </td>
            <td><a href="/testfile?builder={{ file.builder }}" >
                {{ file.builder }}
                </a>
            </td>
            <td>{% if file.test_type %}
                <a href="/testfile?testtype={{ file.test_type }}" >
                {{ file.test_type }}
                </a>
                {% endif %}
            </td>
            <td>
                <a href="/testfile?buildnumber={{ file.build_number }}" >
                {{ file.build_number }}
                </a>
            </td>
            <td><a href="/testfile?builder={{ file.builder }}&name={{ file.name }}&master={{ file.master }}&testtype={{ file.test_type }}&buildnumber={{ file.build_number }}" >
                {{ file.name }}
                </a>
            </td>
            <td>
                <script>
                    // This date format needs to match the format string used in model/testfile.py:get_files.
                    var beforeQueryParameter = 'before={{ file.date|date:"Y-m-d\TH:i:s" }}Z';
                    var url = location.toString();
                    if (url.indexOf('before') == -1)
                        url += (url.indexOf('?') == -1 ? '?' : '&') + beforeQueryParameter;
                    else
                        url = url.replace(/before=[^&]*/, beforeQueryParameter);
                    document.write('<a href="' + url + '">' + new Date('{{ file.date|date:"c" }}').toLocaleString() + '</a>')
                </script>
            </td>
            {% if admin %}
            <td><a href="/testfile/delete?key={{ file.key }}&builder={{ builder }}&name={{ name }}" >
                Delete
                </a>
            </td>
            {% endif %}
        {% endif %}
        </tr>
    {% endfor %}
    </table>
</div>
</body>
</html>
