function RosterGroup(name) { this.name = htmlEnc(name); this.users = new Array(); this.onlUserCount = 0; this.messagesPending = 0; } function RosterUserAdd2Group(group) { this.groups = this.groups.concat(group); } function RosterUser(jid,subscription,groups,name) { this.fulljid = jid; this.jid = cutResource(jid) || 'unknown'; this.jid = this.jid.toLowerCase(); // jids are case insensitive this.subscription = subscription || 'none'; this.groups = groups || ['']; if (name) this.name = name; else if (this.jid == JABBERSERVER) this.name = "Sistema"; else if ((this.jid.indexOf('@') != -1) && this.jid.substring(this.jid.indexOf('@')+1) == JABBERSERVER) // we found a local user this.name = this.jid.substring(0,jid.indexOf('@')); else this.name = this.jid; this.name = htmlEnc(this.name); // initialise defaults this.status = (this.subscription == 'from' || this.subscription == 'none') ? 'stalker' : 'unavailable'; this.statusMsg = null; this.lastsrc = null; this.messages = new Array(); this.chatmsgs = new Array(); this.chatW = null; // chat window // methods this.add2Group = RosterUserAdd2Group; } function getElFromArrByProp(arr,prop,str) { for (var i=0; i 0 && (!user.mW || user.mW.closed)) // display messages user.mW = open('message.html?jid='+escape(jid), "mw"+wName, 'width=360,height=270,dependent=yes,resizable=yes'); else if (!user.sW || user.sW.closed) // open send dialog user.sW = open("send.html?jid="+escape(jid), "sw"+wName, 'width=320,height=200,dependent=yes,resizable=yes'); return false; } function RosterOpenChat(jid) { var user = this.getUserByJID(jid); if (!user) return; if (user.messages.length > 0 && (!user.mW || user.mW.closed)) // display messages this.openMessage(jid); if (!user.chatW || user.chatW.closed) user.chatW = open("chat.html?jid="+escape(jid), "chatW"+makeWindowName(user.jid), "width=320,height=390,resizable=yes"); else if (user.chatW.popMsgs) user.chatW.popMsgs(); } function RosterCleanUp() { for (var i=0; i 1 && user.groups[j] == '') continue; var groupName = (user.groups[j] == '') ? "Non ordinato" : user.groups[j]; var group = this.getGroupByName(groupName); if(group == null) { group = new RosterGroup(groupName); this.groups = this.groups.concat(group); } group.users = group.users.concat(user); } } function RosterUpdateGroups() { var oldGroups = this.groups; this.groups = new Array(); for (var i=0; i groups = groups.concat(items.item(i).childNodes.item(j).firstChild.nodeValue); this.addUser(new RosterUser(items.item(i).getAttribute('jid'),items.item(i).getAttribute('subscription'),groups,name)); } } function rosterSort(a,b) { // if (typeof(a.name) != 'string' || typeof(b.name) != 'string') // return 0; return (a.name.toLowerCase() -1) { this.update(); // update dom, rather than redrawing roster return; } var A = new Array(); /* *** * loop rostergroups */ for (var i=0; i"; var toggleImg = (this.hiddenGroups[this.groups[i].name])?'images/group_close.gif':'images/group_open.gif'; A[A.length] = " "; A[A.length] = this.groups[i].name; A[A.length] = " ("; A[A.length] = this.groups[i].onlUserCount; A[A.length] = "/"; A[A.length] = this.groups[i].users.length; A[A.length] = ")"; A[A.length] = ""; var rosterGroupClass = ( (this.usersHidden && this.groups[i].onlUserCount == 0 && this.groups[i].messagesPending == 0 && this.groups[i].name != "Gateways") || this.hiddenGroups[this.groups[i].name]) ? 'hidden':'rosterGroup'; A[A.length] = "
"; this.groups[i].users = this.groups[i].users.sort(rosterSort); /* *** * loop users in rostergroup */ for (var j=0; j 0) { A[A.length] = " "; A[A.length] = ""+(user.messages.length + user.chatmsgs.length)+" messaggio/i in sospeso"; } A[A.length] = "\">"; var userImg = (user.lastsrc) ? messageImg : eval(user.status + "Led"); A[A.length] = ""; A[A.length] = "
"; A[A.length] = user.name; A[A.length] = ""; if (user.statusMsg) { A[A.length] = "
"; A[A.length] = htmlEnc(user.statusMsg); A[A.length] = ""; } A[A.length] = "
"; } /* END inner loop */ A[A.length] = ""; } this.rosterW.getElementById("roster").innerHTML = A.join(''); this.updateStyleIE(); } function getUserElementId(user, group) { var groupName = group.name || 'Unfiled'; return htmlEnc(user.jid)+"/"+groupName+"Entry"; } function getRosterUserClass(usersHidden, user, group) { return (usersHidden && (user.status == 'unavailable' || user.status == 'stalker') && !user.lastsrc && group.name != "Gateways" ? "hidden" : "rosterUser"); } function getRosterGroupHeaderClass(usersHidden, group) { return (usersHidden && group.onlUserCount == 0 && group.messagesPending == 0 && group.name != "Gateways" ? 'rosterGroupHeaderHidden':'rosterGroupHeader'); } function getUserElementTitle(user) { var elTitle = user.name if (user.realjid) { elTitle += " JID: "; elTitle += htmlEnc(user.realjid); } else { elTitle += " JID: "; elTitle += htmlEnc(user.jid); } elTitle += " "; elTitle += "Stato"; elTitle += ": "; elTitle += user.status; if (user.statusMsg) { elTitle += " "; elTitle += "Messaggio"; elTitle += ": "; elTitle += htmlEnc(user.statusMsg); } if ((user.messages.length + user.chatmsgs.length) > 0) { elTitle += " "; elTitle += ""+(user.messages.length + user.chatmsgs.length)+" messaggio/i in sospeso"; } return elTitle; } function getUserInnerHTML(user, group) { var userImg = (user.lastsrc) ? messageImg : eval(user.status + "Led"); var A = new Array(); A[A.length] = ""; A[A.length] = "
"; A[A.length] = user.name; A[A.length] = ""; if (user.statusMsg) { A[A.length] = "
"; A[A.length] = htmlEnc(user.statusMsg); A[A.length] = ""; } A[A.length] = "
"; return A.join(''); } function updateRoster() { for (var i=0; i"; A[A.length] = getUserInnerHTML(user, group); A[A.length] = ""; } /* END inner loop */ groupEl.innerHTML = A.join(''); } } } // moved into Roster from iRoster.html and groupchat_iroster.html - sam function RosterSelectUser(el) { if(this.lastUserSelected) this.lastUserSelected.className = "rosterUser"; el.className = "rosterUserSelected"; this.lastUserSelected = el; } function RosterUserClicked(el,jid) { this.selectUser(el); if (this.name == 'GroupchatRoster') { return parent.top.user.roster.openChat(jid); } var user = parent.top.roster.getUserByJID(parent.top.cutResource(jid)); if(user && typeof(user.type) != 'undefined' && user.type == 'groupchat') return parent.top.openGroupchat(jid); if (!parent.top.isGateway(jid)) return parent.top.roster.openChat(jid); } /*********************************************************************** * GROUPCHAT ROSTER *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ function GCRosterSort(a,b) { return (a.name.toLowerCase() 0) { A[A.length] = " "; A[A.length] = ""+(user.messages.length + user.chatmsgs.length)+" messaggio/i in sospeso"; } A[A.length] = "\">"; var userImg = (user.lastsrc) ? messageImg : eval(user.status + "Led"); A[A.length] = ""; A[A.length] = "
"; A[A.length] = user.name; A[A.length] = ""; if (user.statusMsg) { A[A.length] = "
"; A[A.length] = htmlEnc(user.statusMsg); A[A.length] = ""; } A[A.length] = "
"; } /* END inner loop */ A[A.length] = ""; } this.rosterW.getElementById("roster").innerHTML = A.join(''); this.updateStyleIE(); } function GroupchatRosterUserAdd2Group(group) { this.groups = [group]; } function GroupchatRosterUser(jid,name) { this.base = RosterUser; this.base(jid,'',[''],name); this.jid = this.fulljid; // always use fulljid this.affiliation = 'none'; this.role = 'none'; this.add2Group = GroupchatRosterUserAdd2Group; } GroupchatRosterUser.prototype = new RosterUser; function getRosterGetRealJIDByNick(nick) { for (var i=0; i