diff --git a/IPython/html/static/notebook/js/kernelselector.js b/IPython/html/static/notebook/js/kernelselector.js new file mode 100644 index 0000000..8dcf714 --- /dev/null +++ b/IPython/html/static/notebook/js/kernelselector.js @@ -0,0 +1,58 @@ +// Copyright (c) IPython Development Team. +// Distributed under the terms of the Modified BSD License. + +define([ + 'base/js/namespace', + 'jquery', + 'base/js/utils', +], function(IPython, $, utils) { + "use strict"; + + var KernelSelector = function(selector, notebook) { + this.selector = selector; + this.notebook = notebook; + this.kernelspecs = {}; + this.current = "python"; + if (this.selector !== undefined) { + this.element = $(selector); + this.style(); + this.request_kernelspecs(); + } + }; + + KernelSelector.prototype.style = function() { + }; + + KernelSelector.prototype.request_kernelspecs = function() { + var url = utils.url_join_encode(this.notebook.base_url, 'api/kernelspecs'); + $.ajax(url, {success: $.proxy(this.got_kernelspecs, this)}); + }; + + KernelSelector.prototype.got_kernelspecs = function(data, status, xhr) { + this.kernelspecs = {}; + var menu = this.element.find("#kernel_selector"); + for (var i = 0; i < data.length; i++) { + var ks = data[i]; + this.kernelspecs[ks.name] = ks; + var ksentry = $("
x'+ 'x'+ diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index d87ab63..0af6642 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -1496,7 +1496,11 @@ define([ * * @method start_session */ - Notebook.prototype.start_session = function () { + Notebook.prototype.start_session = function (kernel_name) { + if (kernel_name === undefined) { + kernel_name = this.default_kernel_name; + } + console.log("start_session", kernel_name); this.session = new session.Session({ base_url: this.base_url, ws_url: this.ws_url, @@ -1505,7 +1509,7 @@ define([ // For now, create all sessions with the 'python' kernel, which is the // default. Later, the user will be able to select kernels. This is // overridden if KernelManager.kernel_cmd is specified for the server. - kernel_name: this.default_kernel_name, + kernel_name: kernel_name, notebook: this}); this.session.start($.proxy(this._session_started, this)); diff --git a/IPython/html/templates/notebook.html b/IPython/html/templates/notebook.html index 959621f..0ad6185 100644 --- a/IPython/html/templates/notebook.html +++ b/IPython/html/templates/notebook.html @@ -40,6 +40,12 @@ class="notebook_app" + + {% endblock %}