2013-01-11 23:49:59 +00:00
|
|
|
<%#
|
|
|
|
# @file
|
|
|
|
# Code to display a map
|
2013-01-23 18:55:50 +00:00
|
|
|
# /maps/:id
|
2013-01-11 23:49:59 +00:00
|
|
|
#%>
|
2013-07-09 16:32:13 +00:00
|
|
|
|
|
|
|
<% content_for :title, @map.name + " | Metamaps" %>
|
2013-01-06 23:40:48 +00:00
|
|
|
|
2014-01-29 03:46:58 +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>
|
2013-01-06 23:40:48 +00:00
|
|
|
<% if authenticated? %>
|
|
|
|
<% 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>
|
2014-01-29 03:46:58 +00:00
|
|
|
<div class="clearfloat"></div> -->
|
2013-01-06 23:40:48 +00:00
|
|
|
|
2014-01-29 03:46:58 +00:00
|
|
|
<div class="index">
|
|
|
|
<div class="openCheatsheet"></div>
|
|
|
|
<span><img width="35" height="35" src="/assets/map.png"></span>
|
|
|
|
<span class="mapName"><%= @map.name %></span>
|
|
|
|
<span class="mapInfo"></span>
|
|
|
|
<div class="clearfloat"></div>
|
|
|
|
</div>
|
2012-10-26 10:04:52 +00:00
|
|
|
|
2013-01-05 02:39:16 +00:00
|
|
|
<div class="maps onMap" id="container">
|
2012-10-26 10:04:52 +00:00
|
|
|
<div id="center-container">
|
|
|
|
<div id="infovis"></div>
|
|
|
|
</div>
|
2013-03-17 09:18:30 +00:00
|
|
|
<div class="showcard" id="showcard"></div>
|
2012-10-26 10:04:52 +00:00
|
|
|
</div>
|
|
|
|
<div class="clearfloat"></div>
|
|
|
|
|
2013-01-05 02:39:16 +00:00
|
|
|
<% if authenticated? %>
|
|
|
|
<%= render :partial => 'newtopic' %>
|
|
|
|
<%= render :partial => 'newsynapse' %>
|
2013-01-06 23:40:48 +00:00
|
|
|
<%= render :partial => 'maps/new' %>
|
2013-01-05 02:39:16 +00:00
|
|
|
<% end %>
|
2013-01-08 04:40:58 +00:00
|
|
|
|
2013-01-05 02:39:16 +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 %>
|
2013-04-26 04:07:29 +00:00
|
|
|
|
2012-12-15 07:39:14 +00:00
|
|
|
viewMode = "graph";
|
2012-10-26 10:04:52 +00:00
|
|
|
json = <%= @mapjson %>;
|
|
|
|
if (json.length > 0) {
|
2014-01-29 03:46:58 +00:00
|
|
|
$(window).load(function() {
|
2012-12-03 23:40:14 +00:00
|
|
|
<% if (@map.arranged) %>
|
2012-12-14 18:31:39 +00:00
|
|
|
initialize("arranged");
|
2012-12-03 23:40:14 +00:00
|
|
|
<% else %>
|
2012-12-14 18:31:39 +00:00
|
|
|
initialize("chaotic");
|
2012-12-03 23:40:14 +00:00
|
|
|
<% end %>
|
2012-10-26 10:04:52 +00:00
|
|
|
});
|
|
|
|
}
|
2012-12-25 23:29:20 +00:00
|
|
|
else {
|
2014-01-29 03:46:58 +00:00
|
|
|
$(window).load(function() {
|
2012-12-25 23:29:20 +00:00
|
|
|
initialize("chaotic", true);
|
|
|
|
});
|
|
|
|
}
|
2013-04-26 04:07:29 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-01-29 03:46:58 +00:00
|
|
|
</script>
|