@@ -58,6 +58,9 @@ var domain = "http://pythontutor.com/"; // for deployment
5858//var domain = "http://localhost:8080/"; // for Google App Engine local testing
5959
6060
61+ var isExecutingCode = false ; // nasty, nasty global
62+
63+
6164var appMode = 'edit' ; // 'edit', 'display', or 'display_no_frills' also support
6265 // 'visualize' for backward compatibility (same as 'display')
6366
@@ -91,6 +94,24 @@ var myVisualizer = null; // singleton ExecutionVisualizer instance
9194
9295var rawInputLst = [ ] ; // a list of strings inputted by the user in response to raw_input or mouse_input events
9396
97+ function genericOptFrontendReady ( ) {
98+ // log a generic AJAX error handler
99+ $ ( document ) . ajaxError ( function ( evt , jqxhr , settings , exception ) {
100+ // ignore errors related to togetherjs stuff:
101+ if ( settings . url . indexOf ( 'togetherjs' ) > - 1 ) {
102+ return ; // get out early
103+ }
104+
105+ alert ( "Server error (possibly due to memory/resource overload). " +
106+ "Report a bug to philip@pgbovine.net\n\n" +
107+ "(Click the 'Generate URL' button to include a unique URL in your email bug report.)" ) ;
108+
109+ $ ( '#executeBtn' ) . html ( "Visualize Execution" ) ;
110+ $ ( '#executeBtn' ) . attr ( 'disabled' , false ) ;
111+
112+ isExecutingCode = false ; // ugh, nasty global
113+ } ) ;
114+ }
94115
95116function getQueryStringOptions ( ) {
96117 // note that any of these can be 'undefined'
@@ -273,6 +294,8 @@ function executePythonCode(pythonSourceCode,
273294 return ;
274295 }
275296
297+ isExecutingCode = true ; // nasty global
298+
276299 $ . get ( backendScript ,
277300 { user_script : pythonSourceCode ,
278301 raw_input_json : rawInputLst . length > 0 ? JSON . stringify ( rawInputLst ) : '' ,
@@ -335,6 +358,11 @@ function executePythonCode(pythonSourceCode,
335358
336359 handleSuccessFunc ( ) ;
337360 }
361+
362+ // WARNING: this line may run before handleSuccessFunc or
363+ // handleUncaughtExceptionFunc fully finishes if they
364+ // contain asynchronous parts
365+ isExecutingCode = false ;
338366 } ,
339367 "json" ) ;
340368}
0 commit comments