##// END OF EJS Templates
dashboard autorefresh...
Matthias BUSSONNIER -
Show More
@@ -1,42 +1,75
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // On document ready
9 // On document ready
10 //============================================================================
10 //============================================================================
11
11
12
12
13 $(document).ready(function () {
13 $(document).ready(function () {
14
14
15 IPython.page = new IPython.Page();
15 IPython.page = new IPython.Page();
16
16
17 $('div#tabs').tabs();
17 $('div#tabs').tabs();
18 $('div#tabs').on('tabsselect', function (event, ui) {
18 $('div#tabs').on('tabsselect', function (event, ui) {
19 var new_url = $('body').data('baseProjectUrl') + '#' + ui.panel.id;
19 var new_url = $('body').data('baseProjectUrl') + '#' + ui.panel.id;
20 window.history.replaceState({}, '', new_url);
20 window.history.replaceState({}, '', new_url);
21 });
21 });
22 $('div#main_app').addClass('border-box-sizing ui-widget');
22 $('div#main_app').addClass('border-box-sizing ui-widget');
23 $('div#notebooks_toolbar').addClass('ui-widget ui-helper-clearfix');
23 $('div#notebooks_toolbar').addClass('ui-widget ui-helper-clearfix');
24 $('#new_notebook').button().click(function (e) {
24 $('#new_notebook').button().click(function (e) {
25 window.open($('body').data('baseProjectUrl')+'new');
25 window.open($('body').data('baseProjectUrl')+'new');
26 });
26 });
27
27
28 IPython.read_only = $('body').data('readOnly') === 'True';
28 IPython.read_only = $('body').data('readOnly') === 'True';
29 IPython.notebook_list = new IPython.NotebookList('div#notebook_list');
29 IPython.notebook_list = new IPython.NotebookList('div#notebook_list');
30 IPython.cluster_list = new IPython.ClusterList('div#cluster_list');
30 IPython.cluster_list = new IPython.ClusterList('div#cluster_list');
31 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
31 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
32
32
33 IPython.notebook_list.load_list();
33 var interval_id=0;
34 IPython.cluster_list.load_list();
34 // auto refresh every xx secondes, no need to be fast,
35 // update is done at least when page get focus
36 var time_refresh = 60; // in sec
37
38 var enable_autorefresh = function(){
39 //refresh immediately , then start interval
40 IPython.notebook_list.load_list();
41 IPython.cluster_list.load_list();
42 if (!interval_id){
43 interval_id = setInterval(function(){
44 IPython.notebook_list.load_list();
45 IPython.cluster_list.load_list();
46 }, time_refresh*1000);
47 }
48 }
49
50 var disable_autorefresh = function(){
51 clearInterval(interval_id);
52 interval_id = 0;
53 }
54
55 // stop autorefresh when page lose focus
56 $(window).blur(function() {
57 disable_autorefresh();
58 })
59
60 //re-enable when page get focus back
61 $(window).focus(function() {
62 enable_autorefresh();
63 });
64
65 // finally start it, it will refresh immediately
66 enable_autorefresh();
67
35 IPython.page.show();
68 IPython.page.show();
36
69
37 // bound the upload method to the on change of the file select list
70 // bound the upload method to the on change of the file select list
38 $("#alternate_upload").change(function (event){
71 $("#alternate_upload").change(function (event){
39 IPython.notebook_list.handelFilesUpload(event,'form');
72 IPython.notebook_list.handelFilesUpload(event,'form');
40 });
73 });
41 });
74 });
42
75
General Comments 0
You need to be logged in to leave comments. Login now