Skip to content

Commit

Permalink
web: add status icons in CL. closes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
borisfaure committed Aug 23, 2010
1 parent 8b03a12 commit 3624382
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
1 change: 0 additions & 1 deletion amsn2/ui/front_ends/web/_web.py
@@ -1,4 +1,3 @@
from bend import *
from main_loop import *
from main import *
from contact_list import *
Expand Down
4 changes: 3 additions & 1 deletion amsn2/ui/front_ends/web/contact_list.py
Expand Up @@ -112,5 +112,7 @@ def contact_updated(self, contactView):
in the affects groups.
"""
self.contacts[contactView.uid]=contactView
self._main.send("contactUpdated", contactView.uid, unicode(contactView.name))
self._main.send("contactUpdated", contactView.uid,
unicode(contactView.name),
unicode(contactView.status))

32 changes: 26 additions & 6 deletions amsn2/ui/front_ends/web/static/js/amsn2.js
Expand Up @@ -227,10 +227,16 @@ function Contact(_gid, _uid)
{
var name = "";
var uid = _uid;
var status = "offline";

var elem = new Element('li',
{id: 'ct_' + _uid + '_' + _gid,
onclick: 'g_cl.contactClick(\''+uid+'\'); return false;'});
var img = new Element('img',
{src: 'static/images/icons/'+status+'.png'});
var span = new Element('span');
elem.insert(img);
elem.insert(span);

var elements = {};
elements[_gid] = elem;
Expand All @@ -249,9 +255,20 @@ function Contact(_gid, _uid)
}

this.setName = function(_name) {
name = _name;
for (k in elements) {
elements[k].update(_name);
if (name != _name) {
name = _name;
for (k in elements) {
elements[k].childElements()[1].update('&nbsp'+_name);
}
}
}
this.setStatus = function(_status) {
if (status != _status) {
status = _status;
for (k in elements) {
e = elements[k].childElements()[0];
e.writeAttribute('src','static/images/icons/'+status+'.png');
}
}
}

Expand Down Expand Up @@ -304,10 +321,13 @@ function groupUpdated(uid, name, contact_ids)
}
}

function contactUpdated(uid, name)
function contactUpdated(uid, name, status)
{
if (g_cl)
g_cl.getContact(uid).setName(name);
if (g_cl) {
c = g_cl.getContact(uid);
c.setName(name);
c.setStatus(status);
}
}
// }}}
// ChatWindow {{{
Expand Down

0 comments on commit 3624382

Please sign in to comment.