From de9901b5caff3d97fab9dd30318b5a823dc30f5a Mon Sep 17 00:00:00 2001 From: timb Date: Tue, 19 Jan 2010 14:45:23 -0800 Subject: fix for blinking userlist --- static/js/pichat.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'static/js') diff --git a/static/js/pichat.js b/static/js/pichat.js index 69a347c..b9e0d46 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -1,3 +1,5 @@ +var cache = {} + function escapeHtml(txt) { if (!txt) { return ""; } else { return $("").text(txt).html(); } @@ -28,13 +30,6 @@ function buildMessageDiv(msg) { + buildMsgContent(msg.content) + ''; } -function buildGrowlDataAndPopDatShit(msg) { - var nick = escapeHtml(msg.nick); - nick = '' + nick + ':' - var msg = buildMsgContent(msg.content) - growl(nick, msg) -} - function buildUserDiv(user) { if (user.avatar) { return '
' + @@ -46,6 +41,20 @@ function buildUserDiv(user) { } } +function buildGrowlDataAndPopDatShit(msg) { + var nick = escapeHtml(msg.nick); + nick = '' + nick + ':' + var msg = buildMsgContent(msg.content) + growl(nick, msg) +} + +function growl(user, msg) { + $.gritter.add({ + title: user, + text: msg + }); +} + function handleMsgError(resp) { var respText = resp.responseText ? resp.responseText.trim() : false; if (respText == 'MUST_LOGIN') { @@ -117,7 +126,11 @@ function updateUI(msgs, users) { } } if (users !== null) { + var flattened = users.sort().join(",") + if (!('userlist' in cache) || flattened != cache.userlist){ $("#userList").html($.map(users, buildUserDiv).join('')); + } + cache.userlist = flattened } } @@ -227,12 +240,3 @@ function initLog() { }); } - -function growl(user, msg) { - $.gritter.add({ - // (string | mandatory) the heading of the notification - title: user, - // (string | mandatory) the text inside the notification - text: msg - }); -} -- cgit v1.2.3-70-g09d2