Skip to content

Commit cb88603

Browse files
authored
Merge pull request #1837 from gnestor/busy-favicon
Change favicon when busy
2 parents a05fe51 + b5cff95 commit cb88603

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed
31.3 KB
Binary file not shown.

notebook/static/notebook/js/notificationarea.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,27 +242,42 @@ define([
242242
$kernel_ind_icon.attr('class','kernel_dead_icon').attr('title','Kernel Dead');
243243
knw.danger(short, undefined, showMsg);
244244
});
245+
246+
var change_favicon = function (src) {
247+
var link = document.createElement('link'),
248+
oldLink = document.getElementById('favicon');
249+
link.id = 'favicon';
250+
link.type = 'image/x-icon';
251+
link.rel = 'shortcut icon';
252+
link.href = src;
253+
if (oldLink) document.head.removeChild(oldLink);
254+
document.head.appendChild(link);
255+
};
245256

246257
this.events.on('kernel_starting.Kernel kernel_created.Session', function () {
247-
window.document.title='(Starting) '+window.document.title;
258+
// window.document.title='(Starting) '+window.document.title;
248259
$kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
249260
knw.set_message("Kernel starting, please wait...");
261+
change_favicon('/static/base/images/favicon-busy.ico');
250262
});
251263

252264
this.events.on('kernel_ready.Kernel', function () {
253-
that.save_widget.update_document_title();
265+
// that.save_widget.update_document_title();
254266
$kernel_ind_icon.attr('class','kernel_idle_icon').attr('title','Kernel Idle');
255267
knw.info("Kernel ready", 500);
268+
change_favicon('/static/base/images/favicon.ico');
256269
});
257270

258271
this.events.on('kernel_idle.Kernel', function () {
259-
that.save_widget.update_document_title();
272+
// that.save_widget.update_document_title();
260273
$kernel_ind_icon.attr('class','kernel_idle_icon').attr('title','Kernel Idle');
274+
change_favicon('/static/base/images/favicon.ico');
261275
});
262276

263277
this.events.on('kernel_busy.Kernel', function () {
264-
window.document.title='(Busy) '+window.document.title;
278+
// window.document.title='(Busy) '+window.document.title;
265279
$kernel_ind_icon.attr('class','kernel_busy_icon').attr('title','Kernel Busy');
280+
change_favicon('/static/base/images/favicon-busy.ico');
266281
});
267282

268283
this.events.on('spec_match_found.Kernel', function (evt, data) {

notebook/templates/page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="utf-8">
66

77
<title>{% block title %}Jupyter Notebook{% endblock %}</title>
8-
{% block favicon %}<link rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon.ico") }}">{% endblock %}
8+
{% block favicon %}<link id="favicon" rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon.ico") }}">{% endblock %}
99
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
1010
<link rel="stylesheet" href="{{static_url("components/jquery-ui/themes/smoothness/jquery-ui.min.css") }}" type="text/css" />
1111
<link rel="stylesheet" href="{{static_url("components/jquery-typeahead/dist/jquery.typeahead.min.css") }}" type="text/css" />

0 commit comments

Comments
 (0)