Show the number of online users.
This commit is contained in:
parent
a20ea9d4e0
commit
b304a54afe
20
chat.js
20
chat.js
@ -24,6 +24,7 @@ var xmppchat = (function (jarnxmpp, $, console) {
|
|||||||
ob.Presence = jarnxmpp.Presence || {};
|
ob.Presence = jarnxmpp.Presence || {};
|
||||||
|
|
||||||
ob.Messages.ClientStorage = (function () {
|
ob.Messages.ClientStorage = (function () {
|
||||||
|
// TODO: Messages must be encrypted with a key and salt
|
||||||
methods = {};
|
methods = {};
|
||||||
|
|
||||||
methods.addMessage = function (jid, msg, direction) {
|
methods.addMessage = function (jid, msg, direction) {
|
||||||
@ -86,14 +87,6 @@ var xmppchat = (function (jarnxmpp, $, console) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ob.Presence.getOwnStatus = function () {
|
|
||||||
return xmppchat.Storage.get(xmppchat.username+'-xmpp-status');
|
|
||||||
};
|
|
||||||
|
|
||||||
ob.Presence.onlineCount = function () {
|
|
||||||
return xmppchat.ChatPartners.getTotal();
|
|
||||||
};
|
|
||||||
|
|
||||||
ob.Taskbuffer = (function ($) {
|
ob.Taskbuffer = (function ($) {
|
||||||
// Executes tasks one after another (i.e next task is started only when
|
// Executes tasks one after another (i.e next task is started only when
|
||||||
// the previous one has been completed).
|
// the previous one has been completed).
|
||||||
@ -723,6 +716,16 @@ xmppchat.RosterClass = (function (stropheRoster, _, $, console) {
|
|||||||
if (item) {
|
if (item) {
|
||||||
return _.size(item.get('resources'));
|
return _.size(item.get('resources'));
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getNumOnlineContacts: function () {
|
||||||
|
var count = 0;
|
||||||
|
for (var i=0; i<this.models.length; i++) {
|
||||||
|
if (_.indexOf(['offline', 'unavailable'], this.models[i].get('status')) === -1) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -826,6 +829,7 @@ xmppchat.RosterView= (function (roster, _, $, console) {
|
|||||||
var user_id = Strophe.getNodeFromJid(model.id);
|
var user_id = Strophe.getNodeFromJid(model.id);
|
||||||
$(that.el).append(children.filter('#online-users-'+user_id));
|
$(that.el).append(children.filter('#online-users-'+user_id));
|
||||||
});
|
});
|
||||||
|
$('#online-count').text(this.model.getNumOnlineContacts());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var view = new View();
|
var view = new View();
|
||||||
|
Loading…
Reference in New Issue
Block a user