Skip to content

Commit 25145f6

Browse files
author
rdvelazquez
committedOct 2, 2018
code cleanup: delete unused files and dead code; address lint warnings
1 parent b9c0a24 commit 25145f6

12 files changed

+80
-1441
lines changed
 

‎.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
dist/
22
node_modules
33
assets
4+
server.js
5+
webpack.config.js

‎.eslintrc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
},
1414
"rules": {
1515
"strict": [1, "never"],
16-
"no-unused-vars": [1, {"vars":"all", "args":"none"}],
16+
"no-unused-vars": [1, { "vars": "all", "args": "none" }],
1717
"no-self-assign": 1,
1818
"no-unreachable": 2,
1919
"no-debugger": 2,
2020
"no-console": 1,
21-
"no-undef": 1,
21+
"no-undef": 0,
2222
"no-mixed-spaces-and-tabs": 0,
2323
"no-redeclare": 1,
2424
"no-empty": 1,
@@ -32,7 +32,7 @@
3232
},
3333
"globals": {
3434
"_": false,
35-
"d3":false,
35+
"d3": false,
3636
"$": false
3737
}
3838
}

‎index.html

-9
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,6 @@ <h4 class="modal-title">Listing nodes in cluster X</h4>
226226
</div>
227227

228228

229-
<!--<div class="nav-trace" id = "network_ui_bar_sliders" style = "display: none">
230-
<div class="input-group">
231-
<label id = "network_ui_bar_sliders_label_from">2001/01/01</label>
232-
<input id = "network_ui_bar_sliders_from" class = "col-lg-3" type = "range" min = "0" max = "100" step = "0.1" value = "1"></input>
233-
<input id = "network_ui_bar_sliders_to" class = "col-lg-3" type = "range" min = "0" max = "100" step = "0.1" value = "1"/>
234-
<label class = "pull-right" id = "network_ui_bar_sliders_label_to">2012/01/01</label>
235-
</div>
236-
</div>-->
237-
238229
</div>
239230
</div>
240231

‎plain.html

-772
This file was deleted.

‎src/clusternetwork.js

+55-320
Large diffs are not rendered by default.

‎src/helpers.js

+7-14
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var datamonkey_save_image = function(type, container) {
7777
}
7878
}
7979
} catch (e) {
80-
console.log("Could not process stylesheet : " + ss);
80+
console.log("Could not process stylesheet : " + ss); // eslint-disable-line
8181
}
8282
}
8383

@@ -94,6 +94,7 @@ var datamonkey_save_image = function(type, container) {
9494
}
9595

9696
var convert_svg_to_png = function(image_string) {
97+
// eslint-disable-line
9798
var image = document.getElementById("hyphy-chart-image");
9899

99100
image.onload = function() {
@@ -104,7 +105,6 @@ var datamonkey_save_image = function(type, container) {
104105
context.fillStyle = "#FFFFFF";
105106
context.fillRect(0, 0, image.width, image.height);
106107
context.drawImage(image, 0, 0);
107-
var img = canvas.toDataURL("image/png");
108108
var pom = document.createElement("a");
109109
pom.setAttribute("download", "image.png");
110110
pom.href = canvas.toDataURL("image/png");
@@ -148,7 +148,6 @@ var datamonkey_save_image = function(type, container) {
148148
var source = new XMLSerializer()
149149
.serializeToString(svg)
150150
.replace("</style>", "<![CDATA[" + styles + "]]></style>");
151-
var rect = svg.getBoundingClientRect();
152151
var doctype =
153152
'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">';
154153
var to_download = [doctype + source];
@@ -171,7 +170,7 @@ var datamonkey_save_image = function(type, container) {
171170
pom.remove();
172171
},
173172
function(error) {
174-
console.log(error);
173+
console.log(error); // eslint-disable-line
175174
}
176175
);
177176
} else {
@@ -286,7 +285,6 @@ function datamonkey_convert_svg_to_png(image_string) {
286285
context.fillStyle = "#FFFFFF";
287286
context.fillRect(0, 0, image.width, image.height);
288287
context.drawImage(image, 0, 0);
289-
var img = canvas.toDataURL("image/png");
290288

291289
var pom = document.createElement("a");
292290
pom.setAttribute("download", "phylotree.png");
@@ -304,7 +302,6 @@ function datamonkey_save_newick_tree(type) {
304302
svg: "http://www.w3.org/2000/svg"
305303
};
306304

307-
var tree_container = "#tree_container";
308305
var svg = $("#tree_container").find("svg")[0];
309306
var styles = datamonkey_get_styles(window.document);
310307

@@ -333,7 +330,6 @@ function datamonkey_save_newick_tree(type) {
333330
var source = new XMLSerializer()
334331
.serializeToString(svg)
335332
.replace("</style>", "<![CDATA[" + styles + "]]></style>");
336-
var rect = svg.getBoundingClientRect();
337333
var doctype =
338334
'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">';
339335
var to_download = [doctype + source];
@@ -354,7 +350,7 @@ function datamonkey_save_newick_tree(type) {
354350

355351
function datamonkey_validate_email(email) {
356352
if ($(this).find("input[name='receive_mail']")[0].checked) {
357-
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
353+
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; // eslint-disable-line
358354
if (
359355
regex.test(
360356
$(this)
@@ -375,10 +371,6 @@ function datamonkey_validate_email(email) {
375371
$(this).removeClass("has-error");
376372
$(this).removeClass("has-success");
377373
$(this).addClass("has-error");
378-
var span = jQuery("<span/>", {
379-
class: "help-block col-lg-9 pull-right",
380-
text: "Invalid Email"
381-
}).insertAfter($(this));
382374
}
383375
} else {
384376
$(this).removeClass("has-error");
@@ -395,7 +387,7 @@ function datamonkey_describe_vector(vector, as_list) {
395387
if (vector.length) {
396388
vector.sort(d3.ascending);
397389

398-
var d = {
390+
d = {
399391
min: d3.min(vector),
400392
max: d3.max(vector),
401393
median: d3.median(vector),
@@ -404,7 +396,7 @@ function datamonkey_describe_vector(vector, as_list) {
404396
mean: d3.mean(vector)
405397
};
406398
} else {
407-
var d = {
399+
d = {
408400
min: null,
409401
max: null,
410402
median: null,
@@ -450,6 +442,7 @@ function datamonkey_export_handler(data, filename, mimeType) {
450442
var ua = window.navigator.userAgent;
451443
var msie = ua.indexOf("MSIE ");
452444
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
445+
// eslint-disable-line
453446
return true;
454447
}
455448
return false;

‎src/histogram.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ function hivtrace_histogram(graph, histogram_tag, histogram_label) {
3333
}
3434

3535
function hivtrace_histogram_distances(graph, histogram_tag, histogram_label) {
36-
var defaultFloatFormat = d3.format(",.3p");
3736
var histogram_w = 300,
3837
histogram_h = 300;
3938

@@ -153,15 +152,15 @@ function hivtrace_render_histogram_continuous(data, w, h, id) {
153152
.attr("dx", "1em")
154153
.attr("dy", "0.5em");
155154

156-
var y_axis_label = histogram_svg
155+
var y_axis_label = histogram_svg // eslint-disable-line
157156
.append("text")
158157
.attr("transform", "rotate(-90)")
159158
.attr("y", 0 - margin.left + y_axis_label_width)
160159
.attr("x", 0 - height / 2)
161160
.style("text-anchor", "middle")
162161
.text("Edges");
163162

164-
var x_axis_label = histogram_svg
163+
var x_axis_label = histogram_svg // eslint-disable-line
165164
.append("text")
166165
.attr(
167166
"transform",
@@ -170,7 +169,7 @@ function hivtrace_render_histogram_continuous(data, w, h, id) {
170169
.style("text-anchor", "middle")
171170
.text("Genetic Distance");
172171

173-
var y_axis = histogram_svg
172+
var y_axis = histogram_svg // eslint-disable-line
174173
.append("g")
175174
.attr("class", "y axis")
176175
//.attr("transform", "translate(0," + height + ")")

‎src/hivtrace.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Bootstrap from "bootstrap/dist/css/bootstrap.css";
1+
import Bootstrap from "bootstrap/dist/css/bootstrap.css"; // eslint-disable-line
22
import { clusterNetwork, graphSummary } from "./clusternetwork.js";
33
import { histogram, histogramDistances } from "./histogram.js";
44
import { scatterPlot } from "./scatterplot.js";

‎src/misc.js

+8-33
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ function hivtrace_compute_shortest_paths_with_reconstruction(
258258
// Floyd-Warshall implementation
259259
var distances = [];
260260
var next = [];
261-
var nodes = obj.Nodes;
262-
var edges = obj.Edges;
263-
var node_ids = [];
264261

265262
var adjacency_list = hivtrace_cluster_adjacency_list(obj);
266263

@@ -283,7 +280,7 @@ function hivtrace_compute_shortest_paths_with_reconstruction(
283280
}
284281

285282
for (var index = 0; index < subset.length; index++) {
286-
var a_node = subset[index];
283+
var a_node = subset[index]; // eslint-disable-line
287284
for (var index2 = 0; index2 < subset.length; index2++) {
288285
var second_node = subset[index2];
289286
if (second_node != a_node) {
@@ -315,14 +312,14 @@ function hivtrace_compute_shortest_paths_with_reconstruction(
315312

316313
// clone distances
317314
var distances2 = _.map(distances, _.clone);
318-
var c = 0;
319315

320316
for (var index_k = 0; index_k < subset.length; index_k++) {
321-
var n_k = subset[index_k];
322317
for (var index_i = 0; index_i < subset.length; index_i++) {
323-
var n_i = subset[index_i];
318+
// eslint-disable-line
319+
var n_i = subset[index_i]; // eslint-disable-line
324320
for (var index_j = 0; index_j < subset.length; index_j++) {
325-
var n_j = subset[index_j];
321+
// eslint-disable-line
322+
var n_j = subset[index_j]; // eslint-disable-line
326323

327324
if (n_i != n_j) {
328325
d_ik = distances[index_k][index_i];
@@ -345,7 +342,6 @@ function hivtrace_compute_shortest_paths_with_reconstruction(
345342
);
346343
}
347344
}
348-
c++;
349345
distances2[index_j][index_i] = distances[index_j][index_i];
350346
distances2[index_i][index_j] = distances[index_i][index_j];
351347
}
@@ -377,7 +373,7 @@ function hivtrace_filter_to_node_in_cluster(node, obj) {
377373
if (node_obj) {
378374
cluster_id = node_obj[0].cluster;
379375
} else {
380-
console.log("could not find node");
376+
console.log("could not find node"); // eslint-disable-line
381377
return null;
382378
}
383379

@@ -428,7 +424,7 @@ function hivtrace_compute_betweenness_centrality_all_nodes_in_cluster(
428424

429425
// get paths
430426
var paths = hivtrace_compute_shortest_paths_with_reconstruction(filtered_obj);
431-
var node_ids = nodes_in_cluster.map(function(n) {
427+
node_ids = nodes_in_cluster.map(function(n) {
432428
return n.id;
433429
});
434430

@@ -571,6 +567,7 @@ function hivtrace_convert_to_csv(obj, callback) {
571567

572568
function hivtrace_export_csv_button(graph, tag) {
573569
var data = hivtrace_convert_to_csv(graph, function(err, data) {
570+
// eslint-disable-line
574571
if (data !== null) {
575572
var pom = document.createElement("a");
576573
pom.setAttribute(
@@ -667,28 +664,6 @@ function hivtrace_format_value(value, formatter) {
667664
return formatter ? formatter(value) : value;
668665
}
669666

670-
function hivtrace_plot_case_time_series(
671-
time_series,
672-
container,
673-
x_title,
674-
y_title,
675-
y_scale,
676-
bin_by,
677-
options
678-
) {
679-
options = options || {
680-
base_line: 20,
681-
top: 40,
682-
right: 30,
683-
bottom: 3 * 20,
684-
left: 5 * 20,
685-
font_size: 18,
686-
rect_size: 22,
687-
width: 1024,
688-
height: 600
689-
};
690-
}
691-
692667
function hivtrace_plot_cluster_dynamics(
693668
time_series,
694669
container,

‎src/prevalence.js

-15
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,6 @@ function hivtrace_render_prevalence(
164164
}
165165
}
166166

167-
var scaler_per_year = 1000 * 60 * 60 * 24 * 365;
168-
169-
var lf = linear_fit(
170-
year_points.map(function(d) {
171-
return [(d["x"] - x.domain()[0]) / scaler_per_year, d["y"]];
172-
})
173-
);
174-
175-
/*var line = d3.svg.line()
176-
.x(function(d) { return x(d['x']); })
177-
.y(function(d) { return y(
178-
Math.max (0,(d['x'] - x.domain ()[0] )*lf["slope"]/scaler_per_year+lf["intercept"]))
179-
; })
180-
.interpolate ("linear");*/
181-
182167
var line = d3.svg
183168
.line()
184169
.x(function(d) {

‎src/scatterplot.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
var d3 = require("d3"),
2-
_ = require("underscore");
1+
var d3 = require("d3");
32

43
function hivtrace_render_scatterplot(points, w, h, id, labels, dates) {
5-
var _defaultDateViewFormat = d3.time.format("%B %d, %Y");
64
var _defaultFloatFormat = d3.format(",.2r");
75
var _defaultDateViewFormatShort = d3.time.format("%B %Y");
86

‎tour.js

-267
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.