xmppchat.UI = (function (xmppUI, $, console) { var ob = xmppUI; ob.chats = []; ob.chat_focus = []; ob.chatbox_width = 205; ob.sanitizePath = function (call) { return xmppchat.base_url + call; }; ob.updateOnPresence = function (jid, status, presence) { var user_id = Strophe.getNodeFromJid(jid), bare_jid = Strophe.getBareJidFromJid(jid), resource, existing_user_element, online_count; if (xmppchat.isOwnUser(jid)) { return; } existing_user_element = $('#online-users-' + user_id); if ((status === 'offline') || (status === 'unavailable')) { // Remove the resource. bare_jid = Strophe.getBareJidFromJid(jid); resource = Strophe.getResourceFromJid(jid); if (xmppchat.ChatPartners.remove(bare_jid, resource) === 0) { // Only set the status offline if there aren't any other resources for that user if (existing_user_element.length > 0) { existing_user_element.attr('class', status); } return; } } else { if (existing_user_element.length > 0) { existing_user_element.attr('class', status); } else { xmppchat.Presence.getUserInfo(user_id, function (data) { if ($('#online-users-' + user_id).length > 0) { return; } var li = $('
').attr('id', 'online-users-'+user_id).attr('data-recipient', bare_jid); li.append($('').addClass('user-details-toggle').text(data.fullname)); $('#online-users').append(li); }); } } $('#online-count').text(xmppchat.Presence.onlineCount()); }; ob.positionNewChat = function ($chat) { var open_chats = 0, offset; for (var i=0; i