Show More
@@ -0,0 +1,70 | |||||
|
1 | ||||
|
2 | //============================================================================ | |||
|
3 | // Pager | |||
|
4 | //============================================================================ | |||
|
5 | ||||
|
6 | var IPython = (function (IPython) { | |||
|
7 | ||||
|
8 | var utils = IPython.utils; | |||
|
9 | ||||
|
10 | var Pager = function (pager_selector, pager_toggle_selector) { | |||
|
11 | this.pager_element = $(pager_selector); | |||
|
12 | this.pager_toggle_element = $(pager_toggle_selector); | |||
|
13 | this.style(); | |||
|
14 | this.bind_events(); | |||
|
15 | this.collapse(); | |||
|
16 | }; | |||
|
17 | ||||
|
18 | ||||
|
19 | Pager.prototype.style = function () { | |||
|
20 | this.pager_toggle_element.addClass('border-box-sizing ui-widget ui-widget-header') | |||
|
21 | this.pager_element.addClass('border-box-sizing') | |||
|
22 | }; | |||
|
23 | ||||
|
24 | ||||
|
25 | Pager.prototype.bind_events = function () { | |||
|
26 | var that = this; | |||
|
27 | this.pager_toggle_element.click(function () { | |||
|
28 | that.pager_element.toggle('fast'); | |||
|
29 | }); | |||
|
30 | ||||
|
31 | this.pager_toggle_element.hover( | |||
|
32 | function () { | |||
|
33 | that.pager_toggle_element.addClass('ui-state-hover'); | |||
|
34 | }, | |||
|
35 | function () { | |||
|
36 | that.pager_toggle_element.removeClass('ui-state-hover'); | |||
|
37 | } | |||
|
38 | ); | |||
|
39 | }; | |||
|
40 | ||||
|
41 | ||||
|
42 | Pager.prototype.collapse = function () { | |||
|
43 | this.pager_element.hide('fast'); | |||
|
44 | }; | |||
|
45 | ||||
|
46 | ||||
|
47 | Pager.prototype.expand = function () { | |||
|
48 | this.pager_element.show('fast'); | |||
|
49 | }; | |||
|
50 | ||||
|
51 | ||||
|
52 | Pager.prototype.clear = function (text) { | |||
|
53 | this.pager_element.empty(); | |||
|
54 | }; | |||
|
55 | ||||
|
56 | ||||
|
57 | Pager.prototype.append_text = function (text) { | |||
|
58 | var toinsert = $("<div/>").addClass("output_area output_stream monospace-font"); | |||
|
59 | toinsert.append($("<pre/>").addClass("monospace-font"). | |||
|
60 | html(utils.fixConsole(text))); | |||
|
61 | this.pager_element.append(toinsert); | |||
|
62 | }; | |||
|
63 | ||||
|
64 | ||||
|
65 | IPython.Pager = Pager; | |||
|
66 | ||||
|
67 | return IPython; | |||
|
68 | ||||
|
69 | }(IPython)); | |||
|
70 |
@@ -1,538 +1,542 | |||||
1 |
|
1 | |||
2 | //============================================================================ |
|
2 | //============================================================================ | |
3 | // Notebook |
|
3 | // Notebook | |
4 | //============================================================================ |
|
4 | //============================================================================ | |
5 |
|
5 | |||
6 | var IPython = (function (IPython) { |
|
6 | var IPython = (function (IPython) { | |
7 |
|
7 | |||
8 | var utils = IPython.utils; |
|
8 | var utils = IPython.utils; | |
9 |
|
9 | |||
10 | var Notebook = function (selector) { |
|
10 | var Notebook = function (selector) { | |
11 | this.element = $(selector); |
|
11 | this.element = $(selector); | |
12 | this.element.scroll(); |
|
12 | this.element.scroll(); | |
13 | this.element.data("notebook", this); |
|
13 | this.element.data("notebook", this); | |
14 | this.next_prompt_number = 1; |
|
14 | this.next_prompt_number = 1; | |
15 | this.kernel = null; |
|
15 | this.kernel = null; | |
16 | this.msg_cell_map = {}; |
|
16 | this.msg_cell_map = {}; | |
17 | this.filename = null; |
|
17 | this.filename = null; | |
18 | this.notebook_load_re = /%notebook load/ |
|
18 | this.notebook_load_re = /%notebook load/ | |
19 | this.notebook_save_re = /%notebook save/ |
|
19 | this.notebook_save_re = /%notebook save/ | |
20 | this.notebook_filename_re = /(\w)+.ipynb/ |
|
20 | this.notebook_filename_re = /(\w)+.ipynb/ | |
|
21 | this.style(); | |||
21 | this.bind_events(); |
|
22 | this.bind_events(); | |
22 | this.start_kernel(); |
|
23 | this.start_kernel(); | |
23 | }; |
|
24 | }; | |
24 |
|
25 | |||
25 |
|
26 | |||
|
27 | Notebook.prototype.style = function () { | |||
|
28 | this.element.addClass('vbox box-flex1 border-box-sizing'); | |||
|
29 | }; | |||
|
30 | ||||
|
31 | ||||
26 | Notebook.prototype.bind_events = function () { |
|
32 | Notebook.prototype.bind_events = function () { | |
27 | var that = this; |
|
33 | var that = this; | |
28 | $(document).keydown(function (event) { |
|
34 | $(document).keydown(function (event) { | |
29 | // console.log(event); |
|
35 | // console.log(event); | |
30 | if (event.which === 38) { |
|
36 | if (event.which === 38) { | |
31 | var cell = that.selected_cell(); |
|
37 | var cell = that.selected_cell(); | |
32 | if (cell.at_top()) { |
|
38 | if (cell.at_top()) { | |
33 | event.preventDefault(); |
|
39 | event.preventDefault(); | |
34 | that.select_prev(); |
|
40 | that.select_prev(); | |
35 | }; |
|
41 | }; | |
36 | } else if (event.which === 40) { |
|
42 | } else if (event.which === 40) { | |
37 | var cell = that.selected_cell(); |
|
43 | var cell = that.selected_cell(); | |
38 | if (cell.at_bottom()) { |
|
44 | if (cell.at_bottom()) { | |
39 | event.preventDefault(); |
|
45 | event.preventDefault(); | |
40 | that.select_next(); |
|
46 | that.select_next(); | |
41 | }; |
|
47 | }; | |
42 | } else if (event.which === 13 && event.shiftKey) { |
|
48 | } else if (event.which === 13 && event.shiftKey) { | |
43 | // The focus is not quite working here. |
|
49 | // The focus is not quite working here. | |
44 | var cell = that.selected_cell(); |
|
50 | var cell = that.selected_cell(); | |
45 | var cell_index = that.find_cell_index(cell); |
|
51 | var cell_index = that.find_cell_index(cell); | |
46 | // TODO: the logic here needs to be moved into appropriate |
|
52 | // TODO: the logic here needs to be moved into appropriate | |
47 | // methods of Notebook. |
|
53 | // methods of Notebook. | |
48 | if (cell instanceof IPython.CodeCell) { |
|
54 | if (cell instanceof IPython.CodeCell) { | |
49 | event.preventDefault(); |
|
55 | event.preventDefault(); | |
50 | cell.clear_output(); |
|
56 | cell.clear_output(); | |
51 | var code = cell.get_code(); |
|
57 | var code = cell.get_code(); | |
52 | if (that.notebook_load_re.test(code)) { |
|
58 | if (that.notebook_load_re.test(code)) { | |
53 | var code_parts = code.split(' '); |
|
59 | var code_parts = code.split(' '); | |
54 | if (code_parts.length === 3) { |
|
60 | if (code_parts.length === 3) { | |
55 | that.load_notebook(code_parts[2]); |
|
61 | that.load_notebook(code_parts[2]); | |
56 | }; |
|
62 | }; | |
57 | } else if (that.notebook_save_re.test(code)) { |
|
63 | } else if (that.notebook_save_re.test(code)) { | |
58 | var code_parts = code.split(' '); |
|
64 | var code_parts = code.split(' '); | |
59 | if (code_parts.length === 3) { |
|
65 | if (code_parts.length === 3) { | |
60 | that.save_notebook(code_parts[2]); |
|
66 | that.save_notebook(code_parts[2]); | |
61 | } else { |
|
67 | } else { | |
62 | that.save_notebook() |
|
68 | that.save_notebook() | |
63 | }; |
|
69 | }; | |
64 | } else { |
|
70 | } else { | |
65 | var msg_id = that.kernel.execute(cell.get_code()); |
|
71 | var msg_id = that.kernel.execute(cell.get_code()); | |
66 | that.msg_cell_map[msg_id] = cell.cell_id; |
|
72 | that.msg_cell_map[msg_id] = cell.cell_id; | |
67 | }; |
|
73 | }; | |
68 | } else if (cell instanceof IPython.TextCell) { |
|
74 | } else if (cell instanceof IPython.TextCell) { | |
69 | event.preventDefault(); |
|
75 | event.preventDefault(); | |
70 | cell.render(); |
|
76 | cell.render(); | |
71 | } |
|
77 | } | |
72 | if (cell_index === (that.ncells()-1)) { |
|
78 | if (cell_index === (that.ncells()-1)) { | |
73 | that.insert_code_cell_after(); |
|
79 | that.insert_code_cell_after(); | |
74 | } else { |
|
80 | } else { | |
75 | that.select(cell_index+1); |
|
81 | that.select(cell_index+1); | |
76 | }; |
|
82 | }; | |
77 | }; |
|
83 | }; | |
78 | }); |
|
84 | }); | |
79 | }; |
|
85 | }; | |
80 |
|
86 | |||
81 |
|
87 | |||
82 | // Cell indexing, retrieval, etc. |
|
88 | // Cell indexing, retrieval, etc. | |
83 |
|
89 | |||
84 |
|
90 | |||
85 | Notebook.prototype.cell_elements = function () { |
|
91 | Notebook.prototype.cell_elements = function () { | |
86 | return this.element.children("div.cell"); |
|
92 | return this.element.children("div.cell"); | |
87 | } |
|
93 | } | |
88 |
|
94 | |||
89 |
|
95 | |||
90 | Notebook.prototype.ncells = function (cell) { |
|
96 | Notebook.prototype.ncells = function (cell) { | |
91 | return this.cell_elements().length; |
|
97 | return this.cell_elements().length; | |
92 | } |
|
98 | } | |
93 |
|
99 | |||
94 |
|
100 | |||
95 | // TODO: we are often calling cells as cells()[i], which we should optimize |
|
101 | // TODO: we are often calling cells as cells()[i], which we should optimize | |
96 | // to cells(i) or a new method. |
|
102 | // to cells(i) or a new method. | |
97 | Notebook.prototype.cells = function () { |
|
103 | Notebook.prototype.cells = function () { | |
98 | return this.cell_elements().toArray().map(function (e) { |
|
104 | return this.cell_elements().toArray().map(function (e) { | |
99 | return $(e).data("cell"); |
|
105 | return $(e).data("cell"); | |
100 | }); |
|
106 | }); | |
101 | } |
|
107 | } | |
102 |
|
108 | |||
103 |
|
109 | |||
104 | Notebook.prototype.find_cell_index = function (cell) { |
|
110 | Notebook.prototype.find_cell_index = function (cell) { | |
105 | var result = null; |
|
111 | var result = null; | |
106 | this.cell_elements().filter(function (index) { |
|
112 | this.cell_elements().filter(function (index) { | |
107 | if ($(this).data("cell") === cell) { |
|
113 | if ($(this).data("cell") === cell) { | |
108 | result = index; |
|
114 | result = index; | |
109 | }; |
|
115 | }; | |
110 | }); |
|
116 | }); | |
111 | return result; |
|
117 | return result; | |
112 | }; |
|
118 | }; | |
113 |
|
119 | |||
114 |
|
120 | |||
115 | Notebook.prototype.index_or_selected = function (index) { |
|
121 | Notebook.prototype.index_or_selected = function (index) { | |
116 | return index || this.selected_index() || 0; |
|
122 | return index || this.selected_index() || 0; | |
117 | } |
|
123 | } | |
118 |
|
124 | |||
119 |
|
125 | |||
120 | Notebook.prototype.select = function (index) { |
|
126 | Notebook.prototype.select = function (index) { | |
121 | if (index !== undefined && index >= 0 && index < this.ncells()) { |
|
127 | if (index !== undefined && index >= 0 && index < this.ncells()) { | |
122 | if (this.selected_index() !== null) { |
|
128 | if (this.selected_index() !== null) { | |
123 | this.selected_cell().unselect(); |
|
129 | this.selected_cell().unselect(); | |
124 | }; |
|
130 | }; | |
125 | this.cells()[index].select(); |
|
131 | this.cells()[index].select(); | |
126 | }; |
|
132 | }; | |
127 | return this; |
|
133 | return this; | |
128 | }; |
|
134 | }; | |
129 |
|
135 | |||
130 |
|
136 | |||
131 | Notebook.prototype.select_next = function () { |
|
137 | Notebook.prototype.select_next = function () { | |
132 | var index = this.selected_index(); |
|
138 | var index = this.selected_index(); | |
133 | if (index !== null && index >= 0 && (index+1) < this.ncells()) { |
|
139 | if (index !== null && index >= 0 && (index+1) < this.ncells()) { | |
134 | this.select(index+1); |
|
140 | this.select(index+1); | |
135 | }; |
|
141 | }; | |
136 | return this; |
|
142 | return this; | |
137 | }; |
|
143 | }; | |
138 |
|
144 | |||
139 |
|
145 | |||
140 | Notebook.prototype.select_prev = function () { |
|
146 | Notebook.prototype.select_prev = function () { | |
141 | var index = this.selected_index(); |
|
147 | var index = this.selected_index(); | |
142 | if (index !== null && index >= 0 && (index-1) < this.ncells()) { |
|
148 | if (index !== null && index >= 0 && (index-1) < this.ncells()) { | |
143 | this.select(index-1); |
|
149 | this.select(index-1); | |
144 | }; |
|
150 | }; | |
145 | return this; |
|
151 | return this; | |
146 | }; |
|
152 | }; | |
147 |
|
153 | |||
148 |
|
154 | |||
149 | Notebook.prototype.selected_index = function () { |
|
155 | Notebook.prototype.selected_index = function () { | |
150 | var result = null; |
|
156 | var result = null; | |
151 | this.cell_elements().filter(function (index) { |
|
157 | this.cell_elements().filter(function (index) { | |
152 | if ($(this).data("cell").selected === true) { |
|
158 | if ($(this).data("cell").selected === true) { | |
153 | result = index; |
|
159 | result = index; | |
154 | }; |
|
160 | }; | |
155 | }); |
|
161 | }); | |
156 | return result; |
|
162 | return result; | |
157 | }; |
|
163 | }; | |
158 |
|
164 | |||
159 |
|
165 | |||
160 | Notebook.prototype.cell_for_msg = function (msg_id) { |
|
166 | Notebook.prototype.cell_for_msg = function (msg_id) { | |
161 | var cell_id = this.msg_cell_map[msg_id]; |
|
167 | var cell_id = this.msg_cell_map[msg_id]; | |
162 | var result = null; |
|
168 | var result = null; | |
163 | this.cell_elements().filter(function (index) { |
|
169 | this.cell_elements().filter(function (index) { | |
164 | cell = $(this).data("cell"); |
|
170 | cell = $(this).data("cell"); | |
165 | if (cell.cell_id === cell_id) { |
|
171 | if (cell.cell_id === cell_id) { | |
166 | result = cell; |
|
172 | result = cell; | |
167 | }; |
|
173 | }; | |
168 | }); |
|
174 | }); | |
169 | return result; |
|
175 | return result; | |
170 | }; |
|
176 | }; | |
171 |
|
177 | |||
172 |
|
178 | |||
173 | Notebook.prototype.selected_cell = function () { |
|
179 | Notebook.prototype.selected_cell = function () { | |
174 | return this.cell_elements().eq(this.selected_index()).data("cell"); |
|
180 | return this.cell_elements().eq(this.selected_index()).data("cell"); | |
175 | } |
|
181 | } | |
176 |
|
182 | |||
177 |
|
183 | |||
178 | // Cell insertion, deletion and moving. |
|
184 | // Cell insertion, deletion and moving. | |
179 |
|
185 | |||
180 |
|
186 | |||
181 | Notebook.prototype.delete_cell = function (index) { |
|
187 | Notebook.prototype.delete_cell = function (index) { | |
182 | var i = index || this.selected_index(); |
|
188 | var i = index || this.selected_index(); | |
183 | if (i !== null && i >= 0 && i < this.ncells()) { |
|
189 | if (i !== null && i >= 0 && i < this.ncells()) { | |
184 | this.cell_elements().eq(i).remove(); |
|
190 | this.cell_elements().eq(i).remove(); | |
185 | if (i === (this.ncells())) { |
|
191 | if (i === (this.ncells())) { | |
186 | this.select(i-1); |
|
192 | this.select(i-1); | |
187 | } else { |
|
193 | } else { | |
188 | this.select(i); |
|
194 | this.select(i); | |
189 | }; |
|
195 | }; | |
190 | }; |
|
196 | }; | |
191 | return this; |
|
197 | return this; | |
192 | }; |
|
198 | }; | |
193 |
|
199 | |||
194 |
|
200 | |||
195 | Notebook.prototype.append_cell = function (cell) { |
|
201 | Notebook.prototype.append_cell = function (cell) { | |
196 | this.element.append(cell.element); |
|
202 | this.element.append(cell.element); | |
197 | return this; |
|
203 | return this; | |
198 | }; |
|
204 | }; | |
199 |
|
205 | |||
200 |
|
206 | |||
201 | Notebook.prototype.insert_cell_after = function (cell, index) { |
|
207 | Notebook.prototype.insert_cell_after = function (cell, index) { | |
202 | var ncells = this.ncells(); |
|
208 | var ncells = this.ncells(); | |
203 | if (ncells === 0) { |
|
209 | if (ncells === 0) { | |
204 | this.append_cell(cell); |
|
210 | this.append_cell(cell); | |
205 | return this; |
|
211 | return this; | |
206 | }; |
|
212 | }; | |
207 | if (index >= 0 && index < ncells) { |
|
213 | if (index >= 0 && index < ncells) { | |
208 | this.cell_elements().eq(index).after(cell.element); |
|
214 | this.cell_elements().eq(index).after(cell.element); | |
209 | }; |
|
215 | }; | |
210 | return this |
|
216 | return this | |
211 | }; |
|
217 | }; | |
212 |
|
218 | |||
213 |
|
219 | |||
214 | Notebook.prototype.insert_cell_before = function (cell, index) { |
|
220 | Notebook.prototype.insert_cell_before = function (cell, index) { | |
215 | var ncells = this.ncells(); |
|
221 | var ncells = this.ncells(); | |
216 | if (ncells === 0) { |
|
222 | if (ncells === 0) { | |
217 | this.append_cell(cell); |
|
223 | this.append_cell(cell); | |
218 | return this; |
|
224 | return this; | |
219 | }; |
|
225 | }; | |
220 | if (index >= 0 && index < ncells) { |
|
226 | if (index >= 0 && index < ncells) { | |
221 | this.cell_elements().eq(index).before(cell.element); |
|
227 | this.cell_elements().eq(index).before(cell.element); | |
222 | }; |
|
228 | }; | |
223 | return this; |
|
229 | return this; | |
224 | }; |
|
230 | }; | |
225 |
|
231 | |||
226 |
|
232 | |||
227 | Notebook.prototype.move_cell_up = function (index) { |
|
233 | Notebook.prototype.move_cell_up = function (index) { | |
228 | var i = index || this.selected_index(); |
|
234 | var i = index || this.selected_index(); | |
229 | if (i !== null && i < this.ncells() && i > 0) { |
|
235 | if (i !== null && i < this.ncells() && i > 0) { | |
230 | var pivot = this.cell_elements().eq(i-1); |
|
236 | var pivot = this.cell_elements().eq(i-1); | |
231 | var tomove = this.cell_elements().eq(i); |
|
237 | var tomove = this.cell_elements().eq(i); | |
232 | if (pivot !== null && tomove !== null) { |
|
238 | if (pivot !== null && tomove !== null) { | |
233 | tomove.detach(); |
|
239 | tomove.detach(); | |
234 | pivot.before(tomove); |
|
240 | pivot.before(tomove); | |
235 | this.select(i-1); |
|
241 | this.select(i-1); | |
236 | }; |
|
242 | }; | |
237 | }; |
|
243 | }; | |
238 | return this; |
|
244 | return this; | |
239 | } |
|
245 | } | |
240 |
|
246 | |||
241 |
|
247 | |||
242 | Notebook.prototype.move_cell_down = function (index) { |
|
248 | Notebook.prototype.move_cell_down = function (index) { | |
243 | var i = index || this.selected_index(); |
|
249 | var i = index || this.selected_index(); | |
244 | if (i !== null && i < (this.ncells()-1) && i >= 0) { |
|
250 | if (i !== null && i < (this.ncells()-1) && i >= 0) { | |
245 | var pivot = this.cell_elements().eq(i+1) |
|
251 | var pivot = this.cell_elements().eq(i+1) | |
246 | var tomove = this.cell_elements().eq(i) |
|
252 | var tomove = this.cell_elements().eq(i) | |
247 | if (pivot !== null && tomove !== null) { |
|
253 | if (pivot !== null && tomove !== null) { | |
248 | tomove.detach(); |
|
254 | tomove.detach(); | |
249 | pivot.after(tomove); |
|
255 | pivot.after(tomove); | |
250 | this.select(i+1); |
|
256 | this.select(i+1); | |
251 | }; |
|
257 | }; | |
252 | }; |
|
258 | }; | |
253 | return this; |
|
259 | return this; | |
254 | } |
|
260 | } | |
255 |
|
261 | |||
256 |
|
262 | |||
257 | Notebook.prototype.sort_cells = function () { |
|
263 | Notebook.prototype.sort_cells = function () { | |
258 | var ncells = this.ncells(); |
|
264 | var ncells = this.ncells(); | |
259 | var sindex = this.selected_index(); |
|
265 | var sindex = this.selected_index(); | |
260 | var swapped; |
|
266 | var swapped; | |
261 | do { |
|
267 | do { | |
262 | swapped = false |
|
268 | swapped = false | |
263 | for (var i=1; i<ncells; i++) { |
|
269 | for (var i=1; i<ncells; i++) { | |
264 | current = this.cell_elements().eq(i).data("cell"); |
|
270 | current = this.cell_elements().eq(i).data("cell"); | |
265 | previous = this.cell_elements().eq(i-1).data("cell"); |
|
271 | previous = this.cell_elements().eq(i-1).data("cell"); | |
266 | if (previous.input_prompt_number > current.input_prompt_number) { |
|
272 | if (previous.input_prompt_number > current.input_prompt_number) { | |
267 | this.move_cell_up(i); |
|
273 | this.move_cell_up(i); | |
268 | swapped = true; |
|
274 | swapped = true; | |
269 | }; |
|
275 | }; | |
270 | }; |
|
276 | }; | |
271 | } while (swapped); |
|
277 | } while (swapped); | |
272 | this.select(sindex); |
|
278 | this.select(sindex); | |
273 | return this; |
|
279 | return this; | |
274 | }; |
|
280 | }; | |
275 |
|
281 | |||
276 |
|
282 | |||
277 | Notebook.prototype.insert_code_cell_before = function (index) { |
|
283 | Notebook.prototype.insert_code_cell_before = function (index) { | |
278 | // TODO: Bounds check for i |
|
284 | // TODO: Bounds check for i | |
279 | var i = this.index_or_selected(index); |
|
285 | var i = this.index_or_selected(index); | |
280 | var cell = new IPython.CodeCell(this); |
|
286 | var cell = new IPython.CodeCell(this); | |
281 | cell.set_input_prompt(this.next_prompt_number); |
|
287 | cell.set_input_prompt(this.next_prompt_number); | |
282 | this.next_prompt_number = this.next_prompt_number + 1; |
|
288 | this.next_prompt_number = this.next_prompt_number + 1; | |
283 | this.insert_cell_before(cell, i); |
|
289 | this.insert_cell_before(cell, i); | |
284 | this.select(this.find_cell_index(cell)); |
|
290 | this.select(this.find_cell_index(cell)); | |
285 | return this; |
|
291 | return this; | |
286 | } |
|
292 | } | |
287 |
|
293 | |||
288 |
|
294 | |||
289 | Notebook.prototype.insert_code_cell_after = function (index) { |
|
295 | Notebook.prototype.insert_code_cell_after = function (index) { | |
290 | // TODO: Bounds check for i |
|
296 | // TODO: Bounds check for i | |
291 | var i = this.index_or_selected(index); |
|
297 | var i = this.index_or_selected(index); | |
292 | var cell = new IPython.CodeCell(this); |
|
298 | var cell = new IPython.CodeCell(this); | |
293 | cell.set_input_prompt(this.next_prompt_number); |
|
299 | cell.set_input_prompt(this.next_prompt_number); | |
294 | this.next_prompt_number = this.next_prompt_number + 1; |
|
300 | this.next_prompt_number = this.next_prompt_number + 1; | |
295 | this.insert_cell_after(cell, i); |
|
301 | this.insert_cell_after(cell, i); | |
296 | this.select(this.find_cell_index(cell)); |
|
302 | this.select(this.find_cell_index(cell)); | |
297 | return this; |
|
303 | return this; | |
298 | } |
|
304 | } | |
299 |
|
305 | |||
300 |
|
306 | |||
301 | Notebook.prototype.insert_text_cell_before = function (index) { |
|
307 | Notebook.prototype.insert_text_cell_before = function (index) { | |
302 | // TODO: Bounds check for i |
|
308 | // TODO: Bounds check for i | |
303 | var i = this.index_or_selected(index); |
|
309 | var i = this.index_or_selected(index); | |
304 | var cell = new IPython.TextCell(this); |
|
310 | var cell = new IPython.TextCell(this); | |
305 | cell.config_mathjax(); |
|
311 | cell.config_mathjax(); | |
306 | this.insert_cell_before(cell, i); |
|
312 | this.insert_cell_before(cell, i); | |
307 | this.select(this.find_cell_index(cell)); |
|
313 | this.select(this.find_cell_index(cell)); | |
308 | return this; |
|
314 | return this; | |
309 | } |
|
315 | } | |
310 |
|
316 | |||
311 |
|
317 | |||
312 | Notebook.prototype.insert_text_cell_after = function (index) { |
|
318 | Notebook.prototype.insert_text_cell_after = function (index) { | |
313 | // TODO: Bounds check for i |
|
319 | // TODO: Bounds check for i | |
314 | var i = this.index_or_selected(index); |
|
320 | var i = this.index_or_selected(index); | |
315 | var cell = new IPython.TextCell(this); |
|
321 | var cell = new IPython.TextCell(this); | |
316 | cell.config_mathjax(); |
|
322 | cell.config_mathjax(); | |
317 | this.insert_cell_after(cell, i); |
|
323 | this.insert_cell_after(cell, i); | |
318 | this.select(this.find_cell_index(cell)); |
|
324 | this.select(this.find_cell_index(cell)); | |
319 | return this; |
|
325 | return this; | |
320 | } |
|
326 | } | |
321 |
|
327 | |||
322 |
|
328 | |||
323 | Notebook.prototype.text_to_code = function (index) { |
|
329 | Notebook.prototype.text_to_code = function (index) { | |
324 | // TODO: Bounds check for i |
|
330 | // TODO: Bounds check for i | |
325 | var i = this.index_or_selected(index); |
|
331 | var i = this.index_or_selected(index); | |
326 | var source_element = this.cell_elements().eq(i); |
|
332 | var source_element = this.cell_elements().eq(i); | |
327 | var source_cell = source_element.data("cell"); |
|
333 | var source_cell = source_element.data("cell"); | |
328 | if (source_cell instanceof IPython.TextCell) { |
|
334 | if (source_cell instanceof IPython.TextCell) { | |
329 | this.insert_code_cell_after(i); |
|
335 | this.insert_code_cell_after(i); | |
330 | var target_cell = this.cells()[i+1]; |
|
336 | var target_cell = this.cells()[i+1]; | |
331 | target_cell.set_code(source_cell.get_text()); |
|
337 | target_cell.set_code(source_cell.get_text()); | |
332 | source_element.remove(); |
|
338 | source_element.remove(); | |
333 | }; |
|
339 | }; | |
334 | }; |
|
340 | }; | |
335 |
|
341 | |||
336 |
|
342 | |||
337 | Notebook.prototype.code_to_text = function (index) { |
|
343 | Notebook.prototype.code_to_text = function (index) { | |
338 | // TODO: Bounds check for i |
|
344 | // TODO: Bounds check for i | |
339 | var i = this.index_or_selected(index); |
|
345 | var i = this.index_or_selected(index); | |
340 | var source_element = this.cell_elements().eq(i); |
|
346 | var source_element = this.cell_elements().eq(i); | |
341 | var source_cell = source_element.data("cell"); |
|
347 | var source_cell = source_element.data("cell"); | |
342 | if (source_cell instanceof IPython.CodeCell) { |
|
348 | if (source_cell instanceof IPython.CodeCell) { | |
343 | this.insert_text_cell_after(i); |
|
349 | this.insert_text_cell_after(i); | |
344 | var target_cell = this.cells()[i+1]; |
|
350 | var target_cell = this.cells()[i+1]; | |
345 | var text = source_cell.get_code(); |
|
351 | var text = source_cell.get_code(); | |
346 | if (text === "") {text = target_cell.placeholder;}; |
|
352 | if (text === "") {text = target_cell.placeholder;}; | |
347 | target_cell.set_text(text); |
|
353 | target_cell.set_text(text); | |
348 | source_element.remove(); |
|
354 | source_element.remove(); | |
349 | target_cell.edit(); |
|
355 | target_cell.edit(); | |
350 | }; |
|
356 | }; | |
351 | }; |
|
357 | }; | |
352 |
|
358 | |||
353 |
|
359 | |||
354 | // Cell collapsing |
|
360 | // Cell collapsing | |
355 |
|
361 | |||
356 | Notebook.prototype.collapse = function (index) { |
|
362 | Notebook.prototype.collapse = function (index) { | |
357 | var i = this.index_or_selected(index); |
|
363 | var i = this.index_or_selected(index); | |
358 | this.cells()[i].collapse(); |
|
364 | this.cells()[i].collapse(); | |
359 | }; |
|
365 | }; | |
360 |
|
366 | |||
361 |
|
367 | |||
362 | Notebook.prototype.expand = function (index) { |
|
368 | Notebook.prototype.expand = function (index) { | |
363 | var i = this.index_or_selected(index); |
|
369 | var i = this.index_or_selected(index); | |
364 | this.cells()[i].expand(); |
|
370 | this.cells()[i].expand(); | |
365 | }; |
|
371 | }; | |
366 |
|
372 | |||
367 |
|
373 | |||
368 | // Kernel related things |
|
374 | // Kernel related things | |
369 |
|
375 | |||
370 | Notebook.prototype.start_kernel = function () { |
|
376 | Notebook.prototype.start_kernel = function () { | |
371 | this.kernel = new IPython.Kernel(); |
|
377 | this.kernel = new IPython.Kernel(); | |
372 | this.kernel.start_kernel($.proxy(this.kernel_started, this)); |
|
378 | this.kernel.start_kernel($.proxy(this.kernel_started, this)); | |
373 | }; |
|
379 | }; | |
374 |
|
380 | |||
375 |
|
381 | |||
376 | Notebook.prototype.handle_shell_reply = function (e) { |
|
382 | Notebook.prototype.handle_shell_reply = function (e) { | |
377 | reply = $.parseJSON(e.data); |
|
383 | reply = $.parseJSON(e.data); | |
378 | var header = reply.header; |
|
384 | var header = reply.header; | |
379 | var content = reply.content; |
|
385 | var content = reply.content; | |
380 | var msg_type = header.msg_type; |
|
386 | var msg_type = header.msg_type; | |
381 | console.log(reply); |
|
387 | console.log(reply); | |
382 | var cell = this.cell_for_msg(reply.parent_header.msg_id); |
|
388 | var cell = this.cell_for_msg(reply.parent_header.msg_id); | |
383 | if (msg_type === "execute_reply") { |
|
389 | if (msg_type === "execute_reply") { | |
384 | cell.set_input_prompt(content.execution_count); |
|
390 | cell.set_input_prompt(content.execution_count); | |
385 | }; |
|
391 | }; | |
386 | var payload = content.payload || []; |
|
392 | var payload = content.payload || []; | |
387 | this.handle_payload(content.payload); |
|
393 | this.handle_payload(content.payload); | |
388 | }; |
|
394 | }; | |
389 |
|
395 | |||
390 |
|
396 | |||
391 | Notebook.prototype.handle_payload = function (payload) { |
|
397 | Notebook.prototype.handle_payload = function (payload) { | |
392 | var l = payload.length; |
|
398 | var l = payload.length; | |
393 | var element = $('div#pager'); |
|
|||
394 | if (l > 0) { |
|
399 | if (l > 0) { | |
395 | element.show(); |
|
400 | IPython.pager.clear(); | |
|
401 | IPython.pager.expand(); | |||
396 | }; |
|
402 | }; | |
397 | for (var i=0; i<l; i++) { |
|
403 | for (var i=0; i<l; i++) { | |
398 | var toinsert = $("<div/>").addClass("output_area output_stream monospace-font"); |
|
404 | IPython.pager.append_text(payload[i].text); | |
399 | toinsert.append($("<pre/>").addClass("monospace-font"). |
|
|||
400 | html(utils.fixConsole(payload[i].text))); |
|
|||
401 | element.append(toinsert); |
|
|||
402 | }; |
|
405 | }; | |
403 | }; |
|
406 | }; | |
404 |
|
407 | |||
|
408 | ||||
405 | Notebook.prototype.handle_iopub_reply = function (e) { |
|
409 | Notebook.prototype.handle_iopub_reply = function (e) { | |
406 | reply = $.parseJSON(e.data); |
|
410 | reply = $.parseJSON(e.data); | |
407 | var content = reply.content; |
|
411 | var content = reply.content; | |
408 | // console.log(reply); |
|
412 | // console.log(reply); | |
409 | var msg_type = reply.header.msg_type; |
|
413 | var msg_type = reply.header.msg_type; | |
410 | var cell = this.cell_for_msg(reply.parent_header.msg_id); |
|
414 | var cell = this.cell_for_msg(reply.parent_header.msg_id); | |
411 | if (msg_type === "stream") { |
|
415 | if (msg_type === "stream") { | |
412 | cell.expand(); |
|
416 | cell.expand(); | |
413 | cell.append_stream(content.data + "\n"); |
|
417 | cell.append_stream(content.data + "\n"); | |
414 | } else if (msg_type === "display_data") { |
|
418 | } else if (msg_type === "display_data") { | |
415 | cell.expand(); |
|
419 | cell.expand(); | |
416 | cell.append_display_data(content.data); |
|
420 | cell.append_display_data(content.data); | |
417 | } else if (msg_type === "pyout") { |
|
421 | } else if (msg_type === "pyout") { | |
418 | cell.expand(); |
|
422 | cell.expand(); | |
419 | cell.append_pyout(content.data, content.execution_count) |
|
423 | cell.append_pyout(content.data, content.execution_count) | |
420 | } else if (msg_type === "pyerr") { |
|
424 | } else if (msg_type === "pyerr") { | |
421 | cell.expand(); |
|
425 | cell.expand(); | |
422 | cell.append_pyerr(content.ename, content.evalue, content.traceback); |
|
426 | cell.append_pyerr(content.ename, content.evalue, content.traceback); | |
423 | } else if (msg_type === "status") { |
|
427 | } else if (msg_type === "status") { | |
424 | if (content.execution_state === "busy") { |
|
428 | if (content.execution_state === "busy") { | |
425 | this.kernel.status_busy(); |
|
429 | this.kernel.status_busy(); | |
426 | } else if (content.execution_state === "idle") { |
|
430 | } else if (content.execution_state === "idle") { | |
427 | this.kernel.status_idle(); |
|
431 | this.kernel.status_idle(); | |
428 | }; |
|
432 | }; | |
429 | } |
|
433 | } | |
430 | }; |
|
434 | }; | |
431 |
|
435 | |||
432 |
|
436 | |||
433 | Notebook.prototype.kernel_started = function () { |
|
437 | Notebook.prototype.kernel_started = function () { | |
434 | console.log("Kernel started: ", this.kernel.kernel_id); |
|
438 | console.log("Kernel started: ", this.kernel.kernel_id); | |
435 | this.kernel.shell_channel.onmessage = $.proxy(this.handle_shell_reply,this); |
|
439 | this.kernel.shell_channel.onmessage = $.proxy(this.handle_shell_reply,this); | |
436 | this.kernel.iopub_channel.onmessage = $.proxy(this.handle_iopub_reply,this); |
|
440 | this.kernel.iopub_channel.onmessage = $.proxy(this.handle_iopub_reply,this); | |
437 | }; |
|
441 | }; | |
438 |
|
442 | |||
439 |
|
443 | |||
440 | // Persistance and loading |
|
444 | // Persistance and loading | |
441 |
|
445 | |||
442 |
|
446 | |||
443 | Notebook.prototype.fromJSON = function (data) { |
|
447 | Notebook.prototype.fromJSON = function (data) { | |
444 | var ncells = this.ncells(); |
|
448 | var ncells = this.ncells(); | |
445 | for (var i=0; i<ncells; i++) { |
|
449 | for (var i=0; i<ncells; i++) { | |
446 | // Always delete cell 0 as they get renumbered as they are deleted. |
|
450 | // Always delete cell 0 as they get renumbered as they are deleted. | |
447 | this.delete_cell(0); |
|
451 | this.delete_cell(0); | |
448 | }; |
|
452 | }; | |
449 | var new_cells = data.cells; |
|
453 | var new_cells = data.cells; | |
450 | ncells = new_cells.length; |
|
454 | ncells = new_cells.length; | |
451 | var cell_data = null; |
|
455 | var cell_data = null; | |
452 | for (var i=0; i<ncells; i++) { |
|
456 | for (var i=0; i<ncells; i++) { | |
453 | cell_data = new_cells[i]; |
|
457 | cell_data = new_cells[i]; | |
454 | if (cell_data.cell_type == 'code') { |
|
458 | if (cell_data.cell_type == 'code') { | |
455 | this.insert_code_cell_after(); |
|
459 | this.insert_code_cell_after(); | |
456 | this.selected_cell().fromJSON(cell_data); |
|
460 | this.selected_cell().fromJSON(cell_data); | |
457 | } else if (cell_data.cell_type === 'text') { |
|
461 | } else if (cell_data.cell_type === 'text') { | |
458 | this.insert_text_cell_after(); |
|
462 | this.insert_text_cell_after(); | |
459 | this.selected_cell().fromJSON(cell_data); |
|
463 | this.selected_cell().fromJSON(cell_data); | |
460 | }; |
|
464 | }; | |
461 | }; |
|
465 | }; | |
462 | }; |
|
466 | }; | |
463 |
|
467 | |||
464 |
|
468 | |||
465 | Notebook.prototype.toJSON = function () { |
|
469 | Notebook.prototype.toJSON = function () { | |
466 | var cells = this.cells(); |
|
470 | var cells = this.cells(); | |
467 | var ncells = cells.length; |
|
471 | var ncells = cells.length; | |
468 | cell_array = new Array(ncells); |
|
472 | cell_array = new Array(ncells); | |
469 | for (var i=0; i<ncells; i++) { |
|
473 | for (var i=0; i<ncells; i++) { | |
470 | cell_array[i] = cells[i].toJSON(); |
|
474 | cell_array[i] = cells[i].toJSON(); | |
471 | }; |
|
475 | }; | |
472 | json = { |
|
476 | json = { | |
473 | cells : cell_array |
|
477 | cells : cell_array | |
474 | }; |
|
478 | }; | |
475 | return json |
|
479 | return json | |
476 | }; |
|
480 | }; | |
477 |
|
481 | |||
478 |
|
482 | |||
479 | Notebook.prototype.test_filename = function (filename) { |
|
483 | Notebook.prototype.test_filename = function (filename) { | |
480 | if (this.notebook_filename_re.test(filename)) { |
|
484 | if (this.notebook_filename_re.test(filename)) { | |
481 | return true; |
|
485 | return true; | |
482 | } else { |
|
486 | } else { | |
483 | var bad_filename = $('<div/>'); |
|
487 | var bad_filename = $('<div/>'); | |
484 | bad_filename.html( |
|
488 | bad_filename.html( | |
485 | "The filename you entered (" + filename + ") is not valid. Notebook filenames must have the following form: foo.ipynb" |
|
489 | "The filename you entered (" + filename + ") is not valid. Notebook filenames must have the following form: foo.ipynb" | |
486 | ); |
|
490 | ); | |
487 | bad_filename.dialog({title: 'Invalid filename', modal: true}); |
|
491 | bad_filename.dialog({title: 'Invalid filename', modal: true}); | |
488 | return false; |
|
492 | return false; | |
489 | }; |
|
493 | }; | |
490 | }; |
|
494 | }; | |
491 |
|
495 | |||
492 | Notebook.prototype.save_notebook = function (filename) { |
|
496 | Notebook.prototype.save_notebook = function (filename) { | |
493 | this.filename = filename || this.filename || ''; |
|
497 | this.filename = filename || this.filename || ''; | |
494 | if (this.filename === '') { |
|
498 | if (this.filename === '') { | |
495 | var no_filename = $('<div/>'); |
|
499 | var no_filename = $('<div/>'); | |
496 | no_filename.html( |
|
500 | no_filename.html( | |
497 | "This notebook has no filename, please specify a filename of the form: foo.ipynb" |
|
501 | "This notebook has no filename, please specify a filename of the form: foo.ipynb" | |
498 | ); |
|
502 | ); | |
499 | no_filename.dialog({title: 'Missing filename', modal: true}); |
|
503 | no_filename.dialog({title: 'Missing filename', modal: true}); | |
500 | return; |
|
504 | return; | |
501 | } |
|
505 | } | |
502 | if (!this.test_filename(this.filename)) {return;} |
|
506 | if (!this.test_filename(this.filename)) {return;} | |
503 | var thedata = this.toJSON(); |
|
507 | var thedata = this.toJSON(); | |
504 | var settings = { |
|
508 | var settings = { | |
505 | processData : false, |
|
509 | processData : false, | |
506 | cache : false, |
|
510 | cache : false, | |
507 | type : "PUT", |
|
511 | type : "PUT", | |
508 | data : JSON.stringify(thedata), |
|
512 | data : JSON.stringify(thedata), | |
509 | success : function (data, status, xhr) {console.log(data);} |
|
513 | success : function (data, status, xhr) {console.log(data);} | |
510 | }; |
|
514 | }; | |
511 | $.ajax("/notebooks/" + this.filename, settings); |
|
515 | $.ajax("/notebooks/" + this.filename, settings); | |
512 | }; |
|
516 | }; | |
513 |
|
517 | |||
514 |
|
518 | |||
515 | Notebook.prototype.load_notebook = function (filename) { |
|
519 | Notebook.prototype.load_notebook = function (filename) { | |
516 | if (!this.test_filename(filename)) {return;} |
|
520 | if (!this.test_filename(filename)) {return;} | |
517 | var that = this; |
|
521 | var that = this; | |
518 | // We do the call with settings so we can set cache to false. |
|
522 | // We do the call with settings so we can set cache to false. | |
519 | var settings = { |
|
523 | var settings = { | |
520 | processData : false, |
|
524 | processData : false, | |
521 | cache : false, |
|
525 | cache : false, | |
522 | type : "GET", |
|
526 | type : "GET", | |
523 | dataType : "json", |
|
527 | dataType : "json", | |
524 | success : function (data, status, xhr) { |
|
528 | success : function (data, status, xhr) { | |
525 | that.fromJSON(data); |
|
529 | that.fromJSON(data); | |
526 | that.filename = filename; |
|
530 | that.filename = filename; | |
527 | that.kernel.restart(); |
|
531 | that.kernel.restart(); | |
528 | } |
|
532 | } | |
529 | }; |
|
533 | }; | |
530 | $.ajax("/notebooks/" + filename, settings); |
|
534 | $.ajax("/notebooks/" + filename, settings); | |
531 | } |
|
535 | } | |
532 |
|
536 | |||
533 | IPython.Notebook = Notebook; |
|
537 | IPython.Notebook = Notebook; | |
534 |
|
538 | |||
535 | return IPython; |
|
539 | return IPython; | |
536 |
|
540 | |||
537 | }(IPython)); |
|
541 | }(IPython)); | |
538 |
|
542 |
@@ -1,96 +1,85 | |||||
1 |
|
1 | |||
2 | //============================================================================ |
|
2 | //============================================================================ | |
3 | // On document ready |
|
3 | // On document ready | |
4 | //============================================================================ |
|
4 | //============================================================================ | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | $(document).ready(function () { |
|
7 | $(document).ready(function () { | |
8 |
|
8 | |||
9 | $('div#wrapper').addClass('vbox border-box-sizing') |
|
9 | $('div#wrapper').addClass('vbox border-box-sizing') | |
10 | $('div#notebook_app').addClass('hbox box-flex1 border-box-sizing') |
|
10 | $('div#notebook_app').addClass('hbox box-flex1 border-box-sizing') | |
11 | $('div#left_panel').addClass('vbox border-box-sizing ui-widget ui-widget-content') |
|
11 | $('div#left_panel').addClass('vbox border-box-sizing ui-widget ui-widget-content') | |
12 | $('div#pager_splitter').addClass('border-box-sizing ui-widget ui-widget-header') |
|
|||
13 | $('div#notebook_panel').addClass('vbox box-flex1 border-box-sizing ui-widget ui-widget-content') |
|
|||
14 | $('div#notebook').addClass('vbox box-flex1 border-box-sizing') |
|
|||
15 | $('div#left_panel_splitter').addClass('border-box-sizing ui-widget ui-widget-header') |
|
12 | $('div#left_panel_splitter').addClass('border-box-sizing ui-widget ui-widget-header') | |
16 |
$('div# |
|
13 | $('div#notebook_panel').addClass('vbox box-flex1 border-box-sizing ui-widget ui-widget-content') | |
17 |
|
||||
18 | $('div#pager_splitter').click(function () { |
|
|||
19 | $('div#pager').toggle('fast'); |
|
|||
20 | }); |
|
|||
21 |
|
||||
22 | $('div#pager_splitter').hover( |
|
|||
23 | function () { |
|
|||
24 | $('div#pager_splitter').addClass('ui-state-hover'); |
|
|||
25 | }, |
|
|||
26 | function () { |
|
|||
27 | $('div#pager_splitter').removeClass('ui-state-hover'); |
|
|||
28 | } |
|
|||
29 | ); |
|
|||
30 |
|
||||
31 | $('div#pager').hide(); |
|
|||
32 |
|
14 | |||
33 | $('div#left_panel_splitter').click(function () { |
|
15 | $('div#left_panel_splitter').click(function () { | |
34 | $('div#left_panel').toggle('fast'); |
|
16 | $('div#left_panel').toggle('fast'); | |
35 | }); |
|
17 | }); | |
36 |
|
18 | |||
37 | $('div#left_panel_splitter').hover( |
|
19 | $('div#left_panel_splitter').hover( | |
38 | function () { |
|
20 | function () { | |
39 | $('div#left_panel_splitter').addClass('ui-state-hover'); |
|
21 | $('div#left_panel_splitter').addClass('ui-state-hover'); | |
40 | }, |
|
22 | }, | |
41 | function () { |
|
23 | function () { | |
42 | $('div#left_panel_splitter').removeClass('ui-state-hover'); |
|
24 | $('div#left_panel_splitter').removeClass('ui-state-hover'); | |
43 | } |
|
25 | } | |
44 | ); |
|
26 | ); | |
45 |
|
27 | |||
46 | MathJax.Hub.Config({ |
|
28 | MathJax.Hub.Config({ | |
47 | tex2jax: { |
|
29 | tex2jax: { | |
48 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], |
|
30 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
49 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], |
|
31 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | |
50 | }, |
|
32 | }, | |
51 | displayAlign: 'left', // Change this to 'center' to center equations. |
|
33 | displayAlign: 'left', // Change this to 'center' to center equations. | |
52 | "HTML-CSS": { |
|
34 | "HTML-CSS": { | |
53 | styles: {'.MathJax_Display': {"margin": 0}} |
|
35 | styles: {'.MathJax_Display': {"margin": 0}} | |
54 | } |
|
36 | } | |
55 | }); |
|
37 | }); | |
56 |
|
38 | |||
|
39 | // $('div#notebook').scroll(function (e) { | |||
|
40 | // console.log(e); | |||
|
41 | // e.preventDefault(); | |||
|
42 | // }); | |||
|
43 | ||||
57 | IPython.notebook = new IPython.Notebook('div#notebook'); |
|
44 | IPython.notebook = new IPython.Notebook('div#notebook'); | |
58 | IPython.notebook.insert_code_cell_after(); |
|
45 | IPython.notebook.insert_code_cell_after(); | |
59 |
|
46 | |||
60 | $("#menu_tabs").tabs(); |
|
47 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); | |
|
48 | ||||
|
49 | // $("#menu_tabs").tabs(); | |||
61 |
|
50 | |||
62 |
|
|
51 | // $("#help_toolbar").buttonset(); | |
63 |
|
52 | |||
64 |
|
|
53 | // $("#kernel_toolbar").buttonset(); | |
65 |
|
|
54 | // $("#interrupt_kernel").click(function () {IPython.notebook.kernel.interrupt();}); | |
66 |
|
|
55 | // $("#restart_kernel").click(function () {IPython.notebook.kernel.restart();}); | |
67 |
|
|
56 | // $("#kernel_status").addClass("status_idle"); | |
68 |
|
57 | |||
69 |
|
|
58 | // $("#move_cell").buttonset(); | |
70 |
|
|
59 | // $("#move_up").button("option", "icons", {primary:"ui-icon-arrowthick-1-n"}); | |
71 |
|
|
60 | // $("#move_up").button("option", "text", false); | |
72 |
|
|
61 | // $("#move_up").click(function () {IPython.notebook.move_cell_up();}); | |
73 |
|
|
62 | // $("#move_down").button("option", "icons", {primary:"ui-icon-arrowthick-1-s"}); | |
74 |
|
|
63 | // $("#move_down").button("option", "text", false); | |
75 |
|
|
64 | // $("#move_down").click(function () {IPython.notebook.move_cell_down();}); | |
76 |
|
65 | |||
77 |
|
|
66 | // $("#insert_delete").buttonset(); | |
78 |
|
|
67 | // $("#insert_cell_before").click(function () {IPython.notebook.insert_code_cell_before();}); | |
79 |
|
|
68 | // $("#insert_cell_after").click(function () {IPython.notebook.insert_code_cell_after();}); | |
80 |
|
|
69 | // $("#delete_cell").button("option", "icons", {primary:"ui-icon-closethick"}); | |
81 |
|
|
70 | // $("#delete_cell").button("option", "text", false); | |
82 |
|
|
71 | // $("#delete_cell").click(function () {IPython.notebook.delete_cell();}); | |
83 |
|
72 | |||
84 |
|
|
73 | // $("#cell_type").buttonset(); | |
85 |
|
|
74 | // $("#to_code").click(function () {IPython.notebook.text_to_code();}); | |
86 |
|
|
75 | // $("#to_text").click(function () {IPython.notebook.code_to_text();}); | |
87 |
|
76 | |||
88 |
|
|
77 | // $("#sort").buttonset(); | |
89 |
|
|
78 | // $("#sort_cells").click(function () {IPython.notebook.sort_cells();}); | |
90 |
|
79 | |||
91 |
|
|
80 | // $("#toggle").buttonset(); | |
92 |
|
|
81 | // $("#collapse").click(function () {IPython.notebook.collapse();}); | |
93 |
|
|
82 | // $("#expand").click(function () {IPython.notebook.expand();}); | |
94 |
|
83 | |||
95 | }); |
|
84 | }); | |
96 |
|
85 |
@@ -1,123 +1,124 | |||||
1 | <!DOCTYPE HTML> |
|
1 | <!DOCTYPE HTML> | |
2 | <html> |
|
2 | <html> | |
3 |
|
3 | |||
4 | <head> |
|
4 | <head> | |
5 | <meta charset="utf-8"> |
|
5 | <meta charset="utf-8"> | |
6 |
|
6 | |||
7 | <title>IPython Notebook</title> |
|
7 | <title>IPython Notebook</title> | |
8 |
|
8 | |||
9 | <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" /> |
|
9 | <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" /> | |
10 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/rocket/jquery-wijmo.css" type="text/css" /> --> |
|
10 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/rocket/jquery-wijmo.css" type="text/css" /> --> | |
11 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/smoothness/jquery-ui-1.8.11.custom.css" type="text/css" /> --> |
|
11 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/smoothness/jquery-ui-1.8.11.custom.css" type="text/css" /> --> | |
12 |
|
12 | |||
13 | <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script> |
|
13 | <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script> | |
14 | <!-- <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script> --> |
|
14 | <!-- <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script> --> | |
15 | <script type="text/javascript"> |
|
15 | <script type="text/javascript"> | |
16 | if (typeof MathJax == 'undefined') { |
|
16 | if (typeof MathJax == 'undefined') { | |
17 | console.log("Trying to load local copy of MathJax"); |
|
17 | console.log("Trying to load local copy of MathJax"); | |
18 | document.write(unescape("%3Cscript type='text/javascript' src='static/mathjax/MathJax.js%3Fconfig=TeX-AMS_HTML' charset='utf-8'%3E%3C/script%3E")); |
|
18 | document.write(unescape("%3Cscript type='text/javascript' src='static/mathjax/MathJax.js%3Fconfig=TeX-AMS_HTML' charset='utf-8'%3E%3C/script%3E")); | |
19 | } |
|
19 | } | |
20 | </script> |
|
20 | </script> | |
21 |
|
21 | |||
22 | <link rel="stylesheet" href="static/codemirror2/lib/codemirror.css"> |
|
22 | <link rel="stylesheet" href="static/codemirror2/lib/codemirror.css"> | |
23 | <link rel="stylesheet" href="static/codemirror2/mode/python/python.css"> |
|
23 | <link rel="stylesheet" href="static/codemirror2/mode/python/python.css"> | |
24 |
|
24 | |||
25 | <link rel="stylesheet" href="static/css/layout.css" type="text/css" /> |
|
25 | <link rel="stylesheet" href="static/css/layout.css" type="text/css" /> | |
26 | <link rel="stylesheet" href="static/css/notebook.css" type="text/css" /> |
|
26 | <link rel="stylesheet" href="static/css/notebook.css" type="text/css" /> | |
27 |
|
27 | |||
28 | </head> |
|
28 | </head> | |
29 |
|
29 | |||
30 | <body> |
|
30 | <body> | |
31 |
|
31 | |||
32 | <div id="wrapper"> |
|
32 | <div id="wrapper"> | |
33 |
|
33 | |||
34 | <div id="header"> |
|
34 | <div id="header"> | |
35 | <span id="ipython_notebook"><h1>IPython Notebook</h1></span> |
|
35 | <span id="ipython_notebook"><h1>IPython Notebook</h1></span> | |
36 | </div> |
|
36 | </div> | |
37 |
|
37 | |||
38 | <div id="notebook_app"> |
|
38 | <div id="notebook_app"> | |
39 |
|
39 | |||
40 | <div id="left_panel"></div> |
|
40 | <div id="left_panel"></div> | |
41 | <div id="left_panel_splitter"></div> |
|
41 | <div id="left_panel_splitter"></div> | |
42 | <div id="notebook_panel"> |
|
42 | <div id="notebook_panel"> | |
43 | <div id="notebook"></div> |
|
43 | <div id="notebook"></div> | |
44 | <div id="pager_splitter"></div> |
|
44 | <div id="pager_splitter"></div> | |
45 | <div id="pager"></div> |
|
45 | <div id="pager"></div> | |
46 | </div> |
|
46 | </div> | |
47 |
|
47 | |||
48 | </div> |
|
48 | </div> | |
49 |
|
49 | |||
50 | </div> |
|
50 | </div> | |
51 |
|
51 | |||
52 | <script src="static/jquery/js/jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script> |
|
52 | <script src="static/jquery/js/jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script> | |
53 | <script src="static/jquery/js/jquery-ui-1.8.11.custom.min.js" type="text/javascript" charset="utf-8"></script> |
|
53 | <script src="static/jquery/js/jquery-ui-1.8.11.custom.min.js" type="text/javascript" charset="utf-8"></script> | |
54 | <script src="static/jquery/js/jquery.autogrow.js" type="text/javascript" charset="utf-8"></script> |
|
54 | <script src="static/jquery/js/jquery.autogrow.js" type="text/javascript" charset="utf-8"></script> | |
55 | <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script> |
|
55 | <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script> | |
56 | <script src="static/js/utils.js" type="text/javascript" charset="utf-8"></script> |
|
56 | <script src="static/js/utils.js" type="text/javascript" charset="utf-8"></script> | |
57 | <script src="static/js/cell.js" type="text/javascript" charset="utf-8"></script> |
|
57 | <script src="static/js/cell.js" type="text/javascript" charset="utf-8"></script> | |
58 | <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script> |
|
58 | <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script> | |
59 | <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script> |
|
59 | <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script> | |
60 | <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script> |
|
60 | <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script> | |
|
61 | <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script> | |||
61 | <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script> |
|
62 | <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script> | |
62 | <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script> |
|
63 | <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script> | |
63 | <script src="static/codemirror2/lib/codemirror.js"></script> |
|
64 | <script src="static/codemirror2/lib/codemirror.js"></script> | |
64 | <script src="static/codemirror2/mode/python/python.js"></script> |
|
65 | <script src="static/codemirror2/mode/python/python.js"></script> | |
65 |
|
66 | |||
66 | </body> |
|
67 | </body> | |
67 |
|
68 | |||
68 | </html> |
|
69 | </html> | |
69 |
|
70 | |||
70 |
|
71 | |||
71 | <!--<div id="tools">--> |
|
72 | <!--<div id="tools">--> | |
72 |
|
73 | |||
73 | <!--<div id="menu_tabs">--> |
|
74 | <!--<div id="menu_tabs">--> | |
74 | <!-- <span id="kernel_status">Idle</span>--> |
|
75 | <!-- <span id="kernel_status">Idle</span>--> | |
75 | <!-- <ul>--> |
|
76 | <!-- <ul>--> | |
76 | <!-- <li><a href="#cell_tab">Cell</a></li>--> |
|
77 | <!-- <li><a href="#cell_tab">Cell</a></li>--> | |
77 | <!-- <li><a href="#kernel_tab">Kernel</a></li>--> |
|
78 | <!-- <li><a href="#kernel_tab">Kernel</a></li>--> | |
78 | <!-- <li><a href="#help_tab">Help</a></li>--> |
|
79 | <!-- <li><a href="#help_tab">Help</a></li>--> | |
79 | <!-- </ul>--> |
|
80 | <!-- </ul>--> | |
80 | <!-- <div id="cell_tab">--> |
|
81 | <!-- <div id="cell_tab">--> | |
81 | <!-- <span id="cell_toolbar">--> |
|
82 | <!-- <span id="cell_toolbar">--> | |
82 | <!-- <span id="move_cell">--> |
|
83 | <!-- <span id="move_cell">--> | |
83 | <!-- <button id="move_up">Move up</button>--> |
|
84 | <!-- <button id="move_up">Move up</button>--> | |
84 | <!-- <button id="move_down">Move down</button>--> |
|
85 | <!-- <button id="move_down">Move down</button>--> | |
85 | <!-- </span>--> |
|
86 | <!-- </span>--> | |
86 | <!-- <span id="insert_delete">--> |
|
87 | <!-- <span id="insert_delete">--> | |
87 | <!-- <button id="insert_cell_before">Before</button>--> |
|
88 | <!-- <button id="insert_cell_before">Before</button>--> | |
88 | <!-- <button id="insert_cell_after">After</button>--> |
|
89 | <!-- <button id="insert_cell_after">After</button>--> | |
89 | <!-- <button id="delete_cell">Delete</button>--> |
|
90 | <!-- <button id="delete_cell">Delete</button>--> | |
90 | <!-- </span>--> |
|
91 | <!-- </span>--> | |
91 | <!-- <span id="cell_type">--> |
|
92 | <!-- <span id="cell_type">--> | |
92 | <!-- <button id="to_code">Code</button>--> |
|
93 | <!-- <button id="to_code">Code</button>--> | |
93 | <!-- <button id="to_text">Text</button>--> |
|
94 | <!-- <button id="to_text">Text</button>--> | |
94 | <!-- </span>--> |
|
95 | <!-- </span>--> | |
95 | <!-- <span id="sort">--> |
|
96 | <!-- <span id="sort">--> | |
96 | <!-- <button id="sort_cells">Sort</button>--> |
|
97 | <!-- <button id="sort_cells">Sort</button>--> | |
97 | <!-- </span>--> |
|
98 | <!-- </span>--> | |
98 | <!-- <span id="toggle">--> |
|
99 | <!-- <span id="toggle">--> | |
99 | <!-- <button id="collapse">Collapse</button>--> |
|
100 | <!-- <button id="collapse">Collapse</button>--> | |
100 | <!-- <button id="expand">Expand</button>--> |
|
101 | <!-- <button id="expand">Expand</button>--> | |
101 | <!-- </span>--> |
|
102 | <!-- </span>--> | |
102 | <!-- </span>--> |
|
103 | <!-- </span>--> | |
103 | <!-- </div>--> |
|
104 | <!-- </div>--> | |
104 | <!-- <div id="kernel_tab">--> |
|
105 | <!-- <div id="kernel_tab">--> | |
105 | <!-- <span id="kernel_toolbar">--> |
|
106 | <!-- <span id="kernel_toolbar">--> | |
106 | <!-- <button id="interrupt_kernel">Interrupt</button>--> |
|
107 | <!-- <button id="interrupt_kernel">Interrupt</button>--> | |
107 | <!-- <button id="restart_kernel">Restart</button>--> |
|
108 | <!-- <button id="restart_kernel">Restart</button>--> | |
108 | <!-- </span>--> |
|
109 | <!-- </span>--> | |
109 | <!-- </div>--> |
|
110 | <!-- </div>--> | |
110 | <!-- <div id="help_tab">--> |
|
111 | <!-- <div id="help_tab">--> | |
111 | <!-- <span id="help_toolbar">--> |
|
112 | <!-- <span id="help_toolbar">--> | |
112 | <!-- <button><a href="http://docs.python.org" target="_blank">Python</a></button>--> |
|
113 | <!-- <button><a href="http://docs.python.org" target="_blank">Python</a></button>--> | |
113 | <!-- <button><a href="http://ipython.github.com/ipython-doc/dev/index.html" target="_blank">IPython</a></button>--> |
|
114 | <!-- <button><a href="http://ipython.github.com/ipython-doc/dev/index.html" target="_blank">IPython</a></button>--> | |
114 | <!-- <button><a href="http://matplotlib.sourceforge.net/" target="_blank">Matplotlib</a></button>--> |
|
115 | <!-- <button><a href="http://matplotlib.sourceforge.net/" target="_blank">Matplotlib</a></button>--> | |
115 | <!-- <button><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></button>--> |
|
116 | <!-- <button><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></button>--> | |
116 | <!-- <button><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></button>--> |
|
117 | <!-- <button><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></button>--> | |
117 | <!-- <button><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></button>--> |
|
118 | <!-- <button><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></button>--> | |
118 | <!-- </span>--> |
|
119 | <!-- </span>--> | |
119 | <!-- </div>--> |
|
120 | <!-- </div>--> | |
120 | <!--</div>--> |
|
121 | <!--</div>--> | |
121 |
|
122 | |||
122 | <!--</div>--> |
|
123 | <!--</div>--> | |
123 |
|
124 |
General Comments 0
You need to be logged in to leave comments.
Login now