moved index code from index.tpl to its own file

This commit is contained in:
Baris Soner Usakli
2013-07-15 13:49:21 -04:00
parent 4527b3d53c
commit 5819b43595
3 changed files with 46 additions and 51 deletions

View File

@@ -0,0 +1,25 @@
(function() {
ajaxify.register_events(['api:get_all_rooms']);
socket.on('api:get_all_rooms', function(data) {
var active_users = document.getElementById('active_users'),
total = 0;
active_users.innerHTML = '';
for(var room in data) {
if (room !== '') {
var count = data[room].length;
total += count;
active_users.innerHTML = active_users.innerHTML + "<div class='alert alert-success'><strong>" + room + "</strong> " + count + " active user" + (count > 1 ? "s" : "") + "</div>";
}
}
document.getElementById('connections').innerHTML = total;
});
app.enter_room('admin');
socket.emit('api:get_all_rooms');
}());