From d841da03bd1473c6f1ae5acc185bdfe543e99f71 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 26 Jul 2015 00:24:28 +0300 Subject: client: various lint fixes --- src/client/model/graph.js | 48 +++++++++++++++++++++++----------------------- src/client/view/layouts.js | 14 ++++++++------ 2 files changed, 32 insertions(+), 30 deletions(-) (limited to 'src/client') diff --git a/src/client/model/graph.js b/src/client/model/graph.js index 1caccbd9..8838b7f5 100644 --- a/src/client/model/graph.js +++ b/src/client/model/graph.js @@ -635,9 +635,9 @@ function Graph(spec) { util.assert(node instanceof model_core.Node); // TODO - fake api for client only (debug, demo, ui work) - if (!rz_config.backend_enabled) return; + if (!rz_config.backend_enabled) { return; } - if (new_node_spec.name !== undefined && node.name != new_node_spec.name){ + if (new_node_spec.name !== undefined && node.name !== new_node_spec.name){ /* * handle name update collision: suggest removal first */ @@ -648,7 +648,7 @@ function Graph(spec) { } } - node['name'] = new_node_spec['name']; // [!] may still fail due to server NAK + node.name = new_node_spec.name; // [!] may still fail due to server NAK } var attr_diff = model_diff.new_attr_diff(); @@ -658,17 +658,17 @@ function Graph(spec) { var on_ajax_success = function(attr_diff_spec){ var attr_diff = model_util.adapt_format_read_diff__attr(attr_diff_spec), - id_to_node_map = attr_diff.id_to_node_map, - key, - n_id = node.id; // original node id + id_to_node_map = attr_diff.id_to_node_map, + key, + n_id = node.id; // original node id util.assert(id_to_node_map && id_to_node_map[n_id], "bad return value from ajax"); var ret_node = id_to_node_map[n_id]; - for (key in ret_node['__attr_write']){ - node[key] = ret_node['__attr_write'][key]; + for (key in ret_node.__attr_write){ + node[key] = ret_node.__attr_write[key]; } - for (key in ret_node['__attr_remove']){ + for (key in ret_node.__attr_remove){ delete node[key]; } @@ -1118,25 +1118,25 @@ function Graph(spec) { // process nodes attr_diff.for_each_node(function(n_id, n_attr_diff) { - var attr_key, - node = id_to_node_map[n_id]; + var attr_key, + node = id_to_node_map[n_id]; - if (undefined == node) { + if (undefined === node) { console.warn('commit_diff__attr: incoming attr diff for non-existing node, discarding'); return; } // apply attr writes: node var count_w = 0; - for (attr_key in n_attr_diff['__attr_write']) { - var attr_value = n_attr_diff['__attr_write'][attr_key]; + for (attr_key in n_attr_diff.__attr_write) { + var attr_value = n_attr_diff.__attr_write[attr_key]; node[attr_key] = attr_value; // write each new attr update count_w = count_w + 1; - }; + } // apply attr removals: node var count_d = 0; - for (attr_key in n_attr_diff['__attr_remove']) { + for (attr_key in n_attr_diff.__attr_remove) { delete node[attr_key]; // apply each attr removal count_d = count_d + 1; }; @@ -1146,28 +1146,28 @@ function Graph(spec) { // process links attr_diff.for_each_link(function(l_id, n_attr_diff) { - var attr_key, - link = id_to_link_map[l_id]; + var attr_key, + link = id_to_link_map[l_id]; - if (undefined == link) { + if (undefined === link) { console.warn('commit_diff__attr: incoming attr diff for non-existing link, discarding'); return; } // apply attr writes: link var count_w = 0; - for (attr_key in n_attr_diff['__attr_write']) { - var attr_value = n_attr_diff['__attr_write'][attr_key]; + for (attr_key in n_attr_diff.__attr_write) { + var attr_value = n_attr_diff.__attr_write[attr_key]; link[attr_key] = attr_value; // write each new attr update count_w = count_w + 1; - }; + } // apply attr removals: link var count_d = 0; - for (attr_key in n_attr_diff['__attr_remove']) { + for (attr_key in n_attr_diff.__attr_remove) { delete link[attr_key]; // apply each attr removal count_d = count_d + 1; - }; + } console.log('commit_diff__attr: l_id: \'' + l_id + '\', write-count: ' + count_w + ', rm-count: ' + count_d); }); diff --git a/src/client/view/layouts.js b/src/client/view/layouts.js index 26e9ead4..32e12e59 100644 --- a/src/client/view/layouts.js +++ b/src/client/view/layouts.js @@ -48,7 +48,7 @@ function(consts, $, d3, _) { node_by_id = _.object(_.map(nodes, "id"), nodes), node_links = calc_node_links(nodes, links); - if (nodes.length == 0) { + if (nodes.length === 0) { return []; } @@ -125,7 +125,7 @@ function(consts, $, d3, _) { var ret = layout__d3_force(graph); ret.zen_mode_inner = function (zen_mode) { if (zen_mode) { - ret.distance(240) + ret.distance(240); } else { ret.linkDistance(function (link) { var d_src = graph.degree(link.__src), @@ -135,7 +135,7 @@ function(consts, $, d3, _) { }); } return ret; - } + }; return ret; } @@ -230,8 +230,10 @@ function(consts, $, d3, _) { _zen_mode__fixed: {}, _zen_mode_inner: donothing, zen_mode: function (zen_mode) { + var nodes, d; + if (zen_mode) { - var nodes = layout.nodes(); + nodes = layout.nodes(); // store fixed position console.log('zen on: storing fixed for ' + _.size(layout.nodes())); @@ -240,8 +242,8 @@ function(consts, $, d3, _) { _.each(nodes, function(node) { node.fixed = false; }); } else { // restore fixed - var nodes = layout.nodes(), - d = _.object(_.pluck(nodes, "id"), nodes); + nodes = layout.nodes(); + d = _.object(_.pluck(nodes, "id"), nodes); console.log('zen off: restoring fixed for ' + _.size(nodes)); _.each(_.keys(layout._zen_mode__fixed), function (node_id) { if (d[node_id] !== undefined && layout._zen_mode__fixed[node_id]) { -- cgit v1.3.1