summaryrefslogtreecommitdiff
path: root/coverage/htmlfiles/coverage_html.js
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-04-17 11:24:28 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-04-17 11:24:28 -0400
commit7fb11b6a98d2ede8a82ac39576b707f6d1284c81 (patch)
tree93c86493ec47af43412c947b42cd0f90645360ab /coverage/htmlfiles/coverage_html.js
parent591efea9573994b362e226d560a9e0b2d02513ed (diff)
downloadpython-coveragepy-7fb11b6a98d2ede8a82ac39576b707f6d1284c81.tar.gz
Even better way to test js: build fixtures programmatically, no need for monkeypatching the code under test.
Diffstat (limited to 'coverage/htmlfiles/coverage_html.js')
-rw-r--r--coverage/htmlfiles/coverage_html.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js
index 046a612..8459327 100644
--- a/coverage/htmlfiles/coverage_html.js
+++ b/coverage/htmlfiles/coverage_html.js
@@ -131,6 +131,10 @@ coverage.num_elt = function(n) {
return $("#n" + n);
};
+coverage.code_container = function(n) {
+ return $(".linenos");
+}
+
coverage.set_sel = function(b, e) {
coverage.sel_begin = b;
coverage.sel_end = e;
@@ -147,7 +151,7 @@ coverage.to_first_chunk = function() {
};
coverage.to_next_chunk = function() {
- var c = coverage;
+ var c = coverage;
// Find the start of the next colored chunk.
var probe = c.sel_end;
@@ -170,7 +174,7 @@ coverage.to_next_chunk = function() {
var next_color = color;
while (next_color === color) {
probe++;
- probe_line = c.line_elt(probe);
+ probe_line = c.line_elt(probe);
next_color = probe_line.css("background-color");
}
c.sel_end = probe;
@@ -178,7 +182,7 @@ coverage.to_next_chunk = function() {
};
coverage.to_prev_chunk = function() {
- var c = coverage;
+ var c = coverage;
// Find the end of the prev colored chunk.
var probe = c.sel_begin-1;
@@ -214,7 +218,7 @@ coverage.show_selection = function() {
var c = coverage;
// Highlight the lines in the chunk
- $(".linenos p").removeClass("highlight");
+ c.code_container().find(".highlight").removeClass("highlight");
for (var probe = c.sel_begin; probe > 0 && probe < c.sel_end; probe++) {
c.num_elt(probe).addClass("highlight");
}
@@ -224,8 +228,8 @@ coverage.show_selection = function() {
coverage.scroll_to_selection = function() {
// Scroll the page if the chunk isn't fully visible.
- var top = coverage.line_elt(c.sel_begin);
- var next = coverage.line_elt(c.sel_end);
+ var top = coverage.line_elt(coverage.sel_begin);
+ var next = coverage.line_elt(coverage.sel_end);
if (!top.isOnScreen() || !next.isOnScreen()) {
// Need to move the page.