@@ -40,6 +40,23 @@ define([
40
40
var $modal_ind_icon = $ ( "#modal_indicator" ) ;
41
41
var $readonly_ind_icon = $ ( '#readonly-indicator' ) ;
42
42
var $body = $ ( 'body' ) ;
43
+ var interval = 0 ;
44
+
45
+ var set_busy_favicon = function ( on ) {
46
+ if ( on && ! interval ) {
47
+ var i = 0 ;
48
+ var icons = [ 'favicon-busy-1.ico' , 'favicon-busy-3.ico' , 'favicon-busy-3.ico' ] ;
49
+ interval = setInterval ( function ( ) {
50
+ var icon = icons [ i % 3 ] ;
51
+ utils . change_favicon ( '/static/base/images/' + icon ) ;
52
+ i += 1 ;
53
+ } , 300 ) ;
54
+ } else {
55
+ clearInterval ( interval ) ;
56
+ utils . change_favicon ( '/static/base/images/favicon-notebook.ico' ) ;
57
+ interval = 0 ;
58
+ }
59
+ } ;
43
60
44
61
// Listen for the notebook loaded event. Set readonly indicator.
45
62
this . events . on ( 'notebook_loaded.Notebook' , function ( ) {
@@ -244,41 +261,30 @@ define([
244
261
knw . danger ( short , undefined , showMsg ) ;
245
262
} ) ;
246
263
247
- var change_favicon = function ( src ) {
248
- var link = document . createElement ( 'link' ) ,
249
- oldLink = document . getElementById ( 'favicon' ) ;
250
- link . id = 'favicon' ;
251
- link . type = 'image/x-icon' ;
252
- link . rel = 'shortcut icon' ;
253
- link . href = utils . url_path_join ( utils . get_body_data ( 'baseUrl' ) , src ) ;
254
- if ( oldLink ) document . head . removeChild ( oldLink ) ;
255
- document . head . appendChild ( link ) ;
256
- } ;
257
-
258
264
this . events . on ( 'kernel_starting.Kernel kernel_created.Session' , function ( ) {
259
265
// window.document.title='(Starting) '+window.document.title;
260
266
$kernel_ind_icon . attr ( 'class' , 'kernel_busy_icon' ) . attr ( 'title' , 'Kernel Busy' ) ;
261
267
knw . set_message ( "Kernel starting, please wait..." ) ;
262
- change_favicon ( '/static/base/images/favicon-busy.ico' ) ;
268
+ set_busy_favicon ( true ) ;
263
269
} ) ;
264
270
265
271
this . events . on ( 'kernel_ready.Kernel' , function ( ) {
266
272
// that.save_widget.update_document_title();
267
273
$kernel_ind_icon . attr ( 'class' , 'kernel_idle_icon' ) . attr ( 'title' , 'Kernel Idle' ) ;
268
274
knw . info ( "Kernel ready" , 500 ) ;
269
- change_favicon ( '/static/base/images/favicon.ico' ) ;
275
+ set_busy_favicon ( false ) ;
270
276
} ) ;
271
277
272
278
this . events . on ( 'kernel_idle.Kernel' , function ( ) {
273
279
// that.save_widget.update_document_title();
274
280
$kernel_ind_icon . attr ( 'class' , 'kernel_idle_icon' ) . attr ( 'title' , 'Kernel Idle' ) ;
275
- change_favicon ( '/static/base/images/favicon.ico' ) ;
281
+ set_busy_favicon ( false ) ;
276
282
} ) ;
277
283
278
284
this . events . on ( 'kernel_busy.Kernel' , function ( ) {
279
285
// window.document.title='(Busy) '+window.document.title;
280
286
$kernel_ind_icon . attr ( 'class' , 'kernel_busy_icon' ) . attr ( 'title' , 'Kernel Busy' ) ;
281
- change_favicon ( '/static/base/images/favicon-busy.ico' ) ;
287
+ set_busy_favicon ( true ) ;
282
288
} ) ;
283
289
284
290
this . events . on ( 'spec_match_found.Kernel' , function ( evt , data ) {
0 commit comments