2012-10-24 06:47:08 +00:00
|
|
|
$('#new_synapse').fadeOut('fast');
|
|
|
|
$('#new_synapse')[0].reset();
|
|
|
|
|
|
|
|
// if there's a map, add the synapse to that
|
|
|
|
map1 = document.getElementById('container');
|
|
|
|
|
|
|
|
if (map1 != null) {
|
|
|
|
|
2012-12-14 18:31:39 +00:00
|
|
|
var newnode, temp1, temp2, temp;
|
2012-10-24 06:47:08 +00:00
|
|
|
|
2012-12-15 07:39:14 +00:00
|
|
|
if ( Mconsole != null) {
|
|
|
|
temp1 = Mconsole.graph.getNode(<%= @synapse.item1.id %>);
|
2012-10-26 10:04:52 +00:00
|
|
|
if (temp1 == null) {
|
|
|
|
newnode = <%= @synapse.item1.self_as_json.html_safe %>;
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.graph.addNode(newnode);
|
|
|
|
temp = Mconsole.graph.getNode('<%= @synapse.item1.id %>');
|
2012-10-26 10:04:52 +00:00
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 40, 'end');
|
2012-12-14 18:31:39 +00:00
|
|
|
if (gType == "arranged" || gType == "chaotic") {
|
2012-12-15 07:39:14 +00:00
|
|
|
temp.setData('xloc',0);
|
|
|
|
temp.setData('yloc',0);
|
|
|
|
temp.setData('mappingid', '<%= @mapping1.id %>');
|
2012-10-26 10:04:52 +00:00
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'end');
|
|
|
|
}
|
2012-12-14 18:31:39 +00:00
|
|
|
else if (gType == "centered") {
|
2012-10-26 10:04:52 +00:00
|
|
|
temp.setPos(new $jit.Polar(5.54, 347.6), 'current');
|
|
|
|
temp.setPos(new $jit.Polar(5.54, 347.6), 'start');
|
|
|
|
temp.setPos(new $jit.Polar(5.54, 347.6), 'end');
|
|
|
|
}
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
temp1 = Mconsole.graph.getNode(<%= @synapse.item1.id %>);
|
2012-10-26 10:04:52 +00:00
|
|
|
}
|
2012-12-15 07:39:14 +00:00
|
|
|
temp2 = Mconsole.graph.getNode(<%= @synapse.item2.id %>);
|
2012-10-26 10:04:52 +00:00
|
|
|
if (temp2 == null) {
|
|
|
|
newnode = <%= @synapse.item2.self_as_json.html_safe %>;
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.graph.addNode(newnode);
|
|
|
|
temp = Mconsole.graph.getNode('<%= @synapse.item2.id %>');
|
2012-10-26 10:04:52 +00:00
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 40, 'end');
|
2012-12-14 18:31:39 +00:00
|
|
|
if (gType == "arranged" || gType == "chaotic") {
|
2012-12-15 07:39:14 +00:00
|
|
|
temp.setData('xloc',0);
|
|
|
|
temp.setData('yloc',0);
|
|
|
|
temp.setData('mappingid', '<%= @mapping2.id %>');
|
2012-10-26 10:04:52 +00:00
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'end');
|
|
|
|
}
|
2012-12-14 18:31:39 +00:00
|
|
|
else if (gType == "centered") {
|
2012-10-26 10:04:52 +00:00
|
|
|
temp.setPos(new $jit.Polar(5.54, 347.6), 'current');
|
|
|
|
temp.setPos(new $jit.Polar(5.54, 347.6), 'start');
|
|
|
|
temp.setPos(new $jit.Polar(5.54, 347.6), 'end');
|
|
|
|
}
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
temp2 = Mconsole.graph.getNode(<%= @synapse.item2.id %>);
|
2012-10-26 10:04:52 +00:00
|
|
|
}
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.graph.addAdjacence(temp1, temp2, {});
|
|
|
|
temp = Mconsole.graph.getAdjacence(temp1.id, temp2.id);
|
2012-10-26 10:04:52 +00:00
|
|
|
temp.setDataset('start', {
|
|
|
|
lineWidth: 0.4,
|
|
|
|
color: '#d1d1d1'
|
|
|
|
});
|
|
|
|
temp.setDataset('end', {
|
|
|
|
lineWidth: 3,
|
|
|
|
color: '#36acfb'
|
|
|
|
});
|
2012-11-25 01:48:26 +00:00
|
|
|
var d = new Array(<%= @synapse.node1_id.to_s() %>, <%= @synapse.node2_id.to_s() %>);
|
2012-10-26 10:04:52 +00:00
|
|
|
temp.setDataset('current', {
|
|
|
|
desc: '<%= @synapse.desc %>',
|
2012-11-25 01:48:26 +00:00
|
|
|
showDesc: false,
|
|
|
|
category: '<%= @synapse.category %>',
|
2012-12-14 18:31:39 +00:00
|
|
|
id: '<%= @synapse.id %>',
|
2012-11-25 01:48:26 +00:00
|
|
|
userid: '<%= @synapse.user.id %>',
|
|
|
|
username: '<%= @synapse.user.name %>'
|
2012-10-26 10:04:52 +00:00
|
|
|
});
|
2012-11-25 01:48:26 +00:00
|
|
|
temp.data.$direction = d;
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.fx.plotLine(temp, Mconsole.canvas);
|
|
|
|
Mconsole.fx.animate({
|
2012-10-26 10:04:52 +00:00
|
|
|
modes: ['node-property:dim','edge-property:lineWidth:color'],
|
|
|
|
duration: 400
|
|
|
|
});
|
2012-10-24 06:47:08 +00:00
|
|
|
}
|
2012-10-26 10:04:52 +00:00
|
|
|
else {
|
|
|
|
json = <%= @synapse.selfplusnodes_as_json.html_safe %>
|
2012-12-14 18:31:39 +00:00
|
|
|
initialize("chaotic");
|
2012-10-24 06:47:08 +00:00
|
|
|
}
|
|
|
|
}
|