diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-11-07 19:45:54 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-11-07 19:45:54 -0500 |
commit | 8da3b01fe961f657613938691dd50f81bf47f2ba (patch) | |
tree | 7b42f7ffffdd56128a29ecfb1cb1d23248869ff2 /coverage/htmlfiles | |
parent | db2b0562b3be9b51998371f47392c39a980ebf46 (diff) | |
download | python-coveragepy-git-8da3b01fe961f657613938691dd50f81bf47f2ba.tar.gz |
Hotkeys for the HTML report.
Diffstat (limited to 'coverage/htmlfiles')
-rw-r--r-- | coverage/htmlfiles/coverage_html.js | 18 | ||||
-rw-r--r-- | coverage/htmlfiles/index.html | 15 | ||||
-rw-r--r-- | coverage/htmlfiles/pyfile.html | 9 |
3 files changed, 31 insertions, 11 deletions
diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js index f9ba3cf3..a3519250 100644 --- a/coverage/htmlfiles/coverage_html.js +++ b/coverage/htmlfiles/coverage_html.js @@ -2,6 +2,20 @@ coverage = {}; +// Find all the elements with shortkey_* class, and use them to assign a shotrtcut key. +coverage.assign_shortkeys = function() { + $("*[class*='shortkey_']").each(function(i, e) { + console.log(i, e); + $.each($(e).attr("class").split(" "), function(i, c) { + if (/^shortkey_/.test(c)) { + $(document).bind('keydown', c.substr(9), function() { + $(e).click(); + }); + } + }); + }); +} + // Loaded on index.html coverage.index_ready = function($) { // Look for a cookie containing previous sort settings: @@ -59,6 +73,8 @@ coverage.index_ready = function($) { headers: headers }); + coverage.assign_shortkeys(); + // Watch for page unload events so we can save the final sort settings: $(window).unload(function() { document.cookie = cookie_name + "=" + sort_list.toString() + "; path=/" @@ -73,6 +89,8 @@ coverage.pyfile_ready = function($) { if (frag.length > 2 && frag[1] == 'n') { $(frag).addClass('highlight'); } + + coverage.assign_shortkeys(); } coverage.toggle_lines = function(btn, cls) { diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html index bd8c097d..f03c325e 100644 --- a/coverage/htmlfiles/index.html +++ b/coverage/htmlfiles/index.html @@ -6,6 +6,7 @@ <link rel='stylesheet' href='style.css' type='text/css'> <script type='text/javascript' src='jquery-1.4.3.min.js'></script> <script type='text/javascript' src='jquery.tablesorter.min.js'></script> + <script type='text/javascript' src='jquery.hotkeys.js'></script> <script type='text/javascript' src='coverage_html.js'></script> <script type='text/javascript' charset='utf-8'> jQuery(document).ready(coverage.index_ready); @@ -26,15 +27,15 @@ <thead> {# The title='' attr doesn't work in Safari. #} <tr class='tablehead' title='Click to sort'> - <th class='name left headerSortDown'>Module</th> - <th>statements</th> - <th>missing</th> - <th>excluded</th> + <th class='name left headerSortDown shortkey_n'>Module</th> + <th class='shortkey_s'>statements</th> + <th class='shortkey_m'>missing</th> + <th class='shortkey_x'>excluded</th> {% if arcs %} - <th>branches</th> - <th>partial</th> + <th class='shortkey_b'>branches</th> + <th class='shortkey_p'>partial</th> {% endif %} - <th class='right'>coverage</th> + <th class='right shortkey_c'>coverage</th> </tr> </thead> {# HTML syntax requires thead, tfoot, tbody #} diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html index f158fa47..d9d0e4c6 100644 --- a/coverage/htmlfiles/pyfile.html +++ b/coverage/htmlfiles/pyfile.html @@ -8,6 +8,7 @@ <title>Coverage for {{cu.name|escape}}: {{nums.pc_covered_str}}%</title> <link rel='stylesheet' href='style.css' type='text/css'> <script type='text/javascript' src='jquery-1.4.3.min.js'></script> + <script type='text/javascript' src='jquery.hotkeys.js'></script> <script type='text/javascript' src='coverage_html.js'></script> <script type='text/javascript' charset='utf-8'> jQuery(document).ready(coverage.pyfile_ready); @@ -22,11 +23,11 @@ </h1> <h2 class='stats'> {{nums.n_statements}} statements - <span class='{{c_run}}' onclick='coverage.toggle_lines(this, "run")'>{{nums.n_executed}} run</span> - <span class='{{c_mis}}' onclick='coverage.toggle_lines(this, "mis")'>{{nums.n_missing}} missing</span> - <span class='{{c_exc}}' onclick='coverage.toggle_lines(this, "exc")'>{{nums.n_excluded}} excluded</span> + <span class='{{c_run}} shortkey_r' onclick='coverage.toggle_lines(this, "run")'>{{nums.n_executed}} run</span> + <span class='{{c_mis}} shortkey_m' onclick='coverage.toggle_lines(this, "mis")'>{{nums.n_missing}} missing</span> + <span class='{{c_exc}} shortkey_x' onclick='coverage.toggle_lines(this, "exc")'>{{nums.n_excluded}} excluded</span> {% if arcs %} - <span class='{{c_par}}' onclick='coverage.toggle_lines(this, "par")'>{{n_par}} partial</span> + <span class='{{c_par}} shortkey_p' onclick='coverage.toggle_lines(this, "par")'>{{n_par}} partial</span> {% endif %} </h2> </div> |