diff --git a/evennia/web/webclient/static/webclient/js/webclient_gui.js b/evennia/web/webclient/static/webclient/js/webclient_gui.js
index dcbb8a60f2..536ea4bd3a 100644
--- a/evennia/web/webclient/static/webclient/js/webclient_gui.js
+++ b/evennia/web/webclient/static/webclient/js/webclient_gui.js
@@ -206,7 +206,9 @@ function onText(args, kwargs) {
mwin.append("
" + args[0] + "
");
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)