diff --git a/IPython/frontend/html/notebook/static/js/cell.js b/IPython/frontend/html/notebook/static/js/cell.js
index 68c876976..9536c9b97 100644
--- a/IPython/frontend/html/notebook/static/js/cell.js
+++ b/IPython/frontend/html/notebook/static/js/cell.js
@@ -19,6 +19,7 @@ var IPython = (function (IPython) {
this.read_only = false;
this.selected = false;
this.element = null;
+ this.metadata = {};
this.create_element();
if (this.element !== null) {
this.element.data("cell", this);
@@ -90,10 +91,16 @@ var IPython = (function (IPython) {
Cell.prototype.toJSON = function () {
+ var data = {};
+ data.metadata = this.metadata;
+ return data;
};
Cell.prototype.fromJSON = function (data) {
+ if (data.metadata !== undefined) {
+ this.metadata = data.metadata;
+ }
};
diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js
index 275493746..1e8b1551f 100644
--- a/IPython/frontend/html/notebook/static/js/codecell.js
+++ b/IPython/frontend/html/notebook/static/js/codecell.js
@@ -264,6 +264,7 @@ var IPython = (function (IPython) {
// JSON serialization
CodeCell.prototype.fromJSON = function (data) {
+ IPython.Cell.prototype.fromJSON.apply(this, arguments);
if (data.cell_type === 'code') {
if (data.input !== undefined) {
this.set_text(data.input);
@@ -286,7 +287,7 @@ var IPython = (function (IPython) {
CodeCell.prototype.toJSON = function () {
- var data = {};
+ var data = IPython.Cell.prototype.toJSON.apply(this);
data.input = this.get_text();
data.cell_type = 'code';
if (this.input_prompt_number) {
diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js
index ef44f7816..5ccfb1adc 100644
--- a/IPython/frontend/html/notebook/static/js/notebook.js
+++ b/IPython/frontend/html/notebook/static/js/notebook.js
@@ -25,6 +25,8 @@ var IPython = (function (IPython) {
this.paste_enabled = false;
this.dirty = false;
this.metadata = {};
+ // single worksheet for now
+ this.worksheet_metadata = {};
this.control_key_active = false;
this.notebook_id = null;
this.notebook_name = null;
@@ -1003,6 +1005,9 @@ var IPython = (function (IPython) {
// Only handle 1 worksheet for now.
var worksheet = data.worksheets[0];
if (worksheet !== undefined) {
+ if (worksheet.metadata) {
+ this.worksheet_metadata = worksheet.metadata;
+ }
var new_cells = worksheet.cells;
ncells = new_cells.length;
var cell_data = null;
@@ -1031,7 +1036,10 @@ var IPython = (function (IPython) {
};
var data = {
// Only handle 1 worksheet for now.
- worksheets : [{cells:cell_array}],
+ worksheets : [{
+ cells: cell_array,
+ metadata: this.worksheet_metadata
+ }],
metadata : this.metadata
};
return data;
diff --git a/IPython/frontend/html/notebook/static/js/textcell.js b/IPython/frontend/html/notebook/static/js/textcell.js
index 38b302e16..3225faa32 100644
--- a/IPython/frontend/html/notebook/static/js/textcell.js
+++ b/IPython/frontend/html/notebook/static/js/textcell.js
@@ -155,6 +155,7 @@ var IPython = (function (IPython) {
TextCell.prototype.fromJSON = function (data) {
+ IPython.Cell.prototype.fromJSON.apply(this, arguments);
if (data.cell_type === this.cell_type) {
if (data.source !== undefined) {
this.set_text(data.source);
@@ -167,7 +168,7 @@ var IPython = (function (IPython) {
TextCell.prototype.toJSON = function () {
- var data = {};
+ var data = IPython.Cell.prototype.toJSON.apply(this);
data.cell_type = this.cell_type;
data.source = this.get_text();
return data;