Skip to content

Commit ffb5a64

Browse files
committed
Fix jshint offenses
1 parent 4122c32 commit ffb5a64

File tree

6 files changed

+101
-88
lines changed

6 files changed

+101
-88
lines changed

Graph.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
2222
Edges:
2323
Connects to nodes together.
24-
24+
2525
Example:
2626
edge = new Edge(node1, node2);
2727
2828
An edge can also be extended with the data attribute. E.g. set a
29-
type like "friends", different types can then be draw in differnt ways.
29+
type like "friends", different types can then be draw in differnt ways.
3030
3131
3232
Graph:
33-
33+
3434
Parameters:
3535
options = {
3636
limit: <int>, maximum number of nodes
@@ -43,7 +43,7 @@
4343
addEdge(node1, node2) - adds an edge for node1 and node2. Returns true if the
4444
edge has been added, otherwise false (e.g.) when the
4545
edge between these nodes already exist.
46-
46+
4747
reached_limit() - returns true if the limit has been reached, otherwise false
4848
4949
*/
@@ -53,11 +53,11 @@ function Graph(options) {
5353
this.nodeSet = {};
5454
this.nodes = [];
5555
this.edges = [];
56-
this.layout;
56+
this.layout = null;
5757
}
5858

5959
Graph.prototype.addNode = function(node) {
60-
if(this.nodeSet[node.id] == undefined && !this.reached_limit()) {
60+
if(this.nodeSet[node.id] === undefined && !this.reached_limit()) {
6161
this.nodeSet[node.id] = node;
6262
this.nodes.push(node);
6363
return true;
@@ -79,7 +79,7 @@ Graph.prototype.addEdge = function(source, target) {
7979
};
8080

8181
Graph.prototype.reached_limit = function() {
82-
if(this.options.limit != undefined)
82+
if(this.options.limit !== undefined)
8383
return this.options.limit <= this.nodes.length;
8484
else
8585
return false;

drawings/simple_graph.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
var Drawing = Drawing || {};
5050

5151
Drawing.SimpleGraph = function(options) {
52-
var options = options || {};
52+
options = options || {};
5353

5454
this.layout = options.layout || "2d";
5555
this.layout_options = options.graphLayout || {};
@@ -115,7 +115,7 @@ Drawing.SimpleGraph = function(options) {
115115
domElement: renderer.domElement,
116116
selected: function(obj) {
117117
// display info
118-
if(obj != null) {
118+
if(obj !== null) {
119119
info_text.select = "Object " + obj.id;
120120
} else {
121121
delete info_text.select;
@@ -163,8 +163,8 @@ Drawing.SimpleGraph = function(options) {
163163
nodes.push(node);
164164

165165
var steps = 1;
166-
while(nodes.length != 0 && steps < that.nodes_count) {
167-
var node = nodes.shift();
166+
while(nodes.length !== 0 && steps < that.nodes_count) {
167+
node = nodes.shift();
168168

169169
var numEdges = randomFromTo(1, that.edges_count);
170170
for(var i=1; i <= numEdges; i++) {
@@ -198,12 +198,13 @@ Drawing.SimpleGraph = function(options) {
198198
*/
199199
function drawNode(node) {
200200
var draw_object = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, opacity: 0.5 } ) );
201+
var label_object;
201202

202203
if(that.show_labels) {
203-
if(node.data.title != undefined) {
204-
var label_object = new THREE.Label(node.data.title);
204+
if(node.data.title !== undefined) {
205+
label_object = new THREE.Label(node.data.title);
205206
} else {
206-
var label_object = new THREE.Label(node.id);
207+
label_object = new THREE.Label(node.id);
207208
}
208209
node.data.label_object = label_object;
209210
scene.add( node.data.label_object );
@@ -259,6 +260,8 @@ Drawing.SimpleGraph = function(options) {
259260

260261

261262
function render() {
263+
var i, length, node;
264+
262265
// Generate layout if not finished
263266
if(!graph.layout.finished) {
264267
info_text.calc = "<span style='color: red'>Calculating layout...</span>";
@@ -268,37 +271,38 @@ Drawing.SimpleGraph = function(options) {
268271
}
269272

270273
// Update position of lines (edges)
271-
for(var i=0; i<geometries.length; i++) {
274+
for(i=0; i<geometries.length; i++) {
272275
geometries[i].verticesNeedUpdate = true;
273276
}
274277

275278

276279
// Show labels if set
277280
// It creates the labels when this options is set during visualization
278281
if(that.show_labels) {
279-
var length = graph.nodes.length;
280-
for(var i=0; i<length; i++) {
281-
var node = graph.nodes[i];
282-
if(node.data.label_object != undefined) {
282+
length = graph.nodes.length;
283+
for(i=0; i<length; i++) {
284+
node = graph.nodes[i];
285+
if(node.data.label_object !== undefined) {
283286
node.data.label_object.position.x = node.data.draw_object.position.x;
284287
node.data.label_object.position.y = node.data.draw_object.position.y - 100;
285288
node.data.label_object.position.z = node.data.draw_object.position.z;
286289
node.data.label_object.lookAt(camera.position);
287290
} else {
288-
if(node.data.title != undefined) {
289-
var label_object = new THREE.Label(node.data.title, node.data.draw_object);
291+
var label_object;
292+
if(node.data.title !== undefined) {
293+
label_object = new THREE.Label(node.data.title, node.data.draw_object);
290294
} else {
291-
var label_object = new THREE.Label(node.id, node.data.draw_object);
295+
label_object = new THREE.Label(node.id, node.data.draw_object);
292296
}
293297
node.data.label_object = label_object;
294298
scene.add( node.data.label_object );
295299
}
296300
}
297301
} else {
298-
var length = graph.nodes.length;
299-
for(var i=0; i<length; i++) {
300-
var node = graph.nodes[i];
301-
if(node.data.label_object != undefined) {
302+
length = graph.nodes.length;
303+
for(i=0; i<length; i++) {
304+
node = graph.nodes[i];
305+
if(node.data.label_object !== undefined) {
302306
scene.remove( node.data.label_object );
303307
node.data.label_object = undefined;
304308
}
@@ -325,7 +329,7 @@ Drawing.SimpleGraph = function(options) {
325329
function printInfo(text) {
326330
var str = '';
327331
for(var index in info_text) {
328-
if(str != '' && info_text[index] != '') {
332+
if(str !== '' && info_text[index] !== '') {
329333
str += " - ";
330334
}
331335
str += info_text[index];
@@ -341,5 +345,5 @@ Drawing.SimpleGraph = function(options) {
341345
// Stop layout calculation
342346
this.stop_calculating = function() {
343347
graph.layout.stop_calculating();
344-
}
345-
}
348+
};
349+
};

drawings/sphere_graph.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
var Drawing = Drawing || {};
5151

5252
Drawing.SphereGraph = function(options) {
53-
var options = options || {};
53+
options = options || {};
5454

5555
this.layout = options.layout || "2d";
5656
this.show_stats = options.showStats || false;
@@ -93,7 +93,7 @@ Drawing.SphereGraph = function(options) {
9393
controls.zoomSpeed = 5.2;
9494
controls.panSpeed = 1;
9595

96-
controls.noZoom = false
96+
controls.noZoom = false;
9797
controls.noPan = false;
9898

9999
controls.staticMoving = false;
@@ -120,7 +120,7 @@ Drawing.SphereGraph = function(options) {
120120
domElement: renderer.domElement,
121121
selected: function(obj) {
122122
// display info
123-
if(obj != null) {
123+
if(obj !== null) {
124124
info_text.select = "Object " + obj.id;
125125
} else {
126126
delete info_text.select;
@@ -164,8 +164,8 @@ Drawing.SphereGraph = function(options) {
164164
nodes.push(node);
165165

166166
var steps = 1;
167-
while(nodes.length != 0 && steps < that.nodes_count) {
168-
var node = nodes.shift();
167+
while(nodes.length !== 0 && steps < that.nodes_count) {
168+
node = nodes.shift();
169169

170170
var numEdges = randomFromTo(1, that.edges_count);
171171
for(var i=1; i <= numEdges; i++) {
@@ -229,7 +229,7 @@ Drawing.SphereGraph = function(options) {
229229

230230
draw_object.id = node.id;
231231
node.data.draw_object = draw_object;
232-
node.layout = {}
232+
node.layout = {};
233233
node.layout.max_X = 90;
234234
node.layout.min_X = -90;
235235
node.layout.max_Y = 180;
@@ -271,6 +271,8 @@ Drawing.SphereGraph = function(options) {
271271

272272

273273
function render() {
274+
var i;
275+
274276
// Generate layout if not finished
275277
if(!graph.layout.finished) {
276278
info_text.calc = "<span style='color: red'>Calculating layout...</span>";
@@ -280,12 +282,12 @@ Drawing.SphereGraph = function(options) {
280282
}
281283

282284
// Update position of lines (edges)
283-
for(var i=0; i<geometries.length; i++) {
285+
for(i=0; i<geometries.length; i++) {
284286
geometries[i].verticesNeedUpdate = true;
285287
}
286288

287289
// set lookat of nodes to camera
288-
for(var i=0; i<graph.nodes.length; i++) {
290+
for(i=0; i<graph.nodes.length; i++) {
289291
graph.nodes[i].data.draw_object.lookAt(camera.position);
290292
}
291293

@@ -310,7 +312,7 @@ Drawing.SphereGraph = function(options) {
310312
function printInfo(text) {
311313
var str = '';
312314
for(var index in info_text) {
313-
if(str != '' && info_text[index] != '') {
315+
if(str !== '' && info_text[index] !== '') {
314316
str += " - ";
315317
}
316318
str += info_text[index];
@@ -327,5 +329,5 @@ Drawing.SphereGraph = function(options) {
327329
// Stop layout calculation
328330
this.stop_calculating = function() {
329331
graph.layout.stop_calculating();
330-
}
331-
}
332+
};
333+
};

0 commit comments

Comments
 (0)