added new images and made realtime send more relevant messages including one when someone turns on realtime

This commit is contained in:
Connor Turland 2014-06-09 16:37:09 -04:00
parent 2f969bb29e
commit 8760cf0280
10 changed files with 70 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 B

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -10,8 +10,10 @@ $(document).ready(function () {
// because anyone who can edit the map can collaborate on it in realtime // because anyone who can edit the map can collaborate on it in realtime
$(".sidebarCollaborateIcon").click(function (event) { $(".sidebarCollaborateIcon").click(function (event) {
if (!goRealtime) { if (!goRealtime) {
window.realtime.sendRealtimeOn();
$('.sidebarCollaborate .tip').html('Stop Realtime Collaboration'); $('.sidebarCollaborate .tip').html('Stop Realtime Collaboration');
} else { } else {
window.realtime.sendRealtimeOff();
$('.sidebarCollaborate .tip').html('Start Realtime Collaboration'); $('.sidebarCollaborate .tip').html('Start Realtime Collaboration');
} }
goRealtime = !goRealtime; goRealtime = !goRealtime;

View file

@ -34,9 +34,9 @@ window.realtime.setupSocket = function () {
// data.userid // data.userid
// data.username // data.username
window.realtime.notifyUser(data.username + ' just came online'); window.realtime.notifyUser(data.username + ' just joined the map');
// send this new mapper back your details, and the awareness that you're online // send this new mapper back your details, and the awareness that you've loaded the map
var update = { var update = {
userToNotify: data.userid, userToNotify: data.userid,
username: username, username: username,
@ -46,11 +46,27 @@ window.realtime.setupSocket = function () {
socket.emit('updateNewMapperList', update); socket.emit('updateNewMapperList', update);
}); });
// receive word that there's a mapper turned on realtime
socket.on('maps-' + mapid + '-newrealtime', function (data) {
// data.userid
// data.username
window.realtime.notifyUser(data.username + ' just turned on realtime');
});
// receive word that there's a mapper turned on realtime
socket.on('maps-' + mapid + '-lostrealtime', function (data) {
// data.userid
// data.username
window.realtime.notifyUser(data.username + ' just turned off realtime');
});
socket.on('maps-' + mapid + '-lostmapper', function (data) { socket.on('maps-' + mapid + '-lostmapper', function (data) {
// data.userid // data.userid
// data.username // data.username
window.realtime.notifyUser(data.username + ' just went offline'); window.realtime.notifyUser(data.username + ' just left the map');
}); });
socket.on('maps-' + mapid, function (data) { socket.on('maps-' + mapid, function (data) {
@ -91,6 +107,26 @@ window.realtime.setupSocket = function () {
}); });
}; };
window.realtime.sendRealtimeOn = function () {
// send this new mapper back your details, and the awareness that you're online
var update = {
username: username,
userid: userid,
mapid: mapid
};
window.realtime.socket.emit('notifyStartRealtime', update);
}
window.realtime.sendRealtimeOff = function () {
// send this new mapper back your details, and the awareness that you're online
var update = {
username: username,
userid: userid,
mapid: mapid
};
window.realtime.socket.emit('notifyStopRealtime', update);
}
window.realtime.addTopicToMap = function (topic) { window.realtime.addTopicToMap = function (topic) {
var newPos, tempForT; var newPos, tempForT;
Mconsole.graph.addNode(topic); Mconsole.graph.addNode(topic);

View file

@ -290,7 +290,8 @@ input[type="submit"]:hover {
display: block; display: block;
height: 20px; height: 20px;
width: 20px; width: 20px;
background: #0FFF2B; background-image: url('MMCCicon_metacode_set_change.png');
background-size:contain;
position: absolute; position: absolute;
z-index: 2; z-index: 2;
top: 20px; top: 20px;
@ -579,6 +580,9 @@ li.accountMaps {
li.accountSettings { li.accountSettings {
background-image: url('MMCCicon_settings.png'); background-image: url('MMCCicon_settings.png');
} }
li.accountAdmin {
background-image: url('MMCCicon_admin.png');
}
li.accountInvite { li.accountInvite {
background-image: url('MMCCicon_invite.png'); background-image: url('MMCCicon_invite.png');
} }

View file

@ -10,7 +10,7 @@
<li class="accountIcon accountMaps"><a href="/maps/mappers/<%= account.id %>">My Maps</a></li> <li class="accountIcon accountMaps"><a href="/maps/mappers/<%= account.id %>">My Maps</a></li>
<li class="accountIcon accountSettings"><%= link_to "Account", edit_user_url(account) %></li> <li class="accountIcon accountSettings"><%= link_to "Account", edit_user_url(account) %></li>
<% if account.admin %> <% if account.admin %>
<li class="accountIcon accountSettings"><%= link_to "Admin", metacodes_path %></li> <li class="accountIcon accountAdmin"><%= link_to "Admin", metacodes_path %></li>
<% end %> <% end %>
<li class="accountIcon accountInvite openLightbox" data-open="invite"><span>Share Invite</span></li> <li class="accountIcon accountInvite openLightbox" data-open="invite"><span>Share Invite</span></li>
<li class="accountIcon accountLogout"><%= link_to "Logout", "/sign_out", id: "Logout" %></li> <li class="accountIcon accountLogout"><%= link_to "Logout", "/sign_out", id: "Logout" %></li>

View file

@ -104,13 +104,13 @@ if (json.length > 0) {
<% if authenticated? && (@map.permission == "commons" || @map.user == user) %> <% if authenticated? && (@map.permission == "commons" || @map.user == user) %>
// this is for the heroku staging environment // this is for the heroku staging environment
window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); //window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com');
// this is for metamaps.cc // this is for metamaps.cc
//window.realtime.socket = io.connect('http://metamaps.cc:5001'); //window.realtime.socket = io.connect('http://metamaps.cc:5001');
// this is for localhost development // this is for localhost development
//window.realtime.socket = io.connect('http://localhost:5001'); window.realtime.socket = io.connect('http://localhost:5001');
window.realtime.socket.on('connect', function () { window.realtime.socket.on('connect', function () {
console.log('socket connected'); console.log('socket connected');

View file

@ -81,6 +81,26 @@ function start() {
}); });
}); });
// this will ping everyone on a map that someone just turned on realtime
socket.on('notifyStartRealtime', function (data) {
var newUser = {
userid: data.userid,
username: data.username
};
socket.broadcast.emit('maps-' + data.mapid + '-newrealtime', newUser);
});
// this will ping everyone on a map that someone just turned on realtime
socket.on('notifyStopRealtime', function (data) {
var newUser = {
userid: data.userid,
username: data.username
};
socket.broadcast.emit('maps-' + data.mapid + '-lostrealtime', newUser);
});
}); });
} }