summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorsostler <sbostler@gmail.com>2010-05-20 15:01:50 -0400
committersostler <sbostler@gmail.com>2010-05-20 15:01:50 -0400
commit984b04cdd4748c88086e1d1ca0b060e1eaebb2a6 (patch)
treef5f859a1ee90dd3931b61aef0967d42b35567e87 /static
parentbe5ae0f99e685177d51ff82304eb525e6790ea7d (diff)
Consolidated away.js
Diffstat (limited to 'static')
-rw-r--r--static/js/pichat.js31
1 files changed, 31 insertions, 0 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);