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-10-26 10:04:52 +00:00
|
|
|
var mymap, newnode, temp1, temp2, temp;
|
2012-10-24 06:47:08 +00:00
|
|
|
if (fd != null) {
|
|
|
|
mymap = fd;
|
|
|
|
}
|
|
|
|
else if (rg != null) {
|
|
|
|
mymap = rg;
|
|
|
|
}
|
|
|
|
|
2012-10-26 10:04:52 +00:00
|
|
|
if (mymap == fd || mymap == rg) {
|
|
|
|
temp1 = mymap.graph.getNode(<%= @synapse.item1.id %>);
|
|
|
|
if (temp1 == null) {
|
|
|
|
newnode = <%= @synapse.item1.self_as_json.html_safe %>;
|
|
|
|
mymap.graph.addNode(newnode);
|
|
|
|
temp = mymap.graph.getNode('<%= @synapse.item1.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 40, 'end');
|
|
|
|
if (mymap == fd) {
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'end');
|
|
|
|
}
|
|
|
|
else if (mymap == rg) {
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
mymap.fx.plotNode(temp, mymap.canvas);
|
|
|
|
temp1 = mymap.graph.getNode(<%= @synapse.item1.id %>);
|
|
|
|
}
|
|
|
|
temp2 = mymap.graph.getNode(<%= @synapse.item2.id %>);
|
|
|
|
if (temp2 == null) {
|
|
|
|
newnode = <%= @synapse.item2.self_as_json.html_safe %>;
|
|
|
|
mymap.graph.addNode(newnode);
|
|
|
|
temp = mymap.graph.getNode('<%= @synapse.item2.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 40, 'end');
|
|
|
|
if (mymap == fd) {
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'end');
|
|
|
|
}
|
|
|
|
else if (mymap == rg) {
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
mymap.fx.plotNode(temp, mymap.canvas);
|
|
|
|
temp2 = mymap.graph.getNode(<%= @synapse.item2.id %>);
|
|
|
|
}
|
|
|
|
mymap.graph.addAdjacence(temp1, temp2, {});
|
|
|
|
temp = mymap.graph.getAdjacence(temp1.id, temp2.id);
|
|
|
|
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() %>);
|
|
|
|
console.log('d=' + d);
|
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 %>',
|
|
|
|
id: '<%= @synapse.id %>',
|
|
|
|
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;
|
|
|
|
console.log(temp);
|
2012-10-26 10:04:52 +00:00
|
|
|
mymap.fx.plotLine(temp, mymap.canvas);
|
|
|
|
mymap.fx.animate({
|
|
|
|
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 %>
|
|
|
|
initFD();
|
2012-10-24 06:47:08 +00:00
|
|
|
}
|
|
|
|
}
|