Show More
@@ -1,49 +1,58 b'' | |||
|
1 | 1 | // leave at least 2 line with only a star on it below, or doc generation fails |
|
2 | 2 | /** |
|
3 | 3 | * |
|
4 | 4 | * |
|
5 | 5 | * Placeholder for custom user javascript |
|
6 | 6 | * mainly to be overridden in profile/static/custom/custom.js |
|
7 | 7 | * This will always be an empty file in IPython |
|
8 | 8 | * |
|
9 | 9 | * User could add any javascript in the `profile/static/custom/custom.js` file |
|
10 | 10 | * (and should create it if it does not exist). |
|
11 | 11 | * It will be executed by the ipython notebook at load time. |
|
12 | 12 | * |
|
13 | 13 | * Same thing with `profile/static/custom/custom.css` to inject custom css into the notebook. |
|
14 | 14 | * |
|
15 | * Example : | |
|
15 | * __Example 1:__ | |
|
16 | 16 | * |
|
17 | 17 | * Create a custom button in toolbar that execute `%qtconsole` in kernel |
|
18 | 18 | * and hence open a qtconsole attached to the same kernel as the current notebook |
|
19 | 19 | * |
|
20 | 20 | * $([IPython.events]).on('app_initialized.NotebookApp', function(){ |
|
21 | 21 | * IPython.toolbar.add_buttons_group([ |
|
22 | 22 | * { |
|
23 | 23 | * 'label' : 'run qtconsole', |
|
24 | 24 | * 'icon' : 'icon-terminal', // select your icon from http://fortawesome.github.io/Font-Awesome/icons |
|
25 | 25 | * 'callback': function () { |
|
26 | 26 | * IPython.notebook.kernel.execute('%qtconsole') |
|
27 | 27 | * } |
|
28 | 28 | * } |
|
29 | 29 | * // add more button here if needed. |
|
30 | 30 | * ]); |
|
31 | 31 | * }); |
|
32 | 32 | * |
|
33 | * Example : | |
|
33 | * __Example 2:__ | |
|
34 | * | |
|
35 | * At the completion of the dashboard loading, load an unofficial javascript extension | |
|
36 | * that is installed in profile/static/custom/ | |
|
37 | * | |
|
38 | * $([IPython.events]).on('app_initialized.DashboardApp', function(){ | |
|
39 | * require(['custom/unofficial_extension.js']) | |
|
40 | * }); | |
|
41 | * | |
|
42 | * __Example 3:__ | |
|
34 | 43 | * |
|
35 | 44 | * Use `jQuery.getScript(url [, success(script, textStatus, jqXHR)] );` |
|
36 | 45 | * to load custom script into the notebook. |
|
37 | 46 | * |
|
38 | 47 | * // to load the metadata ui extension example. |
|
39 | 48 | * $.getScript('/static/notebook/js/celltoolbarpresets/example.js'); |
|
40 | 49 | * // or |
|
41 | 50 | * // to load the metadata ui extension to control slideshow mode / reveal js for nbconvert |
|
42 | 51 | * $.getScript('/static/notebook/js/celltoolbarpresets/slideshow.js'); |
|
43 | 52 | * |
|
44 | 53 | * |
|
45 | 54 | * @module IPython |
|
46 | 55 | * @namespace IPython |
|
47 | 56 | * @class customjs |
|
48 | 57 | * @static |
|
49 | 58 | */ |
@@ -1,91 +1,92 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 | $('#new_notebook').button().click(function (e) { |
|
18 | 18 | IPython.notebook_list.new_notebook() |
|
19 | 19 | }); |
|
20 | 20 | |
|
21 | 21 | var opts = { |
|
22 | 22 | base_url : IPython.utils.get_body_data("baseUrl"), |
|
23 | 23 | notebook_path : IPython.utils.get_body_data("notebookPath"), |
|
24 | 24 | }; |
|
25 | 25 | IPython.session_list = new IPython.SesssionList(opts); |
|
26 | 26 | IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts); |
|
27 | 27 | IPython.cluster_list = new IPython.ClusterList('#cluster_list', opts); |
|
28 | 28 | IPython.kernel_list = new IPython.KernelList('#running_list', opts); |
|
29 | 29 | IPython.login_widget = new IPython.LoginWidget('#login_widget', opts); |
|
30 | 30 | |
|
31 | 31 | var interval_id=0; |
|
32 | 32 | // auto refresh every xx secondes, no need to be fast, |
|
33 | 33 | // update is done at least when page get focus |
|
34 | 34 | var time_refresh = 60; // in sec |
|
35 | 35 | |
|
36 | 36 | var enable_autorefresh = function(){ |
|
37 | 37 | //refresh immediately , then start interval |
|
38 | 38 | if($('.upload_button').length == 0) |
|
39 | 39 | { |
|
40 | 40 | IPython.session_list.load_sessions(); |
|
41 | 41 | IPython.cluster_list.load_list(); |
|
42 | 42 | } |
|
43 | 43 | if (!interval_id){ |
|
44 | 44 | interval_id = setInterval(function(){ |
|
45 | 45 | if($('.upload_button').length == 0) |
|
46 | 46 | { |
|
47 | 47 | IPython.session_list.load_sessions(); |
|
48 | 48 | IPython.cluster_list.load_list(); |
|
49 | 49 | } |
|
50 | 50 | }, time_refresh*1000); |
|
51 | 51 | } |
|
52 | 52 | } |
|
53 | 53 | |
|
54 | 54 | var disable_autorefresh = function(){ |
|
55 | 55 | clearInterval(interval_id); |
|
56 | 56 | interval_id = 0; |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | // stop autorefresh when page lose focus |
|
60 | 60 | $(window).blur(function() { |
|
61 | 61 | disable_autorefresh(); |
|
62 | 62 | }) |
|
63 | 63 | |
|
64 | 64 | //re-enable when page get focus back |
|
65 | 65 | $(window).focus(function() { |
|
66 | 66 | enable_autorefresh(); |
|
67 | 67 | }); |
|
68 | 68 | |
|
69 | 69 | // finally start it, it will refresh immediately |
|
70 | 70 | enable_autorefresh(); |
|
71 | 71 | |
|
72 | 72 | IPython.page.show(); |
|
73 | ||
|
73 | $([IPython.events]).trigger('app_initialized.DashboardApp'); | |
|
74 | ||
|
74 | 75 | // bound the upload method to the on change of the file select list |
|
75 | 76 | $("#alternate_upload").change(function (event){ |
|
76 | 77 | IPython.notebook_list.handleFilesUpload(event,'form'); |
|
77 | 78 | }); |
|
78 | 79 | |
|
79 | 80 | // set hash on tab click |
|
80 | 81 | $("#tabs").find("a").click(function() { |
|
81 | 82 | window.location.hash = $(this).attr("href"); |
|
82 | 83 | }) |
|
83 | 84 | |
|
84 | 85 | // load tab if url hash |
|
85 | 86 | if (window.location.hash) { |
|
86 | 87 | $("#tabs").find("a[href=" + window.location.hash + "]").click(); |
|
87 | 88 | } |
|
88 | 89 | |
|
89 | 90 | |
|
90 | 91 | }); |
|
91 | 92 |
General Comments 0
You need to be logged in to leave comments.
Login now