Skip to content

Commit 7fb0510

Browse files
authored
Merge pull request #3409 from takluyver/js-polish-notebooklist
Javascript lint in notebooklist.js
2 parents 1b3b354 + e2ee7c6 commit 7fb0510

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

notebook/static/tree/js/notebooklist.js

+12-23
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,13 @@ define([
2929
var normalized_list = list.map(function(_item) {
3030
return _item.toLowerCase();
3131
});
32-
return normalized_list.indexOf(item.toLowerCase()) != -1;
32+
return normalized_list.indexOf(item.toLowerCase()) !== -1;
3333
};
3434

3535
var includes_extension = function(filepath, extensionslist) {
3636
return item_in(extension(filepath), extensionslist);
3737
};
3838

39-
var json_or_xml_container_mimetype = function(mimetype) {
40-
// Match */*+json or */*+xml
41-
return (mimetype.substring(mimetype.length - 5) == '+json'
42-
|| mimetype.substring(mimetype.length - 4) == '+xml');
43-
};
44-
4539
function name_sorter(ascending) {
4640
return (function(a, b) {
4741
if (type_order[a['type']] < type_order[b['type']]) {
@@ -58,7 +52,7 @@ define([
5852
}
5953
return 0;
6054
});
61-
};
55+
}
6256

6357
function modified_sorter(ascending) {
6458
var order = ascending ? 1 : 0;
@@ -148,11 +142,10 @@ define([
148142
$('#new-file').click(function(e) {
149143
var w = window.open('', IPython._target);
150144
that.contents.new_untitled(that.notebook_path || '', {type: 'file', ext: '.txt'}).then(function(data) {
151-
var url = utils.url_path_join(
145+
w.location = utils.url_path_join(
152146
that.base_url, 'edit',
153147
utils.encode_uri_components(data.path)
154148
);
155-
w.location = url;
156149
}).catch(function (e) {
157150
w.close();
158151
dialog.modal({
@@ -230,7 +223,7 @@ define([
230223
var sort_on = e.target.id;
231224

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

235228
if ((that.sort_id === sort_on) && (that.sort_direction === 1)) {
236229
that.sort_list(sort_on, 0);
@@ -457,7 +450,7 @@ define([
457450
model = {
458451
type: 'directory',
459452
name: '..',
460-
path: utils.url_path_split(path)[0],
453+
path: utils.url_path_split(path)[0]
461454
};
462455
this.add_link(model, item);
463456
offset += 1;
@@ -567,13 +560,13 @@ define([
567560
NotebookList.icons = {
568561
directory: 'folder_icon',
569562
notebook: 'notebook_icon',
570-
file: 'file_icon',
563+
file: 'file_icon'
571564
};
572565

573566
NotebookList.uri_prefixes = {
574567
directory: 'tree',
575568
notebook: 'notebooks',
576-
file: 'edit',
569+
file: 'edit'
577570
};
578571

579572
/**
@@ -638,7 +631,6 @@ define([
638631
var has_running_notebook = false;
639632
var has_directory = false;
640633
var has_file = false;
641-
var that = this;
642634
var checked = 0;
643635
$('.list_item :checked').each(function(index, item) {
644636
var parent = $(item).parent().parent();
@@ -889,7 +881,7 @@ define([
889881
success : function () {
890882
that.load_sessions();
891883
},
892-
error : utils.log_ajax_error,
884+
error : utils.log_ajax_error
893885
};
894886

895887
var session = this.sessions[path];
@@ -921,15 +913,15 @@ define([
921913
case 'notebook': return i18n.msg._("Enter a new notebook name:");
922914
default: return i18n.msg._("Enter a new name:");
923915
}
924-
}
916+
};
925917
var rename_title = function (type) {
926918
switch(type) {
927919
case 'file': return i18n.msg._("Rename file");
928920
case 'directory': return i18n.msg._("Rename directory");
929921
case 'notebook': return i18n.msg._("Rename notebook");
930922
default: return i18n.msg._("Rename");
931923
}
932-
}
924+
};
933925
var dialog_body = $('<div/>').append(
934926
$("<p/>").addClass("rename-message")
935927
.text(rename_msg(item_type))
@@ -1275,7 +1267,6 @@ define([
12751267
var offset = 0;
12761268
var chunk = 0;
12771269
var chunk_reader = null;
1278-
var upload_file = null;
12791270

12801271
var large_reader_onload = function (event) {
12811272
if (stop_signal === true) {
@@ -1294,7 +1285,6 @@ define([
12941285
upload_file(item, chunk); // Do the upload
12951286
} else {
12961287
console.log("Read error: " + event.target.error);
1297-
return;
12981288
}
12991289
};
13001290
var on_error = function (event) {
@@ -1351,7 +1341,7 @@ define([
13511341
model.chunk = chunk;
13521342
model.content = filedata;
13531343

1354-
var on_success = function (event) {
1344+
var on_success = function () {
13551345
if (offset < f.size) {
13561346
// of to the next chunk
13571347
chunk_reader(offset, f);
@@ -1403,7 +1393,7 @@ define([
14031393
item.find(".item_buttons").empty()
14041394
.append(upload_button)
14051395
.append(cancel_button);
1406-
}
1396+
};
14071397

14081398
NotebookList.prototype.add_upload_button = function (item) {
14091399
var that = this;
@@ -1465,7 +1455,6 @@ define([
14651455
model.content = filedata;
14661456
content_type = 'application/octet-stream';
14671457
}
1468-
filedata = item.data('filedata');
14691458

14701459
var on_success = function () {
14711460
item.removeClass('new-file');

0 commit comments

Comments
 (0)