diff --git a/file/js/be.bastelstu.Chat.litcoffee b/file/js/be.bastelstu.Chat.litcoffee index a429fb6..5776b7a 100644 --- a/file/js/be.bastelstu.Chat.litcoffee +++ b/file/js/be.bastelstu.Chat.litcoffee @@ -490,60 +490,64 @@ Rebuild the userlist based on the given `users`. foundUsers = { } for user in users - id = "timsChatUser#{user.userID}" + do (user) -> + id = "timsChatUser#{user.userID}" Move the user to the new position if he was found in the old list. - if $.wcfIsset id - console.log "Moving User: '#{user.username}'" - element = $("##{id}").detach() - - if user.awayStatus? - element.addClass 'away' - element.attr 'title', user.awayStatus - else - element.removeClass 'away' - element.removeAttr 'title' - element.data 'tooltip', '' - - if user.suspended - element.addClass 'suspended' - else - element.removeClass 'suspended' - - $('#timsChatUserList > ul').append element + if $.wcfIsset id + console.log "Moving User: '#{user.username}'" + element = $("##{id}").detach() + + if user.awayStatus? + element.addClass 'away' + element.attr 'title', user.awayStatus + else + element.removeClass 'away' + element.removeAttr 'title' + element.data 'tooltip', '' + + if user.suspended + element.addClass 'suspended' + else + element.removeClass 'suspended' + + $('#timsChatUserList > ul').append element Build HTML of the user and insert it into the list, if the users was not found in the chat before. - else - console.log "Inserting User: '#{user.username}'" - li = $ '
' - li.attr 'id', id - li.addClass 'timsChatUser' - li.addClass 'jsTooltip' - li.addClass 'dropdown' - li.addClass 'you' if user.userID is WCF.User.userID - li.addClass 'suspended' if user.suspended - if user.awayStatus? - li.addClass 'away' - li.attr 'title', user.awayStatus - li.data 'username', user.username + else + console.log "Inserting User: '#{user.username}'" + li = $ '' + li.attr 'id', id + li.addClass 'timsChatUser' + li.addClass 'jsTooltip' + li.addClass 'dropdown' + li.addClass 'you' if user.userID is WCF.User.userID + li.addClass 'suspended' if user.suspended + if user.awayStatus? + li.addClass 'away' + li.attr 'title', user.awayStatus + li.data 'username', user.username + + li.append v.userTemplate.fetch user + + menu = $ '