Show More
@@ -46,16 +46,23 function (marked) { | |||
|
46 | 46 | $('#ipython-main-app').addClass('border-box-sizing'); |
|
47 | 47 | $('div#notebook_panel').addClass('border-box-sizing'); |
|
48 | 48 | |
|
49 | var baseProjectUrl = $('body').data('baseProjectUrl') | |
|
49 | var baseProjectUrl = $('body').data('baseProjectUrl'); | |
|
50 | var notebookPath = $('body').data('notebookPath'); | |
|
51 | var notebookName = $('body').data('notebookName'); | |
|
52 | notebookName = decodeURIComponent(notebookName); | |
|
53 | console.log(notebookName); | |
|
54 | if (notebookPath == 'None'){ | |
|
55 | notebookPath = ""; | |
|
56 | } | |
|
50 | 57 | |
|
51 | 58 | IPython.page = new IPython.Page(); |
|
52 | 59 | IPython.layout_manager = new IPython.LayoutManager(); |
|
53 | 60 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); |
|
54 | 61 | IPython.quick_help = new IPython.QuickHelp(); |
|
55 | 62 | IPython.login_widget = new IPython.LoginWidget('span#login_widget',{baseProjectUrl:baseProjectUrl}); |
|
56 | IPython.notebook = new IPython.Notebook('div#notebook',{baseProjectUrl:baseProjectUrl}); | |
|
63 | IPython.notebook = new IPython.Notebook('div#notebook',{baseProjectUrl:baseProjectUrl, notebookPath:notebookPath, notebookName:notebookName}); | |
|
57 | 64 | IPython.save_widget = new IPython.SaveWidget('span#save_widget'); |
|
58 | IPython.menubar = new IPython.MenuBar('#menubar',{baseProjectUrl:baseProjectUrl}) | |
|
65 | IPython.menubar = new IPython.MenuBar('#menubar',{baseProjectUrl:baseProjectUrl, notebookPath: notebookPath}) | |
|
59 | 66 | IPython.toolbar = new IPython.MainToolBar('#maintoolbar-container') |
|
60 | 67 | IPython.tooltip = new IPython.Tooltip() |
|
61 | 68 | IPython.notification_area = new IPython.NotificationArea('#notification_area') |
@@ -91,7 +98,7 function (marked) { | |||
|
91 | 98 | |
|
92 | 99 | $([IPython.events]).on('notebook_loaded.Notebook', first_load); |
|
93 | 100 | $([IPython.events]).trigger('app_initialized.NotebookApp'); |
|
94 |
IPython.notebook.load_notebook( |
|
|
101 | IPython.notebook.load_notebook(notebookName, notebookPath); | |
|
95 | 102 | |
|
96 | 103 | if (marked) { |
|
97 | 104 | marked.setOptions({ |
@@ -50,7 +50,10 var IPython = (function (IPython) { | |||
|
50 | 50 | return this._baseProjectUrl || $('body').data('baseProjectUrl'); |
|
51 | 51 | }; |
|
52 | 52 | |
|
53 | ||
|
53 | MenuBar.prototype.notebookPath = function(){ | |
|
54 | return this._notebookPath || $('body').data('notebookPath'); | |
|
55 | }; | |
|
56 | ||
|
54 | 57 | MenuBar.prototype.style = function () { |
|
55 | 58 | this.element.addClass('border-box-sizing'); |
|
56 | 59 | this.element.find("li").click(function (event, ui) { |
@@ -66,38 +69,68 var IPython = (function (IPython) { | |||
|
66 | 69 | MenuBar.prototype.bind_events = function () { |
|
67 | 70 | // File |
|
68 | 71 | var that = this; |
|
69 | this.element.find('#new_notebook').click(function () { | |
|
70 | window.open(that.baseProjectUrl()+'new'); | |
|
71 | }); | |
|
72 | this.element.find('#open_notebook').click(function () { | |
|
73 | window.open(that.baseProjectUrl()); | |
|
74 | }); | |
|
72 | if (this.notebookPath() != 'None') { | |
|
73 | this.element.find('#new_notebook').click(function () { | |
|
74 | window.open(that.baseProjectUrl() + 'notebooks/' + that.notebookPath() +'/new'); | |
|
75 | }); | |
|
76 | this.element.find('#open_notebook').click(function () { | |
|
77 | window.open(that.baseProjectUrl() + 'tree/' + that.notebookPath()); | |
|
78 | }); | |
|
79 | this.element.find('#copy_notebook').click(function () { | |
|
80 | var notebook_name = IPython.notebook.get_notebook_name(); | |
|
81 | var url = that.baseProjectUrl() + 'notebooks/' + that.notebookPath() + '/'+ notebook_name + '/copy'; | |
|
82 | window.open(url,'_blank'); | |
|
83 | return false; | |
|
84 | }); | |
|
85 | this.element.find('#download_ipynb').click(function () { | |
|
86 | var notebook_name = IPython.notebook.get_notebook_name(); | |
|
87 | var url = that.baseProjectUrl() + 'api/notebooks/' + | |
|
88 | notebook_name + '?format=json'; | |
|
89 | window.location.assign(url); | |
|
90 | }); | |
|
91 | this.element.find('#download_py').click(function () { | |
|
92 | var notebook_name = IPython.notebook.get_notebook_name(); | |
|
93 | var url = that.baseProjectUrl() + 'api/notebooks/' + | |
|
94 | notebook_name + '?format=py'; | |
|
95 | window.location.assign(url); | |
|
96 | }); | |
|
97 | } | |
|
98 | else { | |
|
99 | this.element.find('#new_notebook').click(function () { | |
|
100 | window.open(that.baseProjectUrl()+'notebooks/new'); | |
|
101 | }); | |
|
102 | this.element.find('#open_notebook').click(function () { | |
|
103 | window.open(that.baseProjectUrl() + 'tree'); | |
|
104 | }); | |
|
105 | this.element.find('#copy_notebook').click(function () { | |
|
106 | var notebook_name = IPython.notebook.get_notebook_name(); | |
|
107 | var url = that.baseProjectUrl() + 'notebooks/' + notebook_name + '/copy'; | |
|
108 | window.open(url,'_blank'); | |
|
109 | return false; | |
|
110 | }); | |
|
111 | this.element.find('#download_ipynb').click(function () { | |
|
112 | var notebook_name = IPython.notebook.get_notebook_name(); | |
|
113 | var url = that.baseProjectUrl() + 'api/notebooks/' + | |
|
114 | notebook_name + '?format=json'; | |
|
115 | window.location.assign(url); | |
|
116 | }); | |
|
117 | this.element.find('#download_py').click(function () { | |
|
118 | var notebook_name = IPython.notebook.get_notebook_name(); | |
|
119 | var url = that.baseProjectUrl() + 'api/notebooks/' + | |
|
120 | notebook_name + '?format=py'; | |
|
121 | window.location.assign(url); | |
|
122 | }); | |
|
123 | ||
|
124 | ||
|
125 | } | |
|
75 | 126 | this.element.find('#rename_notebook').click(function () { |
|
76 | 127 | IPython.save_widget.rename_notebook(); |
|
77 | 128 | }); |
|
78 | this.element.find('#copy_notebook').click(function () { | |
|
79 | var notebook_id = IPython.notebook.get_notebook_id(); | |
|
80 | var url = that.baseProjectUrl() + notebook_id + '/copy'; | |
|
81 | window.open(url,'_blank'); | |
|
82 | return false; | |
|
83 | }); | |
|
84 | 129 | this.element.find('#save_checkpoint').click(function () { |
|
85 | 130 | IPython.notebook.save_checkpoint(); |
|
86 | 131 | }); |
|
87 | 132 | this.element.find('#restore_checkpoint').click(function () { |
|
88 | 133 | }); |
|
89 | this.element.find('#download_ipynb').click(function () { | |
|
90 | var notebook_id = IPython.notebook.get_notebook_id(); | |
|
91 | var url = that.baseProjectUrl() + 'notebooks/' + | |
|
92 | notebook_id + '?format=json'; | |
|
93 | window.location.assign(url); | |
|
94 | }); | |
|
95 | this.element.find('#download_py').click(function () { | |
|
96 | var notebook_id = IPython.notebook.get_notebook_id(); | |
|
97 | var url = that.baseProjectUrl() + 'notebooks/' + | |
|
98 | notebook_id + '?format=py'; | |
|
99 | window.location.assign(url); | |
|
100 | }); | |
|
101 | 134 | this.element.find('#kill_and_exit').click(function () { |
|
102 | 135 | IPython.notebook.kernel.kill(); |
|
103 | 136 | setTimeout(function(){window.close();}, 200); |
@@ -26,12 +26,13 var IPython = (function (IPython) { | |||
|
26 | 26 | var Notebook = function (selector, options) { |
|
27 | 27 | var options = options || {}; |
|
28 | 28 | this._baseProjectUrl = options.baseProjectUrl; |
|
29 | ||
|
29 | this.notebook_path = options.notebookPath; | |
|
30 | this.notebook_name = options.notebookName; | |
|
30 | 31 | this.element = $(selector); |
|
31 | 32 | this.element.scroll(); |
|
32 | 33 | this.element.data("notebook", this); |
|
33 | 34 | this.next_prompt_number = 1; |
|
34 |
this. |
|
|
35 | this.session = null; | |
|
35 | 36 | this.clipboard = null; |
|
36 | 37 | this.undelete_backup = null; |
|
37 | 38 | this.undelete_index = null; |
@@ -49,7 +50,6 var IPython = (function (IPython) { | |||
|
49 | 50 | // single worksheet for now |
|
50 | 51 | this.worksheet_metadata = {}; |
|
51 | 52 | this.control_key_active = false; |
|
52 | this.notebook_id = null; | |
|
53 | 53 | this.notebook_name = null; |
|
54 | 54 | this.notebook_name_blacklist_re = /[\/\\:]/; |
|
55 | 55 | this.nbformat = 3 // Increment this when changing the nbformat |
@@ -78,6 +78,18 var IPython = (function (IPython) { | |||
|
78 | 78 | return this._baseProjectUrl || $('body').data('baseProjectUrl'); |
|
79 | 79 | }; |
|
80 | 80 | |
|
81 | Notebook.prototype.notebookPath = function() { | |
|
82 | var path = $('body').data('notebookPath'); | |
|
83 | if (path != 'None') { | |
|
84 | if (path[path.length-1] != '/') { | |
|
85 | path = path.substring(0,path.length); | |
|
86 | }; | |
|
87 | return path; | |
|
88 | } else { | |
|
89 | return ''; | |
|
90 | } | |
|
91 | }; | |
|
92 | ||
|
81 | 93 | /** |
|
82 | 94 | * Create an HTML and CSS representation of the notebook. |
|
83 | 95 | * |
@@ -745,7 +757,7 var IPython = (function (IPython) { | |||
|
745 | 757 | var i = this.index_or_selected(index); |
|
746 | 758 | var cell = this.get_selected_cell(); |
|
747 | 759 | this.undelete_backup = cell.toJSON(); |
|
748 | $('#undelete_cell').removeClass('disabled'); | |
|
760 | $('#undelete_cell').removeClass('ui-state-disabled'); | |
|
749 | 761 | if (this.is_valid_cell_index(i)) { |
|
750 | 762 | var ce = this.get_cell_element(i); |
|
751 | 763 | ce.remove(); |
@@ -1028,11 +1040,11 var IPython = (function (IPython) { | |||
|
1028 | 1040 | Notebook.prototype.enable_paste = function () { |
|
1029 | 1041 | var that = this; |
|
1030 | 1042 | if (!this.paste_enabled) { |
|
1031 | $('#paste_cell_replace').removeClass('disabled') | |
|
1043 | $('#paste_cell_replace').removeClass('ui-state-disabled') | |
|
1032 | 1044 | .on('click', function () {that.paste_cell_replace();}); |
|
1033 | $('#paste_cell_above').removeClass('disabled') | |
|
1045 | $('#paste_cell_above').removeClass('ui-state-disabled') | |
|
1034 | 1046 | .on('click', function () {that.paste_cell_above();}); |
|
1035 | $('#paste_cell_below').removeClass('disabled') | |
|
1047 | $('#paste_cell_below').removeClass('ui-state-disabled') | |
|
1036 | 1048 | .on('click', function () {that.paste_cell_below();}); |
|
1037 | 1049 | this.paste_enabled = true; |
|
1038 | 1050 | }; |
@@ -1045,9 +1057,9 var IPython = (function (IPython) { | |||
|
1045 | 1057 | */ |
|
1046 | 1058 | Notebook.prototype.disable_paste = function () { |
|
1047 | 1059 | if (this.paste_enabled) { |
|
1048 | $('#paste_cell_replace').addClass('disabled').off('click'); | |
|
1049 | $('#paste_cell_above').addClass('disabled').off('click'); | |
|
1050 | $('#paste_cell_below').addClass('disabled').off('click'); | |
|
1060 | $('#paste_cell_replace').addClass('ui-state-disabled').off('click'); | |
|
1061 | $('#paste_cell_above').addClass('ui-state-disabled').off('click'); | |
|
1062 | $('#paste_cell_below').addClass('ui-state-disabled').off('click'); | |
|
1051 | 1063 | this.paste_enabled = false; |
|
1052 | 1064 | }; |
|
1053 | 1065 | }; |
@@ -1146,7 +1158,7 var IPython = (function (IPython) { | |||
|
1146 | 1158 | this.undelete_backup = null; |
|
1147 | 1159 | this.undelete_index = null; |
|
1148 | 1160 | } |
|
1149 | $('#undelete_cell').addClass('disabled'); | |
|
1161 | $('#undelete_cell').addClass('ui-state-disabled'); | |
|
1150 | 1162 | } |
|
1151 | 1163 | |
|
1152 | 1164 | // Split/merge |
@@ -1370,50 +1382,20 var IPython = (function (IPython) { | |||
|
1370 | 1382 | this.get_selected_cell().toggle_line_numbers(); |
|
1371 | 1383 | }; |
|
1372 | 1384 | |
|
1373 |
// |
|
|
1385 | // Session related things | |
|
1374 | 1386 | |
|
1375 | 1387 | /** |
|
1376 |
* Start a new |
|
|
1388 | * Start a new session and set it on each code cell. | |
|
1377 | 1389 | * |
|
1378 |
* @method start_ |
|
|
1390 | * @method start_session | |
|
1379 | 1391 | */ |
|
1380 |
Notebook.prototype.start_ |
|
|
1381 | var base_url = $('body').data('baseKernelUrl') + "kernels"; | |
|
1382 | this.kernel = new IPython.Kernel(base_url); | |
|
1383 | this.kernel.start({notebook: this.notebook_id}); | |
|
1384 | // Now that the kernel has been created, tell the CodeCells about it. | |
|
1385 | var ncells = this.ncells(); | |
|
1386 | for (var i=0; i<ncells; i++) { | |
|
1387 | var cell = this.get_cell(i); | |
|
1388 | if (cell instanceof IPython.CodeCell) { | |
|
1389 | cell.set_kernel(this.kernel) | |
|
1390 | }; | |
|
1391 | }; | |
|
1392 | Notebook.prototype.start_session = function () { | |
|
1393 | var notebook_info = this.notebookPath() + this.notebook_name; | |
|
1394 | console.log(notebook_info) | |
|
1395 | this.session = new IPython.Session(notebook_info, this); | |
|
1396 | this.session.start(); | |
|
1392 | 1397 | }; |
|
1393 | 1398 | |
|
1394 | /** | |
|
1395 | * Prompt the user to restart the IPython kernel. | |
|
1396 | * | |
|
1397 | * @method restart_kernel | |
|
1398 | */ | |
|
1399 | Notebook.prototype.restart_kernel = function () { | |
|
1400 | var that = this; | |
|
1401 | IPython.dialog.modal({ | |
|
1402 | title : "Restart kernel or continue running?", | |
|
1403 | body : $("<p/>").html( | |
|
1404 | 'Do you want to restart the current kernel? You will lose all variables defined in it.' | |
|
1405 | ), | |
|
1406 | buttons : { | |
|
1407 | "Continue running" : {}, | |
|
1408 | "Restart" : { | |
|
1409 | "class" : "btn-danger", | |
|
1410 | "click" : function() { | |
|
1411 | that.kernel.restart(); | |
|
1412 | } | |
|
1413 | } | |
|
1414 | } | |
|
1415 | }); | |
|
1416 | }; | |
|
1417 | 1399 | |
|
1418 | 1400 | /** |
|
1419 | 1401 | * Run the selected cell. |
@@ -1548,6 +1530,7 var IPython = (function (IPython) { | |||
|
1548 | 1530 | * @param {Object} data JSON representation of a notebook |
|
1549 | 1531 | */ |
|
1550 | 1532 | Notebook.prototype.fromJSON = function (data) { |
|
1533 | data = data.content; | |
|
1551 | 1534 | var ncells = this.ncells(); |
|
1552 | 1535 | var i; |
|
1553 | 1536 | for (i=0; i<ncells; i++) { |
@@ -1556,7 +1539,7 var IPython = (function (IPython) { | |||
|
1556 | 1539 | }; |
|
1557 | 1540 | // Save the metadata and name. |
|
1558 | 1541 | this.metadata = data.metadata; |
|
1559 | this.notebook_name = data.metadata.name; | |
|
1542 | this.notebook_name = data.metadata.name +'.ipynb'; | |
|
1560 | 1543 | // Only handle 1 worksheet for now. |
|
1561 | 1544 | var worksheet = data.worksheets[0]; |
|
1562 | 1545 | if (worksheet !== undefined) { |
@@ -1671,7 +1654,12 var IPython = (function (IPython) { | |||
|
1671 | 1654 | error : $.proxy(this.save_notebook_error, this) |
|
1672 | 1655 | }; |
|
1673 | 1656 | $([IPython.events]).trigger('notebook_saving.Notebook'); |
|
1674 | var url = this.baseProjectUrl() + 'notebooks/' + this.notebook_id; | |
|
1657 | if (this.notebook_path != "") { | |
|
1658 | var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path+ this.notebook_name; | |
|
1659 | } | |
|
1660 | else { | |
|
1661 | var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name; | |
|
1662 | } | |
|
1675 | 1663 | $.ajax(url, settings); |
|
1676 | 1664 | }; |
|
1677 | 1665 | |
@@ -1730,24 +1718,25 var IPython = (function (IPython) { | |||
|
1730 | 1718 | * Request a notebook's data from the server. |
|
1731 | 1719 | * |
|
1732 | 1720 | * @method load_notebook |
|
1733 |
* @param {String} notebook_ |
|
|
1734 | */ | |
|
1735 |
Notebook.prototype.load_notebook = function (notebook_ |
|
|
1736 | var that = this; | |
|
1737 |
this.notebook_ |
|
|
1738 | // We do the call with settings so we can set cache to false. | |
|
1739 | var settings = { | |
|
1740 | processData : false, | |
|
1741 |
|
|
|
1742 |
|
|
|
1743 |
|
|
|
1744 | success : $.proxy(this.load_notebook_success,this), | |
|
1745 |
|
|
|
1746 | }; | |
|
1747 | $([IPython.events]).trigger('notebook_loading.Notebook'); | |
|
1748 | var url = this.baseProjectUrl() + 'notebooks/' + this.notebook_id; | |
|
1749 | $.ajax(url, settings); | |
|
1750 | }; | |
|
1721 | * @param {String} notebook_naem and path A notebook to load | |
|
1722 | */ | |
|
1723 | Notebook.prototype.load_notebook = function (notebook_name, notebook_path) { | |
|
1724 | var that = this; | |
|
1725 | this.notebook_name = notebook_name; | |
|
1726 | this.notebook_path = notebook_path; | |
|
1727 | // We do the call with settings so we can set cache to false. | |
|
1728 | var settings = { | |
|
1729 | processData : false, | |
|
1730 | cache : false, | |
|
1731 | type : "GET", | |
|
1732 | dataType : "json", | |
|
1733 | success : $.proxy(this.load_notebook_success,this), | |
|
1734 | error : $.proxy(this.load_notebook_error,this), | |
|
1735 | }; | |
|
1736 | $([IPython.events]).trigger('notebook_loading.Notebook'); | |
|
1737 | var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path + this.notebook_name; | |
|
1738 | $.ajax(url, settings); | |
|
1739 | }; | |
|
1751 | 1740 | |
|
1752 | 1741 | /** |
|
1753 | 1742 | * Success callback for loading a notebook from the server. |
@@ -1803,12 +1792,13 var IPython = (function (IPython) { | |||
|
1803 | 1792 | |
|
1804 | 1793 | } |
|
1805 | 1794 | |
|
1806 |
// Create the |
|
|
1795 | // Create the session after the notebook is completely loaded to prevent | |
|
1807 | 1796 | // code execution upon loading, which is a security risk. |
|
1808 | this.start_kernel(); | |
|
1797 | if (this.session == null) { | |
|
1798 | this.start_session(this.notebook_path); | |
|
1799 | } | |
|
1809 | 1800 | // load our checkpoint list |
|
1810 | 1801 | IPython.notebook.list_checkpoints(); |
|
1811 | ||
|
1812 | 1802 | $([IPython.events]).trigger('notebook_loaded.Notebook'); |
|
1813 | 1803 | }; |
|
1814 | 1804 | |
@@ -1876,14 +1866,19 var IPython = (function (IPython) { | |||
|
1876 | 1866 | * |
|
1877 | 1867 | * @method list_checkpoints |
|
1878 | 1868 | */ |
|
1879 | Notebook.prototype.list_checkpoints = function () { | |
|
1880 | var url = this.baseProjectUrl() + 'notebooks/' + this.notebook_id + '/checkpoints'; | |
|
1881 | $.get(url).done( | |
|
1882 | $.proxy(this.list_checkpoints_success, this) | |
|
1883 |
|
|
|
1884 | $.proxy(this.list_checkpoints_error, this) | |
|
1885 |
|
|
|
1886 | }; | |
|
1869 | Notebook.prototype.list_checkpoints = function () { | |
|
1870 | if (this.notebook_path != "") { | |
|
1871 | var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path+ this.notebook_name + '/checkpoints'; | |
|
1872 | } | |
|
1873 | else { | |
|
1874 | var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name + '/checkpoints'; | |
|
1875 | } | |
|
1876 | $.get(url).done( | |
|
1877 | $.proxy(this.list_checkpoints_success, this) | |
|
1878 | ).fail( | |
|
1879 | $.proxy(this.list_checkpoints_error, this) | |
|
1880 | ); | |
|
1881 | }; | |
|
1887 | 1882 | |
|
1888 | 1883 | /** |
|
1889 | 1884 | * Success callback for listing checkpoints. |
@@ -1921,14 +1916,19 var IPython = (function (IPython) { | |||
|
1921 | 1916 | * |
|
1922 | 1917 | * @method create_checkpoint |
|
1923 | 1918 | */ |
|
1924 | Notebook.prototype.create_checkpoint = function () { | |
|
1925 | var url = this.baseProjectUrl() + 'notebooks/' + this.notebook_id + '/checkpoints'; | |
|
1926 | $.post(url).done( | |
|
1927 | $.proxy(this.create_checkpoint_success, this) | |
|
1928 |
|
|
|
1929 | $.proxy(this.create_checkpoint_error, this) | |
|
1930 |
|
|
|
1931 | }; | |
|
1919 | Notebook.prototype.create_checkpoint = function () { | |
|
1920 | if (this.notebook_path != "") { | |
|
1921 | var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path + this.notebook_name + '/checkpoints'; | |
|
1922 | } | |
|
1923 | else { | |
|
1924 | var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name + '/checkpoints'; | |
|
1925 | } | |
|
1926 | $.post(url).done( | |
|
1927 | $.proxy(this.create_checkpoint_success, this) | |
|
1928 | ).fail( | |
|
1929 | $.proxy(this.create_checkpoint_error, this) | |
|
1930 | ); | |
|
1931 | }; | |
|
1932 | 1932 | |
|
1933 | 1933 | /** |
|
1934 | 1934 | * Success callback for creating a checkpoint. |
@@ -2003,7 +2003,12 var IPython = (function (IPython) { | |||
|
2003 | 2003 | */ |
|
2004 | 2004 | Notebook.prototype.restore_checkpoint = function (checkpoint) { |
|
2005 | 2005 | $([IPython.events]).trigger('checkpoint_restoring.Notebook', checkpoint); |
|
2006 | var url = this.baseProjectUrl() + 'notebooks/' + this.notebook_id + '/checkpoints/' + checkpoint; | |
|
2006 | if (this.notebook_path != "") { | |
|
2007 | var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path + this.notebook_name + '/checkpoints/' + checkpoint; | |
|
2008 | } | |
|
2009 | else { | |
|
2010 | var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name + '/checkpoints/' + checkpoint; | |
|
2011 | } | |
|
2007 | 2012 | $.post(url).done( |
|
2008 | 2013 | $.proxy(this.restore_checkpoint_success, this) |
|
2009 | 2014 | ).fail( |
@@ -2021,7 +2026,7 var IPython = (function (IPython) { | |||
|
2021 | 2026 | */ |
|
2022 | 2027 | Notebook.prototype.restore_checkpoint_success = function (data, status, xhr) { |
|
2023 | 2028 | $([IPython.events]).trigger('checkpoint_restored.Notebook'); |
|
2024 |
this.load_notebook(this.notebook_ |
|
|
2029 | this.load_notebook(this.notebook_name, this.notebook_path); | |
|
2025 | 2030 | }; |
|
2026 | 2031 | |
|
2027 | 2032 | /** |
@@ -2043,8 +2048,13 var IPython = (function (IPython) { | |||
|
2043 | 2048 | * @param {String} checkpoint ID |
|
2044 | 2049 | */ |
|
2045 | 2050 | Notebook.prototype.delete_checkpoint = function (checkpoint) { |
|
2046 |
$([IPython.events]).trigger('checkpoint_ |
|
|
2047 | var url = this.baseProjectUrl() + 'notebooks/' + this.notebook_id + '/checkpoints/' + checkpoint; | |
|
2051 | $([IPython.events]).trigger('checkpoint_restoring.Notebook', checkpoint); | |
|
2052 | if (this.notebook_path != "") { | |
|
2053 | var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path + this.notebook_name + '/checkpoints/' + checkpoint; | |
|
2054 | } | |
|
2055 | else { | |
|
2056 | var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name + '/checkpoints/' + checkpoint; | |
|
2057 | } | |
|
2048 | 2058 | $.ajax(url, { |
|
2049 | 2059 | type: 'DELETE', |
|
2050 | 2060 | success: $.proxy(this.delete_checkpoint_success, this), |
@@ -2062,7 +2072,7 var IPython = (function (IPython) { | |||
|
2062 | 2072 | */ |
|
2063 | 2073 | Notebook.prototype.delete_checkpoint_success = function (data, status, xhr) { |
|
2064 | 2074 | $([IPython.events]).trigger('checkpoint_deleted.Notebook', data); |
|
2065 |
this.load_notebook(this.notebook_ |
|
|
2075 | this.load_notebook(this.notebook_name, this.notebook_path); | |
|
2066 | 2076 | }; |
|
2067 | 2077 | |
|
2068 | 2078 | /** |
General Comments 0
You need to be logged in to leave comments.
Login now