Skip to content

Commit 3a10efa

Browse files
author
Stephen Brennan
committed
Renaming and url fixes within notify extension.
1 parent 13f88a0 commit 3a10efa

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/jupyter_contrib_nbextensions/nbextensions/notify/notify.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ define([
1212
"jquery",
1313
"base/js/namespace",
1414
"require",
15-
], function ($, IPython, require) {
15+
], function ($, Jupyter, require) {
1616
"use strict";
1717

1818
var params = {
1919
sticky: false,
20-
sound: false
20+
play_sound: false
2121
};
2222

2323
var current_time = function() {
@@ -63,7 +63,7 @@ define([
6363

6464
var add_permissions_button = function () {
6565
if ($("#permissions-button").length === 0) {
66-
IPython.toolbar.add_buttons_group([
66+
Jupyter.toolbar.add_buttons_group([
6767
{
6868
'label' : 'Grant Notification Permissions',
6969
'icon' : 'fa-check',
@@ -106,13 +106,13 @@ define([
106106
if (enabled && !first_start && !busy_kernel && elapsed_time >= min_time) {
107107
var opts = {
108108
body: "Kernel is now idle\n(ran for " + Math.round(elapsed_time) + " secs)",
109-
icon: "/static/base/images/favicon.ico",
109+
icon: Jupyter.notebook.base_url + "static/base/images/favicon.ico",
110110
requireInteraction: params.sticky
111111
};
112112
if (params.sound) {
113113
opts["sound"] = require.toUrl("./notify.mp3");
114114
}
115-
var n = new Notification(IPython.notebook.notebook_name, opts);
115+
var n = new Notification(Jupyter.notebook.notebook_name, opts);
116116
n.onclick = function(event){ window.focus(); }
117117
}
118118
if (first_start) {
@@ -121,24 +121,24 @@ define([
121121
};
122122

123123
var load_state = function () {
124-
if (!IPython.notebook) return;
124+
if (!Jupyter.notebook) return;
125125

126-
if ("notify_time" in IPython.notebook.metadata) {
127-
min_time = IPython.notebook.metadata.notify_time;
126+
if ("notify_time" in Jupyter.notebook.metadata) {
127+
min_time = Jupyter.notebook.metadata.notify_time;
128128
enabled = true;
129129
}
130130
};
131131

132132
var save_state = function () {
133133
if (enabled) {
134-
if (IPython.notebook.metadata.notify_time !== min_time) {
135-
IPython.notebook.metadata.notify_time = min_time;
136-
IPython.notebook.set_dirty();
134+
if (Jupyter.notebook.metadata.notify_time !== min_time) {
135+
Jupyter.notebook.metadata.notify_time = min_time;
136+
Jupyter.notebook.set_dirty();
137137
}
138138
} else {
139-
if (IPython.notebook.metadata.hasOwnProperty('notify_time')) {
140-
delete IPython.notebook.metadata.notify_time;
141-
IPython.notebook.set_dirty();
139+
if (Jupyter.notebook.metadata.hasOwnProperty('notify_time')) {
140+
delete Jupyter.notebook.metadata.notify_time;
141+
Jupyter.notebook.set_dirty();
142142
}
143143
}
144144
};
@@ -156,16 +156,16 @@ define([
156156
};
157157

158158
var setup_notifier = function () {
159-
$([IPython.events]).on('kernel_starting.Kernel',function () {
159+
$([Jupyter.events]).on('kernel_starting.Kernel',function () {
160160
first_start = true; // reset first_start status when restarting the kernel
161161
});
162162

163-
$([IPython.events]).on('kernel_busy.Kernel',function () {
163+
$([Jupyter.events]).on('kernel_busy.Kernel',function () {
164164
busy_kernel = true;
165165
start_time = current_time(); // reset the timer
166166
});
167167

168-
$([IPython.events]).on('kernel_idle.Kernel',function () {
168+
$([Jupyter.events]).on('kernel_idle.Kernel',function () {
169169
busy_kernel = false; // Used to make sure that kernel doesn't go busy again within the timeout set below.
170170
setTimeout(notify, 500);
171171
});

src/jupyter_contrib_nbextensions/nbextensions/notify/notify.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Parameters:
1212
description: Require interactions on notifications to dismiss them. (Chrome only)
1313
input_type: checkbox
1414
default: false
15-
- name: notify.sound
15+
- name: notify.play_sound
1616
description: Play notification sound. (Not yet supported in browsers)
1717
input_type: checkbox
1818
default: false

0 commit comments

Comments
 (0)