metamaps--metamaps/app/views/main/search.js.erb

60 lines
1.8 KiB
Text
Raw Normal View History

$('.getTopicsInput').attr('value','');
var h = Mconsole.canvas.element.clientHeight / 2;
var w = Mconsole.canvas.element.clientWidth / 2;
var myX = -w + 400;
var myY = -h + 100;
var even = true;
<% @topics.each do |topic| %>
if ($.isEmptyObject(Mconsole.graph.nodes)) {
json = <%= topic.self_as_json.html_safe %>;
Mconsole.loadJSON(json);
var temp = Mconsole.graph.getNode('<%= topic.id %>');
temp.setData('dim', 1, 'start');
temp.setData('dim', 25, 'end');
temp.setData('inCommons',true);
temp.setPos(new $jit.Complex(myX, myY), 'current');
temp.setPos(new $jit.Complex(myX, myY), 'start');
temp.setPos(new $jit.Complex(myX, myY), 'end');
Mconsole.fx.plotNode(temp, Mconsole.canvas);
myX += 100;
even = !even;
}
else {
var temp = Mconsole.graph.getNode('<%= topic.id %>');
if (temp == null) {
var newnode = <%= topic.self_as_json.html_safe %>;
Mconsole.graph.addNode(newnode);
var temp = Mconsole.graph.getNode('<%= topic.id %>');
temp.setData('dim', 1, 'start');
temp.setData('dim', 25, 'end');
temp.setData('inCommons',true);
if (myX > (w-100)) {
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');
}
Mconsole.fx.plotNode(temp, Mconsole.canvas);
myX += 100;
even = !even;
}
}
<% end %>
Mconsole.fx.animate({
modes: ['node-property:dim'],
duration: 500
});