Show More
@@ -313,6 +313,33 b' var IPython = (function (IPython) {' | |||||
313 | return oa; |
|
313 | return oa; | |
314 | }; |
|
314 | }; | |
315 |
|
315 | |||
|
316 | OutputArea.prototype._append_javascript_error = function (err, container) { | |||
|
317 | // display a message when a javascript error occurs in display output | |||
|
318 | var msg = "Javascript error adding output!" | |||
|
319 | console.log(msg, err); | |||
|
320 | if ( container === undefined ) return; | |||
|
321 | container.append( | |||
|
322 | $('<div/>').html(msg + "<br/>" + | |||
|
323 | err.toString() + | |||
|
324 | '<br/>See your browser Javascript console for more details.' | |||
|
325 | ).addClass('js-error') | |||
|
326 | ); | |||
|
327 | container.show(); | |||
|
328 | }; | |||
|
329 | ||||
|
330 | OutputArea.prototype._safe_append = function (toinsert) { | |||
|
331 | // safely append an item to the document | |||
|
332 | // this is an object created by user code, | |||
|
333 | // and may have errors, which should not be raised | |||
|
334 | // under any circumstances. | |||
|
335 | try { | |||
|
336 | this.element.append(toinsert); | |||
|
337 | } catch(err) { | |||
|
338 | console.log(err); | |||
|
339 | this._append_javascript_error(err, this.element); | |||
|
340 | } | |||
|
341 | }; | |||
|
342 | ||||
316 |
|
343 | |||
317 | OutputArea.prototype.append_pyout = function (json, dynamic) { |
|
344 | OutputArea.prototype.append_pyout = function (json, dynamic) { | |
318 | var n = json.prompt_number || ' '; |
|
345 | var n = json.prompt_number || ' '; | |
@@ -321,19 +348,7 b' var IPython = (function (IPython) {' | |||||
321 | toinsert.find('div.prompt').addClass('output_prompt').html('Out[' + n + ']:'); |
|
348 | toinsert.find('div.prompt').addClass('output_prompt').html('Out[' + n + ']:'); | |
322 | } |
|
349 | } | |
323 | this.append_mime_type(json, toinsert, dynamic); |
|
350 | this.append_mime_type(json, toinsert, dynamic); | |
324 | try { |
|
351 | this._safe_append(toinsert); | |
325 | this.element.append(toinsert); |
|
|||
326 | } catch(err) { |
|
|||
327 | console.log("Error attaching output!"); |
|
|||
328 | console.log(err); |
|
|||
329 | this.element.show(); |
|
|||
330 | toinsert.html($('<div/>') |
|
|||
331 | .html("Javascript error adding output!<br/>" + |
|
|||
332 | err.toString() + |
|
|||
333 | '<br/>See your browser Javascript console for more details.') |
|
|||
334 | .addClass('js-error') |
|
|||
335 | ); |
|
|||
336 | } |
|
|||
337 | // If we just output latex, typeset it. |
|
352 | // If we just output latex, typeset it. | |
338 | if ((json.latex !== undefined) || (json.html !== undefined)) { |
|
353 | if ((json.latex !== undefined) || (json.html !== undefined)) { | |
339 | this.typeset(); |
|
354 | this.typeset(); | |
@@ -352,7 +367,7 b' var IPython = (function (IPython) {' | |||||
352 | s = s + '\n'; |
|
367 | s = s + '\n'; | |
353 | var toinsert = this.create_output_area(); |
|
368 | var toinsert = this.create_output_area(); | |
354 | this.append_text(s, {}, toinsert); |
|
369 | this.append_text(s, {}, toinsert); | |
355 |
this. |
|
370 | this._safe_append(toinsert); | |
356 | } |
|
371 | } | |
357 | }; |
|
372 | }; | |
358 |
|
373 | |||
@@ -389,14 +404,14 b' var IPython = (function (IPython) {' | |||||
389 | // If we got here, attach a new div |
|
404 | // If we got here, attach a new div | |
390 | var toinsert = this.create_output_area(); |
|
405 | var toinsert = this.create_output_area(); | |
391 | this.append_text(text, {}, toinsert, "output_stream "+subclass); |
|
406 | this.append_text(text, {}, toinsert, "output_stream "+subclass); | |
392 |
this. |
|
407 | this._safe_append(toinsert); | |
393 | }; |
|
408 | }; | |
394 |
|
409 | |||
395 |
|
410 | |||
396 | OutputArea.prototype.append_display_data = function (json, dynamic) { |
|
411 | OutputArea.prototype.append_display_data = function (json, dynamic) { | |
397 | var toinsert = this.create_output_area(); |
|
412 | var toinsert = this.create_output_area(); | |
398 | this.append_mime_type(json, toinsert, dynamic); |
|
413 | this.append_mime_type(json, toinsert, dynamic); | |
399 |
this. |
|
414 | this._safe_append(toinsert); | |
400 | // If we just output latex, typeset it. |
|
415 | // If we just output latex, typeset it. | |
401 | if ( (json.latex !== undefined) || (json.html !== undefined) ) { |
|
416 | if ( (json.latex !== undefined) || (json.html !== undefined) ) { | |
402 | this.typeset(); |
|
417 | this.typeset(); | |
@@ -444,15 +459,7 b' var IPython = (function (IPython) {' | |||||
444 | try { |
|
459 | try { | |
445 | eval(js); |
|
460 | eval(js); | |
446 | } catch(err) { |
|
461 | } catch(err) { | |
447 | console.log('Error in Javascript!'); |
|
462 | this._append_javascript_error(err, container); | |
448 | console.log(err); |
|
|||
449 | container.show(); |
|
|||
450 | element.append($('<div/>') |
|
|||
451 | .html("Error in Javascript !<br/>"+ |
|
|||
452 | err.toString()+ |
|
|||
453 | '<br/>See your browser Javascript console for more details.') |
|
|||
454 | .addClass('js-error') |
|
|||
455 | ); |
|
|||
456 | } |
|
463 | } | |
457 | }; |
|
464 | }; | |
458 |
|
465 |
General Comments 0
You need to be logged in to leave comments.
Login now