Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1f3eb4fa

Přidáno uživatelem Pavel Fidranský před více než 6 roky(ů)

using lambda functions and "let" keyword wherever appropriate

Zobrazit rozdíly:

sources/src/main/webapp/js/components/navbar.js
135 135
		function search(term) {
136 136
			if (term.length < 2) return;
137 137

  
138
			var found = 0;
138
			let found = 0;
139 139
			
140 140
			app.viewportComponent.getNodeList().forEach(node => {
141 141
				if (node.name.toLowerCase().includes(term.toLowerCase())) {
......
214 214
				id: 'mostEdge',
215 215
				title: 'Exclude components with the most count of edges separately.',
216 216
				onClick: () => {
217
					var vertexList = app.viewportComponent.getVertexList();
217
					let vertexList = app.viewportComponent.getVertexList();
218 218
					if (vertexList.length === 0) return;
219 219

  
220 220
					// find vertex with most edges
221
					var vertexWithMostEdges = vertexList.reduce(function(prev, vertex) {
221
					let vertexWithMostEdges = vertexList.reduce((prev, vertex) => {
222 222
						return vertex.countEdges() > prev.countEdges() ? vertex : prev;
223 223
					});
224 224

  
......
243 243
				id: 'vertexToGroup',
244 244
				title: 'Exclude components with the most count of edges to group.',
245 245
				onClick: () => {
246
					var vertexList = app.viewportComponent.getVertexList();
246
					let vertexList = app.viewportComponent.getVertexList();
247 247
					if (vertexList.length === 0) return;
248 248

  
249 249
					// find vertex with most edges
250
					var vertexWithMostEdges = vertexList.reduce(function(prev, vertex) {
250
					let vertexWithMostEdges = vertexList.reduce((prev, vertex) => {
251 251
						return vertex.countEdges() > prev.countEdges() ? vertex : prev;
252 252
					});
253 253

  
254 254
					// filter vertices with most edges
255
					var verticesWithMostEdges = vertexList.filter(function(vertex) {
255
					let verticesWithMostEdges = vertexList.filter(vertex => {
256 256
						return vertex.countEdges() === vertexWithMostEdges.countEdges();
257 257
					});
258 258

  
259 259
					if (verticesWithMostEdges.length > 0) {
260 260
						let group = Group.create();
261 261

  
262
						verticesWithMostEdges.forEach(function(vertex) {
262
						verticesWithMostEdges.forEach(vertex => {
263 263
							group.addVertex(vertex);
264 264
						});
265 265

  
sources/src/main/webapp/js/components/sidebar.js
21 21
	};
22 22

  
23 23
	this.refreshFloaters = function() {
24
		floaterList.forEach(function(floater) {
24
		floaterList.forEach(floater => {
25 25
			floater.setPosition();
26 26
		});
27 27
	};
sources/src/main/webapp/js/components/sidebarExcludedNodeList.js
132 132

  
133 133
	function includeAll() {
134 134
		var nodeListCopy = nodeList.slice(0);
135
		nodeListCopy.forEach(function(node) {
135
		nodeListCopy.forEach(node => {
136 136
			node.include();
137
		}, this);
137
		});
138 138

  
139 139
		toggleControls.call(this);
140 140
	}
......
159 159
	}
160 160

  
161 161
	function sort() {
162
		nodeList.forEach(function(node) {
162
		nodeList.forEach(node => {
163 163
			node.remove(true);
164 164
			nodeListElement.appendChild(node.render());
165 165
		});
sources/src/main/webapp/js/components/sidebarUnconnectedNodeList.js
104 104

  
105 105
	function includeAll() {
106 106
		var nodeListCopy = nodeList.slice(0);
107
		nodeListCopy.forEach(function(node) {
107
		nodeListCopy.forEach(node => {
108 108
			node.include();
109
		}, this);
109
		});
110 110
	}
111 111

  
112 112
	function excludeAll() {
113
		app.vertexList.filter(function(vertex) {
113
		app.vertexList.filter(vertex => {
114 114
			return vertex.isUnconnected;
115
		}).forEach(function(vertex) {
115
		}).forEach(vertex => {
116 116
			vertex.exclude();
117 117
			this.add(vertex);
118
		}, this);
118
		});
119 119
	}
120 120
}
sources/src/main/webapp/js/components/viewport.js
116 116
		var bbox = rootElement.getBoundingClientRect();
117 117

  
118 118
		var nodeList = app.viewportComponent.getNodeList();
119
		nodeList.forEach(function(node) {
119
		nodeList.forEach(node => {
120 120
			var center = node.center;
121 121

  
122 122
			sumOfCenters.x += center.x;
sources/src/main/webapp/js/services/forceDirected.js
24 24
		var visibleNodes = app.viewportComponent.getNodeList(),
25 25
			otherVisibleNodes = [];
26 26

  
27
		var i = 0,
28
			j = 0;
29

  
30
		for (i = 0; i < visibleNodes.length; i++) {
27
		for (let i = 0; i < visibleNodes.length; i++) {
31 28
			forceField[Utils.getUniqueId(visibleNodes[i])] = [0, 0];
32 29
		}
33 30

  
34 31
		// calculate repulsive force
35
		for (i = 0; i < visibleNodes.length; i++) {
36
			var currNode = visibleNodes[i];
32
		for (let i = 0; i < visibleNodes.length; i++) {
33
			let currNode = visibleNodes[i];
37 34

  
38 35
			// other nodes
39
			for (var j = 0; j < visibleNodes.length; j++){
36
			for (let j = 0; j < visibleNodes.length; j++){
40 37
				otherVisibleNodes[j] = visibleNodes[j];
41 38
			}
42 39
			otherVisibleNodes.splice(i, 1);
43 40

  
44 41
			// iterate over other nodes
45
			for (j = 0; j < otherVisibleNodes.length; j++) {
42
			for (let j = 0; j < otherVisibleNodes.length; j++) {
46 43
				var otherNode = otherVisibleNodes[j];
47 44

  
48 45
				var currPosition = currNode.getPosition();
......
63 60
		}
64 61

  
65 62
		// calculate attractive forces
66
		for (i = 0; i < visibleNodes.length; i++){
67
			var currNode = visibleNodes[i];
63
		for (let i = 0; i < visibleNodes.length; i++){
64
			let currNode = visibleNodes[i];
68 65

  
69 66
			let inEdgeList = currNode.inEdgeList;
70 67
			for (let j = 0; j < inEdgeList.length; j++) {
......
104 101
		}
105 102

  
106 103
		// applying the force
107
		for (i = 0; i < visibleNodes.length; i++){
104
		for (let i = 0; i < visibleNodes.length; i++){
108 105
			var currNode = visibleNodes[i],
109 106

  
110 107
				halfCan = canvas / 2,
......
153 150

  
154 151
			// moving a component
155 152
			if (Math.abs(forceX) > 1 || Math.abs(forceY) > 1) {
156
				var coords = new Coordinates(
153
				let coords = new Coordinates(
157 154
					currNode.getPosition().x + forceX,
158 155
					currNode.getPosition().y + forceY,
159 156
				);
sources/src/main/webapp/js/services/graphExporter.js
7 7
	 * Exports graph to JSON.
8 8
	 */
9 9
	this.run = function() {
10
		// vertices
11
		var vertices = app.vertexList.map(function(vertex) {
12
			return vertex.export();
13
		});
14

  
15
		// edges
16
		var edges = app.edgeList.map(function(edge) {
17
			return edge.export();
18
		});
19

  
20
		// groups
21
		var groups = app.groupList.map(function(group) {
22
			return group.export();
23
		});
24

  
25 10
		// nodes excluded to the sidebar
26
		var excludedNodeList = app.sidebarComponent.excludedNodeListComponent.getNodeList();
27
		var sideBar = excludedNodeList.map(function(node) {
11
		let excludedNodeList = app.sidebarComponent.excludedNodeListComponent.getNodeList();
12
		let sideBar = excludedNodeList.map(node => {
28 13
			return {
29 14
				id: Utils.getUniqueId(node),
30 15
				isIconsDisplayed: node.isIconsDisplayed,
......
38 23
			attributeTypes: app.attributeTypeList,
39 24
			edgeArchetypes: app.archetype.edge,
40 25
			vertexArchetypes: app.archetype.vertex,
41
			vertices: vertices,
42
			edges: edges,
26
			vertices: app.vertexList.map(vertex => vertex.export()),
27
			edges: app.edgeList.map(edge => edge.export()),
43 28
			possibleEnumValues: app.possibleEnumValues,
44
			groups: groups,
29
			groups: app.groupList.map(group => group.export()),
45 30
			sideBar: sideBar,
46 31
			highlightedVertex: Utils.isUndefined(highlightedVertex) ? '' : Utils.getUniqueId(highlightedVertex),
47 32
			highlightedEdge: Utils.isUndefined(highlightedEdge) ? '' : highlightedEdge.id,
sources/src/main/webapp/js/services/graphLoader.js
22 22
		app.attributeTypeList = data.attributeTypes;
23 23
		app.possibleEnumValues = data.possibleEnumValues;
24 24

  
25
		app.archetype.vertex.filter(function(vertexArchetype) {
25
		app.archetype.vertex.filter(vertexArchetype => {
26 26
			return Utils.isDefined(vertexArchetype.icon);
27
		}).forEach(function(vertexArchetype) {
27
		}).forEach(vertexArchetype => {
28 28
			app.viewportComponent.addSvgDefinition('vertexArchetypeIcon-' + vertexArchetype.name, vertexArchetype.icon);
29 29
		});
30 30

  
......
46 46

  
47 47
		// construct vertices
48 48
		var vertexMap = {};
49
		data.vertices.forEach(function(component) {
49
		data.vertices.forEach(component => {
50 50
			var vertex = new Vertex(component);
51 51

  
52 52
			if (highlightedNodeType === 'vertex' && highlightedNodeId === vertex.id ){
......
73 73
		});
74 74

  
75 75
		// construct edges
76
		data.edges.forEach(function(component) {
76
		data.edges.forEach(component => {
77 77
			var edge = new Edge(component);
78 78

  
79 79
            if (highlightedEdgeId === edge.id ){
......
101 101
		delete vertexMap;
102 102

  
103 103
		// render components
104
		app.vertexList.forEach(function(vertex) {
105
			app.viewportComponent.addVertex(vertex);
104
		app.vertexList.forEach(vertex => {
105
			app.viewportComponent.addNode(vertex);
106 106
		});
107 107

  
108
		app.edgeList.forEach(function(edge) {
108
		app.edgeList.forEach(edge => {
109 109
			app.viewportComponent.addEdge(edge);
110 110
		});
111 111

  
112 112
		// find unconnected vertices
113
		app.vertexList.filter(function(vertex) {
113
		app.vertexList.filter(vertex => {
114 114
			return vertex.isUnconnected;
115
		}).forEach(function(vertex) {
115
		}).forEach(vertex => {
116 116
			vertex.exclude();
117 117
			app.sidebarComponent.unconnectedNodeListComponent.add(vertex);
118 118
		});
119 119

  
120 120
		// construct groups
121
		data.groups.forEach(function(component) {
121
		data.groups.forEach(component => {
122 122
			var group = new Group(component);
123 123

  
124 124
			if (highlightedNodeType === 'group' && highlightedNodeId === group.id ){
......
139 139
			}
140 140

  
141 141
			// vertices
142
			app.vertexList.filter(function(vertex) {
142
			app.vertexList.filter(vertex => {
143 143
				return component.verticesId.indexOf(vertex.id) > -1;
144
			}).forEach(function(vertex) {
144
			}).forEach(vertex => {
145 145
				group.addVertex(vertex);
146 146
			});
147 147

  
......
152 152
		});
153 153

  
154 154
		// exclude nodes
155
		data.sideBar.forEach(function(excludedNode) {
155
		data.sideBar.forEach(excludedNode => {
156 156
            if(typeof excludedNode.id !== 'string' && !(excludedNode.id instanceof String)) {
157 157
            	return;
158 158
            }
......
162 162
            }
163 163
            idArr[1] = parseInt(idArr[1], 10);
164 164

  
165
			var node = app.nodeList.find(function(node) {
166
				var prefix = '';
165
			let node = app.nodeList.find(node => {
166
				let prefix = '';
167 167
				if (node instanceof Vertex) {
168 168
					prefix = 'vertex';
169 169
				} else if (node instanceof Group) {

Také k dispozici: Unified diff