From 35dd8c181664b1b3cfc8da17a222b08902dc7d8a Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 14 Feb 2013 21:29:45 -0500 Subject: [PATCH] partway to save to map functionality on topic view --- app/assets/javascripts/application.js | 10 +++++++++- app/views/topics/show.html.erb | 25 ++++++++----------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 9654d26b..7a4124e1 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -182,7 +182,15 @@ function saveToMap() { var nodes_data = "", synapses_data = ""; var synapses_array = new Array(); 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) { synapses_array.push(adj.getData("id")); }); diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 89af1524..ced68f64 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -14,23 +14,13 @@ # #%> - +

Viewing Topic: <%= @topic.name %> @@ -53,6 +43,7 @@ <% if authenticated? %> <%= render :partial => 'topics/new' %> - <%= render :partial => 'synapses/new' %> + <%= render :partial => 'synapses/new' %> + <%= render :partial => 'maps/new' %> <% end %>