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

@ -206,7 +206,9 @@ function onText(args, kwargs) {
mwin.append("<div class='" + cls + "'>" + args[0] + "</div>");
mwin.animate({
scrollTop: document.getElementById("messagewindow").scrollHeight
}, 0);
}, 0);
onNewLine(args[0], null);
}
// Handle prompt output from the server
@ -243,7 +245,23 @@ function onDefault(cmdname, args, kwargs) {
// in Firefox, there it's a standard error.
function onBeforeUnload() {
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
@ -252,7 +270,10 @@ function onBeforeUnload() {
// Event when client finishes loading
$(document).ready(function() {
// Event when client window changes
$(window).bind("resize", doWindowResize);
$(window).bind("resize", doWindowResize);
$(document).on("visibilitychange", onVisibilityChange);
$("#inputfield").bind("resize", doWindowResize)
.keypress(onKeyPress)
.bind("paste", resizeInputField)