// 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.events = notebook.events; this.current_selection = notebook.default_kernel_name; this.kernelspecs = {}; if (this.selector !== undefined) { this.element = $(selector); this.request_kernelspecs(); } this.bind_events(); // Make the object globally available for user convenience & inspection IPython.kernelselector = this; }; 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"); var change_kernel_submenu = $("#menu-change-kernel-submenu"); for (var i = 0; i < data.length; i++) { var ks = data[i]; this.kernelspecs[ks.name] = ks; var ksentry = $("