Show More
@@ -45,16 +45,16 var IPython = (function (IPython) { | |||
|
45 | 45 | |
|
46 | 46 | Cell.prototype.bind_events = function () { |
|
47 | 47 | var that = this; |
|
48 | var nb = that.notebook | |
|
48 | var nb = that.notebook; | |
|
49 | 49 | that.element.click(function (event) { |
|
50 | 50 | if (that.selected === false) { |
|
51 | 51 | nb.select(nb.find_cell_index(that)); |
|
52 |
} |
|
|
52 | } | |
|
53 | 53 | }); |
|
54 | 54 | that.element.focusin(function (event) { |
|
55 | 55 | if (that.selected === false) { |
|
56 | 56 | nb.select(nb.find_cell_index(that)); |
|
57 |
} |
|
|
57 | } | |
|
58 | 58 | }); |
|
59 | 59 | }; |
|
60 | 60 |
@@ -44,7 +44,7 var IPython = (function (IPython) { | |||
|
44 | 44 | var output = $('<div></div>').addClass('output vbox'); |
|
45 | 45 | cell.append(input).append(output); |
|
46 | 46 | this.element = cell; |
|
47 | this.collapse() | |
|
47 | this.collapse(); | |
|
48 | 48 | }; |
|
49 | 49 | |
|
50 | 50 | //TODO, try to diminish the number of parameters. |
@@ -123,7 +123,7 var IPython = (function (IPython) { | |||
|
123 | 123 | return true; |
|
124 | 124 | } else { |
|
125 | 125 | return false; |
|
126 |
} |
|
|
126 | } | |
|
127 | 127 | } else if (event.keyCode === 76 && event.ctrlKey && event.shiftKey |
|
128 | 128 | && event.type == 'keydown') { |
|
129 | 129 | // toggle line numbers with Ctrl-Shift-L |
@@ -138,10 +138,11 var IPython = (function (IPython) { | |||
|
138 | 138 | if (ed_cur.line !== cc_cur.line || ed_cur.ch !== cc_cur.ch) { |
|
139 | 139 | this.is_completing = false; |
|
140 | 140 | this.completion_cursor = null; |
|
141 |
} |
|
|
142 |
} |
|
|
141 | } | |
|
142 | } | |
|
143 | 143 | return false; |
|
144 | 144 | }; |
|
145 | return false; | |
|
145 | 146 | }; |
|
146 | 147 | |
|
147 | 148 | CodeCell.prototype.remove_and_cancell_tooltip = function(timeout) |
@@ -345,7 +346,7 var IPython = (function (IPython) { | |||
|
345 | 346 | } else { |
|
346 | 347 | this.code_mirror.setOption('lineNumbers', false); |
|
347 | 348 | } |
|
348 | this.code_mirror.refresh() | |
|
349 | this.code_mirror.refresh(); | |
|
349 | 350 | }; |
|
350 | 351 | |
|
351 | 352 | CodeCell.prototype.select = function () { |
@@ -447,7 +448,7 var IPython = (function (IPython) { | |||
|
447 | 448 | |
|
448 | 449 | CodeCell.prototype.append_display_data = function (json) { |
|
449 | 450 | var toinsert = this.create_output_area(); |
|
450 | this.append_mime_type(json, toinsert) | |
|
451 | this.append_mime_type(json, toinsert); | |
|
451 | 452 | this.element.find('div.output').append(toinsert); |
|
452 | 453 | // If we just output latex, typeset it. |
|
453 | 454 | if ( (json.latex !== undefined) || (json.html !== undefined) ) { |
@@ -477,7 +478,7 var IPython = (function (IPython) { | |||
|
477 | 478 | var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_html rendered_html"); |
|
478 | 479 | toinsert.append(html); |
|
479 | 480 | element.append(toinsert); |
|
480 | } | |
|
481 | }; | |
|
481 | 482 | |
|
482 | 483 | |
|
483 | 484 | CodeCell.prototype.append_text = function (data, element, extra_class) { |
@@ -517,7 +518,7 var IPython = (function (IPython) { | |||
|
517 | 518 | var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_latex"); |
|
518 | 519 | toinsert.append(latex); |
|
519 | 520 | element.append(toinsert); |
|
520 | } | |
|
521 | }; | |
|
521 | 522 | |
|
522 | 523 | |
|
523 | 524 | CodeCell.prototype.clear_output = function (stdout, stderr, other) { |
@@ -589,7 +590,7 var IPython = (function (IPython) { | |||
|
589 | 590 | |
|
590 | 591 | CodeCell.prototype.set_input_prompt = function (number) { |
|
591 | 592 | var n = number || ' '; |
|
592 | this.input_prompt_number = n | |
|
593 | this.input_prompt_number = n; | |
|
593 | 594 | this.element.find('div.input_prompt').html('In [' + n + ']:'); |
|
594 | 595 | }; |
|
595 | 596 | |
@@ -653,7 +654,7 var IPython = (function (IPython) { | |||
|
653 | 654 | data.input = this.get_code(); |
|
654 | 655 | data.cell_type = 'code'; |
|
655 | 656 | if (this.input_prompt_number !== ' ') { |
|
656 | data.prompt_number = this.input_prompt_number | |
|
657 | data.prompt_number = this.input_prompt_number; | |
|
657 | 658 | }; |
|
658 | 659 | var outputs = []; |
|
659 | 660 | var len = this.outputs.length; |
@@ -23,9 +23,9 var IPython = (function (IPython) { | |||
|
23 | 23 | this.session_id = utils.uuid(); |
|
24 | 24 | |
|
25 | 25 | if (typeof(WebSocket) !== 'undefined') { |
|
26 | this.WebSocket = WebSocket | |
|
26 | this.WebSocket = WebSocket; | |
|
27 | 27 | } else if (typeof(MozWebSocket) !== 'undefined') { |
|
28 | this.WebSocket = MozWebSocket | |
|
28 | this.WebSocket = MozWebSocket; | |
|
29 | 29 | } else { |
|
30 | 30 | alert('Your browser does not have WebSocket support, please try Chrome, Safari or Firefox ≥ 6. Firefox 4 and 5 are also supported by you have to enable WebSockets in about:config.'); |
|
31 | 31 | }; |
@@ -44,13 +44,13 var IPython = (function (IPython) { | |||
|
44 | 44 | parent_header : {} |
|
45 | 45 | }; |
|
46 | 46 | return msg; |
|
47 | } | |
|
47 | }; | |
|
48 | 48 | |
|
49 | 49 | Kernel.prototype.start = function (notebook_id, callback) { |
|
50 | 50 | var that = this; |
|
51 | 51 | if (!this.running) { |
|
52 | 52 | var qs = $.param({notebook:notebook_id}); |
|
53 | var url = this.base_url + '?' + qs | |
|
53 | var url = this.base_url + '?' + qs; | |
|
54 | 54 | $.post(url, |
|
55 | 55 | function (kernel_id) { |
|
56 | 56 | that._handle_start_kernel(kernel_id, callback); |
@@ -95,10 +95,10 var IPython = (function (IPython) { | |||
|
95 | 95 | " You will NOT be able to run code.<br/>" + |
|
96 | 96 | " Your browser may not be compatible with the websocket version in the server," + |
|
97 | 97 | " or if the url does not look right, there could be an error in the" + |
|
98 | " server's configuration." | |
|
98 | " server's configuration."; | |
|
99 | 99 | } else { |
|
100 | 100 | msg = "Websocket connection closed unexpectedly.<br/>" + |
|
101 | " The kernel will no longer be responsive." | |
|
101 | " The kernel will no longer be responsive."; | |
|
102 | 102 | } |
|
103 | 103 | var dialog = $('<div/>'); |
|
104 | 104 | dialog.html(msg); |
@@ -114,7 +114,7 var IPython = (function (IPython) { | |||
|
114 | 114 | } |
|
115 | 115 | }); |
|
116 | 116 | |
|
117 | } | |
|
117 | }; | |
|
118 | 118 | |
|
119 | 119 | Kernel.prototype.start_channels = function () { |
|
120 | 120 | var that = this; |
@@ -125,7 +125,7 var IPython = (function (IPython) { | |||
|
125 | 125 | this.iopub_channel = new this.WebSocket(ws_url + "/iopub"); |
|
126 | 126 | send_cookie = function(){ |
|
127 | 127 | this.send(document.cookie); |
|
128 | } | |
|
128 | }; | |
|
129 | 129 | var already_called_onclose = false; // only alert once |
|
130 | 130 | ws_closed_early = function(evt){ |
|
131 | 131 | if (already_called_onclose){ |
@@ -135,7 +135,7 var IPython = (function (IPython) { | |||
|
135 | 135 | if ( ! evt.wasClean ){ |
|
136 | 136 | that._websocket_closed(ws_url, true); |
|
137 | 137 | } |
|
138 | } | |
|
138 | }; | |
|
139 | 139 | ws_closed_late = function(evt){ |
|
140 | 140 | if (already_called_onclose){ |
|
141 | 141 | return; |
@@ -144,7 +144,7 var IPython = (function (IPython) { | |||
|
144 | 144 | if ( ! evt.wasClean ){ |
|
145 | 145 | that._websocket_closed(ws_url, false); |
|
146 | 146 | } |
|
147 | } | |
|
147 | }; | |
|
148 | 148 | this.shell_channel.onopen = send_cookie; |
|
149 | 149 | this.shell_channel.onclose = ws_closed_early; |
|
150 | 150 | this.iopub_channel.onopen = send_cookie; |
@@ -159,12 +159,12 var IPython = (function (IPython) { | |||
|
159 | 159 | |
|
160 | 160 | Kernel.prototype.stop_channels = function () { |
|
161 | 161 | if (this.shell_channel !== null) { |
|
162 |
this.shell_channel.onclose = function (evt) { |
|
|
162 | this.shell_channel.onclose = function (evt) {}; | |
|
163 | 163 | this.shell_channel.close(); |
|
164 | 164 | this.shell_channel = null; |
|
165 | 165 | }; |
|
166 | 166 | if (this.iopub_channel !== null) { |
|
167 |
this.iopub_channel.onclose = function (evt) { |
|
|
167 | this.iopub_channel.onclose = function (evt) {}; | |
|
168 | 168 | this.iopub_channel.close(); |
|
169 | 169 | this.iopub_channel = null; |
|
170 | 170 | }; |
@@ -189,12 +189,12 var IPython = (function (IPython) { | |||
|
189 | 189 | silent : false, |
|
190 | 190 | user_variables : [], |
|
191 | 191 | user_expressions : {}, |
|
192 |
allow_stdin : false |
|
|
192 | allow_stdin : false | |
|
193 | 193 | }; |
|
194 | 194 | var msg = this.get_msg("execute_request", content); |
|
195 | 195 | this.shell_channel.send(JSON.stringify(msg)); |
|
196 | 196 | return msg.header.msg_id; |
|
197 | } | |
|
197 | }; | |
|
198 | 198 | |
|
199 | 199 | |
|
200 | 200 | Kernel.prototype.complete = function (line, cursor_pos) { |
@@ -206,7 +206,7 var IPython = (function (IPython) { | |||
|
206 | 206 | var msg = this.get_msg("complete_request", content); |
|
207 | 207 | this.shell_channel.send(JSON.stringify(msg)); |
|
208 | 208 | return msg.header.msg_id; |
|
209 | } | |
|
209 | }; | |
|
210 | 210 | |
|
211 | 211 | |
|
212 | 212 | Kernel.prototype.interrupt = function () { |
@@ -221,7 +221,7 var IPython = (function (IPython) { | |||
|
221 | 221 | this.running = false; |
|
222 | 222 | var settings = { |
|
223 | 223 | cache : false, |
|
224 |
type : "DELETE" |
|
|
224 | type : "DELETE" | |
|
225 | 225 | }; |
|
226 | 226 | $.ajax(this.kernel_url, settings); |
|
227 | 227 | }; |
@@ -26,7 +26,7 var IPython = (function (IPython) { | |||
|
26 | 26 | this.element.addClass('ui-widget'); |
|
27 | 27 | this.element.attr('title', "The kernel execution status." + |
|
28 | 28 | " If 'Busy', the kernel is currently running code." + |
|
29 | " If 'Idle', it is available for execution.") | |
|
29 | " If 'Idle', it is available for execution."); | |
|
30 | 30 | }; |
|
31 | 31 | |
|
32 | 32 |
@@ -54,7 +54,7 var IPython = (function (IPython) { | |||
|
54 | 54 | } |
|
55 | 55 | }; |
|
56 | 56 | |
|
57 | IPython.LayoutManager = LayoutManager | |
|
57 | IPython.LayoutManager = LayoutManager; | |
|
58 | 58 | |
|
59 | 59 | return IPython; |
|
60 | 60 |
@@ -71,7 +71,7 var IPython = (function (IPython) { | |||
|
71 | 71 | this.kernel_section = new IPython.KernelSection('div#kernel_section'); |
|
72 | 72 | } |
|
73 | 73 | this.help_section = new IPython.HelpSection('div#help_section'); |
|
74 | } | |
|
74 | }; | |
|
75 | 75 | |
|
76 | 76 | LeftPanel.prototype.collapse = function () { |
|
77 | 77 | if (this.expanded === true) { |
@@ -20,7 +20,7 IPython.namespace = function (ns_string) { | |||
|
20 | 20 | for (i=0; i<parts.length; i+=1) { |
|
21 | 21 | // Create property if it doesn't exist |
|
22 | 22 | if (typeof parent[parts[i]] === "undefined") { |
|
23 |
parent[parts[i]] = |
|
|
23 | parent[parts[i]] = {}; | |
|
24 | 24 | } |
|
25 | 25 | } |
|
26 | 26 | return parent; |
@@ -59,7 +59,7 var IPython = (function (IPython) { | |||
|
59 | 59 | var that = this; |
|
60 | 60 | $(document).keydown(function (event) { |
|
61 | 61 | // console.log(event); |
|
62 | if (that.read_only) return; | |
|
62 | if (that.read_only) return false; | |
|
63 | 63 | if (event.which === 27) { |
|
64 | 64 | // Intercept escape at highest level to avoid closing |
|
65 | 65 | // websocket connection with firefox |
@@ -165,6 +165,7 var IPython = (function (IPython) { | |||
|
165 | 165 | that.control_key_active = false; |
|
166 | 166 | return true; |
|
167 | 167 | }; |
|
168 | return true; | |
|
168 | 169 | }); |
|
169 | 170 | |
|
170 | 171 | this.element.bind('collapse_pager', function () { |
@@ -203,6 +204,7 var IPython = (function (IPython) { | |||
|
203 | 204 | if (that.dirty && ! that.read_only) { |
|
204 | 205 | return "You have unsaved changes that will be lost if you leave this page."; |
|
205 | 206 | }; |
|
207 | return true; | |
|
206 | 208 | }); |
|
207 | 209 | }; |
|
208 | 210 | |
@@ -266,12 +268,12 var IPython = (function (IPython) { | |||
|
266 | 268 | |
|
267 | 269 | Notebook.prototype.cell_elements = function () { |
|
268 | 270 | return this.element.children("div.cell"); |
|
269 | } | |
|
271 | }; | |
|
270 | 272 | |
|
271 | 273 | |
|
272 | 274 | Notebook.prototype.ncells = function (cell) { |
|
273 | 275 | return this.cell_elements().length; |
|
274 | } | |
|
276 | }; | |
|
275 | 277 | |
|
276 | 278 | |
|
277 | 279 | // TODO: we are often calling cells as cells()[i], which we should optimize |
@@ -280,7 +282,7 var IPython = (function (IPython) { | |||
|
280 | 282 | return this.cell_elements().toArray().map(function (e) { |
|
281 | 283 | return $(e).data("cell"); |
|
282 | 284 | }); |
|
283 | } | |
|
285 | }; | |
|
284 | 286 | |
|
285 | 287 | |
|
286 | 288 | Notebook.prototype.find_cell_index = function (cell) { |
@@ -296,7 +298,7 var IPython = (function (IPython) { | |||
|
296 | 298 | |
|
297 | 299 | Notebook.prototype.index_or_selected = function (index) { |
|
298 | 300 | return index || this.selected_index() || 0; |
|
299 | } | |
|
301 | }; | |
|
300 | 302 | |
|
301 | 303 | |
|
302 | 304 | Notebook.prototype.select = function (index) { |
@@ -354,7 +356,7 var IPython = (function (IPython) { | |||
|
354 | 356 | |
|
355 | 357 | Notebook.prototype.selected_cell = function () { |
|
356 | 358 | return this.cell_elements().eq(this.selected_index()).data("cell"); |
|
357 | } | |
|
359 | }; | |
|
358 | 360 | |
|
359 | 361 | |
|
360 | 362 | // Cell insertion, deletion and moving. |
@@ -392,7 +394,7 var IPython = (function (IPython) { | |||
|
392 | 394 | this.cell_elements().eq(index).after(cell.element); |
|
393 | 395 | }; |
|
394 | 396 | this.dirty = true; |
|
395 | return this | |
|
397 | return this; | |
|
396 | 398 | }; |
|
397 | 399 | |
|
398 | 400 | |
@@ -423,14 +425,14 var IPython = (function (IPython) { | |||
|
423 | 425 | }; |
|
424 | 426 | this.dirty = true; |
|
425 | 427 | return this; |
|
426 | } | |
|
428 | }; | |
|
427 | 429 | |
|
428 | 430 | |
|
429 | 431 | Notebook.prototype.move_cell_down = function (index) { |
|
430 | 432 | var i = index || this.selected_index(); |
|
431 | 433 | if (i !== null && i < (this.ncells()-1) && i >= 0) { |
|
432 | var pivot = this.cell_elements().eq(i+1) | |
|
433 | var tomove = this.cell_elements().eq(i) | |
|
434 | var pivot = this.cell_elements().eq(i+1); | |
|
435 | var tomove = this.cell_elements().eq(i); | |
|
434 | 436 | if (pivot !== null && tomove !== null) { |
|
435 | 437 | tomove.detach(); |
|
436 | 438 | pivot.after(tomove); |
@@ -439,7 +441,7 var IPython = (function (IPython) { | |||
|
439 | 441 | }; |
|
440 | 442 | this.dirty = true; |
|
441 | 443 | return this; |
|
442 | } | |
|
444 | }; | |
|
443 | 445 | |
|
444 | 446 | |
|
445 | 447 | Notebook.prototype.sort_cells = function () { |
@@ -447,7 +449,7 var IPython = (function (IPython) { | |||
|
447 | 449 | var sindex = this.selected_index(); |
|
448 | 450 | var swapped; |
|
449 | 451 | do { |
|
450 | swapped = false | |
|
452 | swapped = false; | |
|
451 | 453 | for (var i=1; i<ncells; i++) { |
|
452 | 454 | current = this.cell_elements().eq(i).data("cell"); |
|
453 | 455 | previous = this.cell_elements().eq(i-1).data("cell"); |
@@ -470,7 +472,7 var IPython = (function (IPython) { | |||
|
470 | 472 | this.insert_cell_above(cell, i); |
|
471 | 473 | this.select(this.find_cell_index(cell)); |
|
472 | 474 | return cell; |
|
473 | } | |
|
475 | }; | |
|
474 | 476 | |
|
475 | 477 | |
|
476 | 478 | Notebook.prototype.insert_code_cell_below = function (index) { |
@@ -481,7 +483,7 var IPython = (function (IPython) { | |||
|
481 | 483 | this.insert_cell_below(cell, i); |
|
482 | 484 | this.select(this.find_cell_index(cell)); |
|
483 | 485 | return cell; |
|
484 | } | |
|
486 | }; | |
|
485 | 487 | |
|
486 | 488 | |
|
487 | 489 | Notebook.prototype.insert_html_cell_above = function (index) { |
@@ -492,7 +494,7 var IPython = (function (IPython) { | |||
|
492 | 494 | this.insert_cell_above(cell, i); |
|
493 | 495 | this.select(this.find_cell_index(cell)); |
|
494 | 496 | return cell; |
|
495 | } | |
|
497 | }; | |
|
496 | 498 | |
|
497 | 499 | |
|
498 | 500 | Notebook.prototype.insert_html_cell_below = function (index) { |
@@ -503,7 +505,7 var IPython = (function (IPython) { | |||
|
503 | 505 | this.insert_cell_below(cell, i); |
|
504 | 506 | this.select(this.find_cell_index(cell)); |
|
505 | 507 | return cell; |
|
506 | } | |
|
508 | }; | |
|
507 | 509 | |
|
508 | 510 | |
|
509 | 511 | Notebook.prototype.insert_markdown_cell_above = function (index) { |
@@ -514,7 +516,7 var IPython = (function (IPython) { | |||
|
514 | 516 | this.insert_cell_above(cell, i); |
|
515 | 517 | this.select(this.find_cell_index(cell)); |
|
516 | 518 | return cell; |
|
517 | } | |
|
519 | }; | |
|
518 | 520 | |
|
519 | 521 | |
|
520 | 522 | Notebook.prototype.insert_markdown_cell_below = function (index) { |
@@ -525,7 +527,7 var IPython = (function (IPython) { | |||
|
525 | 527 | this.insert_cell_below(cell, i); |
|
526 | 528 | this.select(this.find_cell_index(cell)); |
|
527 | 529 | return cell; |
|
528 | } | |
|
530 | }; | |
|
529 | 531 | |
|
530 | 532 | |
|
531 | 533 | Notebook.prototype.to_code = function (index) { |
@@ -553,11 +555,11 var IPython = (function (IPython) { | |||
|
553 | 555 | var target_cell = null; |
|
554 | 556 | if (source_cell instanceof IPython.CodeCell) { |
|
555 | 557 | this.insert_markdown_cell_below(i); |
|
556 |
|
|
|
558 | target_cell = this.cells()[i+1]; | |
|
557 | 559 | var text = source_cell.get_code(); |
|
558 | 560 | } else if (source_cell instanceof IPython.HTMLCell) { |
|
559 | 561 | this.insert_markdown_cell_below(i); |
|
560 |
|
|
|
562 | target_cell = this.cells()[i+1]; | |
|
561 | 563 | var text = source_cell.get_source(); |
|
562 | 564 | if (text === source_cell.placeholder) { |
|
563 | 565 | text = target_cell.placeholder; |
@@ -581,11 +583,11 var IPython = (function (IPython) { | |||
|
581 | 583 | var target_cell = null; |
|
582 | 584 | if (source_cell instanceof IPython.CodeCell) { |
|
583 | 585 | this.insert_html_cell_below(i); |
|
584 |
|
|
|
586 | target_cell = this.cells()[i+1]; | |
|
585 | 587 | var text = source_cell.get_code(); |
|
586 | 588 | } else if (source_cell instanceof IPython.MarkdownCell) { |
|
587 | 589 | this.insert_html_cell_below(i); |
|
588 |
|
|
|
590 | target_cell = this.cells()[i+1]; | |
|
589 | 591 | var text = source_cell.get_source(); |
|
590 | 592 | if (text === source_cell.placeholder) { |
|
591 | 593 | text = target_cell.placeholder; |
@@ -643,7 +645,7 var IPython = (function (IPython) { | |||
|
643 | 645 | var cells = this.cells(); |
|
644 | 646 | len = cells.length; |
|
645 | 647 | for (var i=0; i<len; i++) { |
|
646 | cells[i].set_autoindent(state) | |
|
648 | cells[i].set_autoindent(state); | |
|
647 | 649 | }; |
|
648 | 650 | }; |
|
649 | 651 | |
@@ -662,7 +664,7 var IPython = (function (IPython) { | |||
|
662 | 664 | // Other cell functions: line numbers, ... |
|
663 | 665 | |
|
664 | 666 | Notebook.prototype.cell_toggle_line_numbers = function() { |
|
665 | this.selected_cell().toggle_line_numbers() | |
|
667 | this.selected_cell().toggle_line_numbers(); | |
|
666 | 668 | }; |
|
667 | 669 | |
|
668 | 670 | // Kernel related things |
@@ -864,8 +866,8 var IPython = (function (IPython) { | |||
|
864 | 866 | Notebook.prototype.execute_selected_cell = function (options) { |
|
865 | 867 | // add_new: should a new cell be added if we are at the end of the nb |
|
866 | 868 | // terminal: execute in terminal mode, which stays in the current cell |
|
867 | default_options = {terminal: false, add_new: true} | |
|
868 | $.extend(default_options, options) | |
|
869 | default_options = {terminal: false, add_new: true}; | |
|
870 | $.extend(default_options, options); | |
|
869 | 871 | var that = this; |
|
870 | 872 | var cell = that.selected_cell(); |
|
871 | 873 | var cell_index = that.find_cell_index(cell); |
@@ -938,7 +940,8 var IPython = (function (IPython) { | |||
|
938 | 940 | |
|
939 | 941 | Notebook.prototype.fromJSON = function (data) { |
|
940 | 942 | var ncells = this.ncells(); |
|
941 | for (var i=0; i<ncells; i++) { | |
|
943 | var i; | |
|
944 | for (i=0; i<ncells; i++) { | |
|
942 | 945 | // Always delete cell 0 as they get renumbered as they are deleted. |
|
943 | 946 | this.delete_cell(0); |
|
944 | 947 | }; |
@@ -951,7 +954,7 var IPython = (function (IPython) { | |||
|
951 | 954 | ncells = new_cells.length; |
|
952 | 955 | var cell_data = null; |
|
953 | 956 | var new_cell = null; |
|
954 |
for ( |
|
|
957 | for (i=0; i<ncells; i++) { | |
|
955 | 958 | cell_data = new_cells[i]; |
|
956 | 959 | if (cell_data.cell_type == 'code') { |
|
957 | 960 | new_cell = this.insert_code_cell_below(); |
@@ -979,8 +982,8 var IPython = (function (IPython) { | |||
|
979 | 982 | // Only handle 1 worksheet for now. |
|
980 | 983 | worksheets : [{cells:cell_array}], |
|
981 | 984 | metadata : this.metadata |
|
982 | } | |
|
983 | return data | |
|
985 | }; | |
|
986 | return data; | |
|
984 | 987 | }; |
|
985 | 988 | |
|
986 | 989 | Notebook.prototype.save_notebook = function () { |
@@ -1002,7 +1005,7 var IPython = (function (IPython) { | |||
|
1002 | 1005 | error : $.proxy(this.notebook_save_failed,this) |
|
1003 | 1006 | }; |
|
1004 | 1007 | IPython.save_widget.status_saving(); |
|
1005 | var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id | |
|
1008 | var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id; | |
|
1006 | 1009 | $.ajax(url, settings); |
|
1007 | 1010 | }; |
|
1008 | 1011 | }; |
@@ -1012,7 +1015,7 var IPython = (function (IPython) { | |||
|
1012 | 1015 | this.dirty = false; |
|
1013 | 1016 | IPython.save_widget.notebook_saved(); |
|
1014 | 1017 | IPython.save_widget.status_save(); |
|
1015 | } | |
|
1018 | }; | |
|
1016 | 1019 | |
|
1017 | 1020 | |
|
1018 | 1021 | Notebook.prototype.notebook_save_failed = function (xhr, status, error_msg) { |
@@ -1020,7 +1023,7 var IPython = (function (IPython) { | |||
|
1020 | 1023 | // TODO: Handle different types of errors (timeout etc.) |
|
1021 | 1024 | alert('An unexpected error occured while saving the notebook.'); |
|
1022 | 1025 | IPython.save_widget.reset_status(); |
|
1023 | } | |
|
1026 | }; | |
|
1024 | 1027 | |
|
1025 | 1028 | |
|
1026 | 1029 | Notebook.prototype.load_notebook = function (callback) { |
@@ -1040,9 +1043,9 var IPython = (function (IPython) { | |||
|
1040 | 1043 | } |
|
1041 | 1044 | }; |
|
1042 | 1045 | IPython.save_widget.status_loading(); |
|
1043 | var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id | |
|
1046 | var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id; | |
|
1044 | 1047 | $.ajax(url, settings); |
|
1045 | } | |
|
1048 | }; | |
|
1046 | 1049 | |
|
1047 | 1050 | |
|
1048 | 1051 | Notebook.prototype.notebook_loaded = function (data, status, xhr) { |
@@ -67,7 +67,7 var IPython = (function (IPython) { | |||
|
67 | 67 | dataType : "json", |
|
68 | 68 | success : $.proxy(this.list_loaded, this) |
|
69 | 69 | }; |
|
70 | var url = $('body').data('baseProjectUrl') + 'notebooks' | |
|
70 | var url = $('body').data('baseProjectUrl') + 'notebooks'; | |
|
71 | 71 | $.ajax(url, settings); |
|
72 | 72 | }; |
|
73 | 73 | |
@@ -174,7 +174,7 var IPython = (function (IPython) { | |||
|
174 | 174 | parent_item.remove(); |
|
175 | 175 | } |
|
176 | 176 | }; |
|
177 | var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id | |
|
177 | var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id; | |
|
178 | 178 | $.ajax(url, settings); |
|
179 | 179 | $(this).dialog('close'); |
|
180 | 180 | }, |
@@ -222,7 +222,7 var IPython = (function (IPython) { | |||
|
222 | 222 | }; |
|
223 | 223 | |
|
224 | 224 | var qs = $.param({name:nbname, format:nbformat}); |
|
225 | var url = $('body').data('baseProjectUrl') + 'notebooks?' + qs | |
|
225 | var url = $('body').data('baseProjectUrl') + 'notebooks?' + qs; | |
|
226 | 226 | $.ajax(url, settings); |
|
227 | 227 | }); |
|
228 | 228 | var cancel_button = $('<button>Cancel</button>').button(). |
@@ -15,7 +15,7 $(document).ready(function () { | |||
|
15 | 15 | MathJax.Hub.Config({ |
|
16 | 16 | tex2jax: { |
|
17 | 17 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], |
|
18 |
displayMath: [ ['$$','$$'], ["\\[","\\]"] ] |
|
|
18 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ] | |
|
19 | 19 | }, |
|
20 | 20 | displayAlign: 'left', // Change this to 'center' to center equations. |
|
21 | 21 | "HTML-CSS": { |
@@ -76,7 +76,7 $(document).ready(function () { | |||
|
76 | 76 | // and finally unhide the panel contents after collapse |
|
77 | 77 | setTimeout(function(){ |
|
78 | 78 | IPython.left_panel.left_panel_element.css('visibility', 'visible'); |
|
79 | }, 200) | |
|
79 | }, 200); | |
|
80 | 80 | } |
|
81 | 81 | },100); |
|
82 | 82 | }); |
@@ -186,18 +186,18 var IPython = (function (IPython) { | |||
|
186 | 186 | this.content.find('#move_cell_down').attr('title', "Move selected cell down one in the Notebook"); |
|
187 | 187 | |
|
188 | 188 | this.content.find('#cell_type').buttonset(); |
|
189 | this.content.find('#to_markdown').attr('title', 'Change selected cell to markdown (for text)') | |
|
190 | this.content.find('#to_code').attr('title', 'Change selected cell to code (for execution)') | |
|
189 | this.content.find('#to_markdown').attr('title', 'Change selected cell to markdown (for text)'); | |
|
190 | this.content.find('#to_code').attr('title', 'Change selected cell to code (for execution)'); | |
|
191 | 191 | |
|
192 | 192 | this.content.find('#cell_output').buttonset(); |
|
193 | this.content.find('#toggle_output').attr('title', 'Toggle visibility of the output of code cells') | |
|
194 | this.content.find('#clear_all_output').attr('title', 'Clear output of all code cells (actually removes the data, unlike toggle)') | |
|
193 | this.content.find('#toggle_output').attr('title', 'Toggle visibility of the output of code cells'); | |
|
194 | this.content.find('#clear_all_output').attr('title', 'Clear output of all code cells (actually removes the data, unlike toggle)'); | |
|
195 | 195 | |
|
196 | 196 | this.content.find('#run_cells').buttonset(); |
|
197 | this.content.find('#run_selected_cell').attr('title', 'Submit the selected cell for execution') | |
|
198 | this.content.find('#run_all_cells').attr('title', 'Run *all* code cells in the notebook in order') | |
|
199 | this.content.find('#autoindent').attr('title', 'Autoindent code as-you-type') | |
|
200 | this.content.find('#autoindent_label').attr('title', 'Autoindent code as-you-type') | |
|
197 | this.content.find('#run_selected_cell').attr('title', 'Submit the selected cell for execution'); | |
|
198 | this.content.find('#run_all_cells').attr('title', 'Run *all* code cells in the notebook in order'); | |
|
199 | this.content.find('#autoindent').attr('title', 'Autoindent code as-you-type'); | |
|
200 | this.content.find('#autoindent_label').attr('title', 'Autoindent code as-you-type'); | |
|
201 | 201 | }; |
|
202 | 202 | |
|
203 | 203 | |
@@ -304,12 +304,12 var IPython = (function (IPython) { | |||
|
304 | 304 | this.content.find('#help_buttons0').buttonset(); |
|
305 | 305 | this.content.find('#help_buttons1').buttonset(); |
|
306 | 306 | this.content.find('#help_buttons2').buttonset(); |
|
307 | this.content.find('#python_help').attr('title', "Open the online Python documentation in a new tab") | |
|
308 | this.content.find('#ipython_help').attr('title', "Open the online IPython documentation in a new tab") | |
|
309 | this.content.find('#numpy_help').attr('title', "Open the online NumPy documentation in a new tab") | |
|
310 | this.content.find('#scipy_help').attr('title', "Open the online SciPy documentation in a new tab") | |
|
311 | this.content.find('#matplotlib_help').attr('title', "Open the online Matplotlib documentation in a new tab") | |
|
312 | this.content.find('#sympy_help').attr('title', "Open the online SymPy documentation in a new tab") | |
|
307 | this.content.find('#python_help').attr('title', "Open the online Python documentation in a new tab"); | |
|
308 | this.content.find('#ipython_help').attr('title', "Open the online IPython documentation in a new tab"); | |
|
309 | this.content.find('#numpy_help').attr('title', "Open the online NumPy documentation in a new tab"); | |
|
310 | this.content.find('#scipy_help').attr('title', "Open the online SciPy documentation in a new tab"); | |
|
311 | this.content.find('#matplotlib_help').attr('title', "Open the online Matplotlib documentation in a new tab"); | |
|
312 | this.content.find('#sympy_help').attr('title', "Open the online SymPy documentation in a new tab"); | |
|
313 | 313 | }; |
|
314 | 314 | |
|
315 | 315 |
@@ -15,7 +15,7 var IPython = (function (IPython) { | |||
|
15 | 15 | |
|
16 | 16 | var SaveWidget = function (selector) { |
|
17 | 17 | this.selector = selector; |
|
18 | this.notebook_name_blacklist_re = /[\/\\]/ | |
|
18 | this.notebook_name_blacklist_re = /[\/\\]/; | |
|
19 | 19 | this.last_saved_name = ''; |
|
20 | 20 | if (this.selector !== undefined) { |
|
21 | 21 | this.element = $(selector); |
@@ -70,14 +70,14 var IPython = (function (IPython) { | |||
|
70 | 70 | |
|
71 | 71 | SaveWidget.prototype.get_notebook_name = function () { |
|
72 | 72 | return this.element.find('input#notebook_name').attr('value'); |
|
73 | } | |
|
73 | }; | |
|
74 | 74 | |
|
75 | 75 | |
|
76 | 76 | SaveWidget.prototype.set_notebook_name = function (nbname) { |
|
77 | 77 | this.element.find('input#notebook_name').attr('value',nbname); |
|
78 | 78 | this.set_document_title(); |
|
79 | 79 | this.last_saved_name = nbname; |
|
80 | } | |
|
80 | }; | |
|
81 | 81 | |
|
82 | 82 | |
|
83 | 83 | SaveWidget.prototype.set_document_title = function () { |
@@ -34,7 +34,7 var IPython = (function (IPython) { | |||
|
34 | 34 | mode: this.code_mirror_mode, |
|
35 | 35 | theme: 'default', |
|
36 | 36 | value: this.placeholder, |
|
37 |
readOnly: this.read_only |
|
|
37 | readOnly: this.read_only | |
|
38 | 38 | }); |
|
39 | 39 | // The tabindex=-1 makes this div focusable. |
|
40 | 40 | var render_area = $('<div/>').addClass('text_cell_render'). |
@@ -52,8 +52,8 var IPython = (function (IPython) { | |||
|
52 | 52 | if (that.rendered) { |
|
53 | 53 | that.edit(); |
|
54 | 54 | event.preventDefault(); |
|
55 |
} |
|
|
56 |
} |
|
|
55 | } | |
|
56 | } | |
|
57 | 57 | }); |
|
58 | 58 | }; |
|
59 | 59 | |
@@ -77,8 +77,8 var IPython = (function (IPython) { | |||
|
77 | 77 | this.rendered = false; |
|
78 | 78 | if (this.get_source() === this.placeholder) { |
|
79 | 79 | this.set_source(''); |
|
80 |
} |
|
|
81 |
} |
|
|
80 | } | |
|
81 | } | |
|
82 | 82 | }; |
|
83 | 83 | |
|
84 | 84 | |
@@ -145,13 +145,13 var IPython = (function (IPython) { | |||
|
145 | 145 | this.set_rendered(data.rendered || ''); |
|
146 | 146 | this.rendered = false; |
|
147 | 147 | this.render(); |
|
148 |
} |
|
|
149 |
} |
|
|
148 | } | |
|
149 | } | |
|
150 | 150 | }; |
|
151 | 151 | |
|
152 | 152 | |
|
153 | 153 | TextCell.prototype.toJSON = function () { |
|
154 | var data = {} | |
|
154 | var data = {}; | |
|
155 | 155 | data.cell_type = this.cell_type; |
|
156 | 156 | data.source = this.get_source(); |
|
157 | 157 | return data; |
@@ -173,13 +173,13 var IPython = (function (IPython) { | |||
|
173 | 173 | HTMLCell.prototype.render = function () { |
|
174 | 174 | if (this.rendered === false) { |
|
175 | 175 | var text = this.get_source(); |
|
176 |
if (text === "") {text = this.placeholder;} |
|
|
176 | if (text === "") { text = this.placeholder; } | |
|
177 | 177 | this.set_rendered(text); |
|
178 | 178 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); |
|
179 | 179 | this.element.find('div.text_cell_input').hide(); |
|
180 | 180 | this.element.find("div.text_cell_render").show(); |
|
181 | 181 | this.rendered = true; |
|
182 |
} |
|
|
182 | } | |
|
183 | 183 | }; |
|
184 | 184 | |
|
185 | 185 | |
@@ -198,7 +198,7 var IPython = (function (IPython) { | |||
|
198 | 198 | MarkdownCell.prototype.render = function () { |
|
199 | 199 | if (this.rendered === false) { |
|
200 | 200 | var text = this.get_source(); |
|
201 |
if (text === "") {text = this.placeholder;} |
|
|
201 | if (text === "") { text = this.placeholder; } | |
|
202 | 202 | var html = IPython.markdown_converter.makeHtml(text); |
|
203 | 203 | this.set_rendered(html); |
|
204 | 204 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); |
@@ -217,7 +217,7 var IPython = (function (IPython) { | |||
|
217 | 217 | return '<code class="prettyprint">' + code + '</code>'; |
|
218 | 218 | }); |
|
219 | 219 | this.rendered = true; |
|
220 |
} |
|
|
220 | } | |
|
221 | 221 | }; |
|
222 | 222 | |
|
223 | 223 | |
@@ -234,9 +234,9 var IPython = (function (IPython) { | |||
|
234 | 234 | |
|
235 | 235 | |
|
236 | 236 | RSTCell.prototype.render = function () { |
|
237 |
if (this.rendered === false) { |
|
|
237 | if (this.rendered === false) { | |
|
238 | 238 | var text = this.get_source(); |
|
239 |
if (text === "") {text = this.placeholder;} |
|
|
239 | if (text === "") { text = this.placeholder; } | |
|
240 | 240 | var settings = { |
|
241 | 241 | processData : false, |
|
242 | 242 | cache : false, |
@@ -249,7 +249,7 var IPython = (function (IPython) { | |||
|
249 | 249 | this.element.find('div.text_cell_input').hide(); |
|
250 | 250 | this.element.find("div.text_cell_render").show(); |
|
251 | 251 | this.set_rendered("Rendering..."); |
|
252 |
} |
|
|
252 | } | |
|
253 | 253 | }; |
|
254 | 254 | |
|
255 | 255 |
@@ -9,7 +9,7 | |||
|
9 | 9 | // Utilities |
|
10 | 10 | //============================================================================ |
|
11 | 11 | |
|
12 | IPython.namespace('IPython.utils') | |
|
12 | IPython.namespace('IPython.utils'); | |
|
13 | 13 | |
|
14 | 14 | IPython.utils = (function (IPython) { |
|
15 | 15 | |
@@ -35,7 +35,7 IPython.utils = (function (IPython) { | |||
|
35 | 35 | .replace(/>/g,'&'+'gt;') |
|
36 | 36 | .replace(/\'/g,'&'+'apos;') |
|
37 | 37 | .replace(/\"/g,'&'+'quot;') |
|
38 | .replace(/`/g,'&'+'#96;') | |
|
38 | .replace(/`/g,'&'+'#96;'); | |
|
39 | 39 | } |
|
40 | 40 | |
|
41 | 41 | |
@@ -45,32 +45,32 IPython.utils = (function (IPython) { | |||
|
45 | 45 | "32":"ansigreen", "33":"ansiyellow", |
|
46 | 46 | "34":"ansiblue", "35":"ansipurple","36":"ansicyan", |
|
47 | 47 | "37":"ansigrey", "01":"ansibold" |
|
48 | } | |
|
48 | }; | |
|
49 | 49 | |
|
50 | 50 | // Transform ANI color escape codes into HTML <span> tags with css |
|
51 | 51 | // classes listed in the above ansi_colormap object. The actual color used |
|
52 | 52 | // are set in the css file. |
|
53 | 53 | function fixConsole(txt) { |
|
54 | txt = xmlencode(txt) | |
|
55 | var re = /\033\[([\d;]*?)m/ | |
|
56 | var opened = false | |
|
57 | var cmds = [] | |
|
58 | var opener = "" | |
|
59 | var closer = "" | |
|
54 | txt = xmlencode(txt); | |
|
55 | var re = /\033\[([\d;]*?)m/; | |
|
56 | var opened = false; | |
|
57 | var cmds = []; | |
|
58 | var opener = ""; | |
|
59 | var closer = ""; | |
|
60 | 60 | |
|
61 | 61 | while (re.test(txt)) { |
|
62 | var cmds = txt.match(re)[1].split(";") | |
|
63 | closer = opened?"</span>":"" | |
|
64 | opened = cmds.length > 1 || cmds[0] != 0 | |
|
65 | var rep = [] | |
|
62 | var cmds = txt.match(re)[1].split(";"); | |
|
63 | closer = opened?"</span>":""; | |
|
64 | opened = cmds.length > 1 || cmds[0] != 0; | |
|
65 | var rep = []; | |
|
66 | 66 | for (var i in cmds) |
|
67 | 67 | if (typeof(ansi_colormap[cmds[i]]) != "undefined") |
|
68 | rep.push(ansi_colormap[cmds[i]]) | |
|
69 | opener = rep.length > 0?"<span class=\""+rep.join(" ")+"\">":"" | |
|
70 | txt = txt.replace(re, closer + opener) | |
|
68 | rep.push(ansi_colormap[cmds[i]]); | |
|
69 | opener = rep.length > 0?"<span class=\""+rep.join(" ")+"\">":""; | |
|
70 | txt = txt.replace(re, closer + opener); | |
|
71 | 71 | } |
|
72 | if (opened) txt += "</span>" | |
|
73 | return txt | |
|
72 | if (opened) txt += "</span>"; | |
|
73 | return txt; | |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | |
@@ -95,7 +95,7 IPython.utils = (function (IPython) { | |||
|
95 | 95 | uuid : uuid, |
|
96 | 96 | fixConsole : fixConsole, |
|
97 | 97 | grow : grow |
|
98 | } | |
|
98 | }; | |
|
99 | 99 | |
|
100 | 100 | }(IPython)); |
|
101 | 101 |
General Comments 0
You need to be logged in to leave comments.
Login now