diff options
| author | sostler <sbostler@gmail.com> | 2010-05-20 15:01:50 -0400 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-05-20 15:01:50 -0400 |
| commit | 984b04cdd4748c88086e1d1ca0b060e1eaebb2a6 (patch) | |
| tree | f5f859a1ee90dd3931b61aef0967d42b35567e87 | |
| parent | be5ae0f99e685177d51ff82304eb525e6790ea7d (diff) | |
Consolidated away.js
| -rw-r--r-- | static/js/pichat.js | 31 | ||||
| -rw-r--r-- | template/chat.st | 1 |
2 files changed, 31 insertions, 1 deletions
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()$ <script type="text/javascript" src="/static/js/invalid_domains.js"></script> <script type="text/javascript" src="/static/webcam/webcam.js"></script> <script type="text/javascript" src="/static/js/tooltip.js"></script> - <script type="text/javascript" src="/static/js/away.js"></script> <script type="text/javascript" src="/static/js/ajaxupload.js"></script> $if(user_nick)$ <script type="text/javascript" src="/json/$user_nick$/favorites"></script> |
