Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50659 views
1
//----------------------------------------------------------------------------
2
// Copyright (C) 2008-2011 The IPython Development Team
3
//
4
// Distributed under the terms of the BSD License. The full license is in
5
// the file COPYING, distributed as part of this software.
6
//----------------------------------------------------------------------------
7
8
//============================================================================
9
// On document ready
10
//============================================================================
11
12
13
$(document).ready(function () {
14
15
IPython.page = new IPython.Page();
16
17
$('#new_notebook').button().click(function (e) {
18
IPython.notebook_list.new_notebook()
19
});
20
21
var opts = {
22
base_url : IPython.utils.get_body_data("baseUrl"),
23
notebook_path : IPython.utils.get_body_data("notebookPath"),
24
};
25
IPython.session_list = new IPython.SesssionList(opts);
26
IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts);
27
IPython.cluster_list = new IPython.ClusterList('#cluster_list', opts);
28
IPython.kernel_list = new IPython.KernelList('#running_list', opts);
29
IPython.login_widget = new IPython.LoginWidget('#login_widget', opts);
30
31
var interval_id=0;
32
// auto refresh every xx secondes, no need to be fast,
33
// update is done at least when page get focus
34
var time_refresh = 60; // in sec
35
36
var enable_autorefresh = function(){
37
//refresh immediately , then start interval
38
if($('.upload_button').length == 0)
39
{
40
IPython.session_list.load_sessions();
41
IPython.cluster_list.load_list();
42
}
43
if (!interval_id){
44
interval_id = setInterval(function(){
45
if($('.upload_button').length == 0)
46
{
47
IPython.session_list.load_sessions();
48
IPython.cluster_list.load_list();
49
}
50
}, time_refresh*1000);
51
}
52
}
53
54
var disable_autorefresh = function(){
55
clearInterval(interval_id);
56
interval_id = 0;
57
}
58
59
// stop autorefresh when page lose focus
60
$(window).blur(function() {
61
disable_autorefresh();
62
})
63
64
//re-enable when page get focus back
65
$(window).focus(function() {
66
enable_autorefresh();
67
});
68
69
// finally start it, it will refresh immediately
70
enable_autorefresh();
71
72
IPython.page.show();
73
74
// bound the upload method to the on change of the file select list
75
$("#alternate_upload").change(function (event){
76
IPython.notebook_list.handleFilesUpload(event,'form');
77
});
78
79
// set hash on tab click
80
$("#tabs").find("a").click(function() {
81
window.location.hash = $(this).attr("href");
82
})
83
84
// load tab if url hash
85
if (window.location.hash) {
86
$("#tabs").find("a[href=" + window.location.hash + "]").click();
87
}
88
89
90
});
91
92
93