104 lines
No EOL
3.4 KiB
Text
104 lines
No EOL
3.4 KiB
Text
$('#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) {
|
|
|
|
var mymap, newnode, temp1, temp2, temp;
|
|
if (fd != null) {
|
|
mymap = fd;
|
|
}
|
|
else if (rg != null) {
|
|
mymap = rg;
|
|
}
|
|
|
|
else if (map != null) {
|
|
mymap = map;
|
|
}
|
|
|
|
if (mymap == fd || mymap == rg || mymap == map) {
|
|
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');
|
|
}
|
|
<% unless (@mapping1.nil?) %>
|
|
temp.setData('xloc',0);
|
|
temp.setData('yloc',0);
|
|
temp.setData('mappingid', '<%= @mapping1.id %>');
|
|
<% 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');
|
|
}
|
|
<% unless (@mapping2.nil?) %>
|
|
temp.setData('xloc',0);
|
|
temp.setData('yloc',0);
|
|
temp.setData('mappingid', '<%= @mapping2.id %>');
|
|
<% 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'
|
|
});
|
|
var d = new Array(<%= @synapse.node1_id.to_s() %>, <%= @synapse.node2_id.to_s() %>);
|
|
console.log('d=' + d);
|
|
temp.setDataset('current', {
|
|
desc: '<%= @synapse.desc %>',
|
|
showDesc: false,
|
|
category: '<%= @synapse.category %>',
|
|
id: '<%= @synapse.id %>',
|
|
userid: '<%= @synapse.user.id %>',
|
|
username: '<%= @synapse.user.name %>'
|
|
});
|
|
temp.data.$direction = d;
|
|
console.log(temp);
|
|
mymap.fx.plotLine(temp, mymap.canvas);
|
|
mymap.fx.animate({
|
|
modes: ['node-property:dim','edge-property:lineWidth:color'],
|
|
duration: 400
|
|
});
|
|
}
|
|
else {
|
|
json = <%= @synapse.selfplusnodes_as_json.html_safe %>
|
|
initFD();
|
|
}
|
|
} |