summaryrefslogtreecommitdiff
path: root/static/away.js
diff options
context:
space:
mode:
authorsostler <sbostler@gmail.com>2010-01-13 01:48:06 -0500
committersostler <sbostler@gmail.com>2010-01-13 01:48:06 -0500
commit15ea1479fb1bd1e7d79dd53b4597fe8a0aae30db (patch)
tree6b25cf4f4d8392962514e9c9de8b028aa715def7 /static/away.js
parenta11aec2cbfadf39abc8a206f2c549283a2c24f35 (diff)
Added away
Diffstat (limited to 'static/away.js')
-rwxr-xr-xstatic/away.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/static/away.js b/static/away.js
new file mode 100755
index 0000000..e9c6b2e
--- /dev/null
+++ b/static/away.js
@@ -0,0 +1,27 @@
+var UnseenMsgCounter = 0;
+var OrigTitle = $('title').text();
+var HasFocus = true;
+
+function onFocus() {
+ HasFocus = true;
+ UnseenMsgCounter = 0;
+}
+
+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, HasFocus ? 5000 : 2000);
+}
+
+setTimeout(titleUpdater, 10000); \ No newline at end of file