##// END OF EJS Templates
fix tab hash / url behavior...
MinRK -
Show More
@@ -1,74 +1,85 b''
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 $('#new_notebook').click(function (e) {
16 $('#new_notebook').click(function (e) {
17 window.open($('body').data('baseProjectUrl')+'new');
17 window.open($('body').data('baseProjectUrl')+'new');
18 });
18 });
19
19
20 IPython.read_only = $('body').data('readOnly') === 'True';
20 IPython.read_only = $('body').data('readOnly') === 'True';
21 IPython.notebook_list = new IPython.NotebookList('#notebook_list');
21 IPython.notebook_list = new IPython.NotebookList('#notebook_list');
22 IPython.cluster_list = new IPython.ClusterList('#cluster_list');
22 IPython.cluster_list = new IPython.ClusterList('#cluster_list');
23 IPython.login_widget = new IPython.LoginWidget('#login_widget');
23 IPython.login_widget = new IPython.LoginWidget('#login_widget');
24
24
25 var interval_id=0;
25 var interval_id=0;
26 // auto refresh every xx secondes, no need to be fast,
26 // auto refresh every xx secondes, no need to be fast,
27 // update is done at least when page get focus
27 // update is done at least when page get focus
28 var time_refresh = 60; // in sec
28 var time_refresh = 60; // in sec
29
29
30 var enable_autorefresh = function(){
30 var enable_autorefresh = function(){
31 //refresh immediately , then start interval
31 //refresh immediately , then start interval
32 if($('.upload_button').length == 0)
32 if($('.upload_button').length == 0)
33 {
33 {
34 IPython.notebook_list.load_list();
34 IPython.notebook_list.load_list();
35 IPython.cluster_list.load_list();
35 IPython.cluster_list.load_list();
36 }
36 }
37 if (!interval_id){
37 if (!interval_id){
38 interval_id = setInterval(function(){
38 interval_id = setInterval(function(){
39 if($('.upload_button').length == 0)
39 if($('.upload_button').length == 0)
40 {
40 {
41 IPython.notebook_list.load_list();
41 IPython.notebook_list.load_list();
42 IPython.cluster_list.load_list();
42 IPython.cluster_list.load_list();
43 }
43 }
44 }, time_refresh*1000);
44 }, time_refresh*1000);
45 }
45 }
46 }
46 }
47
47
48 var disable_autorefresh = function(){
48 var disable_autorefresh = function(){
49 clearInterval(interval_id);
49 clearInterval(interval_id);
50 interval_id = 0;
50 interval_id = 0;
51 }
51 }
52
52
53 // stop autorefresh when page lose focus
53 // stop autorefresh when page lose focus
54 $(window).blur(function() {
54 $(window).blur(function() {
55 disable_autorefresh();
55 disable_autorefresh();
56 })
56 })
57
57
58 //re-enable when page get focus back
58 //re-enable when page get focus back
59 $(window).focus(function() {
59 $(window).focus(function() {
60 enable_autorefresh();
60 enable_autorefresh();
61 });
61 });
62
62
63 // finally start it, it will refresh immediately
63 // finally start it, it will refresh immediately
64 enable_autorefresh();
64 enable_autorefresh();
65
65
66 IPython.page.show();
66 IPython.page.show();
67
67
68 // bound the upload method to the on change of the file select list
68 // bound the upload method to the on change of the file select list
69 $("#alternate_upload").change(function (event){
69 $("#alternate_upload").change(function (event){
70 IPython.notebook_list.handelFilesUpload(event,'form');
70 IPython.notebook_list.handelFilesUpload(event,'form');
71 });
71 });
72
73 // set hash on tab click
74 $("#tabs").find("a").click(function() {
75 window.location.hash = $(this).attr("href");
76 })
77
78 // load tab if url hash
79 if (window.location.hash) {
80 $("#tabs").find("a[href=" + window.location.hash + "]").click();
81 }
82
72
83
73 });
84 });
74
85
General Comments 0
You need to be logged in to leave comments. Login now