Tab/window title notifications in web client, shows the number of unread messages in brackets before the title.

This commit is contained in:
Joe Roberts 2016-09-07 17:45:20 +01:00 committed by Griatch
parent a6e353548f
commit 5790c82837

View file

@ -207,6 +207,8 @@ function onText(args, kwargs) {
mwin.animate({ mwin.animate({
scrollTop: document.getElementById("messagewindow").scrollHeight scrollTop: document.getElementById("messagewindow").scrollHeight
}, 0); }, 0);
onNewLine(args[0], null);
} }
// Handle prompt output from the server // Handle prompt output from the server
@ -245,6 +247,22 @@ function onBeforeUnload() {
return "You are about to leave the game. Please confirm."; return "You are about to leave the game. Please confirm.";
} }
var unread = 0;
var originalTitle = document.title;
function onVisibilityChange() {
if(!document.hidden) {
document.title = originalTitle;
}
}
function onNewLine(originator, text) {
if(document.hidden) {
unread++;
document.title = "(" + unread + ") " + originalTitle;
}
}
// //
// Register Events // Register Events
// //
@ -253,6 +271,9 @@ function onBeforeUnload() {
$(document).ready(function() { $(document).ready(function() {
// Event when client window changes // Event when client window changes
$(window).bind("resize", doWindowResize); $(window).bind("resize", doWindowResize);
$(document).on("visibilitychange", onVisibilityChange);
$("#inputfield").bind("resize", doWindowResize) $("#inputfield").bind("resize", doWindowResize)
.keypress(onKeyPress) .keypress(onKeyPress)
.bind("paste", resizeInputField) .bind("paste", resizeInputField)