From 8da3b01fe961f657613938691dd50f81bf47f2ba Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 7 Nov 2010 19:45:54 -0500 Subject: Hotkeys for the HTML report. --- CHANGES.txt | 5 +++++ coverage/html.py | 1 + coverage/htmlfiles/coverage_html.js | 18 ++++++++++++++++++ coverage/htmlfiles/index.html | 15 ++++++++------- coverage/htmlfiles/pyfile.html | 9 +++++---- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3c04d3b3..dc95c3f9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -6,6 +6,11 @@ Change history for Coverage.py Version 3.5 ----------- +- The HTML report now has hotkeys. Try ``n``, ``s``, ``m``, ``x``, ``b``, + ``p``, and ``c`` on the overview page to change the column sorting. + On a file page, ``r``, ``m``, ``x``, and ``p`` toggle the run, missing, + excluded, and partial line markings. + - A little bit of Jython support: `coverage run` can now measure Jython execution by adapting when $py.class files are traced. Thanks, Adi Roiban. diff --git a/coverage/html.py b/coverage/html.py index 29842cfb..c2a2443e 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -29,6 +29,7 @@ class HtmlReporter(Reporter): "style.css", "jquery-1.4.3.min.js", "jquery.tablesorter.min.js", + "jquery.hotkeys.js", "coverage_html.js", ] 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 @@ + +