@@ -198,8 +198,11 @@ ExecutionVisualizer.prototype.render = function() {
198198 </div>\
199199 <div id="errorOutput"/>\
200200 <div id="legendDiv"/>\
201+ <div id="stepAnnotationDiv">\
202+ <textarea class="annotationText" id="stepAnnotationEditor" cols="60" rows="3"></textarea>\
203+ <div class="annotationText" id="stepAnnotationViewer"></div>\
204+ </div>\
201205 <div id="annotateLinkDiv"><button id="annotateBtn" type="button">Annotate this step</button></div>\
202- <div id="stepAnnotationDiv"><textarea id="stepAnnotation" cols="50" rows="3" wrap="off"></textarea></div>\
203206 <div id="progOutputs">\
204207 Program output:<br/>\
205208 <textarea id="pyStdout" cols="50" rows="10" wrap="off" readonly></textarea>\
@@ -272,7 +275,7 @@ ExecutionVisualizer.prototype.render = function() {
272275 this . allowEditAnnotations = false ;
273276 }
274277
275- this . domRoot . find ( '#stepAnnotationDiv ' ) . hide ( ) ;
278+ this . domRoot . find ( '#stepAnnotationEditor ' ) . hide ( ) ;
276279
277280
278281 if ( this . params . embeddedMode ) {
@@ -299,15 +302,15 @@ ExecutionVisualizer.prototype.render = function() {
299302 if ( myViz . editAnnotationMode ) {
300303 myViz . enterViewAnnotationsMode ( ) ;
301304
302- myViz . domRoot . find ( "#jmpFirstInstr,#jmpLastInstr,#jmpStepBack,#jmpStepFwd,#executionSlider,#editCodeLinkDiv" ) . show ( ) ;
303- myViz . domRoot . find ( '#stepAnnotationDiv ' ) . hide ( ) ;
305+ myViz . domRoot . find ( "#jmpFirstInstr,#jmpLastInstr,#jmpStepBack,#jmpStepFwd,#executionSlider,#editCodeLinkDiv,#stepAnnotationViewer " ) . show ( ) ;
306+ myViz . domRoot . find ( '#stepAnnotationEditor ' ) . hide ( ) ;
304307 ab . html ( 'Annotate this step' ) ;
305308 }
306309 else {
307310 myViz . enterEditAnnotationsMode ( ) ;
308311
309- myViz . domRoot . find ( "#jmpFirstInstr,#jmpLastInstr,#jmpStepBack,#jmpStepFwd,#executionSlider,#editCodeLinkDiv" ) . hide ( ) ;
310- myViz . domRoot . find ( '#stepAnnotationDiv ' ) . show ( ) ;
312+ myViz . domRoot . find ( "#jmpFirstInstr,#jmpLastInstr,#jmpStepBack,#jmpStepFwd,#executionSlider,#editCodeLinkDiv,#stepAnnotationViewer " ) . hide ( ) ;
313+ myViz . domRoot . find ( '#stepAnnotationEditor ' ) . show ( ) ;
311314 ab . html ( 'Done annotating' ) ;
312315 }
313316 } ) ;
@@ -449,6 +452,18 @@ ExecutionVisualizer.prototype.destroyAllAnnotationBubbles = function() {
449452 myViz . allAnnotationBubbles = null ;
450453}
451454
455+ ExecutionVisualizer . prototype . initStepAnnotation = function ( ) {
456+ var curEntry = this . curTrace [ this . curInstr ] ;
457+ if ( curEntry . stepAnnotation ) {
458+ this . domRoot . find ( "#stepAnnotationViewer" ) . html ( curEntry . stepAnnotation ) ;
459+ this . domRoot . find ( "#stepAnnotationEditor" ) . val ( curEntry . stepAnnotation ) ;
460+ }
461+ else {
462+ this . domRoot . find ( "#stepAnnotationViewer" ) . html ( '' ) ;
463+ this . domRoot . find ( "#stepAnnotationEditor" ) . val ( '' ) ;
464+ }
465+ }
466+
452467ExecutionVisualizer . prototype . initAllAnnotationBubbles = function ( ) {
453468 var myViz = this ;
454469
@@ -505,13 +520,13 @@ ExecutionVisualizer.prototype.enterViewAnnotationsMode = function() {
505520 var myViz = this ;
506521
507522 if ( ! myViz . allAnnotationBubbles ) {
508- if ( curEntry . annotations ) {
523+ if ( curEntry . bubbleAnnotations ) {
509524 // If there is an existing annotations object, then initiate all annotations bubbles
510525 // and display them in 'View' mode
511526 myViz . initAllAnnotationBubbles ( ) ;
512527
513528 $ . each ( myViz . allAnnotationBubbles , function ( i , e ) {
514- var txt = curEntry . annotations [ e . domID ] ;
529+ var txt = curEntry . bubbleAnnotations [ e . domID ] ;
515530 if ( txt ) {
516531 e . preseedText ( txt ) ;
517532 }
@@ -535,9 +550,18 @@ ExecutionVisualizer.prototype.enterViewAnnotationsMode = function() {
535550 // directly mapping domID -> text.
536551 //
537552 // NB: This scheme can break if the functions for generating domIDs are altered.
538- curEntry . annotations = curAnnotations ;
553+ curEntry . bubbleAnnotations = curAnnotations ;
539554 }
540555
556+ var stepAnnotationEditorVal = myViz . domRoot . find ( "#stepAnnotationEditor" ) . val ( ) . trim ( ) ;
557+ if ( stepAnnotationEditorVal ) {
558+ curEntry . stepAnnotation = stepAnnotationEditorVal ;
559+ }
560+ else {
561+ delete curEntry . stepAnnotation ; // go as far as to DELETE this field entirely
562+ }
563+
564+ myViz . initStepAnnotation ( ) ;
541565}
542566
543567ExecutionVisualizer . prototype . enterEditAnnotationsMode = function ( ) {
@@ -546,6 +570,8 @@ ExecutionVisualizer.prototype.enterEditAnnotationsMode = function() {
546570 // TODO: check for memory leaks!!!
547571 var myViz = this ;
548572
573+ var curEntry = this . curTrace [ this . curInstr ] ;
574+
549575 if ( ! myViz . allAnnotationBubbles ) {
550576 myViz . initAllAnnotationBubbles ( ) ;
551577 }
@@ -555,7 +581,12 @@ ExecutionVisualizer.prototype.enterEditAnnotationsMode = function() {
555581 } ) ;
556582
557583
558- //myViz.domRoot.find("#stepAnnotation").val(<TODO: handle me>);
584+ if ( curEntry . stepAnnotation ) {
585+ myViz . domRoot . find ( "#stepAnnotationEditor" ) . val ( curEntry . stepAnnotation ) ;
586+ }
587+ else {
588+ myViz . domRoot . find ( "#stepAnnotationEditor" ) . val ( '' ) ;
589+ }
559590}
560591
561592
@@ -961,7 +992,9 @@ ExecutionVisualizer.prototype.updateOutput = function(smoothTransition) {
961992 return ;
962993 }
963994
964- myViz . destroyAllAnnotationBubbles ( ) ; // TODO: is this a good place to put this function call?
995+ // crucial resets for annotations (TODO: kludgy)
996+ myViz . destroyAllAnnotationBubbles ( ) ;
997+ myViz . initStepAnnotation ( ) ;
965998
966999
9671000 var prevDataVizHeight = myViz . domRoot . find ( '#dataViz' ) . height ( ) ;
0 commit comments