partway to save to map functionality on topic view

This commit is contained in:
Devin Howard 2013-02-14 21:29:45 -05:00
parent dee531e3ef
commit 35dd8c1816
2 changed files with 17 additions and 18 deletions

View file

@ -182,7 +182,15 @@ function saveToMap() {
var nodes_data = "", synapses_data = ""; var nodes_data = "", synapses_data = "";
var synapses_array = new Array(); var synapses_array = new Array();
Mconsole.graph.eachNode(function(n) { Mconsole.graph.eachNode(function(n) {
nodes_data += n.id + '/' + n.pos.x + '/' + n.pos.y + ','; var x, y;
if (n.pos.x && n.pos.y) {
x = n.pos.x;
y = n.pos.y;
} else {
var x = Math.cos(n.pos.theta) * n.pos.rho;
var y = Math.sin(n.pos.theta) * n.pos.rho;
}
nodes_data += n.id + '/' + x + '/' + y + ',';
n.eachAdjacency(function(adj) { n.eachAdjacency(function(adj) {
synapses_array.push(adj.getData("id")); synapses_array.push(adj.getData("id"));
}); });

View file

@ -14,23 +14,13 @@
# #
#%> #%>
<!--<div class="focus topic_<%= @topic.id %>"> <div class="headertop">
<div class="focusleft"> <% if authenticated? %>
<p><%= @topic.metacode.name %></p> <button onclick="saveToMap();">Save to Map</button>
<%= image_tag @topic.metacode.icon, :class => 'icon', :size => '50x50' %> <% end %>
<button onclick='clearCanvasExceptRoot();'>Clear Canvas</button>
</div> </div>
<div class="focusmiddle"> <div class="clearfloat"></div>
<h1 class="title"><span class="title-text"><%= @topic.name %></span> <% if (@topic.permission == "commons" && authenticated?) || @topic.user == user %><%= link_to "[edit]", edit_topic_path(@topic) %><% end %></h1>
<div class="desc">
<p><%= @topic.desc %></p>
</div>
</div>
<div class="focusright">
<p>Link</p>
<%= link_to @topic.link, @topic.link, :class => 'link', :target => '_blank' %>
</div>
</div>
<div class="clearfloat nodemargin"></div>-->
<h1 class="index"> <h1 class="index">
Viewing Topic: <%= @topic.name %> Viewing Topic: <%= @topic.name %>
@ -54,5 +44,6 @@
<% if authenticated? %> <% if authenticated? %>
<%= render :partial => 'topics/new' %> <%= render :partial => 'topics/new' %>
<%= render :partial => 'synapses/new' %> <%= render :partial => 'synapses/new' %>
<%= render :partial => 'maps/new' %>
<% end %> <% end %>