From cac3a7c93bfe4765fe17618017fb5eeb60e4d583 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 4 Jun 2014 16:24:13 -0400 Subject: [PATCH] focus on topic creator after selecting metacode set --- app/assets/javascripts/application.js | 9 +-- realtime/realtime-server.js | 95 +++++++++++++++------------ 2 files changed, 55 insertions(+), 49 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 374da114..6f4b7661 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -276,6 +276,7 @@ function updateMetacodeSet(set, index, custom) { }); $('#lightbox_overlay').hide(); + $('#topic_name').focus(); var mdata = { "metacodes": { @@ -288,14 +289,10 @@ function updateMetacodeSet(set, index, custom) { url: "/user/updatemetacodes", data: mdata, success: function (data) { - console.log('success updating metacodes'); - //setTimeout(function () { - // $('.metacodeTitle').hide(); - // $('.showcard .icon').css('z-index', '1'); - //}, 500); + console.log('selected metacodes saved'); }, error: function () { - alert('failed to update metacodes'); + console.log('failed to save selected metacodes'); } }); } diff --git a/realtime/realtime-server.js b/realtime/realtime-server.js index f85a54f0..9f448809 100644 --- a/realtime/realtime-server.js +++ b/realtime/realtime-server.js @@ -17,62 +17,71 @@ app.configure(function() { }); */ //var rtg = require("url").parse("redis://redistogo:0ca046a3d56533cc162e2447db383192@pearlfish.redistogo.com:9060/"), - //redis = require('redis').createClient(rtg.port, rtg.hostname, {no_ready_check: true}); +//redis = require('redis').createClient(rtg.port, rtg.hostname, {no_ready_check: true}); var io = require('socket.io').listen(5001); var redis = require('redis').createClient(); - + //redis.auth(rtg.auth.split(":")[1], function() { // start(); //}); function start() { - redis.subscribe('maps'); + redis.subscribe('maps'); - io.on('connection', function(socket){ - - // this will ping everyone on a map with updates to the map - redis.on('message', function(channel, message){ - console.log(message); - var m = JSON.parse(message); - var room = 'maps-' + m.mapid; - - socket.emit(room, m); - }); - - // this will ping a new person with awareness of who's already on the map - socket.on('updateNewMapperList', function(data) { - var existingUser = { userid: data.userid, username: data.username }; - socket.broadcast.emit(data.userToNotify + '-' + data.mapid + '-UpdateMapperList', existingUser); - }); - - // this will ping everyone on a map that there's a person just joined the map - socket.on('newMapperNotify', function (data) { - socket.set('mapid', data.mapid); - socket.set('userid', data.userid); - socket.set('username', data.username); - - var newUser = { userid: data.userid, username: data.username }; - - socket.broadcast.emit('maps-' + data.mapid + '-newmapper', newUser); - }); - - // this will ping everyone on a map that there's a person just left the map - socket.on('disconnect', function () { - var socketUserName, socketUserID; - socket.get('userid', function (err, id) { - socketUserID = id; + io.on('connection', function (socket) { + + // this will ping everyone on a map with updates to the map + redis.on('message', function (channel, message) { + console.log(message); + var m = JSON.parse(message); + var room = 'maps-' + m.mapid; + + socket.emit(room, m); }); - socket.get('username', function (err, name) { - socketUserName = name; + + // this will ping a new person with awareness of who's already on the map + socket.on('updateNewMapperList', function (data) { + var existingUser = { + userid: data.userid, + username: data.username + }; + socket.broadcast.emit(data.userToNotify + '-' + data.mapid + '-UpdateMapperList', existingUser); }); - var data = { username: socketUserName, userid: socketUserID }; - socket.get('mapid', function (err, mapid) { - socket.broadcast.emit('maps-' + mapid + '-lostmapper', data); + + // this will ping everyone on a map that there's a person just joined the map + socket.on('newMapperNotify', function (data) { + socket.set('mapid', data.mapid); + socket.set('userid', data.userid); + socket.set('username', data.username); + + var newUser = { + userid: data.userid, + username: data.username + }; + + socket.broadcast.emit('maps-' + data.mapid + '-newmapper', newUser); }); + + // this will ping everyone on a map that there's a person just left the map + socket.on('disconnect', function () { + var socketUserName, socketUserID; + socket.get('userid', function (err, id) { + socketUserID = id; + }); + socket.get('username', function (err, name) { + socketUserName = name; + }); + var data = { + username: socketUserName, + userid: socketUserID + }; + socket.get('mapid', function (err, mapid) { + socket.broadcast.emit('maps-' + mapid + '-lostmapper', data); + }); + }); + }); - - }); } start(); \ No newline at end of file