##// END OF EJS Templates
s/Connection lost/Not Connected/
Min RK -
Show More
@@ -1,384 +1,384
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4 define([
4 define([
5 'base/js/namespace',
5 'base/js/namespace',
6 'jquery',
6 'jquery',
7 'base/js/utils',
7 'base/js/utils',
8 'base/js/dialog',
8 'base/js/dialog',
9 'notebook/js/notificationwidget',
9 'notebook/js/notificationwidget',
10 'moment'
10 'moment'
11 ], function(IPython, $, utils, dialog, notificationwidget, moment) {
11 ], function(IPython, $, utils, dialog, notificationwidget, moment) {
12 "use strict";
12 "use strict";
13
13
14 // store reference to the NotificationWidget class
14 // store reference to the NotificationWidget class
15 var NotificationWidget = notificationwidget.NotificationWidget;
15 var NotificationWidget = notificationwidget.NotificationWidget;
16
16
17 /**
17 /**
18 * Construct the NotificationArea object. Options are:
18 * Construct the NotificationArea object. Options are:
19 * events: $(Events) instance
19 * events: $(Events) instance
20 * save_widget: SaveWidget instance
20 * save_widget: SaveWidget instance
21 * notebook: Notebook instance
21 * notebook: Notebook instance
22 * keyboard_manager: KeyboardManager instance
22 * keyboard_manager: KeyboardManager instance
23 *
23 *
24 * @constructor
24 * @constructor
25 * @param {string} selector - a jQuery selector string for the
25 * @param {string} selector - a jQuery selector string for the
26 * notification area element
26 * notification area element
27 * @param {Object} [options] - a dictionary of keyword arguments.
27 * @param {Object} [options] - a dictionary of keyword arguments.
28 */
28 */
29 var NotificationArea = function (selector, options) {
29 var NotificationArea = function (selector, options) {
30 this.selector = selector;
30 this.selector = selector;
31 this.events = options.events;
31 this.events = options.events;
32 this.save_widget = options.save_widget;
32 this.save_widget = options.save_widget;
33 this.notebook = options.notebook;
33 this.notebook = options.notebook;
34 this.keyboard_manager = options.keyboard_manager;
34 this.keyboard_manager = options.keyboard_manager;
35 if (this.selector !== undefined) {
35 if (this.selector !== undefined) {
36 this.element = $(selector);
36 this.element = $(selector);
37 }
37 }
38 this.widget_dict = {};
38 this.widget_dict = {};
39 };
39 };
40
40
41 /**
41 /**
42 * Get a widget by name, creating it if it doesn't exist.
42 * Get a widget by name, creating it if it doesn't exist.
43 *
43 *
44 * @method widget
44 * @method widget
45 * @param {string} name - the widget name
45 * @param {string} name - the widget name
46 */
46 */
47 NotificationArea.prototype.widget = function (name) {
47 NotificationArea.prototype.widget = function (name) {
48 if (this.widget_dict[name] === undefined) {
48 if (this.widget_dict[name] === undefined) {
49 return this.new_notification_widget(name);
49 return this.new_notification_widget(name);
50 }
50 }
51 return this.get_widget(name);
51 return this.get_widget(name);
52 };
52 };
53
53
54 /**
54 /**
55 * Get a widget by name, throwing an error if it doesn't exist.
55 * Get a widget by name, throwing an error if it doesn't exist.
56 *
56 *
57 * @method get_widget
57 * @method get_widget
58 * @param {string} name - the widget name
58 * @param {string} name - the widget name
59 */
59 */
60 NotificationArea.prototype.get_widget = function (name) {
60 NotificationArea.prototype.get_widget = function (name) {
61 if(this.widget_dict[name] === undefined) {
61 if(this.widget_dict[name] === undefined) {
62 throw('no widgets with this name');
62 throw('no widgets with this name');
63 }
63 }
64 return this.widget_dict[name];
64 return this.widget_dict[name];
65 };
65 };
66
66
67 /**
67 /**
68 * Create a new notification widget with the given name. The
68 * Create a new notification widget with the given name. The
69 * widget must not already exist.
69 * widget must not already exist.
70 *
70 *
71 * @method new_notification_widget
71 * @method new_notification_widget
72 * @param {string} name - the widget name
72 * @param {string} name - the widget name
73 */
73 */
74 NotificationArea.prototype.new_notification_widget = function (name) {
74 NotificationArea.prototype.new_notification_widget = function (name) {
75 if (this.widget_dict[name] !== undefined) {
75 if (this.widget_dict[name] !== undefined) {
76 throw('widget with that name already exists!');
76 throw('widget with that name already exists!');
77 }
77 }
78
78
79 // create the element for the notification widget and add it
79 // create the element for the notification widget and add it
80 // to the notification aread element
80 // to the notification aread element
81 var div = $('<div/>').attr('id', 'notification_' + name);
81 var div = $('<div/>').attr('id', 'notification_' + name);
82 $(this.selector).append(div);
82 $(this.selector).append(div);
83
83
84 // create the widget object and return it
84 // create the widget object and return it
85 this.widget_dict[name] = new NotificationWidget('#notification_' + name);
85 this.widget_dict[name] = new NotificationWidget('#notification_' + name);
86 return this.widget_dict[name];
86 return this.widget_dict[name];
87 };
87 };
88
88
89 /**
89 /**
90 * Initialize the default set of notification widgets.
90 * Initialize the default set of notification widgets.
91 *
91 *
92 * @method init_notification_widgets
92 * @method init_notification_widgets
93 */
93 */
94 NotificationArea.prototype.init_notification_widgets = function () {
94 NotificationArea.prototype.init_notification_widgets = function () {
95 this.init_kernel_notification_widget();
95 this.init_kernel_notification_widget();
96 this.init_notebook_notification_widget();
96 this.init_notebook_notification_widget();
97 };
97 };
98
98
99 /**
99 /**
100 * Initialize the notification widget for kernel status messages.
100 * Initialize the notification widget for kernel status messages.
101 *
101 *
102 * @method init_kernel_notification_widget
102 * @method init_kernel_notification_widget
103 */
103 */
104 NotificationArea.prototype.init_kernel_notification_widget = function () {
104 NotificationArea.prototype.init_kernel_notification_widget = function () {
105 var that = this;
105 var that = this;
106 var knw = this.new_notification_widget('kernel');
106 var knw = this.new_notification_widget('kernel');
107 var $kernel_ind_icon = $("#kernel_indicator_icon");
107 var $kernel_ind_icon = $("#kernel_indicator_icon");
108 var $modal_ind_icon = $("#modal_indicator_icon");
108 var $modal_ind_icon = $("#modal_indicator_icon");
109
109
110 // Command/Edit mode
110 // Command/Edit mode
111 this.events.on('edit_mode.Notebook', function () {
111 this.events.on('edit_mode.Notebook', function () {
112 that.save_widget.update_document_title();
112 that.save_widget.update_document_title();
113 $modal_ind_icon.attr('class','edit_mode_icon').attr('title','Edit Mode');
113 $modal_ind_icon.attr('class','edit_mode_icon').attr('title','Edit Mode');
114 });
114 });
115
115
116 this.events.on('command_mode.Notebook', function () {
116 this.events.on('command_mode.Notebook', function () {
117 that.save_widget.update_document_title();
117 that.save_widget.update_document_title();
118 $modal_ind_icon.attr('class','command_mode_icon').attr('title','Command Mode');
118 $modal_ind_icon.attr('class','command_mode_icon').attr('title','Command Mode');
119 });
119 });
120
120
121 // Implicitly start off in Command mode, switching to Edit mode will trigger event
121 // Implicitly start off in Command mode, switching to Edit mode will trigger event
122 $modal_ind_icon.attr('class','command_mode_icon').attr('title','Command Mode');
122 $modal_ind_icon.attr('class','command_mode_icon').attr('title','Command Mode');
123
123
124 // Kernel events
124 // Kernel events
125
125
126 // this can be either kernel_created.Kernel or kernel_created.Session
126 // this can be either kernel_created.Kernel or kernel_created.Session
127 this.events.on('kernel_created.Kernel kernel_created.Session', function () {
127 this.events.on('kernel_created.Kernel kernel_created.Session', function () {
128 knw.info("Kernel Created", 500);
128 knw.info("Kernel Created", 500);
129 });
129 });
130
130
131 this.events.on('kernel_reconnecting.Kernel', function () {
131 this.events.on('kernel_reconnecting.Kernel', function () {
132 knw.warning("Connecting to kernel");
132 knw.warning("Connecting to kernel");
133 });
133 });
134
134
135 this.events.on('kernel_connection_dead.Kernel', function (evt, info) {
135 this.events.on('kernel_connection_dead.Kernel', function (evt, info) {
136 knw.danger("Connection lost", undefined, function () {
136 knw.danger("Not Connected", undefined, function () {
137 // schedule reconnect a short time in the future, don't reconnect immediately
137 // schedule reconnect a short time in the future, don't reconnect immediately
138 setTimeout($.proxy(info.kernel.reconnect, info.kernel), 500);
138 setTimeout($.proxy(info.kernel.reconnect, info.kernel), 500);
139 }, {title: 'click to reconnect'});
139 }, {title: 'click to reconnect'});
140 });
140 });
141
141
142 this.events.on('kernel_connected.Kernel', function () {
142 this.events.on('kernel_connected.Kernel', function () {
143 knw.info("Connected", 500);
143 knw.info("Connected", 500);
144 });
144 });
145
145
146 this.events.on('kernel_restarting.Kernel', function () {
146 this.events.on('kernel_restarting.Kernel', function () {
147 that.save_widget.update_document_title();
147 that.save_widget.update_document_title();
148 knw.set_message("Restarting kernel", 2000);
148 knw.set_message("Restarting kernel", 2000);
149 });
149 });
150
150
151 this.events.on('kernel_autorestarting.Kernel', function (evt, info) {
151 this.events.on('kernel_autorestarting.Kernel', function (evt, info) {
152 // Only show the dialog on the first restart attempt. This
152 // Only show the dialog on the first restart attempt. This
153 // number gets tracked by the `Kernel` object and passed
153 // number gets tracked by the `Kernel` object and passed
154 // along here, because we don't want to show the user 5
154 // along here, because we don't want to show the user 5
155 // dialogs saying the same thing (which is the number of
155 // dialogs saying the same thing (which is the number of
156 // times it tries restarting).
156 // times it tries restarting).
157 if (info.attempt === 1) {
157 if (info.attempt === 1) {
158
158
159 dialog.kernel_modal({
159 dialog.kernel_modal({
160 notebook: that.notebook,
160 notebook: that.notebook,
161 keyboard_manager: that.keyboard_manager,
161 keyboard_manager: that.keyboard_manager,
162 title: "Kernel Restarting",
162 title: "Kernel Restarting",
163 body: "The kernel appears to have died. It will restart automatically.",
163 body: "The kernel appears to have died. It will restart automatically.",
164 buttons: {
164 buttons: {
165 OK : {
165 OK : {
166 class : "btn-primary"
166 class : "btn-primary"
167 }
167 }
168 }
168 }
169 });
169 });
170 };
170 };
171
171
172 that.save_widget.update_document_title();
172 that.save_widget.update_document_title();
173 knw.danger("Dead kernel");
173 knw.danger("Dead kernel");
174 $kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
174 $kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
175 });
175 });
176
176
177 this.events.on('kernel_interrupting.Kernel', function () {
177 this.events.on('kernel_interrupting.Kernel', function () {
178 knw.set_message("Interrupting kernel", 2000);
178 knw.set_message("Interrupting kernel", 2000);
179 });
179 });
180
180
181 this.events.on('kernel_disconnected.Kernel', function () {
181 this.events.on('kernel_disconnected.Kernel', function () {
182 $kernel_ind_icon
182 $kernel_ind_icon
183 .attr('class', 'kernel_disconnected_icon')
183 .attr('class', 'kernel_disconnected_icon')
184 .attr('title', 'No Connection to Kernel');
184 .attr('title', 'No Connection to Kernel');
185 });
185 });
186
186
187 this.events.on('kernel_connection_failed.Kernel', function (evt, info) {
187 this.events.on('kernel_connection_failed.Kernel', function (evt, info) {
188 // only show the dialog if this is the first failed
188 // only show the dialog if this is the first failed
189 // connect attempt, because the kernel will continue
189 // connect attempt, because the kernel will continue
190 // trying to reconnect and we don't want to spam the user
190 // trying to reconnect and we don't want to spam the user
191 // with messages
191 // with messages
192 if (info.attempt === 1) {
192 if (info.attempt === 1) {
193
193
194 var msg = "A connection to the notebook server could not be established." +
194 var msg = "A connection to the notebook server could not be established." +
195 " The notebook will continue trying to reconnect, but" +
195 " The notebook will continue trying to reconnect, but" +
196 " until it does, you will NOT be able to run code. Check your" +
196 " until it does, you will NOT be able to run code. Check your" +
197 " network connection or notebook server configuration.";
197 " network connection or notebook server configuration.";
198
198
199 dialog.kernel_modal({
199 dialog.kernel_modal({
200 title: "Connection failed",
200 title: "Connection failed",
201 body: msg,
201 body: msg,
202 keyboard_manager: that.keyboard_manager,
202 keyboard_manager: that.keyboard_manager,
203 notebook: that.notebook,
203 notebook: that.notebook,
204 buttons : {
204 buttons : {
205 "OK": {}
205 "OK": {}
206 }
206 }
207 });
207 });
208 }
208 }
209 });
209 });
210
210
211 this.events.on('kernel_killed.Kernel kernel_killed.Session', function () {
211 this.events.on('kernel_killed.Kernel kernel_killed.Session', function () {
212 that.save_widget.update_document_title();
212 that.save_widget.update_document_title();
213 knw.danger("Dead kernel");
213 knw.danger("Dead kernel");
214 $kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
214 $kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
215 });
215 });
216
216
217 this.events.on('kernel_dead.Kernel', function () {
217 this.events.on('kernel_dead.Kernel', function () {
218
218
219 var showMsg = function () {
219 var showMsg = function () {
220
220
221 var msg = 'The kernel has died, and the automatic restart has failed.' +
221 var msg = 'The kernel has died, and the automatic restart has failed.' +
222 ' It is possible the kernel cannot be restarted.' +
222 ' It is possible the kernel cannot be restarted.' +
223 ' If you are not able to restart the kernel, you will still be able to save' +
223 ' If you are not able to restart the kernel, you will still be able to save' +
224 ' the notebook, but running code will no longer work until the notebook' +
224 ' the notebook, but running code will no longer work until the notebook' +
225 ' is reopened.';
225 ' is reopened.';
226
226
227 dialog.kernel_modal({
227 dialog.kernel_modal({
228 title: "Dead kernel",
228 title: "Dead kernel",
229 body : msg,
229 body : msg,
230 keyboard_manager: that.keyboard_manager,
230 keyboard_manager: that.keyboard_manager,
231 notebook: that.notebook,
231 notebook: that.notebook,
232 buttons : {
232 buttons : {
233 "Manual Restart": {
233 "Manual Restart": {
234 class: "btn-danger",
234 class: "btn-danger",
235 click: function () {
235 click: function () {
236 that.notebook.start_session();
236 that.notebook.start_session();
237 }
237 }
238 },
238 },
239 "Don't restart": {}
239 "Don't restart": {}
240 }
240 }
241 });
241 });
242
242
243 return false;
243 return false;
244 };
244 };
245
245
246 that.save_widget.update_document_title();
246 that.save_widget.update_document_title();
247 knw.danger("Dead kernel", undefined, showMsg);
247 knw.danger("Dead kernel", undefined, showMsg);
248 $kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
248 $kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
249
249
250 showMsg();
250 showMsg();
251 });
251 });
252
252
253 this.events.on('kernel_dead.Session', function (evt, info) {
253 this.events.on('kernel_dead.Session', function (evt, info) {
254 var full = info.xhr.responseJSON.message;
254 var full = info.xhr.responseJSON.message;
255 var short = info.xhr.responseJSON.short_message || 'Kernel error';
255 var short = info.xhr.responseJSON.short_message || 'Kernel error';
256 var traceback = info.xhr.responseJSON.traceback;
256 var traceback = info.xhr.responseJSON.traceback;
257
257
258 var showMsg = function () {
258 var showMsg = function () {
259 var msg = $('<div/>').append($('<p/>').text(full));
259 var msg = $('<div/>').append($('<p/>').text(full));
260 var cm, cm_elem, cm_open;
260 var cm, cm_elem, cm_open;
261
261
262 if (traceback) {
262 if (traceback) {
263 cm_elem = $('<div/>')
263 cm_elem = $('<div/>')
264 .css('margin-top', '1em')
264 .css('margin-top', '1em')
265 .css('padding', '1em')
265 .css('padding', '1em')
266 .addClass('output_scroll');
266 .addClass('output_scroll');
267 msg.append(cm_elem);
267 msg.append(cm_elem);
268 cm = CodeMirror(cm_elem.get(0), {
268 cm = CodeMirror(cm_elem.get(0), {
269 mode: "python",
269 mode: "python",
270 readOnly : true
270 readOnly : true
271 });
271 });
272 cm.setValue(traceback);
272 cm.setValue(traceback);
273 cm_open = $.proxy(cm.refresh, cm);
273 cm_open = $.proxy(cm.refresh, cm);
274 }
274 }
275
275
276 dialog.kernel_modal({
276 dialog.kernel_modal({
277 title: "Failed to start the kernel",
277 title: "Failed to start the kernel",
278 body : msg,
278 body : msg,
279 keyboard_manager: that.keyboard_manager,
279 keyboard_manager: that.keyboard_manager,
280 notebook: that.notebook,
280 notebook: that.notebook,
281 open: cm_open,
281 open: cm_open,
282 buttons : {
282 buttons : {
283 "Ok": { class: 'btn-primary' }
283 "Ok": { class: 'btn-primary' }
284 }
284 }
285 });
285 });
286
286
287 return false;
287 return false;
288 };
288 };
289
289
290 that.save_widget.update_document_title();
290 that.save_widget.update_document_title();
291 $kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
291 $kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
292 knw.danger(short, undefined, showMsg);
292 knw.danger(short, undefined, showMsg);
293 });
293 });
294
294
295 this.events.on('kernel_starting.Kernel', function () {
295 this.events.on('kernel_starting.Kernel', function () {
296 window.document.title='(Starting) '+window.document.title;
296 window.document.title='(Starting) '+window.document.title;
297 $kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
297 $kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
298 knw.set_message("Kernel starting, please wait...");
298 knw.set_message("Kernel starting, please wait...");
299 });
299 });
300
300
301 this.events.on('kernel_ready.Kernel', function () {
301 this.events.on('kernel_ready.Kernel', function () {
302 that.save_widget.update_document_title();
302 that.save_widget.update_document_title();
303 $kernel_ind_icon.attr('class','kernel_idle_icon').attr('title','Kernel Idle');
303 $kernel_ind_icon.attr('class','kernel_idle_icon').attr('title','Kernel Idle');
304 knw.info("Kernel ready", 500);
304 knw.info("Kernel ready", 500);
305 });
305 });
306
306
307 this.events.on('kernel_idle.Kernel', function () {
307 this.events.on('kernel_idle.Kernel', function () {
308 that.save_widget.update_document_title();
308 that.save_widget.update_document_title();
309 $kernel_ind_icon.attr('class','kernel_idle_icon').attr('title','Kernel Idle');
309 $kernel_ind_icon.attr('class','kernel_idle_icon').attr('title','Kernel Idle');
310 });
310 });
311
311
312 this.events.on('kernel_busy.Kernel', function () {
312 this.events.on('kernel_busy.Kernel', function () {
313 window.document.title='(Busy) '+window.document.title;
313 window.document.title='(Busy) '+window.document.title;
314 $kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
314 $kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
315 });
315 });
316
316
317 // Start the kernel indicator in the busy state, and send a kernel_info request.
317 // Start the kernel indicator in the busy state, and send a kernel_info request.
318 // When the kernel_info reply arrives, the kernel is idle.
318 // When the kernel_info reply arrives, the kernel is idle.
319 $kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
319 $kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
320 };
320 };
321
321
322 /**
322 /**
323 * Initialize the notification widget for notebook status messages.
323 * Initialize the notification widget for notebook status messages.
324 *
324 *
325 * @method init_notebook_notification_widget
325 * @method init_notebook_notification_widget
326 */
326 */
327 NotificationArea.prototype.init_notebook_notification_widget = function () {
327 NotificationArea.prototype.init_notebook_notification_widget = function () {
328 var nnw = this.new_notification_widget('notebook');
328 var nnw = this.new_notification_widget('notebook');
329
329
330 // Notebook events
330 // Notebook events
331 this.events.on('notebook_loading.Notebook', function () {
331 this.events.on('notebook_loading.Notebook', function () {
332 nnw.set_message("Loading notebook",500);
332 nnw.set_message("Loading notebook",500);
333 });
333 });
334 this.events.on('notebook_loaded.Notebook', function () {
334 this.events.on('notebook_loaded.Notebook', function () {
335 nnw.set_message("Notebook loaded",500);
335 nnw.set_message("Notebook loaded",500);
336 });
336 });
337 this.events.on('notebook_saving.Notebook', function () {
337 this.events.on('notebook_saving.Notebook', function () {
338 nnw.set_message("Saving notebook",500);
338 nnw.set_message("Saving notebook",500);
339 });
339 });
340 this.events.on('notebook_saved.Notebook', function () {
340 this.events.on('notebook_saved.Notebook', function () {
341 nnw.set_message("Notebook saved",2000);
341 nnw.set_message("Notebook saved",2000);
342 });
342 });
343 this.events.on('notebook_save_failed.Notebook', function (evt, xhr, status, data) {
343 this.events.on('notebook_save_failed.Notebook', function (evt, xhr, status, data) {
344 nnw.warning(data || "Notebook save failed");
344 nnw.warning(data || "Notebook save failed");
345 });
345 });
346
346
347 // Checkpoint events
347 // Checkpoint events
348 this.events.on('checkpoint_created.Notebook', function (evt, data) {
348 this.events.on('checkpoint_created.Notebook', function (evt, data) {
349 var msg = "Checkpoint created";
349 var msg = "Checkpoint created";
350 if (data.last_modified) {
350 if (data.last_modified) {
351 var d = new Date(data.last_modified);
351 var d = new Date(data.last_modified);
352 msg = msg + ": " + moment(d).format("HH:mm:ss");
352 msg = msg + ": " + moment(d).format("HH:mm:ss");
353 }
353 }
354 nnw.set_message(msg, 2000);
354 nnw.set_message(msg, 2000);
355 });
355 });
356 this.events.on('checkpoint_failed.Notebook', function () {
356 this.events.on('checkpoint_failed.Notebook', function () {
357 nnw.warning("Checkpoint failed");
357 nnw.warning("Checkpoint failed");
358 });
358 });
359 this.events.on('checkpoint_deleted.Notebook', function () {
359 this.events.on('checkpoint_deleted.Notebook', function () {
360 nnw.set_message("Checkpoint deleted", 500);
360 nnw.set_message("Checkpoint deleted", 500);
361 });
361 });
362 this.events.on('checkpoint_delete_failed.Notebook', function () {
362 this.events.on('checkpoint_delete_failed.Notebook', function () {
363 nnw.warning("Checkpoint delete failed");
363 nnw.warning("Checkpoint delete failed");
364 });
364 });
365 this.events.on('checkpoint_restoring.Notebook', function () {
365 this.events.on('checkpoint_restoring.Notebook', function () {
366 nnw.set_message("Restoring to checkpoint...", 500);
366 nnw.set_message("Restoring to checkpoint...", 500);
367 });
367 });
368 this.events.on('checkpoint_restore_failed.Notebook', function () {
368 this.events.on('checkpoint_restore_failed.Notebook', function () {
369 nnw.warning("Checkpoint restore failed");
369 nnw.warning("Checkpoint restore failed");
370 });
370 });
371
371
372 // Autosave events
372 // Autosave events
373 this.events.on('autosave_disabled.Notebook', function () {
373 this.events.on('autosave_disabled.Notebook', function () {
374 nnw.set_message("Autosave disabled", 2000);
374 nnw.set_message("Autosave disabled", 2000);
375 });
375 });
376 this.events.on('autosave_enabled.Notebook', function (evt, interval) {
376 this.events.on('autosave_enabled.Notebook', function (evt, interval) {
377 nnw.set_message("Saving every " + interval / 1000 + "s", 1000);
377 nnw.set_message("Saving every " + interval / 1000 + "s", 1000);
378 });
378 });
379 };
379 };
380
380
381 IPython.NotificationArea = NotificationArea;
381 IPython.NotificationArea = NotificationArea;
382
382
383 return {'NotificationArea': NotificationArea};
383 return {'NotificationArea': NotificationArea};
384 });
384 });
General Comments 0
You need to be logged in to leave comments. Login now