forked from p15670423/monkey
edges from different types in same direction are shown
This commit is contained in:
parent
347833d619
commit
41a5f0a1ed
|
@ -22,6 +22,9 @@ var edges = [];
|
||||||
const ICONS_DIR = "./css/img/objects/";
|
const ICONS_DIR = "./css/img/objects/";
|
||||||
const ICONS_EXT = ".png";
|
const ICONS_EXT = ".png";
|
||||||
|
|
||||||
|
const EDGE_TYPE_PARENT = "parent";
|
||||||
|
const EDGE_TYPE_TUNNEL = "tunnel";
|
||||||
|
|
||||||
// General options
|
// General options
|
||||||
// If variable from local storage != null, assign it, otherwise set it's default value.
|
// If variable from local storage != null, assign it, otherwise set it's default value.
|
||||||
|
|
||||||
|
@ -174,10 +177,10 @@ function createEdges() {
|
||||||
for (var i = 0; i < monkeys.length; i++) {
|
for (var i = 0; i < monkeys.length; i++) {
|
||||||
var monkey = monkeys[i];
|
var monkey = monkeys[i];
|
||||||
if(monkey.parent != monkey.guid) {
|
if(monkey.parent != monkey.guid) {
|
||||||
parent = getMonkeyByGuid(monkey.parent);
|
var parent = getMonkeyByGuid(monkey.parent);
|
||||||
|
|
||||||
if(parent && !edgeExists([parent.id, monkey.id])) {
|
if(parent && !edgeExists([parent.id, monkey.id, EDGE_TYPE_PARENT])) {
|
||||||
edges.push({from: parent.id, to: monkey.id, arrows:'middle', color: 'red'});
|
edges.push({from: parent.id, to: monkey.id, arrows:'middle', type: EDGE_TYPE_PARENT, color: 'red'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,10 +192,10 @@ function createTunnels() {
|
||||||
for (var i = 0; i < monkeys.length; i++) {
|
for (var i = 0; i < monkeys.length; i++) {
|
||||||
var monkey = monkeys[i];
|
var monkey = monkeys[i];
|
||||||
if(monkey.tunnel_guid) {
|
if(monkey.tunnel_guid) {
|
||||||
tunnel = getMonkeyByGuid(monkey.tunnel_guid);
|
var tunnel = getMonkeyByGuid(monkey.tunnel_guid);
|
||||||
|
|
||||||
if(tunnel && !edgeExists([monkey.id, tunnel.id])) {
|
if(tunnel && !edgeExists([monkey.id, tunnel.id, EDGE_TYPE_TUNNEL])) {
|
||||||
edges.push({from: monkey.id, to: tunnel.id, arrows:'middle', color:'blue'});
|
edges.push({from: monkey.id, to: tunnel.id, arrows:'middle', type: EDGE_TYPE_TUNNEL, color:'blue'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -528,7 +531,8 @@ function edgeExists(link) {
|
||||||
for (var i = 0; i < edges.length; i++) {
|
for (var i = 0; i < edges.length; i++) {
|
||||||
var from = edges[i].from;
|
var from = edges[i].from;
|
||||||
var to = edges[i].to;
|
var to = edges[i].to;
|
||||||
if (from == link[0] && to == link[1]) {
|
var type = edges[i].type;
|
||||||
|
if (from == link[0] && to == link[1] && type == link[2]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue