mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
moved populateOnline users out of app.js
This commit is contained in:
@@ -233,34 +233,6 @@ var socket,
|
||||
}
|
||||
};
|
||||
|
||||
app.populateOnlineUsers = function () {
|
||||
var uids = [];
|
||||
|
||||
$('.post-row').each(function () {
|
||||
var uid = $(this).attr('data-uid');
|
||||
if(uids.indexOf(uid) === -1) {
|
||||
uids.push(uid);
|
||||
}
|
||||
});
|
||||
|
||||
socket.emit('user.getOnlineUsers', uids, function (err, users) {
|
||||
|
||||
$('.username-field').each(function (index, element) {
|
||||
var el = $(this),
|
||||
uid = el.parents('li').attr('data-uid');
|
||||
|
||||
if (uid && users[uid]) {
|
||||
translator.translate('[[global:' + users[uid].status + ']]', function(translated) {
|
||||
el.siblings('i')
|
||||
.attr('class', 'fa fa-circle status ' + users[uid].status)
|
||||
.attr('title', translated)
|
||||
.attr('data-original-title', translated);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function highlightNavigationLink() {
|
||||
var path = window.location.pathname,
|
||||
parts = path.split('/'),
|
||||
@@ -309,12 +281,9 @@ var socket,
|
||||
};
|
||||
|
||||
app.processPage = function () {
|
||||
app.populateOnlineUsers();
|
||||
|
||||
highlightNavigationLink();
|
||||
|
||||
$('span.timeago').timeago();
|
||||
$('.post-content img').addClass('img-responsive');
|
||||
|
||||
utils.makeNumbersHumanReadable($('.human-readable-number'));
|
||||
|
||||
|
||||
@@ -10,10 +10,11 @@ var dependencies = [
|
||||
'forum/topic/postTools',
|
||||
'forum/topic/events',
|
||||
'forum/topic/scrollTo',
|
||||
'forum/topic/browsing',
|
||||
'navigator'
|
||||
];
|
||||
|
||||
define('forum/topic', dependencies, function(pagination, infinitescroll, threadTools, postTools, events, scrollTo, navigator) {
|
||||
define('forum/topic', dependencies, function(pagination, infinitescroll, threadTools, postTools, events, scrollTo, browsing, navigator) {
|
||||
var Topic = {},
|
||||
currentUrl = '';
|
||||
|
||||
@@ -42,6 +43,9 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
||||
|
||||
app.enterRoom('topic_' + tid);
|
||||
|
||||
browsing.populateOnlineUsers();
|
||||
$('.post-content img').addClass('img-responsive');
|
||||
|
||||
showBottomPostBar();
|
||||
|
||||
postTools.init(tid, thread_state);
|
||||
@@ -317,7 +321,7 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
||||
getPostPrivileges(posts[x].pid);
|
||||
}
|
||||
|
||||
app.populateOnlineUsers();
|
||||
browsing.populateOnlineUsers();
|
||||
app.createUserTooltips();
|
||||
app.replaceSelfLinks(html.find('a'));
|
||||
utils.addCommasToNumbers(html.find('.formatted-number'));
|
||||
|
||||
@@ -78,15 +78,43 @@ define('forum/topic/browsing', function() {
|
||||
getReplyingUsers();
|
||||
}
|
||||
|
||||
app.populateOnlineUsers();
|
||||
Browsing.populateOnlineUsers();
|
||||
};
|
||||
|
||||
Browsing.onUserOnline = function(err, data) {
|
||||
app.populateOnlineUsers();
|
||||
Browsing.populateOnlineUsers();
|
||||
|
||||
updateBrowsingUsers(data);
|
||||
};
|
||||
|
||||
Browsing.populateOnlineUsers = function () {
|
||||
var uids = [];
|
||||
|
||||
$('.post-row').each(function () {
|
||||
var uid = $(this).attr('data-uid');
|
||||
if(uids.indexOf(uid) === -1) {
|
||||
uids.push(uid);
|
||||
}
|
||||
});
|
||||
|
||||
socket.emit('user.getOnlineUsers', uids, function (err, users) {
|
||||
|
||||
$('.username-field').each(function (index, element) {
|
||||
var el = $(this),
|
||||
uid = el.parents('li').attr('data-uid');
|
||||
|
||||
if (uid && users[uid]) {
|
||||
translator.translate('[[global:' + users[uid].status + ']]', function(translated) {
|
||||
el.siblings('i')
|
||||
.attr('class', 'fa fa-circle status ' + users[uid].status)
|
||||
.attr('title', translated)
|
||||
.attr('data-original-title', translated);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function updateBrowsingUsers(data) {
|
||||
var activeEl = $('.thread_active_users');
|
||||
var user = activeEl.find('a[data-uid="'+ data.uid + '"]');
|
||||
|
||||
Reference in New Issue
Block a user