diff --git a/public/js/script.js b/public/js/script.js
index b9d81b6..4121e4e 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -170,10 +170,7 @@ $(document).ready(function() {
nameStyle = 'style="display: none"';
}
$.each(clients, function(index, client) {
- var picture = client.picture ? client.picture : DEFAULT_PICTURE;
- var idle = client.idle ? 'idle' : '';
- var idleSince = client.idle ? '<span class="idleSince" idleSince="' + (new Date().getTime() - client.idleFor) + '"></span>' : '';
- $(buddylist).append('<li><img class="profilepic ' + idle + ' middle" title="' +client.name + '" src="' + picture + '"/><span class="profilename ' + idle + '" ' + nameStyle + '>' + client.name + '</span>' + idleSince + '</li>');
+ addClient(client, buddylist, nameStyle);
});
$('#clients-count').html(clients.length);
diff --git a/views/index.jade b/views/index.jade
index 3174218..f118ff3 100644
--- a/views/index.jade
+++ b/views/index.jade
@@ -14,6 +14,7 @@ block append scripts
script(src='/public/js/script.js')
script(src='http://www.google.com/jsapi')
script(src='/public/js/google_calendar.js')
+ script(src='/public/js/helpers.js')
block header
#header.row-fluid
addPorfilePic = function(client) {
var picture = client.picture ? client.picture : DEFAULT_PICTURE;
var idle = client.idle ? 'idle' : '';
return '<img class="profilepic ' + idle + ' middle" title="' +client.name + '" src="' + picture + '"/>'
}
addProfileName = function(client, nameStyle) {
var idleSince = client.idle ? '<span class="idleSince" idleSince="' + (new Date().getTime() - client.idleFor) + '"></span>' : '';
return '<span class="profilename ' + idle + '" ' + nameStyle + '>' + client.name + '</span>' + idleSince
}
addClient = function(client, buddylist, nameStyle) {
clientLi = $("<li>").html(addPorfilePic(client) + addProfileName(client, nameStyle));
$(buddylist).html(clientLi);
}