From 984b04cdd4748c88086e1d1ca0b060e1eaebb2a6 Mon Sep 17 00:00:00 2001 From: sostler Date: Thu, 20 May 2010 15:01:50 -0400 Subject: Consolidated away.js --- static/js/pichat.js | 31 +++++++++++++++++++++++++++++++ template/chat.st | 1 - 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/static/js/pichat.js b/static/js/pichat.js index c92cb62..a7caadc 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -972,3 +972,34 @@ parseUri.options = { function parseDomain(host){ return host.toLowerCase().replace(/^www\./, "") } + +// Away notification + +var UnseenMsgCounter = 0; +var OrigTitle = $('title').text(); +var HasFocus = true; + +function onFocus() { + HasFocus = true; + UnseenMsgCounter = 0; + $('title').text(OrigTitle); +} + +function onBlur() { + HasFocus = false; +} + +$(window).blur(onBlur); +$(window).focus(onFocus); + +function titleUpdater() { + if (HasFocus || UnseenMsgCounter == 0 || $('title').text() != OrigTitle) { + $('title').text(OrigTitle); + } else { + var plural = UnseenMsgCounter > 1 ? 's' : ''; + $('title').text(UnseenMsgCounter + ' new dump' + plural + '! | ' + OrigTitle); + } + setTimeout(titleUpdater, 2000); +} + +setTimeout(titleUpdater, 2000); diff --git a/template/chat.st b/template/chat.st index 5b829fc..c9b1ab7 100644 --- a/template/chat.st +++ b/template/chat.st @@ -23,7 +23,6 @@ $head()$ - $if(user_nick)$ -- cgit v1.2.3-70-g09d2