diff options
| author | sostler <sbostler@gmail.com> | 2010-05-20 20:36:33 -0400 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-05-20 20:36:33 -0400 |
| commit | 7cd97594cf46bb942d07099ffb05fcbceb609e9b (patch) | |
| tree | df701aa1a6a530175e0f3d80c60e6f473d2ea3ba | |
| parent | 04bec93bf1d58e7a75268651b54fdce566c408b1 (diff) | |
Use function to startTitleUpdater
| -rwxr-xr-x | static/js/away.js | 28 | ||||
| -rw-r--r-- | static/js/pichat.js | 9 | ||||
| -rw-r--r-- | template/chat.st | 3 |
3 files changed, 7 insertions, 33 deletions
diff --git a/static/js/away.js b/static/js/away.js deleted file mode 100755 index cf4b19c..0000000 --- a/static/js/away.js +++ /dev/null @@ -1,28 +0,0 @@ -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);
\ No newline at end of file diff --git a/static/js/pichat.js b/static/js/pichat.js index b212fbd..9b58b5c 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -989,9 +989,6 @@ function onBlur() { HasFocus = false; } -$(window).blur(onBlur); -$(window).focus(onFocus); - function titleUpdater() { if (HasFocus || UnseenMsgCounter == 0 || $('title').text() != OrigTitle) { $('title').text(OrigTitle); @@ -1002,4 +999,8 @@ function titleUpdater() { setTimeout(titleUpdater, 2000); } -setTimeout(titleUpdater, 2000); +function startTitleUpdater() { + $(window).blur(onBlur); + $(window).focus(onFocus); + setTimeout(titleUpdater, 2000); +} diff --git a/template/chat.st b/template/chat.st index a0fbe0b..27148f0 100644 --- a/template/chat.st +++ b/template/chat.st @@ -46,7 +46,8 @@ $endif$ function pop(url) { newwindow=window.open(url,'name','height=50,width=400,left=20,top=20,location=0,status=0,scrollbar=0,resizable=0'); if (window.focus) {newwindow.focus()} - } + } + jQuery(document).ready(startTitleUpdater); </script> </head> <body> |
