@@ -33,9 +33,6 @@ var backend_script = 'exec'; // URL of backend script, which must eventually cal
3333
3434var appMode = 'edit' ; // 'edit' or 'visualize'
3535
36- var preseededCode = null ; // if you passed in a 'code=<code string>' in the URL, then set this var
37- var preseededCurInstr = null ; // if you passed in a 'curInstr=<number>' in the URL, then set this var
38-
3936
4037var myVisualizer = null ; // singleton ExecutionVisualizer instance
4138
@@ -70,18 +67,6 @@ $(document).ready(function() {
7067 $ ( window ) . bind ( "hashchange" , function ( e ) {
7168 appMode = $ . bbq . getState ( 'mode' ) ; // assign this to the GLOBAL appMode
7269
73- preseededCode = $ . bbq . getState ( 'code' ) ; // yuck, global!
74- var preseededMode = $ . bbq . getState ( 'mode' ) ;
75-
76- if ( $ . bbq . getState ( 'cumulative_mode' ) == 'true' ) {
77- $ ( '#cumulativeMode' ) . prop ( 'checked' , true ) ;
78- }
79-
80- // only bother with curInstr when we're visualizing ...
81- if ( ! preseededCurInstr && preseededMode == 'visualize' ) { // TODO: kinda gross hack
82- preseededCurInstr = Number ( $ . bbq . getState ( 'curInstr' ) ) ;
83- }
84-
8570 // default mode is 'edit'
8671 if ( appMode == undefined ) {
8772 appMode = 'edit' ;
@@ -91,13 +76,7 @@ $(document).ready(function() {
9176 // nothing to visualize:
9277 if ( ! myVisualizer ) {
9378 appMode = 'edit' ;
94-
95- if ( preseededCode && preseededMode == 'visualize' ) {
96- // punt for now ...
97- }
98- else {
99- $ . bbq . pushState ( { mode : 'edit' } , 2 /* completely override other hash strings to keep URL clean */ ) ;
100- }
79+ $ . bbq . pushState ( { mode : 'edit' } , 2 /* completely override other hash strings to keep URL clean */ ) ;
10180 }
10281
10382
@@ -180,17 +159,9 @@ $(document).ready(function() {
180159 $ ( '#executeBtn' ) . attr ( 'disabled' , false ) ;
181160 }
182161 else {
183- var startingInstruction = 0 ;
184-
185- // only do this at most ONCE, and then clear out preseededCurInstr
186- if ( preseededCurInstr && preseededCurInstr < trace . length ) { // NOP anyways if preseededCurInstr is 0
187- startingInstruction = preseededCurInstr ;
188- preseededCurInstr = null ;
189- }
190-
191162 myVisualizer = new ExecutionVisualizer ( 'pyOutputPane' ,
192163 dataFromBackend ,
193- { startingInstruction : startingInstruction } ) ;
164+ { embeddedMode : true } ) ;
194165
195166 $ . bbq . pushState ( { mode : 'visualize' } , 2 /* completely override other hash strings to keep URL clean */ ) ;
196167 }
@@ -199,199 +170,6 @@ $(document).ready(function() {
199170 } ) ;
200171
201172
202-
203- // canned examples
204-
205- $ ( "#tutorialExampleLink" ) . click ( function ( ) {
206- $ . get ( "example-code/py_tutorial.txt" , setCodeMirrorVal ) ;
207- return false ;
208- } ) ;
209-
210- $ ( "#strtokExampleLink" ) . click ( function ( ) {
211- $ . get ( "example-code/strtok.txt" , setCodeMirrorVal ) ;
212- return false ;
213- } ) ;
214-
215- $ ( "#fibonacciExampleLink" ) . click ( function ( ) {
216- $ . get ( "example-code/fib.txt" , setCodeMirrorVal ) ;
217- return false ;
218- } ) ;
219-
220- $ ( "#memoFibExampleLink" ) . click ( function ( ) {
221- $ . get ( "example-code/memo_fib.txt" , setCodeMirrorVal ) ;
222- return false ;
223- } ) ;
224-
225- $ ( "#factExampleLink" ) . click ( function ( ) {
226- $ . get ( "example-code/fact.txt" , setCodeMirrorVal ) ;
227- return false ;
228- } ) ;
229-
230- $ ( "#filterExampleLink" ) . click ( function ( ) {
231- $ . get ( "example-code/filter.txt" , setCodeMirrorVal ) ;
232- return false ;
233- } ) ;
234-
235- $ ( "#insSortExampleLink" ) . click ( function ( ) {
236- $ . get ( "example-code/ins_sort.txt" , setCodeMirrorVal ) ;
237- return false ;
238- } ) ;
239-
240- $ ( "#aliasExampleLink" ) . click ( function ( ) {
241- $ . get ( "example-code/aliasing.txt" , setCodeMirrorVal ) ;
242- return false ;
243- } ) ;
244-
245- $ ( "#newtonExampleLink" ) . click ( function ( ) {
246- $ . get ( "example-code/sqrt.txt" , setCodeMirrorVal ) ;
247- return false ;
248- } ) ;
249-
250- $ ( "#oopSmallExampleLink" ) . click ( function ( ) {
251- $ . get ( "example-code/oop_small.txt" , setCodeMirrorVal ) ;
252- return false ;
253- } ) ;
254-
255- $ ( "#mapExampleLink" ) . click ( function ( ) {
256- $ . get ( "example-code/map.txt" , setCodeMirrorVal ) ;
257- return false ;
258- } ) ;
259-
260- $ ( "#oop1ExampleLink" ) . click ( function ( ) {
261- $ . get ( "example-code/oop_1.txt" , setCodeMirrorVal ) ;
262- return false ;
263- } ) ;
264-
265- $ ( "#oop2ExampleLink" ) . click ( function ( ) {
266- $ . get ( "example-code/oop_2.txt" , setCodeMirrorVal ) ;
267- return false ;
268- } ) ;
269-
270- $ ( "#inheritanceExampleLink" ) . click ( function ( ) {
271- $ . get ( "example-code/oop_inherit.txt" , setCodeMirrorVal ) ;
272- return false ;
273- } ) ;
274-
275- $ ( "#sumExampleLink" ) . click ( function ( ) {
276- $ . get ( "example-code/sum.txt" , setCodeMirrorVal ) ;
277- return false ;
278- } ) ;
279-
280- $ ( "#pwGcdLink" ) . click ( function ( ) {
281- $ . get ( "example-code/wentworth_gcd.txt" , setCodeMirrorVal ) ;
282- return false ;
283- } ) ;
284-
285- $ ( "#pwSumListLink" ) . click ( function ( ) {
286- $ . get ( "example-code/wentworth_sumList.txt" , setCodeMirrorVal ) ;
287- return false ;
288- } ) ;
289-
290- $ ( "#towersOfHanoiLink" ) . click ( function ( ) {
291- $ . get ( "example-code/towers_of_hanoi.txt" , setCodeMirrorVal ) ;
292- return false ;
293- } ) ;
294-
295- $ ( "#pwTryFinallyLink" ) . click ( function ( ) {
296- $ . get ( "example-code/wentworth_try_finally.txt" , setCodeMirrorVal ) ;
297- return false ;
298- } ) ;
299-
300- $ ( "#sumCubesLink" ) . click ( function ( ) {
301- $ . get ( "example-code/sum-cubes.txt" , setCodeMirrorVal ) ;
302- return false ;
303- } ) ;
304-
305- $ ( "#decoratorsLink" ) . click ( function ( ) {
306- $ . get ( "example-code/decorators.txt" , setCodeMirrorVal ) ;
307- return false ;
308- } ) ;
309-
310-
311-
312- $ ( '#closure1Link' ) . click ( function ( ) {
313- $ . get ( "example-code/closures/closure1.txt" , setCodeMirrorVal ) ;
314- return false ;
315- } ) ;
316- $ ( '#closure2Link' ) . click ( function ( ) {
317- $ . get ( "example-code/closures/closure2.txt" , setCodeMirrorVal ) ;
318- return false ;
319- } ) ;
320- $ ( '#closure3Link' ) . click ( function ( ) {
321- $ . get ( "example-code/closures/closure3.txt" , setCodeMirrorVal ) ;
322- return false ;
323- } ) ;
324- $ ( '#closure4Link' ) . click ( function ( ) {
325- $ . get ( "example-code/closures/closure4.txt" , setCodeMirrorVal ) ;
326- return false ;
327- } ) ;
328- $ ( '#closure5Link' ) . click ( function ( ) {
329- $ . get ( "example-code/closures/closure5.txt" , setCodeMirrorVal ) ;
330- return false ;
331- } ) ;
332- $ ( '#lambdaParamLink' ) . click ( function ( ) {
333- $ . get ( "example-code/closures/lambda-param.txt" , setCodeMirrorVal ) ;
334- return false ;
335- } ) ;
336-
337-
338- $ ( '#aliasing1Link' ) . click ( function ( ) {
339- $ . get ( "example-code/aliasing/aliasing1.txt" , setCodeMirrorVal ) ;
340- return false ;
341- } ) ;
342- $ ( '#aliasing2Link' ) . click ( function ( ) {
343- $ . get ( "example-code/aliasing/aliasing2.txt" , setCodeMirrorVal ) ;
344- return false ;
345- } ) ;
346- $ ( '#aliasing3Link' ) . click ( function ( ) {
347- $ . get ( "example-code/aliasing/aliasing3.txt" , setCodeMirrorVal ) ;
348- return false ;
349- } ) ;
350- $ ( '#aliasing4Link' ) . click ( function ( ) {
351- $ . get ( "example-code/aliasing/aliasing4.txt" , setCodeMirrorVal ) ;
352- return false ;
353- } ) ;
354- $ ( '#aliasing5Link' ) . click ( function ( ) {
355- $ . get ( "example-code/aliasing/aliasing5.txt" , setCodeMirrorVal ) ;
356- return false ;
357- } ) ;
358- $ ( '#aliasing6Link' ) . click ( function ( ) {
359- $ . get ( "example-code/aliasing/aliasing6.txt" , setCodeMirrorVal ) ;
360- return false ;
361- } ) ;
362- $ ( '#aliasing7Link' ) . click ( function ( ) {
363- $ . get ( "example-code/aliasing/aliasing7.txt" , setCodeMirrorVal ) ;
364- return false ;
365- } ) ;
366- $ ( '#aliasing8Link' ) . click ( function ( ) {
367- $ . get ( "example-code/aliasing/aliasing8.txt" , setCodeMirrorVal ) ;
368- return false ;
369- } ) ;
370-
371-
372- $ ( '#ll1Link' ) . click ( function ( ) {
373- $ . get ( "example-code/linked-lists/ll1.txt" , setCodeMirrorVal ) ;
374- return false ;
375- } ) ;
376- $ ( '#ll2Link' ) . click ( function ( ) {
377- $ . get ( "example-code/linked-lists/ll2.txt" , setCodeMirrorVal ) ;
378- return false ;
379- } ) ;
380-
381-
382- if ( preseededCode ) {
383- setCodeMirrorVal ( preseededCode ) ;
384-
385- if ( $ . bbq . getState ( 'mode' ) != 'edit' ) {
386- $ ( "#executeBtn" ) . trigger ( 'click' ) ;
387- }
388- }
389- else {
390- // select a canned example on start-up:
391- $ ( "#aliasExampleLink" ) . trigger ( 'click' ) ;
392- }
393-
394-
395173 // log a generic AJAX error handler
396174 $ ( document ) . ajaxError ( function ( ) {
397175 alert ( "Server error (possibly due to memory/resource overload)." ) ;
@@ -418,5 +196,8 @@ $(document).ready(function() {
418196 2 ) ;
419197 $ ( '#urlOutput' ) . val ( urlStr ) ;
420198 } ) ;
199+
200+
201+ $ . get ( "example-code/aliasing.txt" , setCodeMirrorVal ) ;
421202} ) ;
422203
0 commit comments