summaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
authortimb <timb@mb.local>2010-01-19 14:45:23 -0800
committertimb <timb@mb.local>2010-01-19 14:45:23 -0800
commitde9901b5caff3d97fab9dd30318b5a823dc30f5a (patch)
tree356dc09512a0a152fa6bed98bd73b30ded7db6a8 /static/js
parent860fff28431e405174eb11a41dbb044674b80a9a (diff)
fix for blinking userlist
Diffstat (limited to 'static/js')
-rwxr-xr-xstatic/js/pichat.js36
1 files changed, 20 insertions, 16 deletions
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 $("<span>").text(txt).html(); }
@@ -28,13 +30,6 @@ function buildMessageDiv(msg) {
+ buildMsgContent(msg.content) + '</div>';
}
-function buildGrowlDataAndPopDatShit(msg) {
- var nick = escapeHtml(msg.nick);
- nick = '<a href="/u/' + nick + ' " style="color:pink">' + nick + '</a>:'
- var msg = buildMsgContent(msg.content)
- growl(nick, msg)
-}
-
function buildUserDiv(user) {
if (user.avatar) {
return '<div class="username"><a href="/u/' + escapeHtml(user.nick) + '">' +
@@ -46,6 +41,20 @@ function buildUserDiv(user) {
}
}
+function buildGrowlDataAndPopDatShit(msg) {
+ var nick = escapeHtml(msg.nick);
+ nick = '<a href="/u/' + nick + ' " style="color:pink">' + nick + '</a>:'
+ 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
- });
-}