##// END OF EJS Templates
Javascript output is not run on notebook loading and paste's.
Brian Granger -
Show More
@@ -563,14 +563,15 b' var IPython = (function (IPython) {'
563 563 };
564 564
565 565
566 CodeCell.prototype.append_output = function (json) {
566 CodeCell.prototype.append_output = function (json, dynamic) {
567 // If dynamic is true, javascript output will be eval'd.
567 568 this.expand();
568 569 if (json.output_type === 'pyout') {
569 this.append_pyout(json);
570 this.append_pyout(json, dynamic);
570 571 } else if (json.output_type === 'pyerr') {
571 572 this.append_pyerr(json);
572 573 } else if (json.output_type === 'display_data') {
573 this.append_display_data(json);
574 this.append_display_data(json, dynamic);
574 575 } else if (json.output_type === 'stream') {
575 576 this.append_stream(json);
576 577 };
@@ -585,11 +586,11 b' var IPython = (function (IPython) {'
585 586 };
586 587
587 588
588 CodeCell.prototype.append_pyout = function (json) {
589 CodeCell.prototype.append_pyout = function (json, dynamic) {
589 590 n = json.prompt_number || ' ';
590 591 var toinsert = this.create_output_area();
591 592 toinsert.find('div.prompt').addClass('output_prompt').html('Out[' + n + ']:');
592 this.append_mime_type(json, toinsert);
593 this.append_mime_type(json, toinsert, dynamic);
593 594 this.element.find('div.output').append(toinsert);
594 595 // If we just output latex, typeset it.
595 596 if ((json.latex !== undefined) || (json.html !== undefined)) {
@@ -641,9 +642,9 b' var IPython = (function (IPython) {'
641 642 };
642 643
643 644
644 CodeCell.prototype.append_display_data = function (json) {
645 CodeCell.prototype.append_display_data = function (json, dynamic) {
645 646 var toinsert = this.create_output_area();
646 this.append_mime_type(json, toinsert);
647 this.append_mime_type(json, toinsert, dynamic);
647 648 this.element.find('div.output').append(toinsert);
648 649 // If we just output latex, typeset it.
649 650 if ( (json.latex !== undefined) || (json.html !== undefined) ) {
@@ -652,11 +653,11 b' var IPython = (function (IPython) {'
652 653 };
653 654
654 655
655 CodeCell.prototype.append_mime_type = function (json, element) {
656 if (json.html !== undefined) {
656 CodeCell.prototype.append_mime_type = function (json, element, dynamic) {
657 if (json.javascript !== undefined && dynamic) {
658 this.append_javascript(json.javascript, element, dynamic);
659 } else if (json.html !== undefined) {
657 660 this.append_html(json.html, element);
658 } else if (json.javascript !== undefined) {
659 this.append_javascript(json.javascript, element);
660 661 } else if (json.latex !== undefined) {
661 662 this.append_latex(json.latex, element);
662 663 } else if (json.svg !== undefined) {
@@ -678,8 +679,10 b' var IPython = (function (IPython) {'
678 679 };
679 680
680 681
681 CodeCell.prototype.append_javascript = function (js, element) {
682 CodeCell.prototype.append_javascript = function (js, e) {
682 683 // We just eval the JS code, element appears in the local scope.
684 var element = $("<div/>").addClass("box_flex1 output_subarea");
685 e.append(element);
683 686 eval(js);
684 687 }
685 688
@@ -842,7 +845,8 b' var IPython = (function (IPython) {'
842 845 };
843 846 var len = data.outputs.length;
844 847 for (var i=0; i<len; i++) {
845 this.append_output(data.outputs[i]);
848 // append with dynamic=false.
849 this.append_output(data.outputs[i], false);
846 850 };
847 851 if (data.collapsed !== undefined) {
848 852 if (data.collapsed) {
@@ -1043,7 +1043,8 b' var IPython = (function (IPython) {'
1043 1043 json.evalue = content.evalue;
1044 1044 json.traceback = content.traceback;
1045 1045 };
1046 cell.append_output(json);
1046 // append with dynamic=true
1047 cell.append_output(json, true);
1047 1048 this.dirty = true;
1048 1049 };
1049 1050
General Comments 0
You need to be logged in to leave comments. Login now