diff --git a/dist/vis.js b/dist/vis.js index 1cb8c8c3..f1ec8ecb 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -4,8 +4,8 @@ * * A dynamic, browser-based visualization library. * - * @version 0.4.0-SNAPSHOT - * @date 2014-01-30 + * @version @@version + * @date @@date * * @license * Copyright (C) 2011-2014 Almende B.V, http://almende.com @@ -12581,23 +12581,11 @@ var SelectionMixin = { * selected nodes. */ getSelection : function() { - var nodeIdString = this.getSelectedNodes(); - /* - var edgeIdString = this.getSelectedEdges(); + var nodeIds = this.getSelectedNodes(); - var idString = ""; - if (nodeIdString != "") { - idString = idString.concat("Nodes: ",nodeIdString); + var edgeIds = this.getSelectedEdges(); - if (edgeIdString != "") { - idString = idString.concat("; "); - } - } - if (edgeIdString != "") { - idString = idString.concat("Edges: ",edgeIdString); - } - */ - return nodeIdString + return {nodes:nodeIds, edges:edgeIds}; }, /** @@ -12607,41 +12595,33 @@ var SelectionMixin = { * selected nodes. */ getSelectedNodes : function() { - var idString = "", i = 0; + var idArray = []; for(var objectId in this.selectionObj) { if(this.selectionObj.hasOwnProperty(objectId)) { if (this.selectionObj[objectId] instanceof Node) { - if (i != 0) { - idString = idString.concat(", "); - } - idString = idString.concat(String(objectId)); - i++; + idArray.push(objectId); } } } - return idString + return idArray }, /** * * retrieve the currently selected edges - * @return {String} selection An array with the ids of the + * @return {Array} selection An array with the ids of the * selected nodes. */ getSelectedEdges : function() { - var idString = "", i = 0; + var idArray = []; for(var objectId in this.selectionObj) { if(this.selectionObj.hasOwnProperty(objectId)) { if (this.selectionObj[objectId] instanceof Edge) { - if (i != 0) { - idString = idString.concat(", "); - } - idString = idString.concat(String(objectId)); - i++; + idArray.push(objectId); } } } - return idString + return idArray }, /** diff --git a/examples/graph/02_random_nodes.html b/examples/graph/02_random_nodes.html index fdf27193..6a8a3a0f 100755 --- a/examples/graph/02_random_nodes.html +++ b/examples/graph/02_random_nodes.html @@ -96,7 +96,7 @@ // add event listeners vis.events.addListener(graph, 'select', function(params) { document.getElementById('selection').innerHTML = - 'Selection: ' + graph.getSelection(); + 'Selection: ' + JSON.stringify(graph.getSelection()); }); } diff --git a/examples/graph/18_fully_random_nodes_clustering.html b/examples/graph/18_fully_random_nodes_clustering.html index 8bfd679d..0ee22562 100644 --- a/examples/graph/18_fully_random_nodes_clustering.html +++ b/examples/graph/18_fully_random_nodes_clustering.html @@ -65,7 +65,7 @@ // add event listeners vis.events.addListener(graph, 'select', function(params) { document.getElementById('selection').innerHTML = - 'Selection: ' + graph.getSelection(); + 'Selection: ' + JSON.stringify(graph.getSelection()); }); } diff --git a/examples/graph/19_scale_free_graph_clustering.html b/examples/graph/19_scale_free_graph_clustering.html index 2bce437e..efe43b8f 100644 --- a/examples/graph/19_scale_free_graph_clustering.html +++ b/examples/graph/19_scale_free_graph_clustering.html @@ -102,7 +102,7 @@ // add event listeners vis.events.addListener(graph, 'select', function(params) { document.getElementById('selection').innerHTML = - 'Selection: ' + graph.getSelection(); + 'Selection: ' + JSON.stringify(graph.getSelection()); }); } diff --git a/examples/graph/20_UI_example.html b/examples/graph/20_UI_example.html index bd94dc4d..dd24eb2f 100644 --- a/examples/graph/20_UI_example.html +++ b/examples/graph/20_UI_example.html @@ -122,7 +122,7 @@ // add event listeners vis.events.addListener(graph, 'select', function(params) { document.getElementById('selection').innerHTML = - 'Selection: ' + graph.getSelection(); + 'Selection: ' + JSON.stringify(graph.getSelection()); }); } diff --git a/src/graph/SelectionMixin.js b/src/graph/SelectionMixin.js index 072b4295..5a0154c5 100644 --- a/src/graph/SelectionMixin.js +++ b/src/graph/SelectionMixin.js @@ -400,23 +400,11 @@ var SelectionMixin = { * selected nodes. */ getSelection : function() { - var nodeIdString = this.getSelectedNodes(); - /* - var edgeIdString = this.getSelectedEdges(); + var nodeIds = this.getSelectedNodes(); - var idString = ""; - if (nodeIdString != "") { - idString = idString.concat("Nodes: ",nodeIdString); + var edgeIds = this.getSelectedEdges(); - if (edgeIdString != "") { - idString = idString.concat("; "); - } - } - if (edgeIdString != "") { - idString = idString.concat("Edges: ",edgeIdString); - } - */ - return nodeIdString + return {nodes:nodeIds, edges:edgeIds}; }, /** @@ -426,41 +414,33 @@ var SelectionMixin = { * selected nodes. */ getSelectedNodes : function() { - var idString = "", i = 0; + var idArray = []; for(var objectId in this.selectionObj) { if(this.selectionObj.hasOwnProperty(objectId)) { if (this.selectionObj[objectId] instanceof Node) { - if (i != 0) { - idString = idString.concat(", "); - } - idString = idString.concat(String(objectId)); - i++; + idArray.push(objectId); } } } - return idString + return idArray }, /** * * retrieve the currently selected edges - * @return {String} selection An array with the ids of the + * @return {Array} selection An array with the ids of the * selected nodes. */ getSelectedEdges : function() { - var idString = "", i = 0; + var idArray = []; for(var objectId in this.selectionObj) { if(this.selectionObj.hasOwnProperty(objectId)) { if (this.selectionObj[objectId] instanceof Edge) { - if (i != 0) { - idString = idString.concat(", "); - } - idString = idString.concat(String(objectId)); - i++; + idArray.push(objectId); } } } - return idString + return idArray }, /**