footer stats will display human readable stuff

v1.18.x
Baris Usakli 11 years ago
parent 33bda6fd16
commit a0c7e187f5

@ -7,13 +7,16 @@
socket.emit('user.count', {});
socket.on('user.count', function(data) {
stats_users.innerHTML = data.count;
stats_users.innerHTML = utils.makeNumberHumanReadable(data.count);
stats_users.title = data.count;
});
socket.emit('post.stats');
socket.on('post.stats', function(data) {
stats_topics.innerHTML = data.topics;
stats_posts.innerHTML = data.posts;
stats_topics.innerHTML = utils.makeNumberHumanReadable(data.topics);
stats_topics.title = data.topics;
stats_posts.innerHTML = utils.makeNumberHumanReadable(data.posts);
stats_posts.title = data.posts;
});
socket.emit('api:user.active.get');

@ -162,6 +162,15 @@
isRelativeUrl: function(url) {
var firstChar = url.slice(0, 1);
return (firstChar === '.' || firstChar === '/');
},
makeNumberHumanReadable: function(num) {
num = parseInt(num, 10);
if (num > 999999)
return (num / 1000000).toFixed(1) + 'm';
else if(num > 999)
return (num / 1000).toFixed(1) + 'k';
return num;
}
}

Loading…
Cancel
Save