mirror of
https://github.com/lovasoa/whitebophir
synced 2024-11-10 14:34:20 +00:00
Unread messages count
This commit is contained in:
parent
55851a3c5a
commit
502f210232
1 changed files with 17 additions and 4 deletions
|
@ -176,10 +176,8 @@ Tools.socket.on("broadcast", function (message){
|
|||
} else {
|
||||
///We received a message destinated to a tool that we don't have
|
||||
//So we add it to the pending messages
|
||||
if (!Tools.pendingMessages[tool] === undefined) {
|
||||
Tools.pendingMessages[tool] = [];
|
||||
}
|
||||
Tools.pendingMessages[tool].push(message);
|
||||
if (!Tools.pendingMessages[tool]) Tools.pendingMessages[tool] = [message];
|
||||
else Tools.pendingMessages[tool].push(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,6 +197,16 @@ Tools.socket.on("broadcast", function (message){
|
|||
}
|
||||
});
|
||||
|
||||
Tools.unreadMessagesCount = 0;
|
||||
Tools.newUnreadMessage = function () {
|
||||
document.title = "(" + (++Tools.unreadMessagesCount) + ") WBO";
|
||||
};
|
||||
|
||||
window.addEventListener("focus", function(){
|
||||
Tools.unreadMessagesCount = 0;
|
||||
document.title = "WBO";
|
||||
});
|
||||
|
||||
//List of hook functions that will be applied to messages before sending or drawing them
|
||||
Tools.messageHooks = [
|
||||
function resizeCanvas (m) {
|
||||
|
@ -212,6 +220,11 @@ Tools.messageHooks = [
|
|||
svg.height.baseVal.value = y + 2000;
|
||||
}
|
||||
}
|
||||
},
|
||||
function updateUnreadCount(m) {
|
||||
if (document.hidden && ["child", "update"].indexOf(m.type) === -1) {
|
||||
Tools.newUnreadMessage();
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue