@@ -37,6 +37,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3737
3838
3939function executeCode ( forceStartingInstr , forceRawInputLst ) {
40+ $ ( '#loadingPane' ) . html ( 'Please wait ... executing Python code.' ) . show ( ) ;
41+
4042 if ( forceRawInputLst !== undefined ) {
4143 rawInputLst = forceRawInputLst ; // UGLY global across modules, FIXME
4244 }
@@ -79,6 +81,17 @@ function executeCode(forceStartingInstr, forceRawInputLst) {
7981
8082function optFinishSuccessfulExecution ( ) {
8183 enterDisplayMode ( ) ; // do this first!
84+ $ ( '#pyOutputPane #editCodeLinkDiv' ) . hide ( ) ; // don't have explicit "Edit code" link
85+ $ ( '#loadingPane' ) . hide ( ) ;
86+ }
87+
88+ // override setFronendError in opt-frontend-common.js
89+ // NB: this file must be included AFTER opt-frontend-common.js
90+ function setFronendError ( lines ) {
91+ var errorStr = lines . map ( htmlspecialchars ) . join ( '<br/>' ) ;
92+ $ ( '#loadingPane' ) . html ( 'There was an error. Please return to "Edit" mode, fix it, then re-enter "View" mode.' ) . show ( ) ;
93+ $ ( "#frontendErrorOutput" ) . html ( errorStr ) ;
94+ $ ( "#frontendErrorOutput" ) . show ( ) ;
8295}
8396
8497
@@ -143,7 +156,12 @@ $(document).ready(function() {
143156
144157 // initialize these callbacks only after Labs.connect is successful
145158 Labs . on ( Labs . Core . EventTypes . ModeChanged , function ( data ) {
146- $ ( "#testDiv" ) . append ( '<p>' + data . mode + '</p>' ) ;
159+ if ( data . mode == 'Edit' ) {
160+ enterEditMode ( ) ;
161+ }
162+ else if ( data . mode == 'View' ) {
163+ executeCodeFromScratch ( ) ;
164+ }
147165 } ) ;
148166
149167 Labs . on ( Labs . Core . EventTypes . Activate , function ( ) {
@@ -154,6 +172,4 @@ $(document).ready(function() {
154172 $ ( "#testDiv" ) . append ( '<p>Deactivate</p>' ) ;
155173 } ) ;
156174 } ) ;
157-
158- //$("#executeBtn").click(executeCodeFromScratch);
159175} ) ;
0 commit comments