Override jarnxmpp.Presence.onlineCount to use the ChatPartners storage.
This commit is contained in:
parent
e10256a70e
commit
92a18780ca
22
chat.js
22
chat.js
@ -7,7 +7,8 @@ var helpers = (function (helpers) {
|
||||
}
|
||||
return o;
|
||||
};
|
||||
helpers.hash =function (str) {
|
||||
|
||||
helpers.hash = function (str) {
|
||||
// FIXME
|
||||
if (str == 'online-users-container') {
|
||||
return str;
|
||||
@ -15,6 +16,17 @@ var helpers = (function (helpers) {
|
||||
var shaobj = new jsSHA(str);
|
||||
return shaobj.getHash("HEX");
|
||||
};
|
||||
|
||||
helpers.size = function (obj) {
|
||||
var size = 0, key;
|
||||
for (key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
size++;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
};
|
||||
|
||||
return helpers;
|
||||
})(helpers || {});
|
||||
|
||||
@ -51,6 +63,10 @@ var xmppchat = (function (jarnxmpp, $, console) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
methods.getTotal = function () {
|
||||
return helpers.size(storage);
|
||||
};
|
||||
return methods;
|
||||
})();
|
||||
|
||||
@ -121,6 +137,10 @@ var xmppchat = (function (jarnxmpp, $, console) {
|
||||
xmppchat.connection.sendIQ(iq, this.handleCollectionRetrieval, this.handleError);
|
||||
};
|
||||
|
||||
ob.Presence.onlineCount = function () {
|
||||
return xmppchat.ChatPartners.getTotal();
|
||||
};
|
||||
|
||||
ob.Presence.sendPresence = function (type) {
|
||||
if (type === undefined) {
|
||||
type = xmppchat.Storage.get(xmppchat.username+'-xmpp-status') || 'online';
|
||||
|
Loading…
Reference in New Issue
Block a user