DebugClients/Python/coverage/htmlfiles/coverage_html.js

changeset 31
744cd0b4b8cd
child 3495
fac17a82b431
equal deleted inserted replaced
30:9513afbd57f1 31:744cd0b4b8cd
1 // Coverage.py HTML report browser code.
2
3 // Loaded on index.html
4 function index_page_ready($) {
5 // Look for a cookie containing previous sort settings:
6 sort_list = [];
7 cookie_name = "COVERAGE_INDEX_SORT";
8
9 // This almost makes it worth installing the jQuery cookie plugin:
10 if (document.cookie.indexOf(cookie_name) > -1) {
11 cookies = document.cookie.split(";");
12 for (var i=0; i < cookies.length; i++) {
13 parts = cookies[i].split("=")
14
15 if ($.trim(parts[0]) == cookie_name && parts[1]) {
16 sort_list = eval("[[" + parts[1] + "]]");
17 break;
18 }
19 }
20 }
21
22 // Create a new widget which exists only to save and restore
23 // the sort order:
24 $.tablesorter.addWidget({
25 id: "persistentSort",
26
27 // Format is called by the widget before displaying:
28 format: function(table) {
29 if (table.config.sortList.length == 0 && sort_list.length > 0) {
30 // This table hasn't been sorted before - we'll use
31 // our stored settings:
32 jQuery(table).trigger('sorton', [sort_list]);
33 }
34 else {
35 // This is not the first load - something has
36 // already defined sorting so we'll just update
37 // our stored value to match:
38 sort_list = table.config.sortList;
39 }
40 }
41 });
42
43 // Configure our tablesorter to handle the variable number of
44 // columns produced depending on report options:
45 var headers = {};
46 var col_count = jQuery("table.index > thead > tr > th").length;
47
48 headers[0] = { sorter: 'text' };
49 for (var i = 1; i < col_count-1; i++) {
50 headers[i] = { sorter: 'digit' };
51 }
52 headers[col_count-1] = { sorter: 'percent' };
53
54 // Enable the table sorter:
55 $("table.index").tablesorter({
56 widgets: ['persistentSort'],
57 headers: headers
58 });
59
60 // Watch for page unload events so we can save the final sort settings:
61 $(window).unload(function() {
62 document.cookie = cookie_name + "=" + sort_list.toString() + "; path=/"
63 });
64 }

eric ide

mercurial