@ -40,6 +40,7 @@ var IPython = (function (IPython) {
this . metadata = { } ;
this . _checkpoint _after _save = false ;
this . last _checkpoint = null ;
this . checkpoints = [ ] ;
this . autosave _interval = 0 ;
this . autosave _timer = null ;
// autosave *at most* every two minutes
@ -1825,10 +1826,32 @@ var IPython = (function (IPython) {
this . save _notebook ( ) ;
} ;
/ * *
* Add a checkpoint for this notebook .
* for use as a callback from checkpoint creation .
*
* @ method add _checkpoint
* /
Notebook . prototype . add _checkpoint = function ( checkpoint ) {
var found = false ;
for ( var i = 0 ; i < this . checkpoints . length ; i ++ ) {
var existing = this . checkpoints [ i ] ;
if ( existing . checkpoint _id == checkpoint . checkpoint _id ) {
found = true ;
this . checkpoints [ i ] = checkpoint ;
break ;
}
}
if ( ! found ) {
this . checkpoints . push ( checkpoint ) ;
}
this . last _checkpoint = this . checkpoints [ this . checkpoints . length - 1 ] ;
} ;
/ * *
* List checkpoints for this notebook .
*
* @ method list _checkpoint
* @ method list _checkpoint s
* /
Notebook . prototype . list _checkpoints = function ( ) {
var url = this . baseProjectUrl ( ) + 'notebooks/' + this . notebook _id + '/checkpoints' ;
@ -1849,8 +1872,9 @@ var IPython = (function (IPython) {
* /
Notebook . prototype . list _checkpoints _success = function ( data , status , xhr ) {
var data = $ . parseJSON ( data ) ;
this . checkpoints = data ;
if ( data . length ) {
this . last _checkpoint = data [ 0 ] ;
this . last _checkpoint = data [ data . length - 1 ] ;
} else {
this . last _checkpoint = null ;
}
@ -1893,7 +1917,7 @@ var IPython = (function (IPython) {
* /
Notebook . prototype . create _checkpoint _success = function ( data , status , xhr ) {
var data = $ . parseJSON ( data ) ;
this . last_checkpoint = data ;
this . add_checkpoint ( data ) ;
$ ( [ IPython . events ] ) . trigger ( 'checkpoint_created.Notebook' , data ) ;
} ;