##// END OF EJS Templates
Remove unused style() function
Thomas Kluyver -
Show More
@@ -1,63 +1,59 b''
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4 define([
4 define([
5 'base/js/namespace',
5 'base/js/namespace',
6 'jquery',
6 'jquery',
7 'base/js/utils',
7 'base/js/utils',
8 ], function(IPython, $, utils) {
8 ], function(IPython, $, utils) {
9 "use strict";
9 "use strict";
10
10
11 var KernelSelector = function(selector, notebook) {
11 var KernelSelector = function(selector, notebook) {
12 this.selector = selector;
12 this.selector = selector;
13 this.notebook = notebook;
13 this.notebook = notebook;
14 this.kernelspecs = {};
14 this.kernelspecs = {};
15 if (this.selector !== undefined) {
15 if (this.selector !== undefined) {
16 this.element = $(selector);
16 this.element = $(selector);
17 this.style();
18 this.request_kernelspecs();
17 this.request_kernelspecs();
19 }
18 }
20
19
21 // For now, this is how we make this object available elsewhere
20 // For now, this is how we make this object available elsewhere
22 IPython.kernelselector = this;
21 IPython.kernelselector = this;
23 };
22 };
24
23
25 KernelSelector.prototype.style = function() {
26 };
27
28 KernelSelector.prototype.request_kernelspecs = function() {
24 KernelSelector.prototype.request_kernelspecs = function() {
29 var url = utils.url_join_encode(this.notebook.base_url, 'api/kernelspecs');
25 var url = utils.url_join_encode(this.notebook.base_url, 'api/kernelspecs');
30 $.ajax(url, {success: $.proxy(this.got_kernelspecs, this)});
26 $.ajax(url, {success: $.proxy(this.got_kernelspecs, this)});
31 };
27 };
32
28
33 KernelSelector.prototype.got_kernelspecs = function(data, status, xhr) {
29 KernelSelector.prototype.got_kernelspecs = function(data, status, xhr) {
34 this.kernelspecs = {};
30 this.kernelspecs = {};
35 var menu = this.element.find("#kernel_selector");
31 var menu = this.element.find("#kernel_selector");
36 for (var i = 0; i < data.length; i++) {
32 for (var i = 0; i < data.length; i++) {
37 var ks = data[i];
33 var ks = data[i];
38 this.kernelspecs[ks.name] = ks;
34 this.kernelspecs[ks.name] = ks;
39 var ksentry = $("<li>").attr("id", "kernel-" +ks.name).append($('<a>')
35 var ksentry = $("<li>").attr("id", "kernel-" +ks.name).append($('<a>')
40 .attr('href', '#')
36 .attr('href', '#')
41 .click($.proxy(this.change_kernel, this, ks.name))
37 .click($.proxy(this.change_kernel, this, ks.name))
42 .text(ks.display_name));
38 .text(ks.display_name));
43 menu.append(ksentry);
39 menu.append(ksentry);
44 }
40 }
45 };
41 };
46
42
47 KernelSelector.prototype.change_kernel = function(kernel_name) {
43 KernelSelector.prototype.change_kernel = function(kernel_name) {
48 if (kernel_name === this.notebook.kernel.name) {
44 if (kernel_name === this.notebook.kernel.name) {
49 return;
45 return;
50 }
46 }
51 this.notebook.session.delete();
47 this.notebook.session.delete();
52 this.notebook.start_session(kernel_name);
48 this.notebook.start_session(kernel_name);
53 };
49 };
54
50
55 KernelSelector.prototype.set_displayed_name = function(kernel_name) {
51 KernelSelector.prototype.set_displayed_name = function(kernel_name) {
56 var ks = this.kernelspecs[kernel_name]
52 var ks = this.kernelspecs[kernel_name]
57 if (ks !== undefined) {
53 if (ks !== undefined) {
58 this.element.find("#current_kernel_spec").text(ks.display_name);
54 this.element.find("#current_kernel_spec").text(ks.display_name);
59 }
55 }
60 };
56 };
61
57
62 return {'KernelSelector': KernelSelector};
58 return {'KernelSelector': KernelSelector};
63 });
59 });
General Comments 0
You need to be logged in to leave comments. Login now