From 15ea1479fb1bd1e7d79dd53b4597fe8a0aae30db Mon Sep 17 00:00:00 2001 From: sostler Date: Wed, 13 Jan 2010 01:48:06 -0500 Subject: Added away --- static/away.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 static/away.js (limited to 'static/away.js') 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 -- cgit v1.2.3-70-g09d2