diff options
| author | sostler <sbostler@gmail.com> | 2010-01-13 01:48:06 -0500 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-01-13 01:48:06 -0500 |
| commit | 15ea1479fb1bd1e7d79dd53b4597fe8a0aae30db (patch) | |
| tree | 6b25cf4f4d8392962514e9c9de8b028aa715def7 | |
| parent | a11aec2cbfadf39abc8a206f2c549283a2c24f35 (diff) | |
Added away
| -rwxr-xr-x | static/away.js | 27 | ||||
| -rwxr-xr-x | static/pichat.js | 5 | ||||
| -rwxr-xr-x | template/chat.st | 1 | ||||
| -rwxr-xr-x | template/footer.st | 1 |
4 files changed, 32 insertions, 2 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 diff --git a/static/pichat.js b/static/pichat.js index 8f61c9b..d51d18d 100755 --- a/static/pichat.js +++ b/static/pichat.js @@ -134,7 +134,10 @@ function refresh() { var messages = $.grep( json.messages, function(m) { return !isDuplicateMessage(m) }); - updateUI(messages, json.users); + updateUI(messages, json.users); + if (typeof UnseenMsgCounter !== 'undefined') { + UnseenMsgCounter += messages.length; + } } catch(e) { if (IsAdmin) { alert("Exception in refresh"); diff --git a/template/chat.st b/template/chat.st index 701dd92..4b65aa7 100755 --- a/template/chat.st +++ b/template/chat.st @@ -27,6 +27,7 @@ </style> <script src="http://widgets.getclicky.com/tally/?site_id=170656&sitekey=736f7dd41a0612d8d50797c65768e71a&width=175&height=250&title=Visitors" type="text/javascript"></script> $endif$ + <script src="/static/away.js"></script> </head> <body> $banner()$ diff --git a/template/footer.st b/template/footer.st index 4040c58..86c983e 100755 --- a/template/footer.st +++ b/template/footer.st @@ -1,7 +1,6 @@ <div id="footer" style="text-align: center"> @2010 dump.fm <a href="/">About Us</a> <a href="/">Blog</a> <a href="/">Goodies</a> <a href="/">Help</a> <a href="/">Terms</a> <a href="/">Privacy</a></div> -<a title="Web Analytics" href="http://getclicky.com/170656"><img alt="Web Analytics" src="http://static.getclicky.com/media/links/badge.gif" border="0" /></a> <script src="http://static.getclicky.com/js" type="text/javascript"></script> <script type="text/javascript">clicky.init(170656);</script> |
