@@ -106,10 +106,7 @@ function genericOptFrontendReady() {
106106 "Report a bug to philip@pgbovine.net\n\n" +
107107 "(Click the 'Generate URL' button to include a unique URL in your email bug report.)" ) ;
108108
109- $ ( '#executeBtn' ) . html ( "Visualize Execution" ) ;
110- $ ( '#executeBtn' ) . attr ( 'disabled' , false ) ;
111-
112- isExecutingCode = false ; // ugh, nasty global
109+ doneExecutingCode ( ) ;
113110 } ) ;
114111}
115112
@@ -220,8 +217,7 @@ function updateAppDisplay() {
220217 $ ( "#pyOutputPane,#surveyHeader" ) . show ( ) ;
221218 $ ( "#embedLinkDiv" ) . show ( ) ;
222219
223- $ ( '#executeBtn' ) . html ( "Visualize Execution" ) ;
224- $ ( '#executeBtn' ) . attr ( 'disabled' , false ) ;
220+ doneExecutingCode ( ) ;
225221
226222 // do this AFTER making #pyOutputPane visible, or else
227223 // jsPlumb connectors won't render properly
@@ -263,11 +259,15 @@ function handleUncaughtExceptionFunc(trace) {
263259 pyInputCodeMirror . on ( 'change' , f ) ;
264260 }
265261
266- $ ( '#executeBtn' ) . html ( "Visualize Execution" ) ;
267- $ ( '#executeBtn' ) . attr ( 'disabled' , false ) ;
262+ doneExecutingCode ( ) ;
268263 }
269264}
270265
266+ function doneExecutingCode ( ) {
267+ $ ( '#executeBtn' ) . html ( "Visualize Execution" ) ;
268+ $ ( '#executeBtn' ) . attr ( 'disabled' , false ) ;
269+ isExecutingCode = false ; // nasty global
270+ }
271271
272272function enterDisplayMode ( ) {
273273 $ ( document ) . scrollTop ( 0 ) ; // scroll to top to make UX better on small monitors
@@ -358,11 +358,6 @@ function executePythonCode(pythonSourceCode,
358358
359359 handleSuccessFunc ( ) ;
360360 }
361-
362- // WARNING: this line may run before handleSuccessFunc or
363- // handleUncaughtExceptionFunc fully finishes if they
364- // contain asynchronous parts
365- isExecutingCode = false ;
366361 } ,
367362 "json" ) ;
368363}
0 commit comments