Commit e67afd82 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

cleanup! call /runSimulation in the new format.

parent e83afb62
......@@ -240,7 +240,7 @@
};
priv.formatForManpy = function (data) {
var manpy_dict = {}, coreObject = [];
var manpy_dict = {}, nodes = {}, edges = {}, edge_id = 0;
$.each(data['element'], function (idx, element) {
var clone_element = {};
/* clone the element and put content of 'data' at the top level. */
......@@ -249,15 +249,20 @@
$.each(v, function (kk, vv) {
clone_element[kk] = vv;
});
} else if (k == 'successorList') {
$.each(v, function (i, successor) {
edges[edge_id] = [clone_element['id'], successor, {}];
edge_id += 1;
});
} else {
clone_element[k] = v;
}
});
coreObject.push(clone_element);
nodes[clone_element['id']] = clone_element;
});
manpy_dict['elementList'] = coreObject;
manpy_dict['modelResource'] = [];
manpy_dict['nodes'] = nodes;
manpy_dict['edges'] = edges;
manpy_dict['general'] = data['general'];
return manpy_dict;
};
......@@ -279,7 +284,7 @@
});
that.setGeneralProperties(properties);
var model = that.getDataForManpy();
var model = priv.formatForManpy(that.getData());
$.ajax(
'/runSimulation', {
data: JSON.stringify({
......
......@@ -182,34 +182,6 @@
};
};
priv.getDataForManpy = function () {
var manpy_dict = {}, nodes = {}, edges = {}, edge_id = 0;
$.each(priv.element_container, function (idx, element) {
var clone_element = {};
/* clone the element and put content of 'data' at the top level. */
$.each(element, function (k, v) {
if (k == 'data') {
$.each(v, function (kk, vv) {
clone_element[kk] = vv;
});
} else if (k == 'successorList') {
$.each(v, function (i, successor) {
edges[edge_id] = [clone_element['id'], successor, {}];
edge_id += 1;
});
} else {
clone_element[k] = v;
}
});
nodes[clone_element['id']] = clone_element;
});
manpy_dict['nodes'] = nodes;
manpy_dict['edges'] = edges;
manpy_dict['general'] = priv.general_container;
return manpy_dict;
};
priv.removeElement = function (element_id) {
jsPlumb.removeAllEndpoints($("#" + element_id));
$("#" + element_id).remove();
......@@ -241,10 +213,6 @@
return priv.getData();
};
that.getDataForManpy = function () {
return priv.getDataForManpy();
};
that.clearAll = function () {
$("[id=render]").children().remove();
$.each(priv.element_container, function (element_id) {
......
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