@@ -117,6 +117,9 @@ export abstract class AbstractBaseFrontend {
117117
118118 num414Tries = 0 ;
119119
120+ abstract executeCode ( forceStartingInstr ?: number , forceRawInputLst ?: string [ ] ) : any ;
121+ abstract handleUncaughtExceptionFunc ( trace : any [ ] ) : any ;
122+
120123 constructor ( params : any = { } ) {
121124 // optional params -- TODO: handle later
122125 /*
@@ -227,12 +230,6 @@ export abstract class AbstractBaseFrontend {
227230 // override this with a version in codeopticon-learner.js if needed
228231 logEventCodeopticon ( obj ) { } // NOP
229232
230-
231- abstract executeCode ( forceStartingInstr ?: number , forceRawInputLst ?: string [ ] ) : any ;
232- abstract handleUncaughtExceptionFunc ( trace : any [ ] ) : any ;
233- appStateAugmenter : ( appState ) => { } // NOP
234- loadTestCases : ( testCasesLst ) => { } // NOP
235-
236233 setFronendError ( lines ) {
237234 $ ( "#frontendErrorOutput" ) . html ( lines . map ( pytutor . htmlspecialchars ) . join ( '<br/>' ) ) ;
238235 }
@@ -241,6 +238,26 @@ export abstract class AbstractBaseFrontend {
241238 $ ( "#frontendErrorOutput" ) . html ( '' ) ;
242239 }
243240
241+ // parsing the URL query string hash
242+ getQueryStringOptions ( ) {
243+ var ril = $ . bbq . getState ( 'rawInputLstJSON' ) ;
244+ var testCasesLstJSON = $ . bbq . getState ( 'testCasesJSON' ) ;
245+ // note that any of these can be 'undefined'
246+ return { preseededCode : $ . bbq . getState ( 'code' ) ,
247+ preseededCurInstr : Number ( $ . bbq . getState ( 'curInstr' ) ) ,
248+ verticalStack : $ . bbq . getState ( 'verticalStack' ) ,
249+ appMode : $ . bbq . getState ( 'mode' ) ,
250+ py : $ . bbq . getState ( 'py' ) ,
251+ cumulative : $ . bbq . getState ( 'cumulative' ) ,
252+ heapPrimitives : $ . bbq . getState ( 'heapPrimitives' ) ,
253+ textReferences : $ . bbq . getState ( 'textReferences' ) ,
254+ rawInputLst : ril ? $ . parseJSON ( ril ) : undefined ,
255+ codeopticonSession : $ . bbq . getState ( 'cosession' ) ,
256+ codeopticonUsername : $ . bbq . getState ( 'couser' ) ,
257+ testCasesLst : testCasesLstJSON ? $ . parseJSON ( testCasesLstJSON ) : undefined
258+ } ;
259+ }
260+
244261 redrawConnectors ( ) {
245262 if ( this . myVisualizer &&
246263 ( this . appMode == 'display' ||
@@ -538,78 +555,6 @@ export abstract class AbstractBaseFrontend {
538555 }
539556 }
540557
541- pyInputSetValue ( s : string ) { } ; // NOP unless subclass overrides
542-
543- parseQueryString ( ) {
544- var queryStrOptions = this . getQueryStringOptions ( ) ;
545- this . setToggleOptions ( queryStrOptions ) ;
546- if ( queryStrOptions . preseededCode ) {
547- this . pyInputSetValue ( queryStrOptions . preseededCode ) ;
548- }
549- if ( queryStrOptions . rawInputLst ) {
550- this . rawInputLst = queryStrOptions . rawInputLst ; // global
551- }
552- else {
553- this . rawInputLst = [ ] ;
554- }
555-
556- if ( queryStrOptions . codeopticonSession ) {
557- assert ( false ) ; // TODO: this won't currently work with Webpack, so fix it later
558- codeopticonSession = queryStrOptions . codeopticonSession ; // GLOBAL defined in codeopticon-learner.js
559- codeopticonUsername = queryStrOptions . codeopticonUsername ; // GLOBAL defined in codeopticon-learner.js
560- }
561-
562- if ( queryStrOptions . testCasesLst && this . loadTestCases ) {
563- this . loadTestCases ( queryStrOptions . testCasesLst ) ;
564- }
565-
566- // ugh tricky -- always start in edit mode by default, and then
567- // switch to display mode only after the code successfully executes
568- this . appMode = 'edit' ;
569- if ( ( queryStrOptions . appMode == 'display' ||
570- queryStrOptions . appMode == 'visualize' /* 'visualize' is deprecated */ ) &&
571- queryStrOptions . preseededCode /* jump to display only with pre-seeded code */ ) {
572- this . executeCode ( queryStrOptions . preseededCurInstr ) ; // will switch to 'display' mode
573- }
574- $ . bbq . removeState ( ) ; // clean up the URL no matter what
575- }
576-
577- // parsing the URL query string hash
578- getQueryStringOptions ( ) {
579- var ril = $ . bbq . getState ( 'rawInputLstJSON' ) ;
580- var testCasesLstJSON = $ . bbq . getState ( 'testCasesJSON' ) ;
581- // note that any of these can be 'undefined'
582- return { preseededCode : $ . bbq . getState ( 'code' ) ,
583- preseededCurInstr : Number ( $ . bbq . getState ( 'curInstr' ) ) ,
584- verticalStack : $ . bbq . getState ( 'verticalStack' ) ,
585- appMode : $ . bbq . getState ( 'mode' ) ,
586- py : $ . bbq . getState ( 'py' ) ,
587- cumulative : $ . bbq . getState ( 'cumulative' ) ,
588- heapPrimitives : $ . bbq . getState ( 'heapPrimitives' ) ,
589- textReferences : $ . bbq . getState ( 'textReferences' ) ,
590- rawInputLst : ril ? $ . parseJSON ( ril ) : undefined ,
591- codeopticonSession : $ . bbq . getState ( 'cosession' ) ,
592- codeopticonUsername : $ . bbq . getState ( 'couser' ) ,
593- testCasesLst : testCasesLstJSON ? $ . parseJSON ( testCasesLstJSON ) : undefined
594- } ;
595- }
596-
597- setToggleOptions ( dat ) {
598- // ugh, ugly tristate due to the possibility of each being undefined
599- if ( dat . py !== undefined ) {
600- $ ( '#pythonVersionSelector' ) . val ( dat . py ) ;
601- }
602- if ( dat . cumulative !== undefined ) {
603- $ ( '#cumulativeModeSelector' ) . val ( dat . cumulative ) ;
604- }
605- if ( dat . heapPrimitives !== undefined ) {
606- $ ( '#heapPrimitivesSelector' ) . val ( dat . heapPrimitives ) ;
607- }
608- if ( dat . textReferences !== undefined ) {
609- $ ( '#textualMemoryLabelsSelector' ) . val ( dat . textReferences ) ;
610- }
611- }
612-
613558 // Compress updateHistory before encoding and sending to
614559 // the server so that it takes up less room in the URL. Have each
615560 // entry except for the first be a delta from the FIRST entry.
0 commit comments