Commit ebe1a209 authored by unknown's avatar unknown

linted last files

parent b5bdbe2e
const alert = require('../misc/alert'),
Node = require("../graphosaurus-rex/node"),
Edge = require("../graphosaurus-rex/edge"),
Node = require('../graphosaurus-rex/node'),
Edge = require('../graphosaurus-rex/edge'),
tools = require('../misc/tools');
let INSTANCE = null;
module.exports = class SupernodesManager {
"use strict";
'use strict';
constructor(app) {
if (INSTANCE != null) {
console.error("Multiple SupernodesManager instances !");
if (INSTANCE !== null) {
console.error('Multiple SupernodesManager instances !');
}
this.app = app;
......@@ -24,10 +24,10 @@ module.exports = class SupernodesManager {
}
static getInstance(app) {
if (INSTANCE == null && app != null) {
if (INSTANCE === null && app !== null) {
INSTANCE = new SupernodesManager(app);
} else if (INSTANCE == null) {
console.error("Cannot create SupernodesManager without app !")
} else if (INSTANCE === null) {
console.error('Cannot create SupernodesManager without app !')
}
return INSTANCE;
}
......@@ -35,7 +35,7 @@ module.exports = class SupernodesManager {
load() {
return;
let compress = localStorage.getItem('supernodes');
if (!!compress) {
if (compress) {
let json = LZString.decompressFromUTF16(compress);
this.data = JSON.parse(json);
} else {
......@@ -62,7 +62,7 @@ module.exports = class SupernodesManager {
};
});
alert.textarea("Name of the groupnode", nodes[0].name()).then((name) => {
alert.textarea('Name of the groupnode', nodes[0].name()).then((name) => {
let supernode = {
id: tools.uuid(),
nodes: nodes_data,
......@@ -91,8 +91,8 @@ module.exports = class SupernodesManager {
}
isEntity(id) {
let supernode = this.data.find(n => n.id == id);
return supernode.type == 'entity';
let supernode = this.data.find(n => n.id === id);
return supernode.type === 'entity';
}
// Replace in a list of nodes, the nodes with their supernodes. (formated for nodes-list)
......@@ -102,7 +102,7 @@ module.exports = class SupernodesManager {
nodes.forEach(node => {
this.data.forEach((supernode, i) => {
if (supernode.nodes.findIndex((n) => n.id == node.id) >= 0) {
if (supernode.nodes.findIndex((n) => n.id === node.id) >= 0) {
count[i]++;
return;
}
......@@ -113,7 +113,7 @@ module.exports = class SupernodesManager {
let remove = []
this.data.forEach((supernode, i) => {
if ((supernode.union && count[i] > 0) ||
(!supernode.union && count[i] == supernode.nodes.length)) {
(!supernode.union && count[i] === supernode.nodes.length)) {
let res = supernode.nodes.reduce((total, n) => total + n[this.app.sizeAttributes[this.layerType]], 0)
nodes.push({
......@@ -128,7 +128,7 @@ module.exports = class SupernodesManager {
});
remove.forEach((node) => {
let i = nodes.findIndex(n => n.id == node.id);
let i = nodes.findIndex(n => n.id === node.id);
if (i >= 0) {
nodes.splice(i, 1);
}
......@@ -143,7 +143,7 @@ module.exports = class SupernodesManager {
nodes.forEach(node => {
this.data.forEach((supernode, i) => {
if (supernode.nodes.findIndex((n) => n.id == node.id()) >= 0) {
if (supernode.nodes.findIndex((n) => n.id === node.id()) >= 0) {
count[i]++;
return;
}
......@@ -155,10 +155,10 @@ module.exports = class SupernodesManager {
let eremove = []
this.data.forEach((supernode, i) => {
if ((supernode.union && count[i] > 0) ||
(!supernode.union && count[i] == supernode.nodes.length)) {
(!supernode.union && count[i] === supernode.nodes.length)) {
let children = nodes.filter((node) => {
return supernode.nodes.findIndex(n => n.id == node.id()) >= 0;
return supernode.nodes.findIndex(n => n.id === node.id()) >= 0;
});
let graph = children[0]._graph;
......@@ -169,27 +169,27 @@ module.exports = class SupernodesManager {
_id: supernode.id,
_name: supernode.name,
_type: 'supernode',
_resources: resources
_resources: resources
});
nodes.push(sNode);
let edgesMap = {}; // children: [edge[children, o1], edge[children, o2]]
edges.forEach((edge) => {
let add = null;
if (children.findIndex((child) => child.id() == edge.nodes()[0].id()) >= 0) {
if (children.findIndex((child) => child.id() === edge.nodes()[0].id()) >= 0) {
add = edge;
}
if (children.findIndex((child) => child.id() == edge.nodes()[1].id()) >= 0) {
if (!!add) {
}
if (children.findIndex((child) => child.id() === edge.nodes()[1].id()) >= 0) {
if (add) {
eremove.push(edge);
return;
};
}
add = new Edge(edge._graph, [edge.nodes()[1], edge.nodes()[0]], {
_resources: edge.resources()
});
}
if (!!add) {
if (add) {
let ref = add.nodes()[1].id();
if (!edgesMap[ref]) {
edgesMap[ref] = [];
......@@ -221,17 +221,17 @@ module.exports = class SupernodesManager {
});
nremove.forEach((node) => {
let i = nodes.findIndex(n => n.id() == node.id());
let i = nodes.findIndex(n => n.id() === node.id());
if (i >= 0) {
nodes.splice(i, 1);
}
});
eremove.forEach((edge) => {
let edgeId = edge.nodes()[0].id() + "" + edge.nodes()[1].id();
let edgeId = edge.nodes()[0].id() + '' + edge.nodes()[1].id();
let i = edges.findIndex(e => {
let eId = e.nodes()[0].id() + "" + e.nodes()[1].id();
return eId == edgeId
let eId = e.nodes()[0].id() + '' + e.nodes()[1].id();
return eId === edgeId
});
if (i >= 0) {
edges.splice(i, 1);
......@@ -247,11 +247,11 @@ module.exports = class SupernodesManager {
nodes = nodes.slice();
let del = [];
nodes.forEach((node) => {
if (node.type() == "supernode") {
if (node.type() === 'supernode') {
del.push(node.id());
let supernode = this.data.find(sn => sn.id == node.id());
if (supernode != undefined) {
nodes.push(...supernode.nodes.map(n => {
let supernode = this.data.find(sn => sn.id === node.id());
if (supernode !== undefined) {
nodes.push(...supernode.nodes.map(n => {
let object = new Node();
object._id = n.id;
object._name = n.name;
......@@ -265,7 +265,7 @@ module.exports = class SupernodesManager {
});
del.forEach((id) => {
let i = nodes.findIndex(n => n.id() == id);
let i = nodes.findIndex(n => n.id() === id);
if (i >= 0) {
nodes.splice(i, 1);
}
......@@ -279,8 +279,8 @@ module.exports = class SupernodesManager {
return ids;
let replaced = []
ids.forEach((id) => {
let supernode = this.data.find((supernode) => supernode.id == id);
if (!!supernode) {
let supernode = this.data.find((supernode) => supernode.id === id);
if (supernode) {
supernode.nodes.forEach((node) => {
replaced.push(node.id);
})
......@@ -304,7 +304,7 @@ module.exports = class SupernodesManager {
html += ' <div class="panel-heading" role="tab" id="' + id + '-heading">';
html += ' <h3 class="panel-title">';
html += ' <button id="carret" class="btn btn-default pull-left h-32" data-toggle="collapse" href="#' + id + '-collapse" aria-expanded="true" aria-controls="' + id + '-collapse" style="margin-right: 10px;"><i class="fa fa-arrows-v" aria-hidden="true"></i></button>' ;
html += "<span>" + supernode.name + "</span>";
html += '<span>' + supernode.name + '</span>';
html += ' <button id="' + id + '-close" class="btn btn-danger pull-right h-32"><i class="fa fa-trash" aria-hidden="true"></i></button>';
html += ' <div style="clear: both;"></div>'
html += ' </h3>';
......@@ -321,7 +321,7 @@ module.exports = class SupernodesManager {
this.data.forEach(supernode => {
let mode = supernode.union ? 'Union' : "Intersection";
let mode = supernode.union ? 'Union' : 'Intersection';
this.container.find('#' + supernode.id + '-tab').DataTable({
paging: false,
......
......@@ -14,7 +14,7 @@ module.exports = class TimeEstimate {
load() {
let compress = localStorage.getItem(this.storageKey);
if (!!compress) {
if (compress) {
let json = LZString.decompressFromUTF16(compress);
this.data = JSON.parse(json);
} else {
......@@ -25,7 +25,7 @@ module.exports = class TimeEstimate {
this.data = this.data.concat(JSON.parse(LZString.decompressFromUTF16(DEFAULT_DATA)));
}
this.data = this.data.filter(e => !!e);
this.data = this.data.filter(e => e);
}
save() {
......
......@@ -4,7 +4,7 @@ module.exports = {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
},
},
uniq: (a, id=(e) => e) => {
let seen = {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment