From 4b2986ed19c4a57516fbbba71e525383a1f8b437 Mon Sep 17 00:00:00 2001 From: sostler Date: Fri, 28 May 2010 04:00:37 -0400 Subject: Added fav notification --- static/js/pichat.js | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'static/js') 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 = '
' + + '' + + '' + f.from + '' + + ' just faved you!' + + '
'; + 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; } -- cgit v1.2.3-70-g09d2