@@ -39,23 +39,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3939// should all be imported BEFORE this file
4040
4141
42- var appMode = 'edit' ; // 'edit', 'display', or 'display_no_frills'
43- // also support 'visualize' for backward
44- // compatibility (it's the same as 'display')
45-
46- var preseededCurInstr = null ; // if you passed in a 'curInstr=<number>' in the URL, then set this var
47-
48- var myVisualizer = null ; // singleton ExecutionVisualizer instance
49-
50-
51- var pyInputCodeMirror ; // CodeMirror object that contains the input text
52-
53- function setCodeMirrorVal ( dat ) {
54- pyInputCodeMirror . setValue ( dat . rtrim ( ) /* kill trailing spaces */ ) ;
55- $ ( '#urlOutput,#embedCodeOutput' ) . val ( '' ) ;
56-
57- // also scroll to top to make the UI more usable on smaller monitors
58- $ ( document ) . scrollTop ( 0 ) ;
42+ function redrawConnectors ( ) {
43+ if ( appMode == 'display' || appMode == 'visualize' /* 'visualize' is deprecated */ ) {
44+ if ( myVisualizer ) {
45+ myVisualizer . redrawConnectors ( ) ;
46+ }
47+ }
5948}
6049
6150
@@ -100,6 +89,7 @@ var try_hook = function(hook_name, args) {
10089}
10190
10291
92+ // get the ENTIRE current state of the app
10393function getAppState ( ) {
10494 return { code : pyInputCodeMirror . getValue ( ) ,
10595 mode : appMode ,
@@ -108,7 +98,8 @@ function getAppState() {
10898 drawParentPointers : $ ( '#drawParentPointerSelector' ) . val ( ) ,
10999 textReferences : $ ( '#textualMemoryLabelsSelector' ) . val ( ) ,
110100 showOnlyOutputs : $ ( '#showOnlyOutputsSelector' ) . val ( ) ,
111- py : $ ( '#pythonVersionSelector' ) . val ( ) } ;
101+ py : $ ( '#pythonVersionSelector' ) . val ( ) ,
102+ myVisualizerState : myVisualizerState } ;
112103}
113104
114105
@@ -208,14 +199,14 @@ $(document).ready(function() {
208199 }
209200
210201 if ( dat . helpAvailable ) {
211- $ ( "#togetherJSHeader" ) . fadeIn ( 750 ) ;
202+ $ ( "#togetherJSHeader" ) . fadeIn ( 750 , redrawConnectors ) ;
212203 }
213204 else {
214205 if ( TogetherJS . running ) {
215206 alert ( "No more live tutors are available now.\nPlease check back later." ) ;
216207 TogetherJS ( ) ; // toggle off
217208 }
218- $ ( "#togetherJSHeader" ) . fadeOut ( 750 ) ;
209+ $ ( "#togetherJSHeader" ) . fadeOut ( 750 , redrawConnectors ) ;
219210 }
220211 } ;
221212 }
@@ -332,9 +323,6 @@ $(document).ready(function() {
332323 // undocumented experimental modes:
333324 pyCrazyMode : ( $ ( '#pythonVersionSelector' ) . val ( ) == '2crazy' ) ,
334325 holisticMode : ( $ ( '#cumulativeModeSelector' ) . val ( ) == 'holistic' )
335- //allowEditAnnotations: true,
336-
337- //, hideCode: true,
338326 }
339327
340328 function handleUncaughtExceptionFunc ( trace ) {
@@ -704,12 +692,7 @@ $(document).ready(function() {
704692 } ) ;
705693
706694
707- // redraw connector arrows on window resize
708- $ ( window ) . resize ( function ( ) {
709- if ( appMode == 'display' || appMode == 'visualize' /* 'visualize' is deprecated */ ) {
710- myVisualizer . redrawConnectors ( ) ;
711- }
712- } ) ;
695+ $ ( window ) . resize ( redrawConnectors ) ;
713696
714697 $ ( '#genUrlBtn' ) . bind ( 'click' , function ( ) {
715698 var myArgs = getAppState ( ) ;
0 commit comments