diff --git a/public/language/en_GB/global.json b/public/language/en_GB/global.json index 6bb720802f..40b51f3866 100644 --- a/public/language/en_GB/global.json +++ b/public/language/en_GB/global.json @@ -60,6 +60,7 @@ "online": "Online", "away": "Away", - "donotdisturb": "Do not disturb", - "invisible": "Invisible" + "dnd": "Do not disturb", + "invisible": "Invisible", + "offline": "Offline" } diff --git a/public/src/app.js b/public/src/app.js index b8ef17422e..1a176fc481 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -268,14 +268,13 @@ var socket, }); socket.emit('user.getOnlineUsers', uids, function (err, users) { - jQuery('button .username-field').each(function (index, element) { + + jQuery('.username-field').each(function (index, element) { var el = jQuery(this), uid = el.parents('li').attr('data-uid'); - if (uid && jQuery.inArray(uid, users) !== -1) { - el.parent().addClass('btn-success').removeClass('btn-danger'); - } else { - el.parent().addClass('btn-danger').removeClass('btn-success'); + if (uid && users[uid]) { + el.siblings('i').attr('class', 'fa fa-circle status-' + users[uid].status) } }); }); @@ -528,6 +527,14 @@ var socket, $('.navbar-header button').click(); } }); + + $('#user-control-list .user-status').off('click').on('click', function() { + socket.emit('user.setStatus', $(this).attr('data-status'), function(err) { + if(err) { + return app.alertError(err.message); + } + }); + }); }; jQuery('document').ready(function () { diff --git a/public/src/forum/account.js b/public/src/forum/account.js index b15613810a..8d85955669 100644 --- a/public/src/forum/account.js +++ b/public/src/forum/account.js @@ -84,13 +84,15 @@ define(['forum/accountheader'], function(header) { Account.handleUserOnline = function(err, data) { var onlineStatus = $('.account-online-status'); - if (data.online) { - onlineStatus.find('span span').text('online'); - onlineStatus.find('i').attr('class', 'fa fa-circle'); - } else { - onlineStatus.find('span span').text('offline'); - onlineStatus.find('i').attr('class', 'fa fa-circle-o'); + if(parseInt(templates.get('theirid'), 10) !== parseInt(data.uid, 10)) { + return; } + + translator.get('global:' + data.status, function(translated) { + onlineStatus.find('span span').text(translated); + onlineStatus.find('i').attr('class', 'fa fa-circle status-' + data.status); + }); + }; return Account; diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 2814f8342a..597bbad79f 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -570,7 +570,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { 'event:topic_deleted', 'event:topic_restored', 'event:topic:locked', 'event:topic_unlocked', 'event:topic_pinned', 'event:topic_unpinned', 'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored', - 'posts.favourite' + 'posts.favourite', 'user.isOnline' ]); socket.on('get_users_in_room', function(data) { @@ -652,6 +652,11 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { }); } } + + app.populateOnlineUsers(); + }); + + socket.on('user.isOnline', function(err, data) { app.populateOnlineUsers(); }); diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index 3cd53a81c3..2eff6a9197 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -89,18 +89,9 @@ define(['taskbar', 'string'], function(taskbar, S) { return $('#chat-modal-' + touid).length !== 0; } - function checkStatus(chatModal, callback) { + function checkStatus(chatModal) { socket.emit('user.isOnline', chatModal.touid, function(err, data) { - if(data.online !== chatModal.online) { - if(data.online) { - module.appendChatMessage(chatModal, chatModal.username + ' is currently online.\n', data.timestamp); - } else { - module.appendChatMessage(chatModal, chatModal.username + ' is currently offline.\n', data.timestamp); - } - chatModal.online = data.online; - } - if(callback) - callback(data.online); + $('#chat-user-status').attr('class', 'fa fa-circle status-' + data.status); }); } diff --git a/public/templates/account.tpl b/public/templates/account.tpl index c457b7fd90..95330af0f8 100644 --- a/public/templates/account.tpl +++ b/public/templates/account.tpl @@ -13,7 +13,7 @@
- [[user:offline]] + [[user:offline]]
diff --git a/public/templates/chat.tpl b/public/templates/chat.tpl index 4a34ee5d3e..946fe4054e 100644 --- a/public/templates/chat.tpl +++ b/public/templates/chat.tpl @@ -4,7 +4,8 @@