Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript lint in notebooklist.js #3409

Merged
merged 1 commit into from
Mar 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 12 additions & 23 deletions notebook/static/tree/js/notebooklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,13 @@ define([
var normalized_list = list.map(function(_item) {
return _item.toLowerCase();
});
return normalized_list.indexOf(item.toLowerCase()) != -1;
return normalized_list.indexOf(item.toLowerCase()) !== -1;
};

var includes_extension = function(filepath, extensionslist) {
return item_in(extension(filepath), extensionslist);
};

var json_or_xml_container_mimetype = function(mimetype) {
// Match */*+json or */*+xml
return (mimetype.substring(mimetype.length - 5) == '+json'
|| mimetype.substring(mimetype.length - 4) == '+xml');
};

function name_sorter(ascending) {
return (function(a, b) {
if (type_order[a['type']] < type_order[b['type']]) {
Expand All @@ -58,7 +52,7 @@ define([
}
return 0;
});
};
}

function modified_sorter(ascending) {
var order = ascending ? 1 : 0;
Expand Down Expand Up @@ -148,11 +142,10 @@ define([
$('#new-file').click(function(e) {
var w = window.open('', IPython._target);
that.contents.new_untitled(that.notebook_path || '', {type: 'file', ext: '.txt'}).then(function(data) {
var url = utils.url_path_join(
w.location = utils.url_path_join(
that.base_url, 'edit',
utils.encode_uri_components(data.path)
);
w.location = url;
}).catch(function (e) {
w.close();
dialog.modal({
Expand Down Expand Up @@ -230,7 +223,7 @@ define([
var sort_on = e.target.id;

// Clear sort indications in UI
$(".sort-action i").removeClass("fa-arrow-up").removeClass("fa-arrow-down")
$(".sort-action i").removeClass("fa-arrow-up").removeClass("fa-arrow-down");

if ((that.sort_id === sort_on) && (that.sort_direction === 1)) {
that.sort_list(sort_on, 0);
Expand Down Expand Up @@ -457,7 +450,7 @@ define([
model = {
type: 'directory',
name: '..',
path: utils.url_path_split(path)[0],
path: utils.url_path_split(path)[0]
};
this.add_link(model, item);
offset += 1;
Expand Down Expand Up @@ -567,13 +560,13 @@ define([
NotebookList.icons = {
directory: 'folder_icon',
notebook: 'notebook_icon',
file: 'file_icon',
file: 'file_icon'
};

NotebookList.uri_prefixes = {
directory: 'tree',
notebook: 'notebooks',
file: 'edit',
file: 'edit'
};

/**
Expand Down Expand Up @@ -638,7 +631,6 @@ define([
var has_running_notebook = false;
var has_directory = false;
var has_file = false;
var that = this;
var checked = 0;
$('.list_item :checked').each(function(index, item) {
var parent = $(item).parent().parent();
Expand Down Expand Up @@ -889,7 +881,7 @@ define([
success : function () {
that.load_sessions();
},
error : utils.log_ajax_error,
error : utils.log_ajax_error
};

var session = this.sessions[path];
Expand Down Expand Up @@ -921,15 +913,15 @@ define([
case 'notebook': return i18n.msg._("Enter a new notebook name:");
default: return i18n.msg._("Enter a new name:");
}
}
};
var rename_title = function (type) {
switch(type) {
case 'file': return i18n.msg._("Rename file");
case 'directory': return i18n.msg._("Rename directory");
case 'notebook': return i18n.msg._("Rename notebook");
default: return i18n.msg._("Rename");
}
}
};
var dialog_body = $('<div/>').append(
$("<p/>").addClass("rename-message")
.text(rename_msg(item_type))
Expand Down Expand Up @@ -1275,7 +1267,6 @@ define([
var offset = 0;
var chunk = 0;
var chunk_reader = null;
var upload_file = null;

var large_reader_onload = function (event) {
if (stop_signal === true) {
Expand All @@ -1294,7 +1285,6 @@ define([
upload_file(item, chunk); // Do the upload
} else {
console.log("Read error: " + event.target.error);
return;
}
};
var on_error = function (event) {
Expand Down Expand Up @@ -1351,7 +1341,7 @@ define([
model.chunk = chunk;
model.content = filedata;

var on_success = function (event) {
var on_success = function () {
if (offset < f.size) {
// of to the next chunk
chunk_reader(offset, f);
Expand Down Expand Up @@ -1403,7 +1393,7 @@ define([
item.find(".item_buttons").empty()
.append(upload_button)
.append(cancel_button);
}
};

NotebookList.prototype.add_upload_button = function (item) {
var that = this;
Expand Down Expand Up @@ -1465,7 +1455,6 @@ define([
model.content = filedata;
content_type = 'application/octet-stream';
}
filedata = item.data('filedata');

var on_success = function () {
item.removeClass('new-file');
Expand Down