mirror of
https://github.com/wassname/jupyter_contrib_nbextensions.git
synced 2026-06-27 16:10:24 +08:00
Renaming and url fixes within notify extension.
This commit is contained in:
@@ -12,12 +12,12 @@ define([
|
||||
"jquery",
|
||||
"base/js/namespace",
|
||||
"require",
|
||||
], function ($, IPython, require) {
|
||||
], function ($, Jupyter, require) {
|
||||
"use strict";
|
||||
|
||||
var params = {
|
||||
sticky: false,
|
||||
sound: false
|
||||
play_sound: false
|
||||
};
|
||||
|
||||
var current_time = function() {
|
||||
@@ -63,7 +63,7 @@ define([
|
||||
|
||||
var add_permissions_button = function () {
|
||||
if ($("#permissions-button").length === 0) {
|
||||
IPython.toolbar.add_buttons_group([
|
||||
Jupyter.toolbar.add_buttons_group([
|
||||
{
|
||||
'label' : 'Grant Notification Permissions',
|
||||
'icon' : 'fa-check',
|
||||
@@ -106,13 +106,13 @@ define([
|
||||
if (enabled && !first_start && !busy_kernel && elapsed_time >= min_time) {
|
||||
var opts = {
|
||||
body: "Kernel is now idle\n(ran for " + Math.round(elapsed_time) + " secs)",
|
||||
icon: "/static/base/images/favicon.ico",
|
||||
icon: Jupyter.notebook.base_url + "static/base/images/favicon.ico",
|
||||
requireInteraction: params.sticky
|
||||
};
|
||||
if (params.sound) {
|
||||
opts["sound"] = require.toUrl("./notify.mp3");
|
||||
}
|
||||
var n = new Notification(IPython.notebook.notebook_name, opts);
|
||||
var n = new Notification(Jupyter.notebook.notebook_name, opts);
|
||||
n.onclick = function(event){ window.focus(); }
|
||||
}
|
||||
if (first_start) {
|
||||
@@ -121,24 +121,24 @@ define([
|
||||
};
|
||||
|
||||
var load_state = function () {
|
||||
if (!IPython.notebook) return;
|
||||
if (!Jupyter.notebook) return;
|
||||
|
||||
if ("notify_time" in IPython.notebook.metadata) {
|
||||
min_time = IPython.notebook.metadata.notify_time;
|
||||
if ("notify_time" in Jupyter.notebook.metadata) {
|
||||
min_time = Jupyter.notebook.metadata.notify_time;
|
||||
enabled = true;
|
||||
}
|
||||
};
|
||||
|
||||
var save_state = function () {
|
||||
if (enabled) {
|
||||
if (IPython.notebook.metadata.notify_time !== min_time) {
|
||||
IPython.notebook.metadata.notify_time = min_time;
|
||||
IPython.notebook.set_dirty();
|
||||
if (Jupyter.notebook.metadata.notify_time !== min_time) {
|
||||
Jupyter.notebook.metadata.notify_time = min_time;
|
||||
Jupyter.notebook.set_dirty();
|
||||
}
|
||||
} else {
|
||||
if (IPython.notebook.metadata.hasOwnProperty('notify_time')) {
|
||||
delete IPython.notebook.metadata.notify_time;
|
||||
IPython.notebook.set_dirty();
|
||||
if (Jupyter.notebook.metadata.hasOwnProperty('notify_time')) {
|
||||
delete Jupyter.notebook.metadata.notify_time;
|
||||
Jupyter.notebook.set_dirty();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -156,16 +156,16 @@ define([
|
||||
};
|
||||
|
||||
var setup_notifier = function () {
|
||||
$([IPython.events]).on('kernel_starting.Kernel',function () {
|
||||
$([Jupyter.events]).on('kernel_starting.Kernel',function () {
|
||||
first_start = true; // reset first_start status when restarting the kernel
|
||||
});
|
||||
|
||||
$([IPython.events]).on('kernel_busy.Kernel',function () {
|
||||
$([Jupyter.events]).on('kernel_busy.Kernel',function () {
|
||||
busy_kernel = true;
|
||||
start_time = current_time(); // reset the timer
|
||||
});
|
||||
|
||||
$([IPython.events]).on('kernel_idle.Kernel',function () {
|
||||
$([Jupyter.events]).on('kernel_idle.Kernel',function () {
|
||||
busy_kernel = false; // Used to make sure that kernel doesn't go busy again within the timeout set below.
|
||||
setTimeout(notify, 500);
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ Parameters:
|
||||
description: Require interactions on notifications to dismiss them. (Chrome only)
|
||||
input_type: checkbox
|
||||
default: false
|
||||
- name: notify.sound
|
||||
- name: notify.play_sound
|
||||
description: Play notification sound. (Not yet supported in browsers)
|
||||
input_type: checkbox
|
||||
default: false
|
||||
|
||||
Reference in New Issue
Block a user