From 0168dc2190d91888756dced4e71b597d62b66e68 2011-11-27 23:23:40 From: Stefan van der Walt <stefan@sun.ac.za> Date: 2011-11-27 23:23:40 Subject: [PATCH] Clean up javascript based on js2-mode feedback. --- diff --git a/IPython/frontend/html/notebook/static/js/cell.js b/IPython/frontend/html/notebook/static/js/cell.js index b186bd8..6806dd3 100644 --- a/IPython/frontend/html/notebook/static/js/cell.js +++ b/IPython/frontend/html/notebook/static/js/cell.js @@ -45,16 +45,16 @@ var IPython = (function (IPython) { Cell.prototype.bind_events = function () { var that = this; - var nb = that.notebook + var nb = that.notebook; that.element.click(function (event) { if (that.selected === false) { nb.select(nb.find_cell_index(that)); - }; + } }); that.element.focusin(function (event) { if (that.selected === false) { nb.select(nb.find_cell_index(that)); - }; + } }); }; diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index c96d4b2..8aa7441 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -44,7 +44,7 @@ var IPython = (function (IPython) { var output = $('<div></div>').addClass('output vbox'); cell.append(input).append(output); this.element = cell; - this.collapse() + this.collapse(); }; //TODO, try to diminish the number of parameters. @@ -123,7 +123,7 @@ var IPython = (function (IPython) { return true; } else { return false; - }; + } } else if (event.keyCode === 76 && event.ctrlKey && event.shiftKey && event.type == 'keydown') { // toggle line numbers with Ctrl-Shift-L @@ -138,10 +138,11 @@ var IPython = (function (IPython) { if (ed_cur.line !== cc_cur.line || ed_cur.ch !== cc_cur.ch) { this.is_completing = false; this.completion_cursor = null; - }; - }; + } + } return false; }; + return false; }; CodeCell.prototype.remove_and_cancell_tooltip = function(timeout) @@ -345,7 +346,7 @@ var IPython = (function (IPython) { } else { this.code_mirror.setOption('lineNumbers', false); } - this.code_mirror.refresh() + this.code_mirror.refresh(); }; CodeCell.prototype.select = function () { @@ -447,7 +448,7 @@ var IPython = (function (IPython) { CodeCell.prototype.append_display_data = function (json) { var toinsert = this.create_output_area(); - this.append_mime_type(json, toinsert) + this.append_mime_type(json, toinsert); this.element.find('div.output').append(toinsert); // If we just output latex, typeset it. if ( (json.latex !== undefined) || (json.html !== undefined) ) { @@ -477,7 +478,7 @@ var IPython = (function (IPython) { var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_html rendered_html"); toinsert.append(html); element.append(toinsert); - } + }; CodeCell.prototype.append_text = function (data, element, extra_class) { @@ -517,7 +518,7 @@ var IPython = (function (IPython) { var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_latex"); toinsert.append(latex); element.append(toinsert); - } + }; CodeCell.prototype.clear_output = function (stdout, stderr, other) { @@ -589,7 +590,7 @@ var IPython = (function (IPython) { CodeCell.prototype.set_input_prompt = function (number) { var n = number || ' '; - this.input_prompt_number = n + this.input_prompt_number = n; this.element.find('div.input_prompt').html('In [' + n + ']:'); }; @@ -653,7 +654,7 @@ var IPython = (function (IPython) { data.input = this.get_code(); data.cell_type = 'code'; if (this.input_prompt_number !== ' ') { - data.prompt_number = this.input_prompt_number + data.prompt_number = this.input_prompt_number; }; var outputs = []; var len = this.outputs.length; diff --git a/IPython/frontend/html/notebook/static/js/kernel.js b/IPython/frontend/html/notebook/static/js/kernel.js index b3ae6ba..16f9445 100644 --- a/IPython/frontend/html/notebook/static/js/kernel.js +++ b/IPython/frontend/html/notebook/static/js/kernel.js @@ -23,9 +23,9 @@ var IPython = (function (IPython) { this.session_id = utils.uuid(); if (typeof(WebSocket) !== 'undefined') { - this.WebSocket = WebSocket + this.WebSocket = WebSocket; } else if (typeof(MozWebSocket) !== 'undefined') { - this.WebSocket = MozWebSocket + this.WebSocket = MozWebSocket; } else { alert('Your browser does not have WebSocket support, please try Chrome, Safari or Firefox ≥ 6. Firefox 4 and 5 are also supported by you have to enable WebSockets in about:config.'); }; @@ -44,13 +44,13 @@ var IPython = (function (IPython) { parent_header : {} }; return msg; - } + }; Kernel.prototype.start = function (notebook_id, callback) { var that = this; if (!this.running) { var qs = $.param({notebook:notebook_id}); - var url = this.base_url + '?' + qs + var url = this.base_url + '?' + qs; $.post(url, function (kernel_id) { that._handle_start_kernel(kernel_id, callback); @@ -95,10 +95,10 @@ var IPython = (function (IPython) { " You will NOT be able to run code.<br/>" + " Your browser may not be compatible with the websocket version in the server," + " or if the url does not look right, there could be an error in the" + - " server's configuration." + " server's configuration."; } else { msg = "Websocket connection closed unexpectedly.<br/>" + - " The kernel will no longer be responsive." + " The kernel will no longer be responsive."; } var dialog = $('<div/>'); dialog.html(msg); @@ -114,7 +114,7 @@ var IPython = (function (IPython) { } }); - } + }; Kernel.prototype.start_channels = function () { var that = this; @@ -125,7 +125,7 @@ var IPython = (function (IPython) { this.iopub_channel = new this.WebSocket(ws_url + "/iopub"); send_cookie = function(){ this.send(document.cookie); - } + }; var already_called_onclose = false; // only alert once ws_closed_early = function(evt){ if (already_called_onclose){ @@ -135,7 +135,7 @@ var IPython = (function (IPython) { if ( ! evt.wasClean ){ that._websocket_closed(ws_url, true); } - } + }; ws_closed_late = function(evt){ if (already_called_onclose){ return; @@ -144,7 +144,7 @@ var IPython = (function (IPython) { if ( ! evt.wasClean ){ that._websocket_closed(ws_url, false); } - } + }; this.shell_channel.onopen = send_cookie; this.shell_channel.onclose = ws_closed_early; this.iopub_channel.onopen = send_cookie; @@ -159,12 +159,12 @@ var IPython = (function (IPython) { Kernel.prototype.stop_channels = function () { if (this.shell_channel !== null) { - this.shell_channel.onclose = function (evt) {null}; + this.shell_channel.onclose = function (evt) {}; this.shell_channel.close(); this.shell_channel = null; }; if (this.iopub_channel !== null) { - this.iopub_channel.onclose = function (evt) {null}; + this.iopub_channel.onclose = function (evt) {}; this.iopub_channel.close(); this.iopub_channel = null; }; @@ -189,12 +189,12 @@ var IPython = (function (IPython) { silent : false, user_variables : [], user_expressions : {}, - allow_stdin : false, + allow_stdin : false }; var msg = this.get_msg("execute_request", content); this.shell_channel.send(JSON.stringify(msg)); return msg.header.msg_id; - } + }; Kernel.prototype.complete = function (line, cursor_pos) { @@ -206,7 +206,7 @@ var IPython = (function (IPython) { var msg = this.get_msg("complete_request", content); this.shell_channel.send(JSON.stringify(msg)); return msg.header.msg_id; - } + }; Kernel.prototype.interrupt = function () { @@ -221,7 +221,7 @@ var IPython = (function (IPython) { this.running = false; var settings = { cache : false, - type : "DELETE", + type : "DELETE" }; $.ajax(this.kernel_url, settings); }; diff --git a/IPython/frontend/html/notebook/static/js/kernelstatus.js b/IPython/frontend/html/notebook/static/js/kernelstatus.js index def9db2..da18a06 100644 --- a/IPython/frontend/html/notebook/static/js/kernelstatus.js +++ b/IPython/frontend/html/notebook/static/js/kernelstatus.js @@ -26,7 +26,7 @@ var IPython = (function (IPython) { this.element.addClass('ui-widget'); this.element.attr('title', "The kernel execution status." + " If 'Busy', the kernel is currently running code." + - " If 'Idle', it is available for execution.") + " If 'Idle', it is available for execution."); }; diff --git a/IPython/frontend/html/notebook/static/js/layout.js b/IPython/frontend/html/notebook/static/js/layout.js index 515cf74..bf3e209 100644 --- a/IPython/frontend/html/notebook/static/js/layout.js +++ b/IPython/frontend/html/notebook/static/js/layout.js @@ -54,7 +54,7 @@ var IPython = (function (IPython) { } }; - IPython.LayoutManager = LayoutManager + IPython.LayoutManager = LayoutManager; return IPython; diff --git a/IPython/frontend/html/notebook/static/js/leftpanel.js b/IPython/frontend/html/notebook/static/js/leftpanel.js index 5eb02e1..d5e2003 100644 --- a/IPython/frontend/html/notebook/static/js/leftpanel.js +++ b/IPython/frontend/html/notebook/static/js/leftpanel.js @@ -71,7 +71,7 @@ var IPython = (function (IPython) { this.kernel_section = new IPython.KernelSection('div#kernel_section'); } this.help_section = new IPython.HelpSection('div#help_section'); - } + }; LeftPanel.prototype.collapse = function () { if (this.expanded === true) { diff --git a/IPython/frontend/html/notebook/static/js/namespace.js b/IPython/frontend/html/notebook/static/js/namespace.js index 2ded1eb..9c17386 100644 --- a/IPython/frontend/html/notebook/static/js/namespace.js +++ b/IPython/frontend/html/notebook/static/js/namespace.js @@ -20,7 +20,7 @@ IPython.namespace = function (ns_string) { for (i=0; i<parts.length; i+=1) { // Create property if it doesn't exist if (typeof parent[parts[i]] === "undefined") { - parent[parts[i]] == {}; + parent[parts[i]] = {}; } } return parent; diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index e61b909..bf219b4 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -59,7 +59,7 @@ var IPython = (function (IPython) { var that = this; $(document).keydown(function (event) { // console.log(event); - if (that.read_only) return; + if (that.read_only) return false; if (event.which === 27) { // Intercept escape at highest level to avoid closing // websocket connection with firefox @@ -165,6 +165,7 @@ var IPython = (function (IPython) { that.control_key_active = false; return true; }; + return true; }); this.element.bind('collapse_pager', function () { @@ -203,6 +204,7 @@ var IPython = (function (IPython) { if (that.dirty && ! that.read_only) { return "You have unsaved changes that will be lost if you leave this page."; }; + return true; }); }; @@ -266,12 +268,12 @@ var IPython = (function (IPython) { Notebook.prototype.cell_elements = function () { return this.element.children("div.cell"); - } + }; Notebook.prototype.ncells = function (cell) { return this.cell_elements().length; - } + }; // TODO: we are often calling cells as cells()[i], which we should optimize @@ -280,7 +282,7 @@ var IPython = (function (IPython) { return this.cell_elements().toArray().map(function (e) { return $(e).data("cell"); }); - } + }; Notebook.prototype.find_cell_index = function (cell) { @@ -296,7 +298,7 @@ var IPython = (function (IPython) { Notebook.prototype.index_or_selected = function (index) { return index || this.selected_index() || 0; - } + }; Notebook.prototype.select = function (index) { @@ -354,7 +356,7 @@ var IPython = (function (IPython) { Notebook.prototype.selected_cell = function () { return this.cell_elements().eq(this.selected_index()).data("cell"); - } + }; // Cell insertion, deletion and moving. @@ -392,7 +394,7 @@ var IPython = (function (IPython) { this.cell_elements().eq(index).after(cell.element); }; this.dirty = true; - return this + return this; }; @@ -423,14 +425,14 @@ var IPython = (function (IPython) { }; this.dirty = true; return this; - } + }; Notebook.prototype.move_cell_down = function (index) { var i = index || this.selected_index(); if (i !== null && i < (this.ncells()-1) && i >= 0) { - var pivot = this.cell_elements().eq(i+1) - var tomove = this.cell_elements().eq(i) + var pivot = this.cell_elements().eq(i+1); + var tomove = this.cell_elements().eq(i); if (pivot !== null && tomove !== null) { tomove.detach(); pivot.after(tomove); @@ -439,7 +441,7 @@ var IPython = (function (IPython) { }; this.dirty = true; return this; - } + }; Notebook.prototype.sort_cells = function () { @@ -447,7 +449,7 @@ var IPython = (function (IPython) { var sindex = this.selected_index(); var swapped; do { - swapped = false + swapped = false; for (var i=1; i<ncells; i++) { current = this.cell_elements().eq(i).data("cell"); previous = this.cell_elements().eq(i-1).data("cell"); @@ -470,7 +472,7 @@ var IPython = (function (IPython) { this.insert_cell_above(cell, i); this.select(this.find_cell_index(cell)); return cell; - } + }; Notebook.prototype.insert_code_cell_below = function (index) { @@ -481,7 +483,7 @@ var IPython = (function (IPython) { this.insert_cell_below(cell, i); this.select(this.find_cell_index(cell)); return cell; - } + }; Notebook.prototype.insert_html_cell_above = function (index) { @@ -492,7 +494,7 @@ var IPython = (function (IPython) { this.insert_cell_above(cell, i); this.select(this.find_cell_index(cell)); return cell; - } + }; Notebook.prototype.insert_html_cell_below = function (index) { @@ -503,7 +505,7 @@ var IPython = (function (IPython) { this.insert_cell_below(cell, i); this.select(this.find_cell_index(cell)); return cell; - } + }; Notebook.prototype.insert_markdown_cell_above = function (index) { @@ -514,7 +516,7 @@ var IPython = (function (IPython) { this.insert_cell_above(cell, i); this.select(this.find_cell_index(cell)); return cell; - } + }; Notebook.prototype.insert_markdown_cell_below = function (index) { @@ -525,7 +527,7 @@ var IPython = (function (IPython) { this.insert_cell_below(cell, i); this.select(this.find_cell_index(cell)); return cell; - } + }; Notebook.prototype.to_code = function (index) { @@ -553,11 +555,11 @@ var IPython = (function (IPython) { var target_cell = null; if (source_cell instanceof IPython.CodeCell) { this.insert_markdown_cell_below(i); - var target_cell = this.cells()[i+1]; + target_cell = this.cells()[i+1]; var text = source_cell.get_code(); } else if (source_cell instanceof IPython.HTMLCell) { this.insert_markdown_cell_below(i); - var target_cell = this.cells()[i+1]; + target_cell = this.cells()[i+1]; var text = source_cell.get_source(); if (text === source_cell.placeholder) { text = target_cell.placeholder; @@ -581,11 +583,11 @@ var IPython = (function (IPython) { var target_cell = null; if (source_cell instanceof IPython.CodeCell) { this.insert_html_cell_below(i); - var target_cell = this.cells()[i+1]; + target_cell = this.cells()[i+1]; var text = source_cell.get_code(); } else if (source_cell instanceof IPython.MarkdownCell) { this.insert_html_cell_below(i); - var target_cell = this.cells()[i+1]; + target_cell = this.cells()[i+1]; var text = source_cell.get_source(); if (text === source_cell.placeholder) { text = target_cell.placeholder; @@ -643,7 +645,7 @@ var IPython = (function (IPython) { var cells = this.cells(); len = cells.length; for (var i=0; i<len; i++) { - cells[i].set_autoindent(state) + cells[i].set_autoindent(state); }; }; @@ -662,7 +664,7 @@ var IPython = (function (IPython) { // Other cell functions: line numbers, ... Notebook.prototype.cell_toggle_line_numbers = function() { - this.selected_cell().toggle_line_numbers() + this.selected_cell().toggle_line_numbers(); }; // Kernel related things @@ -864,8 +866,8 @@ var IPython = (function (IPython) { Notebook.prototype.execute_selected_cell = function (options) { // add_new: should a new cell be added if we are at the end of the nb // terminal: execute in terminal mode, which stays in the current cell - default_options = {terminal: false, add_new: true} - $.extend(default_options, options) + default_options = {terminal: false, add_new: true}; + $.extend(default_options, options); var that = this; var cell = that.selected_cell(); var cell_index = that.find_cell_index(cell); @@ -938,7 +940,8 @@ var IPython = (function (IPython) { Notebook.prototype.fromJSON = function (data) { var ncells = this.ncells(); - for (var i=0; i<ncells; i++) { + var i; + for (i=0; i<ncells; i++) { // Always delete cell 0 as they get renumbered as they are deleted. this.delete_cell(0); }; @@ -951,7 +954,7 @@ var IPython = (function (IPython) { ncells = new_cells.length; var cell_data = null; var new_cell = null; - for (var i=0; i<ncells; i++) { + for (i=0; i<ncells; i++) { cell_data = new_cells[i]; if (cell_data.cell_type == 'code') { new_cell = this.insert_code_cell_below(); @@ -979,8 +982,8 @@ var IPython = (function (IPython) { // Only handle 1 worksheet for now. worksheets : [{cells:cell_array}], metadata : this.metadata - } - return data + }; + return data; }; Notebook.prototype.save_notebook = function () { @@ -1002,7 +1005,7 @@ var IPython = (function (IPython) { error : $.proxy(this.notebook_save_failed,this) }; IPython.save_widget.status_saving(); - var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id + var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id; $.ajax(url, settings); }; }; @@ -1012,7 +1015,7 @@ var IPython = (function (IPython) { this.dirty = false; IPython.save_widget.notebook_saved(); IPython.save_widget.status_save(); - } + }; Notebook.prototype.notebook_save_failed = function (xhr, status, error_msg) { @@ -1020,7 +1023,7 @@ var IPython = (function (IPython) { // TODO: Handle different types of errors (timeout etc.) alert('An unexpected error occured while saving the notebook.'); IPython.save_widget.reset_status(); - } + }; Notebook.prototype.load_notebook = function (callback) { @@ -1040,9 +1043,9 @@ var IPython = (function (IPython) { } }; IPython.save_widget.status_loading(); - var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id + var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id; $.ajax(url, settings); - } + }; Notebook.prototype.notebook_loaded = function (data, status, xhr) { diff --git a/IPython/frontend/html/notebook/static/js/notebooklist.js b/IPython/frontend/html/notebook/static/js/notebooklist.js index 316ef0e..1fbf4b7 100644 --- a/IPython/frontend/html/notebook/static/js/notebooklist.js +++ b/IPython/frontend/html/notebook/static/js/notebooklist.js @@ -67,7 +67,7 @@ var IPython = (function (IPython) { dataType : "json", success : $.proxy(this.list_loaded, this) }; - var url = $('body').data('baseProjectUrl') + 'notebooks' + var url = $('body').data('baseProjectUrl') + 'notebooks'; $.ajax(url, settings); }; @@ -174,7 +174,7 @@ var IPython = (function (IPython) { parent_item.remove(); } }; - var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id + var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id; $.ajax(url, settings); $(this).dialog('close'); }, @@ -222,7 +222,7 @@ var IPython = (function (IPython) { }; var qs = $.param({name:nbname, format:nbformat}); - var url = $('body').data('baseProjectUrl') + 'notebooks?' + qs + var url = $('body').data('baseProjectUrl') + 'notebooks?' + qs; $.ajax(url, settings); }); var cancel_button = $('<button>Cancel</button>').button(). diff --git a/IPython/frontend/html/notebook/static/js/notebookmain.js b/IPython/frontend/html/notebook/static/js/notebookmain.js index 78e4c05..c3cb70a 100644 --- a/IPython/frontend/html/notebook/static/js/notebookmain.js +++ b/IPython/frontend/html/notebook/static/js/notebookmain.js @@ -15,7 +15,7 @@ $(document).ready(function () { MathJax.Hub.Config({ tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], - displayMath: [ ['$$','$$'], ["\\[","\\]"] ], + displayMath: [ ['$$','$$'], ["\\[","\\]"] ] }, displayAlign: 'left', // Change this to 'center' to center equations. "HTML-CSS": { @@ -76,7 +76,7 @@ $(document).ready(function () { // and finally unhide the panel contents after collapse setTimeout(function(){ IPython.left_panel.left_panel_element.css('visibility', 'visible'); - }, 200) + }, 200); } },100); }); diff --git a/IPython/frontend/html/notebook/static/js/panelsection.js b/IPython/frontend/html/notebook/static/js/panelsection.js index a99e828..191da5a 100644 --- a/IPython/frontend/html/notebook/static/js/panelsection.js +++ b/IPython/frontend/html/notebook/static/js/panelsection.js @@ -186,18 +186,18 @@ var IPython = (function (IPython) { this.content.find('#move_cell_down').attr('title', "Move selected cell down one in the Notebook"); this.content.find('#cell_type').buttonset(); - this.content.find('#to_markdown').attr('title', 'Change selected cell to markdown (for text)') - this.content.find('#to_code').attr('title', 'Change selected cell to code (for execution)') + this.content.find('#to_markdown').attr('title', 'Change selected cell to markdown (for text)'); + this.content.find('#to_code').attr('title', 'Change selected cell to code (for execution)'); this.content.find('#cell_output').buttonset(); - this.content.find('#toggle_output').attr('title', 'Toggle visibility of the output of code cells') - this.content.find('#clear_all_output').attr('title', 'Clear output of all code cells (actually removes the data, unlike toggle)') + this.content.find('#toggle_output').attr('title', 'Toggle visibility of the output of code cells'); + this.content.find('#clear_all_output').attr('title', 'Clear output of all code cells (actually removes the data, unlike toggle)'); this.content.find('#run_cells').buttonset(); - this.content.find('#run_selected_cell').attr('title', 'Submit the selected cell for execution') - this.content.find('#run_all_cells').attr('title', 'Run *all* code cells in the notebook in order') - this.content.find('#autoindent').attr('title', 'Autoindent code as-you-type') - this.content.find('#autoindent_label').attr('title', 'Autoindent code as-you-type') + this.content.find('#run_selected_cell').attr('title', 'Submit the selected cell for execution'); + this.content.find('#run_all_cells').attr('title', 'Run *all* code cells in the notebook in order'); + this.content.find('#autoindent').attr('title', 'Autoindent code as-you-type'); + this.content.find('#autoindent_label').attr('title', 'Autoindent code as-you-type'); }; @@ -304,12 +304,12 @@ var IPython = (function (IPython) { this.content.find('#help_buttons0').buttonset(); this.content.find('#help_buttons1').buttonset(); this.content.find('#help_buttons2').buttonset(); - this.content.find('#python_help').attr('title', "Open the online Python documentation in a new tab") - this.content.find('#ipython_help').attr('title', "Open the online IPython documentation in a new tab") - this.content.find('#numpy_help').attr('title', "Open the online NumPy documentation in a new tab") - this.content.find('#scipy_help').attr('title', "Open the online SciPy documentation in a new tab") - this.content.find('#matplotlib_help').attr('title', "Open the online Matplotlib documentation in a new tab") - this.content.find('#sympy_help').attr('title', "Open the online SymPy documentation in a new tab") + this.content.find('#python_help').attr('title', "Open the online Python documentation in a new tab"); + this.content.find('#ipython_help').attr('title', "Open the online IPython documentation in a new tab"); + this.content.find('#numpy_help').attr('title', "Open the online NumPy documentation in a new tab"); + this.content.find('#scipy_help').attr('title', "Open the online SciPy documentation in a new tab"); + this.content.find('#matplotlib_help').attr('title', "Open the online Matplotlib documentation in a new tab"); + this.content.find('#sympy_help').attr('title', "Open the online SymPy documentation in a new tab"); }; diff --git a/IPython/frontend/html/notebook/static/js/savewidget.js b/IPython/frontend/html/notebook/static/js/savewidget.js index 2c7f631..673aee2 100644 --- a/IPython/frontend/html/notebook/static/js/savewidget.js +++ b/IPython/frontend/html/notebook/static/js/savewidget.js @@ -15,7 +15,7 @@ var IPython = (function (IPython) { var SaveWidget = function (selector) { this.selector = selector; - this.notebook_name_blacklist_re = /[\/\\]/ + this.notebook_name_blacklist_re = /[\/\\]/; this.last_saved_name = ''; if (this.selector !== undefined) { this.element = $(selector); @@ -70,14 +70,14 @@ var IPython = (function (IPython) { SaveWidget.prototype.get_notebook_name = function () { return this.element.find('input#notebook_name').attr('value'); - } + }; SaveWidget.prototype.set_notebook_name = function (nbname) { this.element.find('input#notebook_name').attr('value',nbname); this.set_document_title(); this.last_saved_name = nbname; - } + }; SaveWidget.prototype.set_document_title = function () { diff --git a/IPython/frontend/html/notebook/static/js/textcell.js b/IPython/frontend/html/notebook/static/js/textcell.js index 817c0dc..55a9887 100644 --- a/IPython/frontend/html/notebook/static/js/textcell.js +++ b/IPython/frontend/html/notebook/static/js/textcell.js @@ -34,7 +34,7 @@ var IPython = (function (IPython) { mode: this.code_mirror_mode, theme: 'default', value: this.placeholder, - readOnly: this.read_only, + readOnly: this.read_only }); // The tabindex=-1 makes this div focusable. var render_area = $('<div/>').addClass('text_cell_render'). @@ -52,8 +52,8 @@ var IPython = (function (IPython) { if (that.rendered) { that.edit(); event.preventDefault(); - }; - }; + } + } }); }; @@ -77,8 +77,8 @@ var IPython = (function (IPython) { this.rendered = false; if (this.get_source() === this.placeholder) { this.set_source(''); - }; - }; + } + } }; @@ -145,13 +145,13 @@ var IPython = (function (IPython) { this.set_rendered(data.rendered || ''); this.rendered = false; this.render(); - }; - }; + } + } }; TextCell.prototype.toJSON = function () { - var data = {} + var data = {}; data.cell_type = this.cell_type; data.source = this.get_source(); return data; @@ -173,13 +173,13 @@ var IPython = (function (IPython) { HTMLCell.prototype.render = function () { if (this.rendered === false) { var text = this.get_source(); - if (text === "") {text = this.placeholder;}; + if (text === "") { text = this.placeholder; } this.set_rendered(text); MathJax.Hub.Queue(["Typeset",MathJax.Hub]); this.element.find('div.text_cell_input').hide(); this.element.find("div.text_cell_render").show(); this.rendered = true; - }; + } }; @@ -198,7 +198,7 @@ var IPython = (function (IPython) { MarkdownCell.prototype.render = function () { if (this.rendered === false) { var text = this.get_source(); - if (text === "") {text = this.placeholder;}; + if (text === "") { text = this.placeholder; } var html = IPython.markdown_converter.makeHtml(text); this.set_rendered(html); MathJax.Hub.Queue(["Typeset",MathJax.Hub]); @@ -217,7 +217,7 @@ var IPython = (function (IPython) { return '<code class="prettyprint">' + code + '</code>'; }); this.rendered = true; - }; + } }; @@ -234,9 +234,9 @@ var IPython = (function (IPython) { RSTCell.prototype.render = function () { - if (this.rendered === false) { + if (this.rendered === false) { var text = this.get_source(); - if (text === "") {text = this.placeholder;}; + if (text === "") { text = this.placeholder; } var settings = { processData : false, cache : false, @@ -249,7 +249,7 @@ var IPython = (function (IPython) { this.element.find('div.text_cell_input').hide(); this.element.find("div.text_cell_render").show(); this.set_rendered("Rendering..."); - }; + } }; diff --git a/IPython/frontend/html/notebook/static/js/utils.js b/IPython/frontend/html/notebook/static/js/utils.js index f81c7d4..bce44b3 100644 --- a/IPython/frontend/html/notebook/static/js/utils.js +++ b/IPython/frontend/html/notebook/static/js/utils.js @@ -9,7 +9,7 @@ // Utilities //============================================================================ -IPython.namespace('IPython.utils') +IPython.namespace('IPython.utils'); IPython.utils = (function (IPython) { @@ -35,7 +35,7 @@ IPython.utils = (function (IPython) { .replace(/>/g,'&'+'gt;') .replace(/\'/g,'&'+'apos;') .replace(/\"/g,'&'+'quot;') - .replace(/`/g,'&'+'#96;') + .replace(/`/g,'&'+'#96;'); } @@ -45,32 +45,32 @@ IPython.utils = (function (IPython) { "32":"ansigreen", "33":"ansiyellow", "34":"ansiblue", "35":"ansipurple","36":"ansicyan", "37":"ansigrey", "01":"ansibold" - } + }; // Transform ANI color escape codes into HTML <span> tags with css // classes listed in the above ansi_colormap object. The actual color used // are set in the css file. function fixConsole(txt) { - txt = xmlencode(txt) - var re = /\033\[([\d;]*?)m/ - var opened = false - var cmds = [] - var opener = "" - var closer = "" + txt = xmlencode(txt); + var re = /\033\[([\d;]*?)m/; + var opened = false; + var cmds = []; + var opener = ""; + var closer = ""; while (re.test(txt)) { - var cmds = txt.match(re)[1].split(";") - closer = opened?"</span>":"" - opened = cmds.length > 1 || cmds[0] != 0 - var rep = [] + var cmds = txt.match(re)[1].split(";"); + closer = opened?"</span>":""; + opened = cmds.length > 1 || cmds[0] != 0; + var rep = []; for (var i in cmds) if (typeof(ansi_colormap[cmds[i]]) != "undefined") - rep.push(ansi_colormap[cmds[i]]) - opener = rep.length > 0?"<span class=\""+rep.join(" ")+"\">":"" - txt = txt.replace(re, closer + opener) + rep.push(ansi_colormap[cmds[i]]); + opener = rep.length > 0?"<span class=\""+rep.join(" ")+"\">":""; + txt = txt.replace(re, closer + opener); } - if (opened) txt += "</span>" - return txt + if (opened) txt += "</span>"; + return txt; } @@ -95,7 +95,7 @@ IPython.utils = (function (IPython) { uuid : uuid, fixConsole : fixConsole, grow : grow - } + }; }(IPython));