Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ define([
) {
'use strict';

var mod_name = 'ExecuteTime';
var log_prefix = '[' + mod_name + ']';

var CodeCell = codecell.CodeCell;

function patch_CodeCell_get_callbacks () {
console.log('[ExecuteTime] patching CodeCell.prototype.get_callbacks to insert an ExecuteTime shell.reply callback');
console.log(log_prefix, 'patching CodeCell.prototype.get_callbacks to insert an ExecuteTime shell.reply callback');
var old_get_callbacks = CodeCell.prototype.get_callbacks;
CodeCell.prototype.get_callbacks = function () {
var callbacks = old_get_callbacks.apply(this, arguments);
Expand Down Expand Up @@ -201,6 +204,11 @@ define([
return timing_area;
}

function update_all_timing_areas () {
console.log(log_prefix, 'updating all timing areas');
Jupyter.notebook.get_cells().forEach(update_timing_area);
}

function add_css(url) {
$('<link/>')
.attr({
Expand All @@ -214,14 +222,13 @@ define([
function load_jupyter_extension () {
// try to load jquery-ui
if ($.ui === undefined) {
require('jquery-ui', function ($) {}, function (err) {
require(['jquery-ui'], function ($) {}, function (err) {
// try to load using the older, non-standard name (without hyphen)
require(['jqueryui'], function ($) {}, function (err) {});
require(['jqueryui'], function ($) {}, function (err) {
console.log(log_prefix, 'couldn\'t find jquery-ui, so no animations');
});
});
}
if ($.ui === undefined) {
console.log('[ExecuteTime] couldn\'t find jquery-ui, so no animations');
}

add_css('./ExecuteTime.css');

Expand All @@ -231,7 +238,11 @@ define([
create_menu();

// add any existing timing info
Jupyter.notebook.get_cells().forEach(update_timing_area);
events.on("notebook_loaded.Notebook", update_all_timing_areas);
if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
// notebook already loaded, so we missed the event, so update all
update_all_timing_areas();
}
}

return {
Expand Down