summaryrefslogtreecommitdiff
path: root/coverage/htmlfiles/index.html
blob: cd5a27b6d0a66efc4c9d12f7facf474631b31f22 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
        <title>Coverage report</title>
        <link rel='stylesheet' href='style.css' type='text/css'>
        <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
        <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
    </head>
    <body>

        <div id='header'>
            <div class='content'>
                <h1>Coverage report: 
                    <span class='pc_cov'>{{totals.pc_covered|format_pct}}%</span>
                </h1>
            </div>
        </div>

        <div id='index'>
            <table class='index'>
                <thead>
                    {# The title='' attr doesn't work in Safari. #}
                    <tr class='tablehead' title='Click to sort'>
                        <th class='name left'>Module</th>
                        <th>statements</th>
                        <th>run</th>
                        <th>excluded</th>
                        {% if arcs %}
                        <th>branches</th>
                        <th>br exec</th>
                        {% endif %}
                        <th class='right'>coverage</th>
                    </tr>
                </thead>
                {# HTML syntax requires thead, tfoot, tbody #}
                <tfoot>
                    <tr class='total'>
                        <td class='name left'>Total</td>
                        <td>{{totals.n_statements}}</td>
                        <td>{{totals.n_executed}}</td>
                        <td>{{totals.n_excluded}}</td>
                        {% if arcs %}
                        <td>{{totals.n_branches}}</td>
                        <td>{{totals.n_executed_branches}}</td>
                        {% endif %}
                        <td class='right'>{{totals.pc_covered|format_pct}}%</td>
                    </tr>
                </tfoot>
                <tbody>
                    {% for file in files %}
                    <tr class='file'>
                        <td class='name left'><a href='{{file.html_filename}}'>{{file.cu.name}}</a></td>
                        <td>{{file.nums.n_statements}}</td>
                        <td>{{file.nums.n_executed}}</td>
                        <td>{{file.nums.n_excluded}}</td>
                        {% if arcs %}
                        <td>{{file.nums.n_branches}}</td>
                        <td>{{file.nums.n_executed_branches}}</td>
                        {% endif %}
                        <td class='right'>{{file.nums.pc_covered|format_pct}}%</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>

        <div id='footer'>
            <div class='content'>
                <p>
                    <a class='nav' href='{{__url__}}'>coverage.py v{{__version__}}</a>
                </p>
            </div>
        </div>

        <script type="text/javascript" charset="utf-8">
            jQuery(function($) {
                // Look for a cookie containing previous sort settings:
                sort_list = [];
                cookie_name = "COVERAGE_INDEX_SORT";

                // This almost makes it worth installing the jQuery cookie plugin:
                if (document.cookie.indexOf(cookie_name) > -1) {
                    cookies = document.cookie.split(";");
                    for (var i=0; i < cookies.length; i++) {
                        parts = cookies[i].split("=")

                        if ($.trim(parts[0]) == cookie_name && parts[1]) {
                            sort_list = eval("[[" + parts[1] + "]]");
                            break;
                        }
                    }
                }

                // Create a new widget which exists only to save and restore
                // the sort order:
                $.tablesorter.addWidget({
                    id: "persistentSort",

                    // Format is called by the widget before displaying:
                    format: function(table) {
                        if (table.config.sortList.length == 0 && sort_list.length > 0) {
                            // This table hasn't been sorted before - we'll use
                            // our stored settings:
                            jQuery(table).trigger('sorton', [sort_list]);
                        } else {
                            // This is not the first load - something has
                            // already defined sorting so we'll just update         
                            // our stored value to match:
                            sort_list = table.config.sortList;
                        }
                    }
                });

                // Configure our tablesorter to handle the variable number of
                // columns produced depending on report options:
                var headers = {};
                var col_count = jQuery("table.index > thead > tr > th").length;

                for (var i = 0; i < col_count; i++) {
                    headers[i] = {sorter: "digit"};
                }

                headers[0]           = { sorter:'text' };
                headers[col_count-1] = { sorter:'percent' };

                // Enable the table sorter:
                $("table.index").tablesorter({
                    widgets: ['persistentSort'],
                    headers: headers
                });
            
                // Watch for page unload events so we can save the final sort settings:
                $(window).unload(function() { 
                    document.cookie = cookie_name + "=" + sort_list.toString() + "; path=/" 
                });
            });            
        </script>        
    </body>
</html>