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() {
|
function highlightNavigationLink() {
|
||||||
var path = window.location.pathname,
|
var path = window.location.pathname,
|
||||||
parts = path.split('/'),
|
parts = path.split('/'),
|
||||||
@@ -309,12 +281,9 @@ var socket,
|
|||||||
};
|
};
|
||||||
|
|
||||||
app.processPage = function () {
|
app.processPage = function () {
|
||||||
app.populateOnlineUsers();
|
|
||||||
|
|
||||||
highlightNavigationLink();
|
highlightNavigationLink();
|
||||||
|
|
||||||
$('span.timeago').timeago();
|
$('span.timeago').timeago();
|
||||||
$('.post-content img').addClass('img-responsive');
|
|
||||||
|
|
||||||
utils.makeNumbersHumanReadable($('.human-readable-number'));
|
utils.makeNumbersHumanReadable($('.human-readable-number'));
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ var dependencies = [
|
|||||||
'forum/topic/postTools',
|
'forum/topic/postTools',
|
||||||
'forum/topic/events',
|
'forum/topic/events',
|
||||||
'forum/topic/scrollTo',
|
'forum/topic/scrollTo',
|
||||||
|
'forum/topic/browsing',
|
||||||
'navigator'
|
'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 = {},
|
var Topic = {},
|
||||||
currentUrl = '';
|
currentUrl = '';
|
||||||
|
|
||||||
@@ -42,6 +43,9 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
|||||||
|
|
||||||
app.enterRoom('topic_' + tid);
|
app.enterRoom('topic_' + tid);
|
||||||
|
|
||||||
|
browsing.populateOnlineUsers();
|
||||||
|
$('.post-content img').addClass('img-responsive');
|
||||||
|
|
||||||
showBottomPostBar();
|
showBottomPostBar();
|
||||||
|
|
||||||
postTools.init(tid, thread_state);
|
postTools.init(tid, thread_state);
|
||||||
@@ -317,7 +321,7 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
|||||||
getPostPrivileges(posts[x].pid);
|
getPostPrivileges(posts[x].pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.populateOnlineUsers();
|
browsing.populateOnlineUsers();
|
||||||
app.createUserTooltips();
|
app.createUserTooltips();
|
||||||
app.replaceSelfLinks(html.find('a'));
|
app.replaceSelfLinks(html.find('a'));
|
||||||
utils.addCommasToNumbers(html.find('.formatted-number'));
|
utils.addCommasToNumbers(html.find('.formatted-number'));
|
||||||
|
|||||||
@@ -78,15 +78,43 @@ define('forum/topic/browsing', function() {
|
|||||||
getReplyingUsers();
|
getReplyingUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.populateOnlineUsers();
|
Browsing.populateOnlineUsers();
|
||||||
};
|
};
|
||||||
|
|
||||||
Browsing.onUserOnline = function(err, data) {
|
Browsing.onUserOnline = function(err, data) {
|
||||||
app.populateOnlineUsers();
|
Browsing.populateOnlineUsers();
|
||||||
|
|
||||||
updateBrowsingUsers(data);
|
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) {
|
function updateBrowsingUsers(data) {
|
||||||
var activeEl = $('.thread_active_users');
|
var activeEl = $('.thread_active_users');
|
||||||
var user = activeEl.find('a[data-uid="'+ data.uid + '"]');
|
var user = activeEl.find('a[data-uid="'+ data.uid + '"]');
|
||||||
|
|||||||
Reference in New Issue
Block a user