summaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js')
-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);