Merge pull request #114 from SamStudio8/master

Improve online users UI [REQ Bootstrap]
This commit is contained in:
Luke Slater 2013-01-11 02:01:35 -08:00
commit 0d082bc755
4 changed files with 74 additions and 43 deletions

View File

@ -25,33 +25,44 @@ var pages = function(dbot) {
if(connections.hasOwnProperty(connection) && if(connections.hasOwnProperty(connection) &&
connections[connection].channels.hasOwnProperty(channel)) { connections[connection].channels.hasOwnProperty(channel)) {
var userData = { "active": [], "inactive": [], "offline": []};
var channelUsers = dbot.db.knownUsers[connection].channelUsers[channel]; var channelUsers = dbot.db.knownUsers[connection].channelUsers[channel];
var usersData = {};
for(var i=0;i<channelUsers.length;i++) {
usersData[channelUsers[i]] = {
'name': channelUsers[i],
'online': false,
'active': false
};
}
var onlineNicks = connections[connection].channels[channel].nicks; var onlineNicks = connections[connection].channels[channel].nicks;
onlineNicks.each(function(nick) { for(var i=0;i<channelUsers.length;i++) {
var nick = nick.name; if(channelUsers[i] == dbot.config.name){
var user = dbot.api.users.resolveUser(connection, nick); continue;
if(onlineNicks.hasOwnProperty(nick)) {
usersData[user].online = true;
} }
console.log(user); if(onlineNicks.hasOwnProperty(channelUsers[i])){
usersData[user].active = dbot.api.stats.isActive({ var user = dbot.api.users.resolveUser(connection, channelUsers[i]);
'server': connection, if(dbot.api.stats.isActive({'server': connection,
'user': user, 'user': user,
'channel': channel 'channel': channel
}); })){
}.bind(this)); userData.active.push(channelUsers[i]);
}
else{
userData.inactive.push(channelUsers[i]);
}
}
else{
userData.offline.push(channelUsers[i]);
}
}
var userSort = function(a, b){
var x = a.toLowerCase();
var y = b.toLowerCase();
if(x > y) return 1;
if(x < y) return -1;
return 0;
}
userData.active.sort(userSort);
userData.inactive.sort(userSort);
userData.offline.sort(userSort);
res.render('users', { 'name': dbot.config.name, 'connection': connection, res.render('users', { 'name': dbot.config.name, 'connection': connection,
'channel': channel, 'nicks': usersData }); 'channel': channel, 'nicks': userData });
} else { } else {
res.render_core('error', { 'name': dbot.config.name, 'message': 'No such connection or channel.' }); res.render_core('error', { 'name': dbot.config.name, 'message': 'No such connection or channel.' });
} }

View File

@ -6,19 +6,19 @@
*/ */
html { html {
background: url("background.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
} }
body { body {
padding: 25px; padding: 25px;
margin: 0; margin: 0;
font-family: "Lucida Grande"; font-family: "Source Sans Pro", sans-serif;
color: #444; color: #444;
text-shadow: 1px 1px 2px #2B2B2B; text-shadow: 1px 1px 2px #2B2B2B;
background: url("background.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
} }
h1,h2 { h1,h2 {

View File

@ -2,12 +2,17 @@
html(lang='en') html(lang='en')
head head
meta(charset='utf-8') meta(charset='utf-8')
link(rel="stylesheet", type="text/css", href="http://fonts.googleapis.com/css?family=Source+Sans+Pro")
link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css")
link(rel='stylesheet', type='text/css', href='/styles.css') link(rel='stylesheet', type='text/css', href='/styles.css')
title #{name} web interface title #{name} web interface
body body
div#page div.container
div#title div#page
a(href='/') #{name} web interface div#title
div#main a(href='/') #{name} web interface
block content div#main
block content
script(type="text/javascript", src="/bootstrap/js/bootstrap.min.js")
script(type="text/javascript", src="/script.js") script(type="text/javascript", src="/script.js")

View File

@ -4,14 +4,29 @@ block content
h3 Users of #{channel} on #{connection} h3 Users of #{channel} on #{connection}
div#backlink div#backlink
a(href='/channels/'+connection) &laquo; Channel List a(href='/channels/'+connection) &laquo; Channel List
ul#quotelist div#row
-each nick in nicks table.table.table-striped
if nicks.hasOwnProperty(nick.name) thead
a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick.name) tr: th Users
if nick.online tbody
if nick.active -each nick in nicks.active
li.quotes #{nick.name} (Online, Active) tr
else td
li.quotes #{nick.name} (Online, Inactive) a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick)
else #{nick}
li.quotes #{nick.name} (Offline) span
span.label.label-success Active
-each nick in nicks.inactive
tr
td
a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick)
#{nick}
span
span.label.label-important Inactive
-each nick in nicks.offline
tr
td
a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick)
#{nick}
span
span.label Offline