www/js/visuility.js
// Checks whether node already exists in nodes or not
Checks whether node already exists in nodes or not
Checks whether node already exists in nodes or not
function addNode(node, otherNode) {
    var i = nodes.map(function(d) { return d.id; }).indexOf(node.id);
    if (i === -1) {
        node.type = node.id.split(".")[0];
        if (nodes.length === 0) {  
            node.x = w/2; node.px = node.x;
            node.y = h/2; node.py = node.y;
        } else {
            if (otherNode) {
                node.px = otherNode.x; 
                node.py = otherNode.y - h/10; 
                node.fixed = true;
            }
        }
        nodes.push(node);
        return node;
    } else {
        return nodes[i];
    }
}
function addNode ( node , otherNode ) { var i = nodes . map ( function ( d ) { return d . id ; } ) . indexOf ( node . id ) ; if ( i === - 1 ) { node . type = node . id . split ( "." ) [ 0 ] ; if ( nodes . length === 0 ) { node . x = w / 2 ; node . px = node . x ; node . y = h / 2 ; node . py = node . y ; } else { if ( otherNode ) { node . px = otherNode . x ; node . py = otherNode . y - h / 10 ; node . fixed = true ; } } nodes . push ( node ) ; return node ; } else { return nodes [ i ] ; } }
Checks whether node already exists in nodes or not
Checks whether node already exists in nodes or not
//        if (otherNode && nodeTypes[node.type].offset) node.parent = otherNode;                         // first one goes in center //console.log("Special position indicated relative to otherNode x="+otherNode.x+" y="+otherNode.y); //nodes[i] = node;  // Replace the node doesnt work unless change the id // update the node??? // TODO: update the node data //        if (otherNode && nodeTypes[nodes[i].type].offset && !nodes[i].parent) { //            nodes[i].parent = otherNode; //        }