commit 1f3eb4fa77824725efdee61d5035381ac75ff470
Author: Pavel Fidranský <fidransky@outlook.com>
Date:   Sat Oct 27 08:54:11 2018 +0200

    using lambda functions and "let" keyword wherever appropriate

diff --git a/sources/src/main/webapp/js/components/navbar.js b/sources/src/main/webapp/js/components/navbar.js
index c7b29d4..255f34b 100644
--- a/sources/src/main/webapp/js/components/navbar.js
+++ b/sources/src/main/webapp/js/components/navbar.js
@@ -135,7 +135,7 @@ class Navbar {
 		function search(term) {
 			if (term.length < 2) return;
 
-			var found = 0;
+			let found = 0;
 			
 			app.viewportComponent.getNodeList().forEach(node => {
 				if (node.name.toLowerCase().includes(term.toLowerCase())) {
@@ -214,11 +214,11 @@ class Navbar {
 				id: 'mostEdge',
 				title: 'Exclude components with the most count of edges separately.',
 				onClick: () => {
-					var vertexList = app.viewportComponent.getVertexList();
+					let vertexList = app.viewportComponent.getVertexList();
 					if (vertexList.length === 0) return;
 
 					// find vertex with most edges
-					var vertexWithMostEdges = vertexList.reduce(function(prev, vertex) {
+					let vertexWithMostEdges = vertexList.reduce((prev, vertex) => {
 						return vertex.countEdges() > prev.countEdges() ? vertex : prev;
 					});
 
@@ -243,23 +243,23 @@ class Navbar {
 				id: 'vertexToGroup',
 				title: 'Exclude components with the most count of edges to group.',
 				onClick: () => {
-					var vertexList = app.viewportComponent.getVertexList();
+					let vertexList = app.viewportComponent.getVertexList();
 					if (vertexList.length === 0) return;
 
 					// find vertex with most edges
-					var vertexWithMostEdges = vertexList.reduce(function(prev, vertex) {
+					let vertexWithMostEdges = vertexList.reduce((prev, vertex) => {
 						return vertex.countEdges() > prev.countEdges() ? vertex : prev;
 					});
 
 					// filter vertices with most edges
-					var verticesWithMostEdges = vertexList.filter(function(vertex) {
+					let verticesWithMostEdges = vertexList.filter(vertex => {
 						return vertex.countEdges() === vertexWithMostEdges.countEdges();
 					});
 
 					if (verticesWithMostEdges.length > 0) {
 						let group = Group.create();
 
-						verticesWithMostEdges.forEach(function(vertex) {
+						verticesWithMostEdges.forEach(vertex => {
 							group.addVertex(vertex);
 						});
 
diff --git a/sources/src/main/webapp/js/components/sidebar.js b/sources/src/main/webapp/js/components/sidebar.js
index b455c8a..d531e49 100644
--- a/sources/src/main/webapp/js/components/sidebar.js
+++ b/sources/src/main/webapp/js/components/sidebar.js
@@ -21,7 +21,7 @@ function Sidebar() {
 	};
 
 	this.refreshFloaters = function() {
-		floaterList.forEach(function(floater) {
+		floaterList.forEach(floater => {
 			floater.setPosition();
 		});
 	};
diff --git a/sources/src/main/webapp/js/components/sidebarExcludedNodeList.js b/sources/src/main/webapp/js/components/sidebarExcludedNodeList.js
index c102a05..0b3d4d4 100644
--- a/sources/src/main/webapp/js/components/sidebarExcludedNodeList.js
+++ b/sources/src/main/webapp/js/components/sidebarExcludedNodeList.js
@@ -132,9 +132,9 @@ function SidebarExcludedNodeList(props) {
 
 	function includeAll() {
 		var nodeListCopy = nodeList.slice(0);
-		nodeListCopy.forEach(function(node) {
+		nodeListCopy.forEach(node => {
 			node.include();
-		}, this);
+		});
 
 		toggleControls.call(this);
 	}
@@ -159,7 +159,7 @@ function SidebarExcludedNodeList(props) {
 	}
 
 	function sort() {
-		nodeList.forEach(function(node) {
+		nodeList.forEach(node => {
 			node.remove(true);
 			nodeListElement.appendChild(node.render());
 		});
diff --git a/sources/src/main/webapp/js/components/sidebarUnconnectedNodeList.js b/sources/src/main/webapp/js/components/sidebarUnconnectedNodeList.js
index d28ff39..02a0589 100644
--- a/sources/src/main/webapp/js/components/sidebarUnconnectedNodeList.js
+++ b/sources/src/main/webapp/js/components/sidebarUnconnectedNodeList.js
@@ -104,17 +104,17 @@ function SidebarUnconnectedNodeList(props) {
 
 	function includeAll() {
 		var nodeListCopy = nodeList.slice(0);
-		nodeListCopy.forEach(function(node) {
+		nodeListCopy.forEach(node => {
 			node.include();
-		}, this);
+		});
 	}
 
 	function excludeAll() {
-		app.vertexList.filter(function(vertex) {
+		app.vertexList.filter(vertex => {
 			return vertex.isUnconnected;
-		}).forEach(function(vertex) {
+		}).forEach(vertex => {
 			vertex.exclude();
 			this.add(vertex);
-		}, this);
+		});
 	}
 }
diff --git a/sources/src/main/webapp/js/components/viewport.js b/sources/src/main/webapp/js/components/viewport.js
index 6746c0e..f5da57f 100644
--- a/sources/src/main/webapp/js/components/viewport.js
+++ b/sources/src/main/webapp/js/components/viewport.js
@@ -116,7 +116,7 @@ function Viewport() {
 		var bbox = rootElement.getBoundingClientRect();
 
 		var nodeList = app.viewportComponent.getNodeList();
-		nodeList.forEach(function(node) {
+		nodeList.forEach(node => {
 			var center = node.center;
 
 			sumOfCenters.x += center.x;
diff --git a/sources/src/main/webapp/js/services/forceDirected.js b/sources/src/main/webapp/js/services/forceDirected.js
index 94e6e73..a6aaecf 100644
--- a/sources/src/main/webapp/js/services/forceDirected.js
+++ b/sources/src/main/webapp/js/services/forceDirected.js
@@ -24,25 +24,22 @@ function ForceDirected() {
 		var visibleNodes = app.viewportComponent.getNodeList(),
 			otherVisibleNodes = [];
 
-		var i = 0,
-			j = 0;
-
-		for (i = 0; i < visibleNodes.length; i++) {
+		for (let i = 0; i < visibleNodes.length; i++) {
 			forceField[Utils.getUniqueId(visibleNodes[i])] = [0, 0];
 		}
 
 		// calculate repulsive force
-		for (i = 0; i < visibleNodes.length; i++) {
-			var currNode = visibleNodes[i];
+		for (let i = 0; i < visibleNodes.length; i++) {
+			let currNode = visibleNodes[i];
 
 			// other nodes
-			for (var j = 0; j < visibleNodes.length; j++){
+			for (let j = 0; j < visibleNodes.length; j++){
 				otherVisibleNodes[j] = visibleNodes[j];
 			}
 			otherVisibleNodes.splice(i, 1);
 
 			// iterate over other nodes
-			for (j = 0; j < otherVisibleNodes.length; j++) {
+			for (let j = 0; j < otherVisibleNodes.length; j++) {
 				var otherNode = otherVisibleNodes[j];
 
 				var currPosition = currNode.getPosition();
@@ -63,8 +60,8 @@ function ForceDirected() {
 		}
 
 		// calculate attractive forces
-		for (i = 0; i < visibleNodes.length; i++){
-			var currNode = visibleNodes[i];
+		for (let i = 0; i < visibleNodes.length; i++){
+			let currNode = visibleNodes[i];
 
 			let inEdgeList = currNode.inEdgeList;
 			for (let j = 0; j < inEdgeList.length; j++) {
@@ -104,7 +101,7 @@ function ForceDirected() {
 		}
 
 		// applying the force
-		for (i = 0; i < visibleNodes.length; i++){
+		for (let i = 0; i < visibleNodes.length; i++){
 			var currNode = visibleNodes[i],
 
 				halfCan = canvas / 2,
@@ -153,7 +150,7 @@ function ForceDirected() {
 
 			// moving a component
 			if (Math.abs(forceX) > 1 || Math.abs(forceY) > 1) {
-				var coords = new Coordinates(
+				let coords = new Coordinates(
 					currNode.getPosition().x + forceX,
 					currNode.getPosition().y + forceY,
 				);
diff --git a/sources/src/main/webapp/js/services/graphExporter.js b/sources/src/main/webapp/js/services/graphExporter.js
index 3b58e5d..8b71924 100644
--- a/sources/src/main/webapp/js/services/graphExporter.js
+++ b/sources/src/main/webapp/js/services/graphExporter.js
@@ -7,24 +7,9 @@ function GraphExporter() {
 	 * Exports graph to JSON.
 	 */
 	this.run = function() {
-		// vertices
-		var vertices = app.vertexList.map(function(vertex) {
-			return vertex.export();
-		});
-
-		// edges
-		var edges = app.edgeList.map(function(edge) {
-			return edge.export();
-		});
-
-		// groups
-		var groups = app.groupList.map(function(group) {
-			return group.export();
-		});
-
 		// nodes excluded to the sidebar
-		var excludedNodeList = app.sidebarComponent.excludedNodeListComponent.getNodeList();
-		var sideBar = excludedNodeList.map(function(node) {
+		let excludedNodeList = app.sidebarComponent.excludedNodeListComponent.getNodeList();
+		let sideBar = excludedNodeList.map(node => {
 			return {
 				id: Utils.getUniqueId(node),
 				isIconsDisplayed: node.isIconsDisplayed,
@@ -38,10 +23,10 @@ function GraphExporter() {
 			attributeTypes: app.attributeTypeList,
 			edgeArchetypes: app.archetype.edge,
 			vertexArchetypes: app.archetype.vertex,
-			vertices: vertices,
-			edges: edges,
+			vertices: app.vertexList.map(vertex => vertex.export()),
+			edges: app.edgeList.map(edge => edge.export()),
 			possibleEnumValues: app.possibleEnumValues,
-			groups: groups,
+			groups: app.groupList.map(group => group.export()),
 			sideBar: sideBar,
 			highlightedVertex: Utils.isUndefined(highlightedVertex) ? '' : Utils.getUniqueId(highlightedVertex),
 			highlightedEdge: Utils.isUndefined(highlightedEdge) ? '' : highlightedEdge.id,
diff --git a/sources/src/main/webapp/js/services/graphLoader.js b/sources/src/main/webapp/js/services/graphLoader.js
index 37e2688..359af46 100644
--- a/sources/src/main/webapp/js/services/graphLoader.js
+++ b/sources/src/main/webapp/js/services/graphLoader.js
@@ -22,9 +22,9 @@ function GraphLoader() {
 		app.attributeTypeList = data.attributeTypes;
 		app.possibleEnumValues = data.possibleEnumValues;
 
-		app.archetype.vertex.filter(function(vertexArchetype) {
+		app.archetype.vertex.filter(vertexArchetype => {
 			return Utils.isDefined(vertexArchetype.icon);
-		}).forEach(function(vertexArchetype) {
+		}).forEach(vertexArchetype => {
 			app.viewportComponent.addSvgDefinition('vertexArchetypeIcon-' + vertexArchetype.name, vertexArchetype.icon);
 		});
 
@@ -46,7 +46,7 @@ function GraphLoader() {
 
 		// construct vertices
 		var vertexMap = {};
-		data.vertices.forEach(function(component) {
+		data.vertices.forEach(component => {
 			var vertex = new Vertex(component);
 
 			if (highlightedNodeType === 'vertex' && highlightedNodeId === vertex.id ){
@@ -73,7 +73,7 @@ function GraphLoader() {
 		});
 
 		// construct edges
-		data.edges.forEach(function(component) {
+		data.edges.forEach(component => {
 			var edge = new Edge(component);
 
             if (highlightedEdgeId === edge.id ){
@@ -101,24 +101,24 @@ function GraphLoader() {
 		delete vertexMap;
 
 		// render components
-		app.vertexList.forEach(function(vertex) {
-			app.viewportComponent.addVertex(vertex);
+		app.vertexList.forEach(vertex => {
+			app.viewportComponent.addNode(vertex);
 		});
 
-		app.edgeList.forEach(function(edge) {
+		app.edgeList.forEach(edge => {
 			app.viewportComponent.addEdge(edge);
 		});
 
 		// find unconnected vertices
-		app.vertexList.filter(function(vertex) {
+		app.vertexList.filter(vertex => {
 			return vertex.isUnconnected;
-		}).forEach(function(vertex) {
+		}).forEach(vertex => {
 			vertex.exclude();
 			app.sidebarComponent.unconnectedNodeListComponent.add(vertex);
 		});
 
 		// construct groups
-		data.groups.forEach(function(component) {
+		data.groups.forEach(component => {
 			var group = new Group(component);
 
 			if (highlightedNodeType === 'group' && highlightedNodeId === group.id ){
@@ -139,9 +139,9 @@ function GraphLoader() {
 			}
 
 			// vertices
-			app.vertexList.filter(function(vertex) {
+			app.vertexList.filter(vertex => {
 				return component.verticesId.indexOf(vertex.id) > -1;
-			}).forEach(function(vertex) {
+			}).forEach(vertex => {
 				group.addVertex(vertex);
 			});
 
@@ -152,7 +152,7 @@ function GraphLoader() {
 		});
 
 		// exclude nodes
-		data.sideBar.forEach(function(excludedNode) {
+		data.sideBar.forEach(excludedNode => {
             if(typeof excludedNode.id !== 'string' && !(excludedNode.id instanceof String)) {
             	return;
             }
@@ -162,8 +162,8 @@ function GraphLoader() {
             }
             idArr[1] = parseInt(idArr[1], 10);
 
-			var node = app.nodeList.find(function(node) {
-				var prefix = '';
+			let node = app.nodeList.find(node => {
+				let prefix = '';
 				if (node instanceof Vertex) {
 					prefix = 'vertex';
 				} else if (node instanceof Group) {
