diff --git a/app/assets/javascripts/Jit/ForceDirected/metamap.js b/app/assets/javascripts/Jit/ForceDirected/metamap.js
index 5b2bb78f..712d86ca 100644
--- a/app/assets/javascripts/Jit/ForceDirected/metamap.js
+++ b/app/assets/javascripts/Jit/ForceDirected/metamap.js
@@ -10,22 +10,11 @@ var labelType, useGradients, nativeTextSupport, animate, json;
//I'm setting this based on the fact that ExCanvas provides text support for IE
//and that as of today iPhone/iPad current text support is lame
labelType = (!nativeCanvasSupport || (textSupport && !iStuff))? 'Native' : 'HTML';
- console.log(labelType);
nativeTextSupport = labelType == 'Native';
useGradients = nativeCanvasSupport;
animate = !(iStuff || !nativeCanvasSupport);
})();
-var Log = {
- elem: false,
- write: function(text){
- if (!this.elem)
- this.elem = document.getElementById('log');
- this.elem.innerHTML = text;
- this.elem.style.left = (500 - this.elem.offsetWidth / 2) + 'px';
- }
-};
-
var imgArray = new Object();
imgArray['Group'] = new Image(); imgArray['Group'].src = '/assets/group.png';
@@ -183,13 +172,13 @@ function init(){
// This is done by traversing the clicked node connections.
var html = '
';
//append connections information
- $jit.id('inner-details').innerHTML = html;
+ $jit.id('showcard').innerHTML = html;
}
},
//Number of iterations for the FD algorithm
iterations: 200,
//Edge length
- levelDistance: 130,
+ levelDistance: 150,
// Add text to the labels. This method is only triggered
// on label creation and only for DOM labels (not native canvas ones).
onCreateLabel: function(domElement, node){
@@ -257,7 +246,7 @@ function init(){
// This is done by traversing the clicked node connections.
var html = '';
//append connections information
- $jit.id('inner-details').innerHTML = html;
+ $jit.id('showcard').innerHTML = html;
};
},
// Change node styles when DOM labels are placed
@@ -280,10 +269,8 @@ function init(){
iter: 40,
property: 'end',
onStep: function(perc){
- Log.write(perc + '% loaded...');
},
onComplete: function(){
- Log.write('done');
fd.animate({
modes: ['linear'],
transition: $jit.Trans.Elastic.easeOut,
diff --git a/app/assets/stylesheets/base.css b/app/assets/stylesheets/base.css
index 1153c4e6..9f55e8bd 100644
--- a/app/assets/stylesheets/base.css
+++ b/app/assets/stylesheets/base.css
@@ -1,45 +1,32 @@
#center-container {
position:relative;
- height:500px;
- width:70%;
- float:left;
+ height:800px;
+ width:95%;
/* background-color:#031924; */
color:#ccc;
- max-width:900px;
}
-#right-container {
- height:500px;
- width:29%;
+#showcard{
+ width:auto;
+ height:auto;
color:#FFF;
text-align: left;
overflow: auto;
-}
-
-#right-container h4{
- font-size:16px;
- line-height:18px;
+ position:absolute;
+ top:50%;
+ left:10px;
+ margin-top:-150px;
+
}
.text {
margin: 7px;
}
-#inner-details {
-}
-
-#log {
- font-size:1.0em;
- font-weight:bold;
- color:#23A4FF;
- display:none;
-}
-
-
#infovis {
position:relative;
width:100%;
- height:500px;
+ height:800px;
margin:0 0 0 50px;
overflow:hidden;
}
diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb
index 2cbcd0e6..ac1bf8bf 100644
--- a/app/controllers/items_controller.rb
+++ b/app/controllers/items_controller.rb
@@ -24,7 +24,7 @@ class ItemsController < ApplicationController
def show
@item = Item.find(params[:id])
- @relatives = @item.as_json.html_safe
+ @relatives = @item.map_as_json.html_safe
respond_to do |format|
format.html { respond_with(@item) }
diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb
index 5619d864..1f1255b9 100644
--- a/app/controllers/main_controller.rb
+++ b/app/controllers/main_controller.rb
@@ -6,9 +6,14 @@ class MainController < ApplicationController
def home
@current_user = current_user
- @all = Item.all
+ @item = Item.all.first
- respond_with(@all)
+ @alljson = @item.all_as_json.html_safe
+
+ respond_to do |format|
+ format.html { respond_with(@item) }
+ format.json { respond_with(@alljson) }
+ end
end
def userobjects
diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb
index cff0c9fe..b3559ca4 100644
--- a/app/helpers/items_helper.rb
+++ b/app/helpers/items_helper.rb
@@ -1,2 +1,11 @@
module ItemsHelper
+
+ def network(node)
+
+ @test = Array.new
+ @test.push(node)
+
+ end
+
+
end
diff --git a/app/models/item.rb b/app/models/item.rb
index 5a78f76d..36ae92c9 100644
--- a/app/models/item.rb
+++ b/app/models/item.rb
@@ -17,11 +17,64 @@ has_many :items2, :through => :synapses1, :source => :item2
belongs_to :item_category
- def as_json
+ def self_as_json
Jbuilder.encode do |json|
@single = Array.new
@single.push(self)
- #@items = @single + self.relatives
+
+ json.array!(@single) do |item|
+ json.adjacencies item.synapses2.delete_if{|synapse| not @items.include?(Item.find_by_id(synapse.node1_id))} do |json, synapse|
+ json.nodeTo synapse.node1_id
+ json.nodeFrom synapse.node2_id
+
+ @synapsedata = Hash.new
+ @synapsedata['$desc'] = synapse.desc
+ @synapsedata['$category'] = synapse.category
+ json.data @synapsedata
+ end
+
+ @itemdata = Hash.new
+ @itemdata['$desc'] = item.desc
+ @itemdata['$link'] = item.link
+ @itemdata['$itemcatname'] = item.item_category.name
+ json.data @itemdata
+ json.id item.id
+ json.name item.name
+ end
+ end
+ end
+
+ def map_as_json
+ Jbuilder.encode do |json|
+ @single = Array.new
+ @single.push(self)
+ @items = @single + self.relatives
+
+ json.array!(@items) do |item|
+ json.adjacencies item.synapses2.delete_if{|synapse| not @items.include?(Item.find_by_id(synapse.node1_id))} do |json, synapse|
+ json.nodeTo synapse.node1_id
+ json.nodeFrom synapse.node2_id
+
+ @synapsedata = Hash.new
+ @synapsedata['$desc'] = synapse.desc
+ @synapsedata['$category'] = synapse.category
+ json.data @synapsedata
+ end
+
+ @itemdata = Hash.new
+ @itemdata['$desc'] = item.desc
+ @itemdata['$link'] = item.link
+ @itemdata['$itemcatname'] = item.item_category.name
+ json.data @itemdata
+ json.id item.id
+ json.name item.name
+ end
+ end
+ end
+
+ def all_as_json
+ Jbuilder.encode do |json|
+
@items = Item.all
json.array!(@items) do |item|
diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb
index 647d6ef4..bb3b714d 100644
--- a/app/views/items/show.html.erb
+++ b/app/views/items/show.html.erb
@@ -18,13 +18,10 @@
-
<%= @item.name %> is connected to these items
-
diff --git a/app/views/main/home.html.erb b/app/views/main/home.html.erb
index 59ef992d..2d72ab10 100644
--- a/app/views/main/home.html.erb
+++ b/app/views/main/home.html.erb
@@ -1,9 +1,20 @@
-
- <% @all.each do |object| %>
- <%= render object %>
- <% end %>
- <% if @all.empty? %>
-
Shucks, there is nothing in metamaps.
- <% end %>
+<% unless @item.nil? %>
+
+
+<% end %>
+<% if @item.nil? %>
+
Shucks, there is nothing in metamaps.
+<% end %>