2012-12-23 06:12:56 +00:00
|
|
|
$('.getTopicsInput').attr('value','');
|
|
|
|
|
|
|
|
var h = Mconsole.canvas.element.clientHeight / 2;
|
|
|
|
var w = Mconsole.canvas.element.clientWidth / 2;
|
|
|
|
|
2012-12-25 23:29:20 +00:00
|
|
|
var myX = -w + 400;
|
2012-12-23 06:12:56 +00:00
|
|
|
var myY = -h + 100;
|
2012-12-25 23:29:20 +00:00
|
|
|
var even = true;
|
2012-12-23 06:12:56 +00:00
|
|
|
|
2013-01-01 22:45:35 +00:00
|
|
|
<% @topics.each do |topic| %>
|
2012-12-23 06:12:56 +00:00
|
|
|
if ($.isEmptyObject(Mconsole.graph.nodes)) {
|
2013-01-01 22:45:35 +00:00
|
|
|
json = <%= topic.self_as_json.html_safe %>;
|
2012-12-23 06:12:56 +00:00
|
|
|
Mconsole.loadJSON(json);
|
2013-01-01 22:45:35 +00:00
|
|
|
var temp = Mconsole.graph.getNode('<%= topic.id %>');
|
2012-12-23 06:12:56 +00:00
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 25, 'end');
|
2012-12-25 23:29:20 +00:00
|
|
|
temp.setData('inCommons',true);
|
2013-01-03 08:53:25 +00:00
|
|
|
temp.setData('onCanvas',false);
|
2012-12-23 06:12:56 +00:00
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'end');
|
2013-01-03 08:53:25 +00:00
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
Mconsole.labels.plotLabel(Mconsole.canvas, temp, Mconsole.config);
|
2012-12-23 06:12:56 +00:00
|
|
|
myX += 100;
|
2012-12-25 23:29:20 +00:00
|
|
|
even = !even;
|
2012-12-23 06:12:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-01-01 22:45:35 +00:00
|
|
|
var temp = Mconsole.graph.getNode('<%= topic.id %>');
|
2013-01-03 08:53:25 +00:00
|
|
|
if (temp == null || temp.getData('inCommons')) {
|
2013-01-01 22:45:35 +00:00
|
|
|
var newnode = <%= topic.self_as_json.html_safe %>;
|
2012-12-23 06:12:56 +00:00
|
|
|
Mconsole.graph.addNode(newnode);
|
2013-01-01 22:45:35 +00:00
|
|
|
var temp = Mconsole.graph.getNode('<%= topic.id %>');
|
2012-12-23 06:12:56 +00:00
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 25, 'end');
|
2012-12-25 23:29:20 +00:00
|
|
|
temp.setData('inCommons',true);
|
2013-01-03 08:53:25 +00:00
|
|
|
temp.setData('onCanvas',false);
|
2012-12-23 06:12:56 +00:00
|
|
|
if (myX > (w-100)) {
|
2012-12-25 23:29:20 +00:00
|
|
|
myX = -w + 400;
|
|
|
|
myY += 200;
|
|
|
|
even = true;
|
|
|
|
}
|
|
|
|
if (even) {
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'end');
|
|
|
|
}
|
|
|
|
else if (!even) {
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY+100), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY+100), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY+100), 'end');
|
2012-12-23 06:12:56 +00:00
|
|
|
}
|
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
2013-01-03 08:53:25 +00:00
|
|
|
Mconsole.labels.plotLabel(Mconsole.canvas, temp, Mconsole.config);
|
2012-12-23 06:12:56 +00:00
|
|
|
myX += 100;
|
2012-12-25 23:29:20 +00:00
|
|
|
even = !even;
|
2012-12-23 06:12:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
<% end %>
|
2013-01-03 08:53:25 +00:00
|
|
|
|
|
|
|
<% @synapses.each do |synapse| %>
|
|
|
|
var temp1 = null, temp2 = null;
|
|
|
|
temp1 = Mconsole.graph.getNode(<%= synapse.topic1.id %>);
|
|
|
|
temp2 = Mconsole.graph.getNode(<%= synapse.topic2.id %>);
|
|
|
|
if (!(temp1 == undefined || temp2 == undefined)) {
|
|
|
|
Mconsole.graph.addAdjacence(temp1, temp2, {});
|
|
|
|
temp = Mconsole.graph.getAdjacence(temp1.id, temp2.id);
|
|
|
|
temp.setDataset('start', {
|
|
|
|
lineWidth: 0.4
|
|
|
|
});
|
|
|
|
temp.setDataset('end', {
|
|
|
|
lineWidth: 2
|
|
|
|
});
|
|
|
|
var d = new Array(<%= synapse.node1_id.to_s() %>, <%= synapse.node2_id.to_s() %>);
|
|
|
|
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;
|
|
|
|
Mconsole.fx.plotLine(temp, Mconsole.canvas);
|
|
|
|
}
|
|
|
|
<% end %>
|
2012-12-23 06:12:56 +00:00
|
|
|
|
|
|
|
Mconsole.fx.animate({
|
2013-01-03 08:53:25 +00:00
|
|
|
modes: ['node-property:dim','edge-property:lineWidth'],
|
2012-12-23 06:12:56 +00:00
|
|
|
duration: 500
|
|
|
|
});
|