focus on topic creator after selecting metacode set

This commit is contained in:
Connor Turland 2014-06-04 16:24:13 -04:00
parent c2b21ecc13
commit cac3a7c93b
2 changed files with 55 additions and 49 deletions

View file

@ -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');
}
});
}

View file

@ -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();