@@ -625,6 +625,26 @@ ExecutionVisualizer.prototype.render = function() {
625625 // EXPERIMENTAL!
626626 if ( this . tabularView ) {
627627 this . renderTabularView ( ) ;
628+
629+ // scroll vizLayoutTdFirst down to always align with the vertical
630+ // scrolling ...
631+ $ ( window ) . scroll ( function ( ) {
632+ var codePane = myViz . domRoot . find ( '#vizLayoutTdFirst' ) ;
633+ var docScrollTop = $ ( document ) . scrollTop ( ) ;
634+ var offset = codePane . offset ( ) . top ;
635+ var delta = docScrollTop - offset ;
636+ if ( delta < 0 ) {
637+ delta = 0 ;
638+ }
639+
640+ // don't scroll past the bottom of the optTabularView table:
641+ var optTable = myViz . domRoot . find ( '#optTabularView' ) ;
642+ var optTableBottom = optTable . height ( ) + optTable . offset ( ) . top ;
643+ var codeDisplayHeight = myViz . domRoot . find ( '#codeDisplayDiv' ) . height ( ) ;
644+ if ( delta - offset < optTableBottom - codeDisplayHeight ) {
645+ codePane . css ( 'padding-top' , delta ) ;
646+ }
647+ } ) ;
628648 }
629649
630650 this . updateOutput ( ) ;
@@ -2872,7 +2892,7 @@ ExecutionVisualizer.prototype.renderTabularView = function() {
28722892 });
28732893 */
28742894
2875- var allVarNames = [ ] ;
2895+ var allVarNames = [ 'Step' ] ;
28762896
28772897 $ . each ( allGlobalVars , function ( i , e ) {
28782898 allVarNames . push ( e ) ;
@@ -2885,7 +2905,9 @@ ExecutionVisualizer.prototype.renderTabularView = function() {
28852905
28862906 // get the values of all objects in trace entry e
28872907 function getAllOrderedValues ( curEntry ) {
2888- var allVarValues = [ ] ;
2908+ // HACK! start with a blank sentinel since the first column of the
2909+ // table is the step number
2910+ var allVarValues = [ '' ] ;
28892911
28902912 $ . each ( allGlobalVars , function ( i , e ) {
28912913 allVarValues . push ( curEntry . globals [ e ] ) ;
@@ -2928,14 +2950,19 @@ ExecutionVisualizer.prototype.renderTabularView = function() {
29282950
29292951 var tblRoot = myViz . domRootD3 . select ( "#optTabularView" ) ;
29302952 var tbl = tblRoot . append ( "table" ) ;
2931- var tHead = tbl . append ( 'thead' ) . append ( 'tr' ) ;
2953+ tbl . attr ( 'id' , 'optTable' ) ;
2954+
2955+ var tHead = tbl . append ( 'thead' ) . attr ( 'class' , 'stepTableThead' ) . append ( 'tr' ) ;
2956+ tHead . attr ( 'class' , 'stepTableTr' ) ;
29322957 tHead . selectAll ( 'thead td' )
29332958 . data ( allVarNames )
29342959 . enter ( )
29352960 . append ( 'td' )
2961+ . attr ( 'class' , 'stepTableTd' )
29362962 . html ( function ( d ) { return d ; } )
29372963
29382964 var tBody = tbl . append ( 'tbody' ) ;
2965+ tBody . attr ( 'class' , 'stepTableTbody' ) ;
29392966
29402967 var stepsAndTraceEntries = [ ] ;
29412968 $ . each ( myViz . curTrace , function ( i , e ) {
@@ -2946,22 +2973,30 @@ ExecutionVisualizer.prototype.renderTabularView = function() {
29462973 . data ( stepsAndTraceEntries )
29472974 . enter ( )
29482975 . append ( "tr" )
2949- . attr ( "step" , function ( d , i ) { return i ; } ) ;
2976+ . attr ( "step" , function ( d , i ) { return i ; } )
2977+ . attr ( "class" , 'stepTableTr' ) ;
29502978
29512979 var td = tr . selectAll ( "td" )
29522980 . data ( function ( e ) { return getAllOrderedValues ( e [ 1 ] ) ; } )
29532981 . enter ( )
29542982 . append ( "td" )
2983+ . attr ( 'class' , 'stepTableTd' )
29552984 . each ( function ( obj , i ) {
29562985 $ ( this ) . empty ( ) ;
2986+
29572987 // TODO: fixme -- this is super kludgy; must be a better way
29582988 var step = parseInt ( $ ( this ) . closest ( 'tr' ) . attr ( 'step' ) ) ;
29592989
2960- if ( obj === undefined ) {
2961- // keep this table cell EMPTY
2990+ if ( i == 0 ) {
2991+ $ ( this ) . html ( step + 1 ) ; // one-indexed for readability
29622992 }
29632993 else {
2964- myViz . renderNestedObject ( obj , step , $ ( this ) , 'tabular' ) ;
2994+ if ( obj === undefined ) {
2995+ // keep this table cell EMPTY
2996+ }
2997+ else {
2998+ myViz . renderNestedObject ( obj , step , $ ( this ) , 'tabular' ) ;
2999+ }
29653000 }
29663001 } ) ;
29673002
0 commit comments