Finishing display system work.

* Added image/jpeg MIME type to notebook format, the core display
  logic and the notebook.
* Finished HTML, SVG, Image, Math, Javascript, JSON classes.
This commit is contained in:
Brian E. Granger 2011-08-11 14:17:01 -07:00
parent 3ad866c73d
commit 0db7ab16a3
2 changed files with 23 additions and 7 deletions

View File

@ -205,13 +205,15 @@ var IPython = (function (IPython) {
CodeCell.prototype.append_pyerr = function (json) {
var tb = json.traceback;
var s = '';
var len = tb.length;
for (var i=0; i<len; i++) {
s = s + tb[i] + '\n';
}
s = s + '\n';
this.append_text(s);
if (tb !== undefined) {
var s = '';
var len = tb.length;
for (var i=0; i<len; i++) {
s = s + tb[i] + '\n';
}
s = s + '\n';
this.append_text(s);
};
};
@ -240,6 +242,8 @@ var IPython = (function (IPython) {
this.append_svg(json.svg, element);
} else if (json.png !== undefined) {
this.append_png(json.png, element);
} else if (json.jpeg !== undefined) {
this.append_jpeg(json.jpeg, element);
} else if (json.text !== undefined) {
this.append_text(json.text, element);
};
@ -283,6 +287,15 @@ var IPython = (function (IPython) {
};
CodeCell.prototype.append_jpeg = function (jpeg, element) {
element = element || this.element.find("div.output");
var toinsert = $("<div/>").addClass("output_area output_jpeg");
toinsert.append($("<img/>").attr('src','data:image/jpeg;base64,'+jpeg));
element.append(toinsert);
return element;
};
CodeCell.prototype.append_latex = function (latex, element) {
// This method cannot do the typesetting because the latex first has to
// be on the page.

View File

@ -544,6 +544,9 @@ var IPython = (function (IPython) {
if (data['image/png'] !== undefined) {
json.png = data['image/png'];
};
if (data['image/jpeg'] !== undefined) {
json.jpeg = data['image/jpeg'];
};
if (data['text/latex'] !== undefined) {
json.latex = data['text/latex'];
};