Show More
@@ -60,8 +60,8 b' var IPython = (function (IPython) {' | |||
|
60 | 60 | * @param {object|undefined} [options] |
|
61 | 61 | * @param [options.cm_config] {object} config to pass to CodeMirror |
|
62 | 62 | */ |
|
63 |
var CodeCell = function ( |
|
|
64 |
this. |
|
|
63 | var CodeCell = function (kernel, options) { | |
|
64 | this.kernel = kernel || null; | |
|
65 | 65 | this.code_mirror = null; |
|
66 | 66 | this.input_prompt_number = null; |
|
67 | 67 | this.collapsed = false; |
@@ -231,8 +231,8 b' var IPython = (function (IPython) {' | |||
|
231 | 231 | |
|
232 | 232 | // Kernel related calls. |
|
233 | 233 | |
|
234 |
CodeCell.prototype.set_ |
|
|
235 |
this. |
|
|
234 | CodeCell.prototype.set_kernel = function (kernel) { | |
|
235 | this.kernel = kernel; | |
|
236 | 236 | } |
|
237 | 237 | |
|
238 | 238 | /** |
@@ -250,7 +250,7 b' var IPython = (function (IPython) {' | |||
|
250 | 250 | 'set_next_input': $.proxy(this._handle_set_next_input, this), |
|
251 | 251 | 'input_request': $.proxy(this._handle_input_request, this) |
|
252 | 252 | }; |
|
253 |
this.last_msg_id = this |
|
|
253 | this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true}); | |
|
254 | 254 | }; |
|
255 | 255 | |
|
256 | 256 | /** |
@@ -153,7 +153,7 b' var IPython = (function (IPython) {' | |||
|
153 | 153 | var callbacks = { |
|
154 | 154 | 'complete_reply': $.proxy(this.finish_completing, this) |
|
155 | 155 | }; |
|
156 |
this.cell |
|
|
156 | this.cell.kernel.complete(line, cur.ch, callbacks); | |
|
157 | 157 | } |
|
158 | 158 | }; |
|
159 | 159 |
@@ -33,6 +33,7 b' var IPython = (function (IPython) {' | |||
|
33 | 33 | this.element.data("notebook", this); |
|
34 | 34 | this.next_prompt_number = 1; |
|
35 | 35 | this.session = null; |
|
36 | this.kernel = null; | |
|
36 | 37 | this.clipboard = null; |
|
37 | 38 | this.undelete_backup = null; |
|
38 | 39 | this.undelete_index = null; |
@@ -797,7 +798,7 b' var IPython = (function (IPython) {' | |||
|
797 | 798 | |
|
798 | 799 | if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) { |
|
799 | 800 | if (type === 'code') { |
|
800 |
cell = new IPython.CodeCell(this. |
|
|
801 | cell = new IPython.CodeCell(this.kernel); | |
|
801 | 802 | cell.set_input_prompt(); |
|
802 | 803 | } else if (type === 'markdown') { |
|
803 | 804 | cell = new IPython.MarkdownCell(); |
@@ -1390,21 +1391,21 b' var IPython = (function (IPython) {' | |||
|
1390 | 1391 | */ |
|
1391 | 1392 | Notebook.prototype.start_session = function () { |
|
1392 | 1393 | this.session = new IPython.Session(this.notebook_name, this.notebook_path, this); |
|
1393 | this.session.start(); | |
|
1394 | this.link_cells_to_session(); | |
|
1394 | this.session.start($.proxy(this._session_started, this)); | |
|
1395 | 1395 | }; |
|
1396 | 1396 | |
|
1397 | 1397 | |
|
1398 | 1398 | /** |
|
1399 |
* Once a session is started, link the code cells to the |
|
|
1399 | * Once a session is started, link the code cells to the kernel | |
|
1400 | 1400 | * |
|
1401 | 1401 | */ |
|
1402 |
Notebook.prototype. |
|
|
1402 | Notebook.prototype._session_started = function(){ | |
|
1403 | this.kernel = this.session.kernel; | |
|
1403 | 1404 | var ncells = this.ncells(); |
|
1404 | 1405 | for (var i=0; i<ncells; i++) { |
|
1405 | 1406 | var cell = this.get_cell(i); |
|
1406 | 1407 | if (cell instanceof IPython.CodeCell) { |
|
1407 |
cell.set_ |
|
|
1408 | cell.set_kernel(this.session.kernel); | |
|
1408 | 1409 | }; |
|
1409 | 1410 | }; |
|
1410 | 1411 | }; |
@@ -1806,21 +1807,20 b' var IPython = (function (IPython) {' | |||
|
1806 | 1807 | $.ajax(url,settings); |
|
1807 | 1808 | }; |
|
1808 | 1809 | |
|
1809 |
Notebook.prototype. |
|
|
1810 | Notebook.prototype.rename = function (nbname) { | |
|
1810 | 1811 | var that = this; |
|
1811 |
var |
|
|
1812 | var name = {'name': new_name}; | |
|
1812 | var data = {name: nbname + '.ipynb'}; | |
|
1813 | 1813 | var settings = { |
|
1814 | 1814 | processData : false, |
|
1815 | 1815 | cache : false, |
|
1816 | 1816 | type : "PATCH", |
|
1817 |
data : JSON.stringify( |
|
|
1817 | data : JSON.stringify(data), | |
|
1818 | 1818 | dataType: "json", |
|
1819 | 1819 | headers : {'Content-Type': 'application/json'}, |
|
1820 | 1820 | success : $.proxy(that.rename_success, this), |
|
1821 | 1821 | error : $.proxy(that.rename_error, this) |
|
1822 | 1822 | }; |
|
1823 |
$([IPython.events]).trigger('notebook |
|
|
1823 | $([IPython.events]).trigger('rename_notebook.Notebook', data); | |
|
1824 | 1824 | var url = utils.url_path_join( |
|
1825 | 1825 | this.baseProjectUrl(), |
|
1826 | 1826 | 'api/notebooks', |
@@ -1835,8 +1835,8 b' var IPython = (function (IPython) {' | |||
|
1835 | 1835 | this.notebook_name = json.name |
|
1836 | 1836 | var name = this.notebook_name |
|
1837 | 1837 | var path = json.path |
|
1838 |
this.session.notebook |
|
|
1839 | $([IPython.events]).trigger('notebook_renamed.Notebook'); | |
|
1838 | this.session.rename_notebook(name, path); | |
|
1839 | $([IPython.events]).trigger('notebook_renamed.Notebook', json); | |
|
1840 | 1840 | } |
|
1841 | 1841 | |
|
1842 | 1842 | Notebook.prototype.rename_error = function (json, status, xhr) { |
@@ -95,7 +95,7 b' var IPython = (function (IPython) {' | |||
|
95 | 95 | ); |
|
96 | 96 | return false; |
|
97 | 97 | } else { |
|
98 |
IPython.notebook. |
|
|
98 | IPython.notebook.rename(new_name); | |
|
99 | 99 | } |
|
100 | 100 | }} |
|
101 | 101 | }, |
@@ -128,7 +128,7 b' var IPython = (function (IPython) {' | |||
|
128 | 128 | // reexecute last call in pager by appending ? to show back in pager |
|
129 | 129 | var that = this; |
|
130 | 130 | var empty = function () {}; |
|
131 |
cell |
|
|
131 | cell.kernel.execute( | |
|
132 | 132 | that.name + '?', { |
|
133 | 133 | 'execute_reply': empty, |
|
134 | 134 | 'output': empty, |
@@ -226,7 +226,7 b' var IPython = (function (IPython) {' | |||
|
226 | 226 | 'object_info_reply': $.proxy(this._show, this) |
|
227 | 227 | } |
|
228 | 228 | var oir_token = this.extract_oir_token(line); |
|
229 |
var msg_id = cell |
|
|
229 | var msg_id = cell.kernel.object_info_request(oir_token, callbacks); | |
|
230 | 230 | } |
|
231 | 231 | |
|
232 | 232 | // make an imediate completion request |
@@ -23,7 +23,7 b' var IPython = (function (IPython) {' | |||
|
23 | 23 | this._baseProjectUrl = notebook.baseProjectUrl(); |
|
24 | 24 | }; |
|
25 | 25 | |
|
26 | Session.prototype.start = function() { | |
|
26 | Session.prototype.start = function(callback) { | |
|
27 | 27 | var that = this; |
|
28 | 28 | var model = { |
|
29 | 29 | notebook : { |
@@ -37,13 +37,18 b' var IPython = (function (IPython) {' | |||
|
37 | 37 | type : "POST", |
|
38 | 38 | data: JSON.stringify(model), |
|
39 | 39 | dataType : "json", |
|
40 |
success : |
|
|
40 | success : function (data, status, xhr) { | |
|
41 | that._handle_start_success(data); | |
|
42 | if (callback) { | |
|
43 | callback(data, status, xhr); | |
|
44 | } | |
|
45 | }, | |
|
41 | 46 | }; |
|
42 | 47 | var url = utils.url_path_join(this._baseProjectUrl, 'api/sessions'); |
|
43 | 48 | $.ajax(url, settings); |
|
44 | 49 | }; |
|
45 | 50 | |
|
46 |
Session.prototype.notebook |
|
|
51 | Session.prototype.rename_notebook = function (name, path) { | |
|
47 | 52 | this.name = name; |
|
48 | 53 | this.path = path; |
|
49 | 54 | var model = { |
@@ -63,7 +68,7 b' var IPython = (function (IPython) {' | |||
|
63 | 68 | $.ajax(url, settings); |
|
64 | 69 | }; |
|
65 | 70 | |
|
66 |
Session.prototype.delete |
|
|
71 | Session.prototype.delete = function() { | |
|
67 | 72 | var settings = { |
|
68 | 73 | processData : false, |
|
69 | 74 | cache : false, |
@@ -76,16 +81,15 b' var IPython = (function (IPython) {' | |||
|
76 | 81 | |
|
77 | 82 | // Kernel related things |
|
78 | 83 | /** |
|
79 | * Start a new kernel and set it on each code cell. | |
|
84 | * Create the Kernel object associated with this Session. | |
|
80 | 85 | * |
|
81 |
* @method start_ |
|
|
86 | * @method _handle_start_success | |
|
82 | 87 | */ |
|
83 |
Session.prototype.start_ |
|
|
84 |
this.id = |
|
|
85 | this.kernel_content = json.kernel; | |
|
88 | Session.prototype._handle_start_success = function (data, status, xhr) { | |
|
89 | this.id = data.id; | |
|
86 | 90 | var base_url = utils.url_path_join($('body').data('baseKernelUrl'), "api/kernels"); |
|
87 |
this.kernel = new IPython.Kernel(base_url |
|
|
88 |
this.kernel._kernel_started( |
|
|
91 | this.kernel = new IPython.Kernel(base_url); | |
|
92 | this.kernel._kernel_started(data.kernel); | |
|
89 | 93 | }; |
|
90 | 94 | |
|
91 | 95 | /** |
General Comments 0
You need to be logged in to leave comments.
Login now