@@ -129,7 +129,10 @@ function setFronendError(lines) {
129129}
130130
131131
132- function officeMixEnterViewMode ( firstTime ) {
132+ // temp safety for MSR faculty summit
133+ var tempSafe = true ;
134+
135+ function officeMixEnterViewMode ( ) {
133136 if ( _labEditor ) {
134137 _labEditor . done ( function ( ) { _labEditor = null ; } ) ;
135138 }
@@ -138,22 +141,25 @@ function officeMixEnterViewMode(firstTime) {
138141 if ( labInstance ) {
139142 _labViewer = labInstance ; // global
140143
141- if ( firstTime ) {
142- var savedAppState = _labViewer . components [ 0 ] . component . data ;
143- setToggleOptions ( savedAppState ) ;
144- if ( savedAppState . code ) {
145- pyInputSetValue ( savedAppState . code ) ;
144+ var savedAppState = _labViewer . components [ 0 ] . component . data ;
145+ setToggleOptions ( savedAppState ) ;
146+ if ( savedAppState . code ) {
147+ pyInputSetValue ( savedAppState . code ) ;
148+
149+ if ( ! tempSafe ) {
146150 executeCodeFromScratch ( ) ;
147151 }
148152 }
153+
154+ if ( tempSafe ) {
155+ $ ( "#toggleModebtn" ) . html ( "Visualize code" ) . show ( ) ;
156+ enterEditMode ( ) ;
157+ }
149158 }
150159 } ) ;
151-
152- // on second thought, don't hide this
153- //$("#toggleModebtn").hide();
154160}
155161
156- function officeMixEnterEditMode ( firstTime ) {
162+ function officeMixEnterEditMode ( ) {
157163 if ( _labViewer ) {
158164 _labViewer . done ( function ( ) { _labViewer = null ; } ) ;
159165 }
@@ -162,32 +168,30 @@ function officeMixEnterEditMode(firstTime) {
162168 if ( labEditor ) {
163169 _labEditor = labEditor ; // global
164170
165- if ( firstTime ) {
166- _labEditor . getConfiguration ( function ( err , configuration ) {
167- if ( configuration ) {
168- var savedAppState = configuration . components [ 0 ] . data ;
169- setToggleOptions ( savedAppState ) ;
170- if ( savedAppState . code ) {
171- pyInputSetValue ( savedAppState . code ) ;
172- }
171+ _labEditor . getConfiguration ( function ( err , configuration ) {
172+ if ( configuration ) {
173+ var savedAppState = configuration . components [ 0 ] . data ;
174+ setToggleOptions ( savedAppState ) ;
175+ if ( savedAppState . code ) {
176+ pyInputSetValue ( savedAppState . code ) ;
173177 }
174- } ) ;
175-
176- // set configuration on every code edit and option toggle, to
177- // set the 'dirty bit' on the enclosing PPT file
178- if ( useCodeMirror ) {
179- pyInputCodeMirror . on ( "change" , saveCurrentConfiguration ) ;
180- }
181- else {
182- pyInputAceEditor . getSession ( ) . on ( "change" , saveCurrentConfiguration ) ;
183178 }
184- $ ( 'select' ) . change ( saveCurrentConfiguration ) ;
179+ } ) ;
180+
181+ // set configuration on every code edit and option toggle, to
182+ // set the 'dirty bit' on the enclosing PPT file
183+ if ( useCodeMirror ) {
184+ pyInputCodeMirror . on ( "change" , saveCurrentConfiguration ) ;
185+ }
186+ else {
187+ pyInputAceEditor . getSession ( ) . on ( "change" , saveCurrentConfiguration ) ;
185188 }
189+ $ ( 'select' ) . change ( saveCurrentConfiguration ) ;
190+
191+ $ ( "#toggleModebtn" ) . html ( "Visualize code" ) . show ( ) ;
192+ enterEditMode ( ) ;
186193 }
187194 } ) ;
188-
189- $ ( "#toggleModebtn" ) . html ( "Visualize code" ) . show ( ) ;
190- enterEditMode ( ) ;
191195}
192196
193197function saveCurrentConfiguration ( ) {
@@ -278,17 +282,17 @@ $(document).ready(function() {
278282 var initialMode = Labs . Core . LabMode [ connectionResponse . mode ] ;
279283
280284 if ( initialMode == 'Edit' ) {
281- officeMixEnterEditMode ( true ) ;
285+ officeMixEnterEditMode ( ) ;
282286 } else if ( initialMode == 'View' ) {
283- officeMixEnterViewMode ( true ) ;
287+ officeMixEnterViewMode ( ) ;
284288 }
285289
286290 // initialize these callbacks only after Labs.connect is successful
287291 Labs . on ( Labs . Core . EventTypes . ModeChanged , function ( data ) {
288292 if ( data . mode == 'Edit' ) {
289- officeMixEnterEditMode ( false ) ;
293+ officeMixEnterEditMode ( ) ;
290294 } else if ( data . mode == 'View' ) {
291- officeMixEnterViewMode ( false ) ;
295+ officeMixEnterViewMode ( ) ;
292296 }
293297 } ) ;
294298
@@ -298,6 +302,4 @@ $(document).ready(function() {
298302 Labs . on ( Labs . Core . EventTypes . Deactivate , function ( ) {
299303 } ) ;
300304 } ) ;
301-
302- pyInputSetValue ( 'x = "world"\nprint("hello " + x)' ) ; // set default
303305} ) ;
0 commit comments