changed the mechanism for realtime so that it only pulls in new information

This commit is contained in:
Connor Turland 2013-01-04 16:51:37 -05:00
parent e3cbc9cf8f
commit ea19ce5375
119 changed files with 291 additions and 79 deletions

View file

@ -76,6 +76,7 @@ function graphSettings(type) {
tempNode2 = null;
tempInit = false;
}
else if (dragged != 0 && goRealtime) { saveLayout(dragged); }
},
onDragCancel: function() {
tempNode = null;
@ -479,7 +480,10 @@ function clickDragOnTopic(node, eventInfo, e) {
var pos = eventInfo.getPos();
// if it's a left click, move the node
if (e.button == 0 && !e.altKey && (e.buttons == 0 || e.buttons == 1 || e.buttons == undefined)) {
dragged = node.id;
node.pos.setc(pos.x, pos.y);
node.data.$xloc = pos.x;
node.data.$yloc = pos.y;
Mconsole.plot();
}
// if it's a right click or holding down alt, start synapse creation ->third option is for firefox

View file

@ -86,10 +86,16 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
);
// this is to save the layout of maps when you're on a map page
var coor = "";
$("#saveLayout").click(function(event) {
event.preventDefault();
coor = "";
saveLayoutAll();
});
});
// this is to save the layout of a map
function saveLayoutAll() {
var coor = "";
if (gType == "arranged" || gType == "chaotic") {
Mconsole.graph.eachNode(function(n) {
coor = coor + n.data.$mappingid + '/' + n.pos.x + '/' + n.pos.y + ',';
@ -97,11 +103,16 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
coor = coor.slice(0, -1);
$('#map_coordinates').val(coor);
$('#saveMapLayout').submit();
}
});
}
});
// this is to update the location coordinate of a single node on a map
function saveLayout(id) {
var n = Mconsole.graph.getNode(id);
$('#map_coordinates').val(n.data.$mappingid + '/' + n.pos.x + '/' + n.pos.y);
$('#saveMapLayout').submit();
dragged = 0;
}
// this is to save your console to a map
function saveToMap() {

View file

@ -129,9 +129,11 @@ class MapsController < ApplicationController
@all.each do |topic|
topic = topic.split('/')
@mapping = Mapping.find(topic[0])
if @mapping
@mapping.xloc = topic[1]
@mapping.yloc = topic[2]
@mapping.save
end
end
@map.arranged = true
@map.save
@ -143,10 +145,19 @@ class MapsController < ApplicationController
@current = current_user
@map = Map.find(params[:id])
@mapjson = @map.self_as_json(@current).html_safe
@time = params[:map][:time]
@time = @time.to_i
@topics = Array.new()
@synapses = Array.new()
@mappings = Array.new()
# add code for finding deleted topics and sending the ids of those back to the client here
@topics = @map.topics.select{|t| t.updated_at.to_i > @time}
@synapses = @map.synapses.select{|t| t.updated_at.to_i > @time}
@mappings = @map.mappings.select{|t| t.updated_at.to_i > @time && t.category == "Topic"}
respond_to do |format|
format.js { respond_with(@mapjson) }
format.js { respond_with(@map,@topics,@synapses,@mappings) }
end
end

View file

@ -55,6 +55,30 @@ belongs_to :metacode
end
end
def selfonmap_as_json(mapid)
Jbuilder.encode do |json|
@inmaps = Array.new
self.maps.each do |map|
@inmaps.push(map.id)
end
@topicdata = Hash.new
@topicdata['$desc'] = self.desc
@topicdata['$link'] = self.link
@topicdata['$metacode'] = self.metacode.name
@topicdata['$inmaps'] = @inmaps
@topicdata['$userid'] = self.user.id
@topicdata['$username'] = self.user.name
@mapping = Mapping.find_by_topic_id_and_map_id(self.id,mapid)
@topicdata['$xloc'] = @mapping.xloc
@topicdata['$yloc'] = @mapping.yloc
@topicdata['$mappingid'] = @mapping.id
json.data @topicdata
json.id self.id
json.name self.name
end
end
#build a json object of everything connected to a specified node
def network_as_json(current)
Jbuilder.encode do |json|

View file

@ -1,63 +1,89 @@
function arraysEqual(a1,a2) {
return JSON.stringify(a1)==JSON.stringify(a2);
}
var tempForT, tempForS, tempForM;
newJSON = <%= @mapjson %>;
if (!arraysEqual(json,newJSON)) {
json = newJSON;
$.each(json, function(i,topic){
var temp = Mconsole.graph.getNode(topic.id);
// in this case the node wasn't on the page before, so we create it
if (temp == null) {
<% @topics.each do |topic| %>
var topic = <%= topic.selfonmap_as_json(@map.id).html_safe %>;
tempForT = Mconsole.graph.getNode(topic.id);
if (tempForT === undefined) {
Mconsole.graph.addNode(topic);
var temp = Mconsole.graph.getNode(topic.id);
temp.setData('dim', 1, 'start');
temp.setData('dim', 25, 'end');
var tempForT = Mconsole.graph.getNode(topic.id);
tempForT.setData('dim', 1, 'start');
tempForT.setData('dim', 25, 'end');
var newPos = new $jit.Complex();
newPos.x = temp.data.$xloc;
newPos.y = temp.data.$yloc;
temp.setPos(newPos, 'start');
temp.setPos(newPos, 'current');
temp.setPos(newPos, 'end');
Mconsole.fx.plotNode(temp, Mconsole.canvas);
Mconsole.labels.plotLabel(Mconsole.canvas, temp, Mconsole.config);
Mconsole.fx.animate({
modes: ['node-property:dim','edge-property:lineWidth'],
duration: 1000
});
newPos.x = tempForT.data.$xloc;
newPos.y = tempForT.data.$yloc;
tempForT.setPos(newPos, 'start');
tempForT.setPos(newPos, 'current');
tempForT.setPos(newPos, 'end');
Mconsole.fx.plotNode(tempForT, Mconsole.canvas);
Mconsole.labels.plotLabel(Mconsole.canvas, tempForT, Mconsole.config);
}
else { // in this case we found a topic so we have to update it
var newPos = new $jit.Complex();
newPos.x = temp.data.$xloc;
newPos.y = temp.data.$yloc;
temp.setPos(newPos, 'end');
else {
var label = Mconsole.labels.getLabel(topic.id);
if (temp.name != topic.name) {
temp.name = topic.name;
tempForT.setData('dim', 25, 'start');
tempForT.setData('dim', 25, 'current');
tempForT.setData('dim', 25, 'end');
if (tempForT.name != topic.name) {
tempForT.name = topic.name;
$(label).find('.best_in_place_name').html(topic.name);
$(label).find('.label').html(topic.name);
}
if (temp.data.$metacode != topic.data.$metacode) {
if (tempForT.data.$metacode != topic.data.$metacode) {
$(label).find('.best_in_place_metacode').html(topic.data.$metacode);
$(label).find('img.icon').attr('alt', topic.data.$metacode);
$(label).find('img.icon').attr('src', imgArray[topic.data.$metacode].src);
}
if (temp.data.$desc != topic.data.$desc) {
if (tempForT.data.$desc != topic.data.$desc) {
$(label).find('.best_in_place_desc').html(topic.data.$desc);
}
if (temp.data.$link != topic.data.$link) {
if (tempForT.data.$link != topic.data.$link) {
$(label).find('.best_in_place_link').html(topic.data.$link);
$(label).find('.link').attr('href',topic.data.$link);
}
temp.data = topic.data;
tempForT.data = topic.data;
}
});
<% end %>
Mconsole.animate({
modes: ['linear'],
transition: $jit.Trans.Quad.easeInOut,
duration: 500
<% @synapses.each do |synapse| %>
var Node1 = Mconsole.graph.getNode(<%= synapse.topic1.id %>);
var Node2 = Mconsole.graph.getNode(<%= synapse.topic2.id %>);
Mconsole.graph.addAdjacence(Node1, Node2, {});
tempForS = Mconsole.graph.getAdjacence(Node1.id, Node2.id);
tempForS.setDataset('start', {
lineWidth: 0.4
});
}
tempForS.setDataset('end', {
lineWidth: 2
});
var d = new Array(<%= synapse.node1_id.to_s() %>, <%= synapse.node2_id.to_s() %>);
tempForS.setDataset('current', {
desc: '<%= synapse.desc %>',
showDesc: false,
category: '<%= synapse.category %>',
id: '<%= synapse.id %>',
userid: '<%= synapse.user.id %>',
username: '<%= synapse.user.name %>'
});
tempForS.data.$direction = d;
Mconsole.fx.plotLine(tempForS, Mconsole.canvas);
<% end %>
<% @mappings.each do |mapping| %>
tempForM = Mconsole.graph.getNode(<%= mapping.topic_id %>);
tempForM.data.$xloc = <%= mapping.xloc %>;
tempForM.data.$yloc = <%= mapping.yloc %>;
var newPos = new $jit.Complex();
newPos.x = tempForM.data.$xloc;
newPos.y = tempForM.data.$yloc;
tempForM.setPos(newPos, 'start');
tempForM.setPos(newPos, 'current');
tempForM.setPos(newPos, 'end');
<% end %>
<% if @topics.length > 0 || @synapses.length > 0 || @mappings.length > 0 %>
$('#map_time').val(Math.round((new Date()).getTime() / 1000));
Mconsole.fx.animate({
modes: ['linear','node-property:dim','edge-property:lineWidth'],
transition: $jit.Trans.Quad.easeInOut,
duration: 3000
});
<% end %>

View file

@ -8,7 +8,7 @@
<%= form.submit "Save Layout", class: "saveLayout", id: "saveLayout" %>
<% end %>
<% end %>
<button onclick="if (!goRealtime) { this.innerHTML = 'Stop Realtime'} else if (goRealtime) { this.innerHTML = 'Start Realtime'} goRealtime = !goRealtime;">Start Realtime</button>
<button onclick="if (!goRealtime) { this.innerHTML = 'Stop Realtime'; $('#saveLayout').css('display','none');} else if (goRealtime) { this.innerHTML = 'Start Realtime'; $('#saveLayout').css('display','block');} goRealtime = !goRealtime;">Start Realtime</button>
</div>
<div class="focusmiddle">
<h1 class="title"><%= @map.name %> <% if (@map.permission == "commons" && authenticated?) || @map.user == user %><%= link_to "[edit]", edit_map_path(@map) %><% end %></h1>
@ -55,7 +55,14 @@
<%= render :partial => 'newsynapse' %>
<% end %>
<%= form_for @map, :url => realtime_path(@map), :method => "GET", :html => { :id => "MapRealtime"}, remote: true do |form| %>
<%= form.hidden_field :time, :value => Time.now.to_i %>
<%= form.hidden_field :ids, :value => 0 %>
<% end %>
<script>
var int = setInterval(function(){if (goRealtime) {$('#MapRealtime').submit();}},5000);
var dragged = 0;
var int = setInterval(function(){
if (goRealtime) {
$('#MapRealtime').submit();
}
},4000);
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
public/assets/action.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
public/assets/activity.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/assets/argument.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
public/assets/bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
public/assets/bizarre.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

BIN
public/assets/catalyst.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
public/assets/closed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/assets/con_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/assets/decision.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
public/assets/example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
public/assets/foresight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
public/assets/futuredev.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
public/assets/go-arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
public/assets/group.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
public/assets/idea.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
public/assets/insight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
public/assets/intention.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/assets/junto.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

BIN
public/assets/knowledge.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/assets/list.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

BIN
public/assets/location.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View file

@ -0,0 +1,55 @@
---
action.png: action-02bd981b8466a7b2cb167afffc284703.png
activity.png: activity-27aedb9b5baea69ea88f1f2b5303862c.png
argument.png: argument-4c3b1c568d758e134c36e4be294ed3a5.png
background.jpg: background-2fcc9f96ace4764a02278ada04bc0d9d.jpg
background2-for-repeating.jpg: background2-for-repeating-8d022369a362b364c9395039167f1ffd.jpg
background2.jpg: background2-c2b46d9ebc7d31aea8135e3c505aa1e9.jpg
bg.png: bg-eea3f1ec61623cbc3833f8fcbf114bf8.png
bizarre.png: bizarre-4154e4b7b2e0169cfc4af24c32119305.png
catalyst.png: catalyst-21e04cdb0f34140b3e00d0b98aca240c.png
closed.png: closed-11f6970ed42d52bc9352fa8860ab7479.png
con_icon.png: con_icon-d8aee295fac276c5de66ba835b251137.png
decision.png: decision-7cee13c9510c1119ba34c8bb654ffdde.png
example.png: example-fc70515d308ee9ef5b3b2b38d0eecb8e.png
experience.png: experience-79528f6bceb2a66a98bdbdff2c64dc02.png
foresight.png: foresight-0e62c71e1eb88a2b7ff4d20ba12f3f54.png
futuredev.png: futuredev-e3c62458cfd457b0501dddc6d9b2d8d4.png
go-arrow.png: go-arrow-1d87c9870031ea6b0179cd00ead5cbf1.png
goodpractice.png: goodpractice-928b04810ec395c188e90cc05f219387.png
group.png: group-70155e13e72ec389d64a4f80a8d62d24.png
idea.png: idea-5092d85514a1fdacec53760d7ecf63c4.png
implication.png: implication-652ece8bc0b1060dd5ca0756393cf21e.png
insight.png: insight-858ccca7357b37837a257e0202319b27.png
intention.png: intention-a487d116bfcf64c7ac559ef89ed61544.png
junto.png: junto-3bca283ec5fe80ef34d6a888b7c676b4.png
knowledge.png: knowledge-eb4b1dc4412b210c286b934737b04f80.png
list.png: list-c2cade39d3e1e606162d860d9eb58690.png
location.png: location-e1642892214a5cb4b2891f3837f437de.png
map.png: map-acf615128f2f9f581a225ed908fd5f3b.png
moviemap.png: moviemap-7b2052b46a57fd1554fdeaed5470ac87.png
note.png: note-607459da5972ee3b48469762ad879864.png
openissue.png: openissue-d9c50446b2dbd0587942ae298bda2a75.png
opinion.png: opinion-eabcaf3f05d2bf38dfd075e8449cea57.png
opportunity.png: opportunity-4fe7c2f4f5cbe678058c76924ec43a7f.png
person.png: person-2cb4eace780426c21c109ca6475431ce.png
platform.png: platform-29f4dc32fb5f2a9f369b92d2f51ba005.png
pro.png: pro-205bd7f40d88f6d13369780d0d115ebf.png
problem.png: problem-d660aa3522f737dfd25487937bed6db1.png
question.png: question-9ac8258ba7e5bcb83114651b43dcc92e.png
reference.png: reference-114b70ecccc3971ad9942f5fc8b5b654.png
requirement.png: requirement-d200e129a41fff36f64111f554abea72.png
research.png: research-0c10ce1c3fbdad073555b64ab85aef9d.png
resource.png: resource-4017b1e9535d80d205ceff916930cf5d.png
role.png: role-c474b1fcb4b4f836e7ca0db67e744dc3.png
spinner.gif: spinner-3dc049c5763846dcf9ff6cab669b2b87.gif
task.png: task-0ac599d122a709a5e73990f1745019e0.png
tool.png: tool-92f28a86b5ece18668698a0b9a19aca7.png
topbg.png: topbg-eb18f5cf8dcfaf7dfd7e47f503956a5d.png
topbg2.png: topbg2-f9640f6cb183bb610d0954c7759ecc23.png
trajectory.png: trajectory-a7c520e746d4c1ffe401805b3d0cb6cd.png
ui-bg_flat_75_ffffff_40x100.png: ui-bg_flat_75_ffffff_40x100-841636c8f8d33987bb8d2f31e8ef92ca.png
wildcard.png: wildcard-22dead854b0b5f4ec0aba7a05425839e.png
application.js: application-3057218917de97811252e48546a44e4e.js
scroll/mCSB_buttons.png: scroll/mCSB_buttons-6eb1e766df3b6b28f5cb2a218697658f.png
application.css: application-36fbfd1a7f25ac80214f83065ab39d70.css

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
public/assets/map.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
public/assets/moviemap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
public/assets/note.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
public/assets/openissue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/assets/opinion.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
public/assets/person.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

BIN
public/assets/platform.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/assets/pro.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
public/assets/problem.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/assets/question.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/assets/reference.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
public/assets/research.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
public/assets/resource.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Some files were not shown because too many files have changed in this diff Show more