@@ -214,7 +214,7 @@ coverage.LINE_FILTERS_STORAGE = "COVERAGE_LINE_FILTERS";
214214coverage . pyfile_ready = function ( ) {
215215 // If we're directed to a particular line number, highlight the line.
216216 var frag = location . hash ;
217- if ( frag . length > 2 && frag [ 1 ] === 't' ) {
217+ if ( frag . length > 2 && frag [ 1 ] === "t" ) {
218218 document . querySelector ( frag ) . closest ( ".n" ) . classList . add ( "highlight" ) ;
219219 coverage . set_sel ( parseInt ( frag . substr ( 2 ) , 10 ) ) ;
220220 } else {
@@ -257,6 +257,10 @@ coverage.pyfile_ready = function () {
257257 coverage . init_scroll_markers ( ) ;
258258 coverage . wire_up_sticky_header ( ) ;
259259
260+ document . querySelectorAll ( "[id^=ctxs]" ) . forEach (
261+ cbox => cbox . addEventListener ( "click" , coverage . expand_contexts )
262+ ) ;
263+
260264 // Rebuild scroll markers when the window height changes.
261265 window . addEventListener ( "resize" , coverage . build_scroll_markers ) ;
262266} ;
@@ -528,14 +532,14 @@ coverage.scroll_window = function (to_pos) {
528532
529533coverage . init_scroll_markers = function ( ) {
530534 // Init some variables
531- coverage . lines_len = document . querySelectorAll ( ' #source > p' ) . length ;
535+ coverage . lines_len = document . querySelectorAll ( " #source > p" ) . length ;
532536
533537 // Build html
534538 coverage . build_scroll_markers ( ) ;
535539} ;
536540
537541coverage . build_scroll_markers = function ( ) {
538- const temp_scroll_marker = document . getElementById ( ' scroll_marker' )
542+ const temp_scroll_marker = document . getElementById ( " scroll_marker" )
539543 if ( temp_scroll_marker ) temp_scroll_marker . remove ( ) ;
540544 // Don't build markers if the window has no scroll bar.
541545 if ( document . body . scrollHeight <= window . innerHeight ) {
@@ -549,8 +553,8 @@ coverage.build_scroll_markers = function () {
549553
550554 const scroll_marker = document . createElement ( "div" ) ;
551555 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"
554558 ) . forEach ( element => {
555559 const line_top = Math . floor ( element . offsetTop * marker_scale ) ;
556560 const line_number = parseInt ( element . querySelector ( ".n a" ) . id . substr ( 1 ) ) ;
@@ -577,24 +581,40 @@ coverage.build_scroll_markers = function () {
577581} ;
578582
579583coverage . wire_up_sticky_header = function ( ) {
580- const header = document . querySelector ( ' header' ) ;
584+ const header = document . querySelector ( " header" ) ;
581585 const header_bottom = (
582- header . querySelector ( ' .content h2' ) . getBoundingClientRect ( ) . top -
586+ header . querySelector ( " .content h2" ) . getBoundingClientRect ( ) . top -
583587 header . getBoundingClientRect ( ) . top
584588 ) ;
585589
586590 function updateHeader ( ) {
587591 if ( window . scrollY > header_bottom ) {
588- header . classList . add ( ' sticky' ) ;
592+ header . classList . add ( " sticky" ) ;
589593 } else {
590- header . classList . remove ( ' sticky' ) ;
594+ header . classList . remove ( " sticky" ) ;
591595 }
592596 }
593597
594- window . addEventListener ( ' scroll' , updateHeader ) ;
598+ window . addEventListener ( " scroll" , updateHeader ) ;
595599 updateHeader ( ) ;
596600} ;
597601
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+
598618document . addEventListener ( "DOMContentLoaded" , ( ) => {
599619 if ( document . body . classList . contains ( "indexfile" ) ) {
600620 coverage . index_ready ( ) ;
0 commit comments