Commit 92a18780 authored by JC Brand's avatar JC Brand

Override jarnxmpp.Presence.onlineCount to use the ChatPartners storage.

parent e10256a7
...@@ -7,7 +7,8 @@ var helpers = (function (helpers) { ...@@ -7,7 +7,8 @@ var helpers = (function (helpers) {
} }
return o; return o;
}; };
helpers.hash =function (str) {
helpers.hash = function (str) {
// FIXME // FIXME
if (str == 'online-users-container') { if (str == 'online-users-container') {
return str; return str;
...@@ -15,6 +16,17 @@ var helpers = (function (helpers) { ...@@ -15,6 +16,17 @@ var helpers = (function (helpers) {
var shaobj = new jsSHA(str); var shaobj = new jsSHA(str);
return shaobj.getHash("HEX"); 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; return helpers;
})(helpers || {}); })(helpers || {});
...@@ -51,6 +63,10 @@ var xmppchat = (function (jarnxmpp, $, console) { ...@@ -51,6 +63,10 @@ var xmppchat = (function (jarnxmpp, $, console) {
} }
} }
}; };
methods.getTotal = function () {
return helpers.size(storage);
};
return methods; return methods;
})(); })();
...@@ -121,6 +137,10 @@ var xmppchat = (function (jarnxmpp, $, console) { ...@@ -121,6 +137,10 @@ var xmppchat = (function (jarnxmpp, $, console) {
xmppchat.connection.sendIQ(iq, this.handleCollectionRetrieval, this.handleError); xmppchat.connection.sendIQ(iq, this.handleCollectionRetrieval, this.handleError);
}; };
ob.Presence.onlineCount = function () {
return xmppchat.ChatPartners.getTotal();
};
ob.Presence.sendPresence = function (type) { ob.Presence.sendPresence = function (type) {
if (type === undefined) { if (type === undefined) {
type = xmppchat.Storage.get(xmppchat.username+'-xmpp-status') || 'online'; type = xmppchat.Storage.get(xmppchat.username+'-xmpp-status') || 'online';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment