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