diff --git a/lib/DataSet.js b/lib/DataSet.js index ca1ef8878..6b3450ba5 100644 --- a/lib/DataSet.js +++ b/lib/DataSet.js @@ -321,7 +321,7 @@ DataSet.prototype.update = function (data, senderId) { * {String | function} [order] Order the items by a field name or custom sort function. * @throws Error */ -DataSet.prototype.get = function (args) { +DataSet.prototype.get = function (args) { // eslint-disable-line no-unused-vars var me = this; // parse the arguments diff --git a/lib/DataView.js b/lib/DataView.js index 04725868f..8d8ec7884 100644 --- a/lib/DataView.js +++ b/lib/DataView.js @@ -158,7 +158,7 @@ DataView.prototype.refresh = function () { * DataTable. * @param args */ -DataView.prototype.get = function (args) { +DataView.prototype.get = function (args) { // eslint-disable-line no-unused-vars var me = this; // parse the arguments diff --git a/lib/network/CachedImage.js b/lib/network/CachedImage.js index fde6cb054..d35e8cb48 100644 --- a/lib/network/CachedImage.js +++ b/lib/network/CachedImage.js @@ -9,6 +9,7 @@ * for svg, but the mipmapping may not be necessary. */ class CachedImage { + // eslint-disable-next-line no-unused-vars constructor(image) { this.NUM_ITERATIONS = 4; // Number of items in the coordinates array @@ -138,7 +139,7 @@ class CachedImage { * * @private */ - _isImageOk(img) { + _isImageOk() { var img = this.image; // During the onload event, IE correctly identifies any images that diff --git a/lib/network/Images.js b/lib/network/Images.js index 7256f2a8f..e14f49809 100644 --- a/lib/network/Images.js +++ b/lib/network/Images.js @@ -50,7 +50,7 @@ class Images { * @param {string} brokenUrl Url of an image to use if the url image is not found * @return {Image} img The image object */ - load (url, brokenUrl, id) { + load (url, brokenUrl, id) { // eslint-disable-line no-unused-vars //Try and get the image from the cache, if successful then return the cached image var cachedImage = this.images[url]; if (cachedImage) return cachedImage; diff --git a/lib/network/Network.js b/lib/network/Network.js index 1df33bdf8..d43f60e41 100644 --- a/lib/network/Network.js +++ b/lib/network/Network.js @@ -3,8 +3,6 @@ require('./shapes'); let Emitter = require('emitter-component'); let util = require('../util'); -let DataSet = require('../DataSet'); -let DataView = require('../DataView'); let dotparser = require('./dotparser'); let gephiParser = require('./gephiParser'); let Activator = require('../shared/Activator'); diff --git a/lib/network/gephiParser.js b/lib/network/gephiParser.js index 66da1eb64..dc1d2e136 100644 --- a/lib/network/gephiParser.js +++ b/lib/network/gephiParser.js @@ -40,9 +40,9 @@ function parseGephi(gephiJSON, optionsObj) { edges.push(edge); } - for (var i = 0; i < gNodes.length; i++) { + for (var j = 0; j < gNodes.length; j++) { var node = {}; - var gNode = gNodes[i]; + var gNode = gNodes[j]; node['id'] = gNode.id; node['attributes'] = gNode.attributes; node['x'] = gNode.x; diff --git a/lib/network/modules/Canvas.js b/lib/network/modules/Canvas.js index 25ef90d0f..123737360 100644 --- a/lib/network/modules/Canvas.js +++ b/lib/network/modules/Canvas.js @@ -330,7 +330,7 @@ class Canvas { // set initialized so the get and set camera will work from now on. this.initialized = true; return emitEvent; - }; + } getContext() { diff --git a/lib/network/modules/Clustering.js b/lib/network/modules/Clustering.js index 50c7abf1c..49f5a6329 100644 --- a/lib/network/modules/Clustering.js +++ b/lib/network/modules/Clustering.js @@ -902,7 +902,7 @@ class ClusterEngine { } return hubThreshold; - }; + } /** diff --git a/lib/network/modules/EdgesHandler.js b/lib/network/modules/EdgesHandler.js index 818415251..8aaa665e8 100644 --- a/lib/network/modules/EdgesHandler.js +++ b/lib/network/modules/EdgesHandler.js @@ -4,7 +4,6 @@ var DataView = require('../../DataView'); var Edge = require("./components/Edge").default; var Label = require("./components/shared/Label").default; -var LayoutEngine = require("./LayoutEngine").default; // For access to LayoutEngine.getStaticType() class EdgesHandler { constructor(body, images, groups) { diff --git a/lib/network/modules/LayoutEngine.js b/lib/network/modules/LayoutEngine.js index 769356907..22955da51 100644 --- a/lib/network/modules/LayoutEngine.js +++ b/lib/network/modules/LayoutEngine.js @@ -616,7 +616,6 @@ class LayoutEngine { // get the size of the largest hubs and check if the user has defined a level for a node. let node, nodeId; let definedLevel = false; - let definedPositions = true; let undefinedLevel = false; this.lastNodeOnLevel = {}; this.hierarchical = new HierarchicalStatus(); @@ -624,9 +623,6 @@ class LayoutEngine { for (nodeId in this.body.nodes) { if (this.body.nodes.hasOwnProperty(nodeId)) { node = this.body.nodes[nodeId]; - if (node.options.x === undefined && node.options.y === undefined) { - definedPositions = false; - } if (node.options.level !== undefined) { definedLevel = true; this.hierarchical.levels[nodeId] = node.options.level; @@ -779,7 +775,7 @@ class LayoutEngine { } return [min, max, minSpace, maxSpace]; - }; + } // check what the maximum level is these nodes have in common. @@ -832,8 +828,11 @@ class LayoutEngine { // check the largest distance between the branches let maxLevel = getCollisionLevel(node1, node2); - let [min1,max1, minSpace1, maxSpace1] = getBranchBoundary(branchNodes1, maxLevel); - let [min2,max2, minSpace2, maxSpace2] = getBranchBoundary(branchNodes2, maxLevel); + let branchNodeBoundary1 = getBranchBoundary(branchNodes1, maxLevel); + let branchNodeBoundary2 = getBranchBoundary(branchNodes2, maxLevel); + let max1 = branchNodeBoundary1[1]; + let min2 = branchNodeBoundary2[0]; + let minSpace2 = branchNodeBoundary2[2]; //console.log(node1.id, getBranchBoundary(branchNodes1, maxLevel), node2.id, // getBranchBoundary(branchNodes2, maxLevel), maxLevel); @@ -935,7 +934,9 @@ class LayoutEngine { getBranchNodes(node, branchNodes); branches[node.id] = branchNodes; } - let [minBranch, maxBranch, minSpaceBranch, maxSpaceBranch] = getBranchBoundary(branches[node.id]); + let branchBoundary = getBranchBoundary(branches[node.id]); + let minSpaceBranch = branchBoundary[2]; + let maxSpaceBranch = branchBoundary[3]; let diff = guess - nodePosition; @@ -1389,7 +1390,7 @@ class LayoutEngine { let minLevel = 100000; // TODO: this should come from options. - let customCallback = function(nodeA, nodeB, edge) { + let customCallback = function(nodeA, nodeB, edge) { // eslint-disable-line no-unused-vars }; diff --git a/lib/network/modules/ManipulationSystem.js b/lib/network/modules/ManipulationSystem.js index 2a821435a..b8d7200ed 100644 --- a/lib/network/modules/ManipulationSystem.js +++ b/lib/network/modules/ManipulationSystem.js @@ -696,10 +696,11 @@ class ManipulationSystem { } _createDeleteButton(locale) { + var deleteBtnClass; if (this.options.rtl) { - var deleteBtnClass = 'vis-button vis-delete-rtl'; + deleteBtnClass = 'vis-button vis-delete-rtl'; } else { - var deleteBtnClass = 'vis-button vis-delete'; + deleteBtnClass = 'vis-button vis-delete'; } let button = this._createButton('delete', deleteBtnClass, locale['del'] || this.options.locales['en']['del']); this.manipulationDiv.appendChild(button); @@ -840,7 +841,7 @@ class ManipulationSystem { * @param event * @private */ - _controlNodeDragStart(event) { + _controlNodeDragStart(event) { // eslint-disable-line no-unused-vars let pointer = this.lastTouch; let pointerObj = this.selectionHandler._pointerToPositionObject(pointer); let from = this.body.nodes[this.temporaryIds.nodes[0]]; diff --git a/lib/network/modules/View.js b/lib/network/modules/View.js index 07029783e..e9491c672 100644 --- a/lib/network/modules/View.js +++ b/lib/network/modules/View.js @@ -265,7 +265,7 @@ class View { } this.body.emitter.emit("animationFinished"); } - }; + } getScale() { diff --git a/lib/network/modules/components/NavigationHandler.js b/lib/network/modules/components/NavigationHandler.js index 9d044fdc3..67dcbb900 100644 --- a/lib/network/modules/components/NavigationHandler.js +++ b/lib/network/modules/components/NavigationHandler.js @@ -1,4 +1,3 @@ -var util = require('../../../util'); var Hammer = require('../../../module/hammer'); var hammerUtil = require('../../../hammerUtil'); var keycharm = require('keycharm'); diff --git a/lib/network/modules/components/Node.js b/lib/network/modules/components/Node.js index 9683f4670..1b333a635 100644 --- a/lib/network/modules/components/Node.js +++ b/lib/network/modules/components/Node.js @@ -16,7 +16,6 @@ var Star = require('./nodes/shapes/Star').default; var Text = require('./nodes/shapes/Text').default; var Triangle = require('./nodes/shapes/Triangle').default; var TriangleDown = require('./nodes/shapes/TriangleDown').default; -var Validator = require("../../../shared/Validator").default; var { printStyle } = require("../../../shared/Validator"); diff --git a/lib/network/modules/components/edges/util/EdgeBase.js b/lib/network/modules/components/edges/util/EdgeBase.js index f8f608eac..0fa0dff80 100644 --- a/lib/network/modules/components/edges/util/EdgeBase.js +++ b/lib/network/modules/components/edges/util/EdgeBase.js @@ -62,7 +62,7 @@ class EdgeBase { } } - _drawDashedLine(ctx, values, viaNode, fromPoint, toPoint) { + _drawDashedLine(ctx, values, viaNode, fromPoint, toPoint) { // eslint-disable-line no-unused-vars ctx.lineCap = 'round'; let pattern = [5,5]; if (Array.isArray(values.dashes) === true) { @@ -129,7 +129,7 @@ class EdgeBase { to = this._findBorderPosition(this.to, ctx); } else { - let [x,y,radius] = this._getCircleData(ctx); + let [x,y] = this._getCircleData(ctx).slice(0, 2); from = this._findBorderPositionCircle(this.from, ctx, {x, y, low:0.25, high:0.6, direction:-1}); to = this._findBorderPositionCircle(this.from, ctx, {x, y, low:0.6, high:0.8, direction:1}); @@ -255,7 +255,7 @@ class EdgeBase { } - getColor(ctx, values, selected, hover) { + getColor(ctx, values, selected, hover) { // eslint-disable-line no-unused-vars if (values.inheritsColor !== false) { // when this is a loop edge, just use the 'from' method if ((values.inheritsColor === 'both') && (this.from.id !== this.to.id)) { @@ -316,6 +316,7 @@ class EdgeBase { /** * Calculate the distance between a point (x3,y3) and a line segment from * (x1,y1) to (x2,y2). + * x3,y3 is the point. * http://stackoverflow.com/questions/849211/shortest-distancae-between-a-point-and-a-line-segment * @param {number} x1 * @param {number} y1 @@ -323,9 +324,10 @@ class EdgeBase { * @param {number} y2 * @param {number} x3 * @param {number} y3 + * @param via * @private */ - getDistanceToEdge(x1, y1, x2, y2, x3, y3, via, values) { // x3,y3 is the point + getDistanceToEdge(x1, y1, x2, y2, x3, y3, via, values) { // eslint-disable-line no-unused-vars let returnValue = 0; if (this.from != this.to) { returnValue = this._getDistanceToEdge(x1, y1, x2, y2, x3, y3, via) diff --git a/lib/network/modules/components/nodes/shapes/Circle.js b/lib/network/modules/components/nodes/shapes/Circle.js index 710c2e2e8..125292397 100644 --- a/lib/network/modules/components/nodes/shapes/Circle.js +++ b/lib/network/modules/components/nodes/shapes/Circle.js @@ -4,7 +4,7 @@ import CircleImageBase from '../util/CircleImageBase' class Circle extends CircleImageBase { constructor(options, body, labelModule) { - super(options, body, labelModule) + super(options, body, labelModule); this._setMargins(labelModule); } @@ -40,7 +40,7 @@ class Circle extends CircleImageBase { this.boundingBox.bottom = y + this.options.size; } - distanceToBorder(ctx, angle) { + distanceToBorder(ctx, angle) { // eslint-disable-line no-unused-vars this.resize(ctx); return this.width * 0.5; } diff --git a/lib/network/modules/components/nodes/shapes/CircularImage.js b/lib/network/modules/components/nodes/shapes/CircularImage.js index 6f743d5b5..4c0a70718 100644 --- a/lib/network/modules/components/nodes/shapes/CircularImage.js +++ b/lib/network/modules/components/nodes/shapes/CircularImage.js @@ -65,7 +65,7 @@ class CircularImage extends CircleImageBase { } - distanceToBorder(ctx, angle) { + distanceToBorder(ctx, angle) { // eslint-disable-line no-unused-vars this.resize(ctx); return this.width * 0.5; } diff --git a/lib/network/modules/components/nodes/shapes/Dot.js b/lib/network/modules/components/nodes/shapes/Dot.js index 79746753c..73d3a3053 100644 --- a/lib/network/modules/components/nodes/shapes/Dot.js +++ b/lib/network/modules/components/nodes/shapes/Dot.js @@ -11,7 +11,7 @@ class Dot extends ShapeBase { this._drawShape(ctx, 'circle', 2, x, y, selected, hover, values); } - distanceToBorder(ctx, angle) { + distanceToBorder(ctx, angle) { // eslint-disable-line no-unused-vars this.resize(ctx); return this.options.size; } diff --git a/lib/network/modules/components/nodes/util/CircleImageBase.js b/lib/network/modules/components/nodes/util/CircleImageBase.js index 2fcd81ba1..815223c44 100644 --- a/lib/network/modules/components/nodes/util/CircleImageBase.js +++ b/lib/network/modules/components/nodes/util/CircleImageBase.js @@ -1,6 +1,4 @@ import NodeBase from './NodeBase'; -import CachedImage from '../../../../CachedImage'; - /** * NOTE: This is a bad base class @@ -86,11 +84,11 @@ class CircleImageBase extends NodeBase { // Only calculate the proper ratio if both width and height not zero if (this.imageObj.width && this.imageObj.height) { - if (this.imageObj.width > this.imageObj.height) { - ratio_width = this.imageObj.width / this.imageObj.height; + if (this.imageObj.width > this.imageObj.height) { + ratio_width = this.imageObj.width / this.imageObj.height; } else { - ratio_height = this.imageObj.height / this.imageObj.width; + ratio_height = this.imageObj.height / this.imageObj.width; } } diff --git a/lib/network/modules/components/physics/HierarchicalSpringSolver.js b/lib/network/modules/components/physics/HierarchicalSpringSolver.js index e9bde3e3f..ff26db12c 100644 --- a/lib/network/modules/components/physics/HierarchicalSpringSolver.js +++ b/lib/network/modules/components/physics/HierarchicalSpringSolver.js @@ -73,7 +73,7 @@ class HierarchicalSpringSolver { } // normalize spring forces - var springForce = 1; + springForce = 1; var springFx, springFy; for (let i = 0; i < nodeIndices.length; i++) { let nodeId = nodeIndices[i]; @@ -101,7 +101,6 @@ class HierarchicalSpringSolver { forces[nodeId].y -= correctionFy; } } - } -export default HierarchicalSpringSolver; \ No newline at end of file +export default HierarchicalSpringSolver; diff --git a/lib/network/modules/components/shared/Label.js b/lib/network/modules/components/shared/Label.js index da037b9df..0f0f7cf9b 100644 --- a/lib/network/modules/components/shared/Label.js +++ b/lib/network/modules/components/shared/Label.js @@ -663,7 +663,7 @@ class Label { }; s.mod = function() { return (this.modStack.length === 0) ? 'normal' : this.modStack[0]; - } + }; s.modName = function() { if (this.modStack.length === 0) return 'normal'; @@ -678,8 +678,8 @@ class Label { return 'ital'; } } - } - s.emitBlock = function(override = false) { + }; + s.emitBlock = function(override=false) { // eslint-disable-line no-unused-vars if (this.spacing) { this.add(" "); this.spacing = false; @@ -688,7 +688,7 @@ class Label { blocks.push({ text: this.buffer, mod: this.modName() }); this.buffer = ""; } - } + }; s.add = function(text) { if (text === " ") { s.spacing = true; @@ -700,7 +700,7 @@ class Label { if (text != " ") { this.buffer += text; } - } + }; while (s.position < text.length) { let ch = text.charAt(s.position); if (/[ \t]/.test(ch)) { @@ -780,7 +780,7 @@ class Label { }; s.mod = function() { return (this.modStack.length === 0) ? 'normal' : this.modStack[0]; - } + }; s.modName = function() { if (this.modStack.length === 0) return 'normal'; @@ -795,8 +795,8 @@ class Label { return 'ital'; } } - } - s.emitBlock = function(override = false) { + }; + s.emitBlock = function(override=false) { // eslint-disable-line no-unused-vars if (this.spacing) { this.add(" "); this.spacing = false; @@ -805,7 +805,7 @@ class Label { blocks.push({ text: this.buffer, mod: this.modName() }); this.buffer = ""; } - } + }; s.add = function(text) { if (text === " ") { s.spacing = true; @@ -817,7 +817,7 @@ class Label { if (text != " ") { this.buffer += text; } - } + }; while (s.position < text.length) { let ch = text.charAt(s.position); if (/[ \t]/.test(ch)) {