Show More
@@ -224,11 +224,11 b' var IPython = (function (IPython) {' | |||
|
224 | 224 | this.update_restore_checkpoint(null); |
|
225 | 225 | |
|
226 | 226 | $([IPython.events]).on('checkpoints_listed.Notebook', function (event, data) { |
|
227 |
that.update_restore_checkpoint( |
|
|
227 | that.update_restore_checkpoint(IPython.notebook.checkpoints); | |
|
228 | 228 | }); |
|
229 | 229 | |
|
230 | 230 | $([IPython.events]).on('checkpoint_created.Notebook', function (event, data) { |
|
231 |
that.update_restore_checkpoint( |
|
|
231 | that.update_restore_checkpoint(IPython.notebook.checkpoints); | |
|
232 | 232 | }); |
|
233 | 233 | }; |
|
234 | 234 | |
@@ -247,8 +247,7 b' var IPython = (function (IPython) {' | |||
|
247 | 247 | return; |
|
248 | 248 | }; |
|
249 | 249 | |
|
250 | for (var i = 0; i < checkpoints.length; i++) { | |
|
251 | var checkpoint = checkpoints[i]; | |
|
250 | checkpoints.map(function (checkpoint) { | |
|
252 | 251 | var d = new Date(checkpoint.last_modified); |
|
253 | 252 | ul.append( |
|
254 | 253 | $("<li/>").append( |
@@ -260,7 +259,7 b' var IPython = (function (IPython) {' | |||
|
260 | 259 | }) |
|
261 | 260 | ) |
|
262 | 261 | ); |
|
263 | }; | |
|
262 | }); | |
|
264 | 263 | }; |
|
265 | 264 | |
|
266 | 265 | IPython.MenuBar = MenuBar; |
@@ -40,6 +40,7 b' var IPython = (function (IPython) {' | |||
|
40 | 40 | this.metadata = {}; |
|
41 | 41 | this._checkpoint_after_save = false; |
|
42 | 42 | this.last_checkpoint = null; |
|
43 | this.checkpoints = []; | |
|
43 | 44 | this.autosave_interval = 0; |
|
44 | 45 | this.autosave_timer = null; |
|
45 | 46 | // autosave *at most* every two minutes |
@@ -1826,9 +1827,31 b' var IPython = (function (IPython) {' | |||
|
1826 | 1827 | }; |
|
1827 | 1828 | |
|
1828 | 1829 | /** |
|
1830 | * Add a checkpoint for this notebook. | |
|
1831 | * for use as a callback from checkpoint creation. | |
|
1832 | * | |
|
1833 | * @method add_checkpoint | |
|
1834 | */ | |
|
1835 | Notebook.prototype.add_checkpoint = function (checkpoint) { | |
|
1836 | var found = false; | |
|
1837 | for (var i = 0; i < this.checkpoints.length; i++) { | |
|
1838 | var existing = this.checkpoints[i]; | |
|
1839 | if (existing.checkpoint_id == checkpoint.checkpoint_id) { | |
|
1840 | found = true; | |
|
1841 | this.checkpoints[i] = checkpoint; | |
|
1842 | break; | |
|
1843 | } | |
|
1844 | } | |
|
1845 | if (!found) { | |
|
1846 | this.checkpoints.push(checkpoint); | |
|
1847 | } | |
|
1848 | this.last_checkpoint = this.checkpoints[this.checkpoints.length - 1]; | |
|
1849 | }; | |
|
1850 | ||
|
1851 | /** | |
|
1829 | 1852 | * List checkpoints for this notebook. |
|
1830 | 1853 | * |
|
1831 | * @method list_checkpoint | |
|
1854 | * @method list_checkpoints | |
|
1832 | 1855 | */ |
|
1833 | 1856 | Notebook.prototype.list_checkpoints = function () { |
|
1834 | 1857 | var url = this.baseProjectUrl() + 'notebooks/' + this.notebook_id + '/checkpoints'; |
@@ -1849,8 +1872,9 b' var IPython = (function (IPython) {' | |||
|
1849 | 1872 | */ |
|
1850 | 1873 | Notebook.prototype.list_checkpoints_success = function (data, status, xhr) { |
|
1851 | 1874 | var data = $.parseJSON(data); |
|
1875 | this.checkpoints = data; | |
|
1852 | 1876 | if (data.length) { |
|
1853 |
this.last_checkpoint = data[ |
|
|
1877 | this.last_checkpoint = data[data.length - 1]; | |
|
1854 | 1878 | } else { |
|
1855 | 1879 | this.last_checkpoint = null; |
|
1856 | 1880 | } |
@@ -1893,7 +1917,7 b' var IPython = (function (IPython) {' | |||
|
1893 | 1917 | */ |
|
1894 | 1918 | Notebook.prototype.create_checkpoint_success = function (data, status, xhr) { |
|
1895 | 1919 | var data = $.parseJSON(data); |
|
1896 |
this. |
|
|
1920 | this.add_checkpoint(data); | |
|
1897 | 1921 | $([IPython.events]).trigger('checkpoint_created.Notebook', data); |
|
1898 | 1922 | }; |
|
1899 | 1923 |
General Comments 0
You need to be logged in to leave comments.
Login now