diff --git a/app/assets/images/MMCCicon_admin.png b/app/assets/images/MMCCicon_admin.png new file mode 100644 index 00000000..a3b9a767 Binary files /dev/null and b/app/assets/images/MMCCicon_admin.png differ diff --git a/app/assets/images/MMCCicon_metacode_set_change.png b/app/assets/images/MMCCicon_metacode_set_change.png new file mode 100644 index 00000000..56279526 Binary files /dev/null and b/app/assets/images/MMCCicon_metacode_set_change.png differ diff --git a/app/assets/images/MMCCicon_save_new_map.png b/app/assets/images/MMCCicon_save_new_map.png index 9138e632..ac6d5e95 100644 Binary files a/app/assets/images/MMCCicon_save_new_map.png and b/app/assets/images/MMCCicon_save_new_map.png differ diff --git a/app/assets/images/metamap128x128.png b/app/assets/images/metamap128x128.png index 6285f6d6..e4052738 100644 Binary files a/app/assets/images/metamap128x128.png and b/app/assets/images/metamap128x128.png differ diff --git a/app/assets/javascripts/jquery/AuthCanEditMapPage.js b/app/assets/javascripts/jquery/AuthCanEditMapPage.js index 79cf4760..0800caec 100644 --- a/app/assets/javascripts/jquery/AuthCanEditMapPage.js +++ b/app/assets/javascripts/jquery/AuthCanEditMapPage.js @@ -10,8 +10,10 @@ $(document).ready(function () { // because anyone who can edit the map can collaborate on it in realtime $(".sidebarCollaborateIcon").click(function (event) { if (!goRealtime) { + window.realtime.sendRealtimeOn(); $('.sidebarCollaborate .tip').html('Stop Realtime Collaboration'); } else { + window.realtime.sendRealtimeOff(); $('.sidebarCollaborate .tip').html('Start Realtime Collaboration'); } goRealtime = !goRealtime; diff --git a/app/assets/javascripts/realtime/realtime.js b/app/assets/javascripts/realtime/realtime.js index 20db2265..2428e3f3 100644 --- a/app/assets/javascripts/realtime/realtime.js +++ b/app/assets/javascripts/realtime/realtime.js @@ -6,7 +6,7 @@ window.realtime.notifyUser = function (message) { $('body').prepend('
'); } $('.notice.metamaps').hide().html(message).fadeIn('fast'); - + clearTimeout(window.realtime.notifyTimeOut); window.realtime.notifyTimeOut = setTimeout(function () { $('.notice.metamaps').fadeOut('fast'); @@ -34,9 +34,9 @@ window.realtime.setupSocket = function () { // data.userid // 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 = { userToNotify: data.userid, username: username, @@ -45,12 +45,28 @@ window.realtime.setupSocket = function () { }; 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) { // data.userid // 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) { @@ -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) { var newPos, tempForT; Mconsole.graph.addNode(topic); diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 80db82c9..6bb0b6d6 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -290,7 +290,8 @@ input[type="submit"]:hover { display: block; height: 20px; width: 20px; - background: #0FFF2B; + background-image: url('MMCCicon_metacode_set_change.png'); + background-size:contain; position: absolute; z-index: 2; top: 20px; @@ -579,6 +580,9 @@ li.accountMaps { li.accountSettings { background-image: url('MMCCicon_settings.png'); } +li.accountAdmin { + background-image: url('MMCCicon_admin.png'); +} li.accountInvite { background-image: url('MMCCicon_invite.png'); } diff --git a/app/views/layouts/_account.html.erb b/app/views/layouts/_account.html.erb index 6d281697..d97fbb91 100644 --- a/app/views/layouts/_account.html.erb +++ b/app/views/layouts/_account.html.erb @@ -10,7 +10,7 @@
  • My Maps
  • <%= link_to "Account", edit_user_url(account) %>
  • <% if account.admin %> -
  • <%= link_to "Admin", metacodes_path %>
  • +
  • <%= link_to "Admin", metacodes_path %>
  • <% end %>
  • Share Invite
  • <%= link_to "Logout", "/sign_out", id: "Logout" %>
  • diff --git a/app/views/maps/show.html.erb b/app/views/maps/show.html.erb index 6fd4daf9..58a3b3a8 100644 --- a/app/views/maps/show.html.erb +++ b/app/views/maps/show.html.erb @@ -104,13 +104,13 @@ if (json.length > 0) { <% if authenticated? && (@map.permission == "commons" || @map.user == user) %> // 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 //window.realtime.socket = io.connect('http://metamaps.cc:5001'); // 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 () { console.log('socket connected'); diff --git a/realtime/realtime-server.js b/realtime/realtime-server.js index 9f448809..0f714535 100644 --- a/realtime/realtime-server.js +++ b/realtime/realtime-server.js @@ -80,6 +80,26 @@ function start() { socket.broadcast.emit('maps-' + mapid + '-lostmapper', data); }); }); + + // 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); + }); }); }