From fc7b719920b1ed2cb52fc9d49cf2ecae8908e9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 30 Jan 2012 17:31:54 +0100 Subject: [PATCH] Adding consoleMock for use in production --- file/js/TimWolla.WCF.Chat.coffee | 18 ++++++++++++------ template/chat.tpl | 9 ++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 4d67405..d5e7dd6 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -9,8 +9,11 @@ TimWolla ?= {} TimWolla.WCF ?= {} +consoleMock ?= + log: () ->, + warn: () -> -(($, window) -> +(($, window, console) -> TimWolla.WCF.Chat = # Templates titleTemplate: null @@ -267,19 +270,19 @@ TimWolla.WCF ?= {} # @param array users ### handleUsers: (users) -> - foundUsers = {} + foundUsers = { } for user in users id = 'chatUser-'+user.userID element = $('#'+id) # Move the user to the correct position if element[0] - console.log '[TimWolla.WCF.Chat] Shifting user ' + user.userID + console.log '[TimWolla.WCF.Chat] Moving User: "' + user.username + '"' element = element.detach() $('#chatUserList').append element # Insert the user else - console.log '[TimWolla.WCF.Chat] Inserting user ' + user.userID + console.log '[TimWolla.WCF.Chat] Inserting User: "' + user.username + '"' li = $ '
  • ' li.attr 'id', id li.addClass 'chatUser' @@ -302,9 +305,12 @@ TimWolla.WCF ?= {} foundUsers[id] = true + # Remove users that were not found $('.chatUser').each () -> if typeof foundUsers[$(@).attr('id')] is 'undefined' - $(@).remove() + console.log '[TimWolla.WCF.Chat] Removing User: "' + $(@).data('username') + '"' + $(@).remove(); + $('#toggleUsers .badge').text(users.length); ### @@ -435,4 +441,4 @@ TimWolla.WCF ?= {} else li.addClass 'activeMenuItem' li.find('.chatUserMenu').wcfBlindIn 'vertical' -)(jQuery, @) +)(jQuery, @, consoleMock) diff --git a/template/chat.tpl b/template/chat.tpl index ecb684a..adfaba3 100755 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -183,7 +183,6 @@ {include file='chatCopyright'} - {include file='chatJavascriptInclude'}