metamaps--metamaps/app/views/maps/show.html.erb

127 lines
4.3 KiB
Text
Raw Normal View History

<%#
# @file
# Code to display a map
# /maps/:id
#%>
<% content_for :title, @map.name + " | Metamaps" %>
2013-01-06 23:40:48 +00:00
<div class="headertop">
2013-07-10 18:02:38 +00:00
<div class="tab"></div>
<button class="hidelabels" onclick="hideLabels();">Hide Labels</button>
2013-01-25 05:47:32 +00:00
<button onclick="if (!goRealtime) { this.innerHTML = 'Stop Realtime'; } else if (goRealtime) { this.innerHTML = 'Start Realtime'; } goRealtime = !goRealtime;">Start Realtime</button>
<button onclick="hideSelectedEdges();hideSelectedNodes();">Hide Selected</button>
<button onclick="enterKeyHandler();">Keep Selected</button>
2013-01-06 23:40:48 +00:00
<% if authenticated? %>
2013-01-25 05:47:32 +00:00
<% if (@map.permission == "commons" && authenticated?) || @map.user == user %>
2013-07-10 18:02:38 +00:00
<button onclick="removeSelectedEdges();removeSelectedNodes();">Remove Selected</button>
2013-01-25 05:47:32 +00:00
<% end %>
2013-07-10 18:02:38 +00:00
<button onclick="var r=confirm('Are you sure you want to permanently delete selected objects?!'); if (r == true) {deleteSelectedEdges();deleteSelectedNodes();}">Delete Selected</button>
2013-01-06 23:40:48 +00:00
<% if (@map.permission == "commons" && authenticated?) || @map.user == user %>
<%= form_for @map, :url => savelayout_path(@map), :html => { :class => "saveMapLayout", :id => "saveMapLayout"}, remote: true do |form| %>
<%= form.hidden_field "coordinates", :value => "" %>
<%= form.submit "Save Layout", class: "saveLayout", id: "saveLayout" %>
<% end %>
<% end %>
<button onclick="saveToMap();">Save to New Map</button>
<% end %>
<button onclick='clearCanvas();'>Clear Canvas</button>
</div>
<div class="clearfloat"></div>
<h1 class="index">
<% if (@map.permission == "commons" && authenticated?) || @map.user == user %>
Editing Map:
<% else %>
Viewing Map:
<% end %>
<%= @map.name %>
2013-01-08 04:40:58 +00:00
<% if (@map.permission == "commons" && authenticated?) || @map.user == user %>
<%= link_to "[edit]", edit_map_path(@map) %>
<% end %>
2013-01-06 23:40:48 +00:00
</h1>
<div class="maps onMap" id="container">
<div id="center-container">
<div id="infovis"></div>
</div>
<div class="showcard" id="showcard"></div>
</div>
<div class="clearfloat"></div>
<% if authenticated? %>
<%= render :partial => 'newtopic' %>
<%= render :partial => 'newsynapse' %>
2013-01-06 23:40:48 +00:00
<%= render :partial => 'maps/new' %>
<% end %>
2013-01-08 04:40:58 +00:00
<script>
var dragged = 0;
mapid = <%= @map.id %>;
2013-01-25 05:47:32 +00:00
<% if (@map.permission == "commons" && authenticated?) || @map.user == user %>
mapperm = true;
<% end %>
viewMode = "graph";
json = <%= @mapjson %>;
if (json.length > 0) {
$(document).ready(function() {
<% if (@map.arranged) %>
2012-12-14 18:31:39 +00:00
initialize("arranged");
<% else %>
2012-12-14 18:31:39 +00:00
initialize("chaotic");
<% end %>
});
}
else {
$(document).ready(function() {
initialize("chaotic", true);
});
}
function subscribeToRooms() {
window.app.socket.on('maps-' + mapid, function(data) {
//as long as you weren't the origin of the changes, update your map
if (data.origin != userid && goRealtime) {
if (data.resource == 'Topic') {
topic = $.parseJSON(data.obj);
if (data.action == 'create') {
window.app.addTopicToMap(topic);
}
else if (data.action == 'update' && Mconsole.graph.getNode(topic.id) != 'undefined') {
window.app.updateTopicOnMap(topic);
}
else if (data.action == 'destroy' && Mconsole.graph.getNode(topic.id) != 'undefined') {
hideNode(topic.id)
}
return;
}
else if (data.resource == 'Synapse') {
synapse = $.parseJSON(data.obj);
if (data.action == 'create') {
window.app.addSynapseToMap(synapse);
}
else if (data.action == 'update' &&
Mconsole.graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']) != 'undefined') {
window.app.updateSynapseOnMap(synapse);
}
else if (data.action == 'destroy' &&
Mconsole.graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']) != 'undefined') {
var edge = Mconsole.graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']);
hideEdge(edge);
}
return;
}
}
});
}
2013-01-06 23:40:48 +00:00
</script>
<%= render :partial => 'main/find' %>
<%= render :partial => 'main/analyze' %>
<%= render :partial => 'main/organize' %>