OLD | NEW |
1 /** | 1 /** |
2 * Common JS that talks XHR back to the server and runs the code and receives | 2 * Common JS that talks XHR back to the server and runs the code and receives |
3 * the results. | 3 * the results. |
4 */ | 4 */ |
5 | 5 |
6 | 6 |
7 /** | 7 /** |
8 * All the functionality is wrapped up in this anonymous closure, but we need | 8 * All the functionality is wrapped up in this anonymous closure, but we need |
9 * to be told if we are on the workspace page or a normal try page, so the | 9 * to be told if we are on the workspace page or a normal try page, so the |
10 * workspaceName is passed into the closure, it must be set in the global | 10 * workspaceName is passed into the closure, it must be set in the global |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 // The response is JSON of the form: | 262 // The response is JSON of the form: |
263 // { | 263 // { |
264 // "message": "you had an error...", | 264 // "message": "you had an error...", |
265 // "img": "<base64 encoded image but only on success>" | 265 // "img": "<base64 encoded image but only on success>" |
266 // } | 266 // } |
267 // | 267 // |
268 // The img is optional and only appears if there is a valid | 268 // The img is optional and only appears if there is a valid |
269 // image to display. | 269 // image to display. |
270 endWait(); | 270 endWait(); |
271 body = JSON.parse(e.target.response); | 271 body = JSON.parse(e.target.response); |
272 if (body.compileErrors.length) { | 272 if (null != body.compileErrors && body.compileErrors.length) { |
273 html = ""; | 273 html = ""; |
274 for (i = 0 ; i < body.compileErrors.length ; i++) { | 274 for (i = 0 ; i < body.compileErrors.length ; i++) { |
275 compileError = body.compileErrors[i]; | 275 compileError = body.compileErrors[i]; |
276 | 276 |
277 err = document.createElement("div"); | 277 err = document.createElement("div"); |
278 err.className = "compile-error"; | 278 err.className = "compile-error"; |
279 | 279 |
280 loc = document.createElement("span"); | 280 loc = document.createElement("span"); |
281 loc.className = "error-location"; | 281 loc.className = "error-location"; |
282 loc.innerHTML = "Line " + compileError.line + ", col " + compileErro
r.column + ": "; | 282 loc.innerHTML = "Line " + compileError.line + ", col " + compileErro
r.column + ": "; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 368 } |
369 | 369 |
370 // If loaded via HTML Imports then DOMContentLoaded will be long done. | 370 // If loaded via HTML Imports then DOMContentLoaded will be long done. |
371 if (document.readyState != "loading") { | 371 if (document.readyState != "loading") { |
372 onLoad(); | 372 onLoad(); |
373 } else { | 373 } else { |
374 this.addEventListener('load', onLoad); | 374 this.addEventListener('load', onLoad); |
375 } | 375 } |
376 | 376 |
377 })(); | 377 })(); |
OLD | NEW |