@@ -214,7 +214,7 @@ coverage.LINE_FILTERS_STORAGE = "COVERAGE_LINE_FILTERS";
214
214
coverage . pyfile_ready = function ( ) {
215
215
// If we're directed to a particular line number, highlight the line.
216
216
var frag = location . hash ;
217
- if ( frag . length > 2 && frag [ 1 ] === 't' ) {
217
+ if ( frag . length > 2 && frag [ 1 ] === "t" ) {
218
218
document . querySelector ( frag ) . closest ( ".n" ) . classList . add ( "highlight" ) ;
219
219
coverage . set_sel ( parseInt ( frag . substr ( 2 ) , 10 ) ) ;
220
220
} else {
@@ -257,6 +257,10 @@ coverage.pyfile_ready = function () {
257
257
coverage . init_scroll_markers ( ) ;
258
258
coverage . wire_up_sticky_header ( ) ;
259
259
260
+ document . querySelectorAll ( "[id^=ctxs]" ) . forEach (
261
+ cbox => cbox . addEventListener ( "click" , coverage . expand_contexts )
262
+ ) ;
263
+
260
264
// Rebuild scroll markers when the window height changes.
261
265
window . addEventListener ( "resize" , coverage . build_scroll_markers ) ;
262
266
} ;
@@ -528,14 +532,14 @@ coverage.scroll_window = function (to_pos) {
528
532
529
533
coverage . init_scroll_markers = function ( ) {
530
534
// Init some variables
531
- coverage . lines_len = document . querySelectorAll ( ' #source > p' ) . length ;
535
+ coverage . lines_len = document . querySelectorAll ( " #source > p" ) . length ;
532
536
533
537
// Build html
534
538
coverage . build_scroll_markers ( ) ;
535
539
} ;
536
540
537
541
coverage . build_scroll_markers = function ( ) {
538
- const temp_scroll_marker = document . getElementById ( ' scroll_marker' )
542
+ const temp_scroll_marker = document . getElementById ( " scroll_marker" )
539
543
if ( temp_scroll_marker ) temp_scroll_marker . remove ( ) ;
540
544
// Don't build markers if the window has no scroll bar.
541
545
if ( document . body . scrollHeight <= window . innerHeight ) {
@@ -549,8 +553,8 @@ coverage.build_scroll_markers = function () {
549
553
550
554
const scroll_marker = document . createElement ( "div" ) ;
551
555
scroll_marker . id = "scroll_marker" ;
552
- document . getElementById ( ' source' ) . querySelectorAll (
553
- ' p.show_run, p.show_mis, p.show_exc, p.show_exc, p.show_par'
556
+ document . getElementById ( " source" ) . querySelectorAll (
557
+ " p.show_run, p.show_mis, p.show_exc, p.show_exc, p.show_par"
554
558
) . forEach ( element => {
555
559
const line_top = Math . floor ( element . offsetTop * marker_scale ) ;
556
560
const line_number = parseInt ( element . querySelector ( ".n a" ) . id . substr ( 1 ) ) ;
@@ -577,24 +581,40 @@ coverage.build_scroll_markers = function () {
577
581
} ;
578
582
579
583
coverage . wire_up_sticky_header = function ( ) {
580
- const header = document . querySelector ( ' header' ) ;
584
+ const header = document . querySelector ( " header" ) ;
581
585
const header_bottom = (
582
- header . querySelector ( ' .content h2' ) . getBoundingClientRect ( ) . top -
586
+ header . querySelector ( " .content h2" ) . getBoundingClientRect ( ) . top -
583
587
header . getBoundingClientRect ( ) . top
584
588
) ;
585
589
586
590
function updateHeader ( ) {
587
591
if ( window . scrollY > header_bottom ) {
588
- header . classList . add ( ' sticky' ) ;
592
+ header . classList . add ( " sticky" ) ;
589
593
} else {
590
- header . classList . remove ( ' sticky' ) ;
594
+ header . classList . remove ( " sticky" ) ;
591
595
}
592
596
}
593
597
594
- window . addEventListener ( ' scroll' , updateHeader ) ;
598
+ window . addEventListener ( " scroll" , updateHeader ) ;
595
599
updateHeader ( ) ;
596
600
} ;
597
601
602
+ coverage . expand_contexts = function ( e ) {
603
+ var ctxs = e . target . parentNode . querySelector ( ".ctxs" ) ;
604
+
605
+ if ( ! ctxs . classList . contains ( "expanded" ) ) {
606
+ var ctxs_text = ctxs . textContent ;
607
+ var width = Number ( ctxs_text [ 0 ] ) ;
608
+ ctxs . textContent = "" ;
609
+ for ( var i = 1 ; i < ctxs_text . length ; i += width ) {
610
+ key = ctxs_text . substring ( i , i + width ) . trim ( ) ;
611
+ ctxs . appendChild ( document . createTextNode ( contexts [ key ] ) ) ;
612
+ ctxs . appendChild ( document . createElement ( "br" ) ) ;
613
+ }
614
+ ctxs . classList . add ( "expanded" ) ;
615
+ }
616
+ } ;
617
+
598
618
document . addEventListener ( "DOMContentLoaded" , ( ) => {
599
619
if ( document . body . classList . contains ( "indexfile" ) ) {
600
620
coverage . index_ready ( ) ;
0 commit comments