Commit bf763ba9 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

automatically call /positionGraph if no coordinates information exists in imported data.

parent 54242ede
...@@ -268,13 +268,13 @@ ...@@ -268,13 +268,13 @@
dream_instance.setPreferences(preference); dream_instance.setPreferences(preference);
// Add all elements // Add all elements
var coordinates = preference['coordinates'];
$.each(data.nodes, function (key, value) { $.each(data.nodes, function (key, value) {
var coordinates = preference['coordinates'] || {}; if (coordinates === undefined || coordinates[key] === undefined) {
var coordinate = coordinates[key]; value['coordinate'] = {'top':0.0, 'left':0.0};
if (coordinate === undefined) { } else {
coordinate = {'top':0.0, 'left':0.0}; value['coordinate'] = coordinates[key];
} }
value['coordinate'] = coordinate;
value['id'] = key; value['id'] = key;
dream_instance.newElement(value); dream_instance.newElement(value);
dream_instance.updateElementData(key, { dream_instance.updateElementData(key, {
...@@ -287,9 +287,13 @@ ...@@ -287,9 +287,13 @@
dream_instance.setGeneralProperties(data.general); dream_instance.setGeneralProperties(data.general);
dream_instance.initGeneralProperties(); // XXX dream_instance.initGeneralProperties(); // XXX
dream_instance.redraw();
$("#json_output").val(JSON.stringify(dream_instance.getData(), $("#json_output").val(JSON.stringify(dream_instance.getData(),
undefined, " ")); undefined, " "));
if ($.isEmptyObject(coordinates)) {
dream_instance.positionGraph();
} else {
dream_instance.redraw();
}
}; };
// Check if there is already data when we first load the page, if yes, then build graph from it // Check if there is already data when we first load the page, if yes, then build graph from it
......
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