From 4f7160aac65126f31a442c50e38a0069341cb061 Mon Sep 17 00:00:00 2001 From: Min RK Date: Fri, 6 Jan 2017 15:32:25 +0100 Subject: [PATCH] es5ify - const, let -> var - evaluated object keys --- notebook/static/base/js/keyboard.js | 14 +++--- notebook/static/base/js/namespace.js | 2 +- notebook/static/notebook/js/outputarea.js | 55 ++++++++++------------ notebook/static/services/kernels/kernel.js | 2 +- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/notebook/static/base/js/keyboard.js b/notebook/static/base/js/keyboard.js index b8b88ee4a..4c128c5b7 100644 --- a/notebook/static/base/js/keyboard.js +++ b/notebook/static/base/js/keyboard.js @@ -417,8 +417,8 @@ define([ shortcut = shortcut.toLowerCase(); this.remove_shortcut(shortcut); - const patch = {keys:{}}; - const b = {bind:{}}; + var patch = {keys: {}}; + var b = {bind: {}}; patch.keys[this._mode] = {bind:{}}; patch.keys[this._mode].bind[shortcut] = null; this._config.update(patch); @@ -426,16 +426,16 @@ define([ // if the shortcut we unbind is a default one, we add it to the list of // things to unbind at startup if( this._defaults_bindings.indexOf(shortcut) !== -1 ){ - const cnf = (this._config.data.keys||{})[this._mode]; - const unbind_array = cnf.unbind||[]; + var cnf = (this._config.data.keys || {})[this._mode]; + var unbind_array = cnf.unbind || []; // unless it's already there (like if we have remapped a default // shortcut to another command): unbind it) if(unbind_array.indexOf(shortcut) === -1){ - const _parray = unbind_array.concat(shortcut); - const unbind_patch = {keys:{}}; - unbind_patch.keys[this._mode] = {unbind:_parray} + var _parray = unbind_array.concat(shortcut); + var unbind_patch = {keys:{}}; + unbind_patch.keys[this._mode] = {unbind:_parray}; console.warn('up:', unbind_patch); this._config.update(unbind_patch); } diff --git a/notebook/static/base/js/namespace.js b/notebook/static/base/js/namespace.js index 1778937c4..22f47bafb 100644 --- a/notebook/static/base/js/namespace.js +++ b/notebook/static/base/js/namespace.js @@ -79,4 +79,4 @@ define(function(){ }); // deprecated since 4.0, remove in 5+ -var IPython = Jupyter +var IPython = Jupyter; diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index f29482c7d..0631fe21a 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -1,6 +1,6 @@ // Copyright (c) Jupyter Development Team. // Distributed under the terms of the Modified BSD License. -// jshint esnext: true + define([ 'jquery', 'base/js/utils', @@ -242,15 +242,15 @@ define([ }; // Declare mime type as constants - const MIME_JAVASCRIPT = 'application/javascript'; - const MIME_HTML = 'text/html'; - const MIME_MARKDOWN = 'text/markdown'; - const MIME_LATEX = 'text/latex'; - const MIME_SVG = 'image/svg+xml'; - const MIME_PNG = 'image/png'; - const MIME_JPEG = 'image/jpeg'; - const MIME_PDF = 'application/pdf'; - const MIME_TEXT = 'text/plain'; + var MIME_JAVASCRIPT = 'application/javascript'; + var MIME_HTML = 'text/html'; + var MIME_MARKDOWN = 'text/markdown'; + var MIME_LATEX = 'text/latex'; + var MIME_SVG = 'image/svg+xml'; + var MIME_PNG = 'image/png'; + var MIME_JPEG = 'image/jpeg'; + var MIME_PDF = 'application/pdf'; + var MIME_TEXT = 'text/plain'; OutputArea.output_types = [ @@ -262,7 +262,7 @@ define([ MIME_PNG, MIME_JPEG, MIME_PDF, - MIME_TEXT + MIME_TEXT, ]; OutputArea.prototype.validate_mimebundle = function (bundle) { @@ -637,14 +637,12 @@ define([ } }; + OutputArea.safe_outputs = {}; + OutputArea.safe_outputs[MIME_TEXT] = true; + OutputArea.safe_outputs[MIME_LATEX] = true; + OutputArea.safe_outputs[MIME_PNG] = true; + OutputArea.safe_outputs[MIME_JPEG] = true; - OutputArea.safe_outputs = { - [MIME_TEXT] : true, - [MIME_LATEX] : true, - [MIME_PNG] : true, - [MIME_JPEG] : true - }; - OutputArea.prototype.append_mime_type = function (json, element, handle_inserted) { for (var i=0; i < OutputArea.display_order.length; i++) { var type = OutputArea.display_order[i]; @@ -1057,17 +1055,16 @@ define([ MIME_TEXT ]; - OutputArea.append_map = { - [MIME_TEXT] : append_text, - [MIME_HTML] : append_html, - [MIME_MARKDOWN]: append_markdown, - [MIME_SVG] : append_svg, - [MIME_PNG] : append_png, - [MIME_JPEG] : append_jpeg, - [MIME_LATEX] : append_latex, - [MIME_JAVASCRIPT] : append_javascript, - [MIME_PDF] : append_pdf - }; + OutputArea.append_map = {}; + OutputArea.append_map[MIME_TEXT] = append_text; + OutputArea.append_map[MIME_HTML] = append_html; + OutputArea.append_map[MIME_MARKDOWN] = append_markdown; + OutputArea.append_map[MIME_SVG] = append_svg; + OutputArea.append_map[MIME_PNG] = append_png; + OutputArea.append_map[MIME_JPEG] = append_jpeg; + OutputArea.append_map[MIME_LATEX] = append_latex; + OutputArea.append_map[MIME_JAVASCRIPT] = append_javascript; + OutputArea.append_map[MIME_PDF] = append_pdf; OutputArea.prototype.mime_types = function () { return OutputArea.display_order; diff --git a/notebook/static/services/kernels/kernel.js b/notebook/static/services/kernels/kernel.js index 53d323253..f890e17d9 100644 --- a/notebook/static/services/kernels/kernel.js +++ b/notebook/static/services/kernels/kernel.js @@ -979,7 +979,7 @@ define([ */ Kernel.prototype.output_callback_overrides_push = function(msg_id, callback_id) { var output_callbacks = this._msg_callbacks_overrides[msg_id]; - if (output_callbacks === void 0) { + if (!output_callbacks) { this._msg_callbacks_overrides[msg_id] = output_callbacks = []; } output_callbacks.push(callback_id);