diff options
| author | sostler <sbostler@gmail.com> | 2010-05-28 04:00:37 -0400 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-05-28 04:00:37 -0400 |
| commit | 4b2986ed19c4a57516fbbba71e525383a1f8b437 (patch) | |
| tree | 39c2356841523b8ac8934084f128c7cb08711046 /static/js/pichat.js | |
| parent | b5ecbae40ab352995df2461301d72067ae5ed397 (diff) | |
Added fav notification
Diffstat (limited to 'static/js/pichat.js')
| -rw-r--r-- | static/js/pichat.js | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js index 93e2f05..e884c15 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -202,6 +202,36 @@ function buildUserDiv(user) { } } +// Favs + +function buildFav(f) { + var h = '<div class="fav-note">' + + '<img src="/static/img/thumbs/chatheartover.gif">' + + '<a href="http://dump.fm/' + f.from + '">' + f.from + '</a>' + + ' <span>just faved you!</span>' + + '</div>'; + return $(h); +} + +function removeFavAndHideBox() { + $(this).remove(); + if ($('#favbox').children().length == 0) + $('#favbox').hide(); +} + +function showFav(f) { + $('#favbox').show(); + buildFav(f).appendTo('#favbox').fadeOut(3000, removeFavAndHideBox); +} + +function updateFavs(fs) { + if (fs.length == 0) + return; + $('#favbox').show(); + $(fs).each(function(i, f) { showFav(f) }); +} + + // Growl function buildGrowlDataAndPopDatShit(msg) { @@ -318,8 +348,7 @@ function flattenUserJson(users) { return s; } -function updateUI(msgs, users) { - +function updateUI(msgs, users, favs) { if (window['growlize'] && msgs && msgs.length > 0) { $.map(msgs, buildGrowlDataAndPopDatShit) } else if (msgs && msgs.length > 0) { @@ -332,6 +361,7 @@ function updateUI(msgs, users) { } cache.userlist = flattened } + updateFavs(favs); } function sortUsersByAlpha(a, b){ @@ -365,7 +395,7 @@ function refresh() { var messages = $.grep( json.messages, function(m) { return !isDuplicateMessage(m) }); - updateUI(messages, json.users); + updateUI(messages, json.users, json.favs); if (typeof UnseenMsgCounter !== 'undefined' && !HasFocus) { UnseenMsgCounter += messages.length; } |
