From 9a1c8072cdab8633448da2d761b4beab25f0aad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 22 Jan 2012 20:47:12 +0100 Subject: [PATCH 01/17] Ask for permission only if status is active --- file/js/TimWolla.WCF.Chat.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index b8257bf..602e13e 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -76,7 +76,7 @@ TimWolla.WCF ?= {} element.attr 'title', element.data 'disableMessage' if typeof window.webkitNotifications isnt 'undefined' $('#chatNotify').click (event) -> - window.webkitNotifications.requestPermission() + window.webkitNotifications.requestPermission() if $(this).data 'status' ### # Changes the chat-room. From 8f6b7c5e12750c795d95c8a481acefb69dbccf1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 14:08:51 +0100 Subject: [PATCH 02/17] Adding autocompleter --- file/js/TimWolla.WCF.Chat.coffee | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 602e13e..425d2ba 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -15,6 +15,9 @@ TimWolla.WCF ?= {} titleTemplate: null messageTemplate: null newMessageCount: null + isActive: true + autocompleteOffset: 0 + autocompleteValue: null events: newMessage: $.Callbacks() userMenu: $.Callbacks() @@ -30,10 +33,20 @@ TimWolla.WCF ?= {} console.log '[TimWolla.WCF.Chat] Finished initializing' ### + # Autocompletes a username + ### + autocomplete: (firstChars, offset = @autocompleteOffset) -> + users = [] + for user in $ '.chatUser' + username = $(user).data('username'); + if username.indexOf(firstChars) is 0 + users.push username + + return if users.length is 0 then firstChars else users[offset % users.length] + ### # Binds all the events needed for Tims Chat. ### bindEvents: () -> - @isActive = true $(window).focus $.proxy () -> document.title = @titleTemplate.fetch({ title: $('#chatRoomList .activeMenuItem a').text() }) @newMessageCount = 0 @@ -58,6 +71,23 @@ TimWolla.WCF ?= {} @submit $ event.target , @ + $('#chatInput').keydown $.proxy (event) -> + if event.keyCode is 9 + event.preventDefault() + if @autocompleteValue is null + @autocompleteValue = $('#chatInput').val() + + firstChars = @autocompleteValue.substring(@autocompleteValue.lastIndexOf(' ')+1) + + console.log '[TimWolla.WCF.Chat] Autocompleting "' + firstChars + '"' + return if firstChars.length is 0 + + $('#chatInput').val(@autocompleteValue.substring(0, @autocompleteValue.lastIndexOf(' ')+1) + @autocomplete(firstChars) + ', ') + @autocompleteOffset++ + else + @autocompleteOffset = 0 + @autocompleteValue = null + , @ $('#chatClear').click (event) -> event.preventDefault() $('.chatMessage').remove() @@ -198,6 +228,7 @@ TimWolla.WCF ?= {} li = $ '
  • ' li.attr 'id', id li.addClass 'chatUser' + li.data 'username', user.username a = $ ''+user.username+'' a.click $.proxy (event) -> event.preventDefault() From c1fac59618294c3da8a747c2cfdd387b161c6433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 15:40:33 +0100 Subject: [PATCH 03/17] Automagically disable scrolling when user scrolls --- file/js/TimWolla.WCF.Chat.coffee | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 425d2ba..3215b90 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -18,6 +18,7 @@ TimWolla.WCF ?= {} isActive: true autocompleteOffset: 0 autocompleteValue: null + scrollHeightTopDiff: null events: newMessage: $.Callbacks() userMenu: $.Callbacks() @@ -72,6 +73,7 @@ TimWolla.WCF ?= {} , @ $('#chatInput').keydown $.proxy (event) -> + # tab key if event.keyCode is 9 event.preventDefault() if @autocompleteValue is null @@ -104,6 +106,12 @@ TimWolla.WCF ?= {} element.data 'status', 1 icon.attr 'src', icon.attr('src').replace /disabled(\d?).([a-z]{3})$/, 'enabled$1.$2' element.attr 'title', element.data 'disableMessage' + + $('#chatAutoscroll').click (event) -> + $(this).removeClass('hot') + if $(this).data 'status' + $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() + if typeof window.webkitNotifications isnt 'undefined' $('#chatNotify').click (event) -> window.webkitNotifications.requestPermission() if $(this).data 'status' @@ -182,7 +190,7 @@ TimWolla.WCF ?= {} fish.animate top: '+=' + top left: '+=' + left - , 1000 + , 1e3 , 1.5e3); ### # Loads new messages. @@ -201,6 +209,13 @@ TimWolla.WCF ?= {} # @param array messages ### handleMessages: (messages) -> + # disable scrolling automagically when user manually scrolled + if @scrollHeightTopDiff isnt null + if @scrollHeightTopDiff isnt $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() + if $('#chatAutoscroll').data('status') is 1 + $('#chatAutoscroll').click() + $('#chatAutoscroll').addClass('hot').fadeOut('slow').fadeIn('slow') + for message in messages @events.newMessage.fire message @@ -211,9 +226,11 @@ TimWolla.WCF ?= {} li.append output li.appendTo $ '.chatMessageContainer ul' - $('.chatMessageContainer').animate - scrollTop: $('.chatMessageContainer ul').height() - , 1000 + + # autoscroll down + if $('#chatAutoscroll').data('status') is 1 + $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() + @scrollHeightTopDiff = $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() handleUsers: (users) -> foundUsers = {} for user in users From a0ea7bce951050274918a56a2e87610fdf5dedbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 15:57:33 +0100 Subject: [PATCH 04/17] Some more comments --- file/js/TimWolla.WCF.Chat.coffee | 55 +++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 3215b90..6892425 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -38,11 +38,15 @@ TimWolla.WCF ?= {} ### autocomplete: (firstChars, offset = @autocompleteOffset) -> users = [] + + # Search all matching users for user in $ '.chatUser' username = $(user).data('username'); if username.indexOf(firstChars) is 0 users.push username + # None found -> return firstChars + # otherwise return the user at the current offset return if users.length is 0 then firstChars else users[offset % users.length] ### # Binds all the events needed for Tims Chat. @@ -58,20 +62,24 @@ TimWolla.WCF ?= {} @isActive = false , @ + # Insert a smiley $('.smiley').click $.proxy (event) -> @insertText ' ' + $(event.target).attr('alt') + ' ' , @ + # Switch sidebar tab $('.chatSidebarTabs li').click $.proxy (event) -> event.preventDefault() @toggleSidebarContents $ event.target , @ + # Submit Handler $('#chatForm').submit $.proxy (event) -> event.preventDefault() @submit $ event.target , @ + # Autocompleter $('#chatInput').keydown $.proxy (event) -> # tab key if event.keyCode is 9 @@ -84,17 +92,21 @@ TimWolla.WCF ?= {} console.log '[TimWolla.WCF.Chat] Autocompleting "' + firstChars + '"' return if firstChars.length is 0 + # Insert name and increment offset $('#chatInput').val(@autocompleteValue.substring(0, @autocompleteValue.lastIndexOf(' ')+1) + @autocomplete(firstChars) + ', ') @autocompleteOffset++ else @autocompleteOffset = 0 @autocompleteValue = null , @ + + # Clears the stream $('#chatClear').click (event) -> event.preventDefault() $('.chatMessage').remove() $('#chatInput').focus() - + + # Toggle Buttons $('.chatToggle').click (event) -> element = $ @ icon = element.find 'img' @@ -107,11 +119,13 @@ TimWolla.WCF ?= {} icon.attr 'src', icon.attr('src').replace /disabled(\d?).([a-z]{3})$/, 'enabled$1.$2' element.attr 'title', element.data 'disableMessage' + # Immediatly scroll down when activating autoscroll $('#chatAutoscroll').click (event) -> $(this).removeClass('hot') if $(this).data 'status' $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() - + + # Desktop Notifications if typeof window.webkitNotifications isnt 'undefined' $('#chatNotify').click (event) -> window.webkitNotifications.requestPermission() if $(this).data 'status' @@ -133,11 +147,11 @@ TimWolla.WCF ?= {} @loading = false target.parent().removeClass 'ajaxLoad' - # mark as active + # Mark as active $('.activeMenuItem .chatRoom').parent().removeClass 'activeMenuItem' target.parent().addClass 'activeMenuItem' - # set new topic + # Set new topic if data.topic is '' return if $('#topic').text().trim() is '' @@ -151,7 +165,7 @@ TimWolla.WCF ?= {} @getMessages() , @) error: () -> - # reload page to change the room the old fashion-way + # Reload the page to change the room the old fashion-way # inclusive the error-message :) window.location.reload true beforeSend: $.proxy(() -> @@ -166,7 +180,7 @@ TimWolla.WCF ?= {} freeTheFish: () -> return if $.wcfIsset('fish') console.warn '[TimWolla.WCF.Chat] Freeing the fish' - fish = $ '
    ' + WCF.String.escapeHTML('><((((°>') + '
    ' + fish = $ '
    ' + WCF.String.escapeHTML('><((((\u00B0>') + '
    ' fish.css position: 'absolute' top: '150px' @@ -181,11 +195,11 @@ TimWolla.WCF ?= {} top = (Math.random() * 100 - 50) fish = $('#fish') - left *= -1 if((fish.position().left + left) < (0 + fish.width()) or (fish.position().left + left) > ($(document).width() - fish.width())) - top *= -1 if((fish.position().top + top) < (0 + fish.height()) or (fish.position().top + top) > ($(document).height() - fish.height())) + left *= -1 if ((fish.position().left + left) < (0 + fish.width()) or (fish.position().left + left) > ($(document).width() - fish.width())) + top *= -1 if ((fish.position().top + top) < (0 + fish.height()) or (fish.position().top + top) > ($(document).height() - fish.height())) - fish.text('><((((°>') if (left > 0) - fish.text('<°))))><') if (left < 0) + fish.text('><((((\u00B0>') if (left > 0) + fish.text('<\u00B0))))><') if (left < 0) fish.animate top: '+=' + top @@ -209,13 +223,14 @@ TimWolla.WCF ?= {} # @param array messages ### handleMessages: (messages) -> - # disable scrolling automagically when user manually scrolled + # Disable scrolling automagically when user manually scrolled if @scrollHeightTopDiff isnt null if @scrollHeightTopDiff isnt $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() if $('#chatAutoscroll').data('status') is 1 $('#chatAutoscroll').click() $('#chatAutoscroll').addClass('hot').fadeOut('slow').fadeIn('slow') - + + # Insert the messages for message in messages @events.newMessage.fire message @@ -227,19 +242,27 @@ TimWolla.WCF ?= {} li.appendTo $ '.chatMessageContainer ul' - # autoscroll down + # Autoscroll down if $('#chatAutoscroll').data('status') is 1 $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() @scrollHeightTopDiff = $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() + ### + # Builds the userlist. + # + # @param array users + ### handleUsers: (users) -> 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 element = element.detach() $('#chatUserList').append element + # Insert the user else console.log '[TimWolla.WCF.Chat] Inserting user ' + user.userID li = $ '
  • ' @@ -300,6 +323,7 @@ TimWolla.WCF ?= {} document.title = '(' + @newMessageCount + ') ' + @titleTemplate.fetch({ title: $('#chatRoomList .activeMenuItem a').text() }) + # Desktop Notifications if typeof window.webkitNotifications isnt 'undefined' if window.webkitNotifications.checkPermission() is 0 notification = window.webkitNotifications.createNotification WCF.Icon.get('timwolla.wcf.chat.chat'), WCF.Language.get('wcf.chat.newMessages'), message.username + ' ' + message.message @@ -311,7 +335,7 @@ TimWolla.WCF ?= {} # Refreshes the room-list. ### refreshRoomList: () -> - console.log '[TimWolla.WCF.Chat] Refreshing the room-list' + console.log '[TimWolla.WCF.Chat] Refreshing the roomlist' $('#toggleRooms a').addClass 'ajaxLoad' $.ajax $('#toggleRooms a').data('refreshUrl'), @@ -342,9 +366,10 @@ TimWolla.WCF ?= {} # @param jQuery-object target ### submit: (target) -> - # break if input contains only whitespace + # Break if input contains only whitespace return false if $('#chatInput').val().trim().length is 0 + # Finally free the fish @freeTheFish() if $('#chatInput').val().trim().toLowerCase() is '/free the fish' $.ajax $('#chatForm').attr('action'), From dfdfedc7fa6479cdec7aa4c5ed599272a5ea6012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 16:09:24 +0100 Subject: [PATCH 05/17] Some optimizations for readability --- file/js/TimWolla.WCF.Chat.coffee | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 6892425..0ef01dc 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -12,13 +12,22 @@ TimWolla.WCF ?= {} (($, window) -> TimWolla.WCF.Chat = + # Templates titleTemplate: null messageTemplate: null + + # Notifications newMessageCount: null isActive: true + + # Autocompleter autocompleteOffset: 0 autocompleteValue: null + + # Autoscroll scrollHeightTopDiff: null + + # Events events: newMessage: $.Callbacks() userMenu: $.Callbacks() @@ -28,7 +37,7 @@ TimWolla.WCF ?= {} @events.newMessage.add $.proxy @notify, @ new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, @), 60e3 - new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1000 + new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1e3 @refreshRoomList() @getMessages() @@ -126,7 +135,7 @@ TimWolla.WCF ?= {} $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() # Desktop Notifications - if typeof window.webkitNotifications isnt 'undefined' + unless typeof window.webkitNotifications is 'undefined' $('#chatNotify').click (event) -> window.webkitNotifications.requestPermission() if $(this).data 'status' @@ -191,15 +200,15 @@ TimWolla.WCF ?= {} fish.appendTo $ 'body' new WCF.PeriodicalExecuter(() -> - left = (Math.random() * 100 - 50) - top = (Math.random() * 100 - 50) + left = Math.random() * 100 - 50 + top = Math.random() * 100 - 50 fish = $('#fish') - left *= -1 if ((fish.position().left + left) < (0 + fish.width()) or (fish.position().left + left) > ($(document).width() - fish.width())) - top *= -1 if ((fish.position().top + top) < (0 + fish.height()) or (fish.position().top + top) > ($(document).height() - fish.height())) + left *= -1 unless fish.width() < (fish.position().left + left) < ($(document).width() - fish.width())) + top *= -1 unless fish.height() < (fish.position().top + top) < ($(document).height() - fish.height())) - fish.text('><((((\u00B0>') if (left > 0) - fish.text('<\u00B0))))><') if (left < 0) + fish.text('><((((\u00B0>') if left > 0 + fish.text('<\u00B0))))><') if left < 0 fish.animate top: '+=' + top @@ -224,8 +233,8 @@ TimWolla.WCF ?= {} ### handleMessages: (messages) -> # Disable scrolling automagically when user manually scrolled - if @scrollHeightTopDiff isnt null - if @scrollHeightTopDiff isnt $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() + unless @scrollHeightTopDiff is null + if $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() isnt @scrollHeighTopDiff if $('#chatAutoscroll').data('status') is 1 $('#chatAutoscroll').click() $('#chatAutoscroll').addClass('hot').fadeOut('slow').fadeIn('slow') @@ -318,7 +327,7 @@ TimWolla.WCF ?= {} # @param object message ### notify: (message) -> - return if (@isActive or $('#chatNotify').data('status') is 0) + return if @isActive or $('#chatNotify').data('status') is 0 @newMessageCount++ document.title = '(' + @newMessageCount + ') ' + @titleTemplate.fetch({ title: $('#chatRoomList .activeMenuItem a').text() }) From cca83a596fb19810d681c64712ad49e26aa7e7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 16:37:27 +0100 Subject: [PATCH 06/17] Simpler detection whether the user scrolled --- file/js/TimWolla.WCF.Chat.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 0ef01dc..08ae58f 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -25,7 +25,7 @@ TimWolla.WCF ?= {} autocompleteValue: null # Autoscroll - scrollHeightTopDiff: null + oldScrollTop: null # Events events: @@ -204,8 +204,8 @@ TimWolla.WCF ?= {} top = Math.random() * 100 - 50 fish = $('#fish') - left *= -1 unless fish.width() < (fish.position().left + left) < ($(document).width() - fish.width())) - top *= -1 unless fish.height() < (fish.position().top + top) < ($(document).height() - fish.height())) + left *= -1 unless fish.width() < (fish.position().left + left) < ($(document).width() - fish.width()) + top *= -1 unless fish.height() < (fish.position().top + top) < ($(document).height() - fish.height()) fish.text('><((((\u00B0>') if left > 0 fish.text('<\u00B0))))><') if left < 0 @@ -233,8 +233,8 @@ TimWolla.WCF ?= {} ### handleMessages: (messages) -> # Disable scrolling automagically when user manually scrolled - unless @scrollHeightTopDiff is null - if $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() isnt @scrollHeighTopDiff + unless @oldScrollTop is null + if $('.chatMessageContainer').scrollTop() isnt @oldScrollTop if $('#chatAutoscroll').data('status') is 1 $('#chatAutoscroll').click() $('#chatAutoscroll').addClass('hot').fadeOut('slow').fadeIn('slow') @@ -254,7 +254,7 @@ TimWolla.WCF ?= {} # Autoscroll down if $('#chatAutoscroll').data('status') is 1 $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() - @scrollHeightTopDiff = $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() + @oldScrollTop = $('.chatMessageContainer').scrollTop() ### # Builds the userlist. # From 192a421a19190a8f85bdfd27de03e69358f5ce20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 16:43:48 +0100 Subject: [PATCH 07/17] Adding Force-Refresh Button for the RoomList --- file/js/TimWolla.WCF.Chat.coffee | 3 +++ template/chat.tpl | 1 + 2 files changed, 4 insertions(+) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 08ae58f..e1caf01 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -109,6 +109,9 @@ TimWolla.WCF ?= {} @autocompleteValue = null , @ + # Refreshes the roomlist + $('#chatRoomList button').click $.proxy(@refreshRoomList, @) + # Clears the stream $('#chatClear').click (event) -> event.preventDefault() diff --git a/template/chat.tpl b/template/chat.tpl index 87e1c19..aabd9d0 100755 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -119,6 +119,7 @@ {/if} {/foreach} +
    From 7fe21df49c86ded019715aabb052bf097cae444d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 16:56:20 +0100 Subject: [PATCH 08/17] Show newestMessages when switching room via ajax as well --- file/js/TimWolla.WCF.Chat.coffee | 4 ++-- file/lib/page/ChatPage.class.php | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index e1caf01..8fd51eb 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -173,8 +173,8 @@ TimWolla.WCF ?= {} $('#topic').text data.topic $('#topic').wcfBlindIn() if $('#topic').text().trim() isnt '' and $('#topic').is(':hidden') - $('title').text @titleTemplate.fetch(data) - @getMessages() + @handleMessages(data.messages) + document.title = @titleTemplate.fetch(data) , @) error: () -> # Reload the page to change the room the old fashion-way diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index a3922fb..5bab350 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -66,8 +66,6 @@ public function readData() { $this->readRoom(); $this->userData['color'] = \wcf\util\ChatUtil::readUserData('color'); \wcf\util\ChatUtil::writeUserData(array('roomID' => $this->room->roomID)); - $this->newestMessages = chat\message\ChatMessageList::getNewestMessages($this->room, CHAT_LASTMESSAGES); - \wcf\util\ChatUtil::writeUserData(array('lastSeen' => count($this->newestMessages) ? end($this->newestMessages)->messageID : 0)); if (CHAT_DISPLAY_JOIN_LEAVE) { $messageAction = new chat\message\ChatMessageAction(array(), 'create', array( @@ -86,6 +84,9 @@ public function readData() { $return = $messageAction->getReturnValues(); } + $this->newestMessages = chat\message\ChatMessageList::getNewestMessages($this->room, CHAT_LASTMESSAGES); + \wcf\util\ChatUtil::writeUserData(array('lastSeen' => end($this->newestMessages)->messageID)); + $this->readDefaultSmileys(); $this->readChatVersion(); } @@ -173,9 +174,12 @@ public function show() { if ($this->useTemplate) exit; @header('Content-type: application/json'); + $messages = array(); + foreach ($this->newestMessages as $message) $messages[] = $message->jsonify(true); echo \wcf\util\JSON::encode(array( 'title' => $this->room->getTitle(), - 'topic' => WCF::getLanguage()->get($this->room->topic) + 'topic' => WCF::getLanguage()->get($this->room->topic), + 'messages' => $messages )); exit; } From 2f937df323afcfc7c1b5cdff18e5a6450a07bee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 17:50:33 +0100 Subject: [PATCH 09/17] 2011 -> 2012 --- file/js/TimWolla.WCF.Chat.coffee | 2 +- file/lib/data/chat/message/ChatMessage.class.php | 2 +- file/lib/data/chat/message/ChatMessageAction.class.php | 2 +- file/lib/data/chat/message/ChatMessageEditor.class.php | 2 +- file/lib/data/chat/message/ChatMessageList.class.php | 2 +- file/lib/data/chat/room/ChatRoom.class.php | 2 +- file/lib/data/chat/room/ChatRoomEditor.class.php | 2 +- file/lib/data/chat/room/ChatRoomList.class.php | 2 +- file/lib/form/ChatForm.class.php | 2 +- file/lib/page/ChatCopyrightPage.class.php | 2 +- file/lib/page/ChatMessagePage.class.php | 2 +- file/lib/page/ChatPage.class.php | 2 +- file/lib/page/ChatRefreshRoomListPage.class.php | 2 +- file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php | 2 +- file/lib/system/chat/commands/ChatCommandHandler.class.php | 2 +- .../system/chat/permissions/ChatPermissionHandler.class.php | 4 ++-- file/lib/system/event/listener/ChatRouteListener.class.php | 2 +- file/lib/system/menu/page/ChatPageMenuItemProvider.class.php | 2 +- file/lib/system/option/TimeIntervalOptionType.class.php | 2 +- file/lib/util/ChatUtil.class.php | 2 +- file/style/timwolla.wcf.chat.scss | 2 +- 21 files changed, 22 insertions(+), 22 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 8fd51eb..cbac210 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -2,7 +2,7 @@ # TimWolla.WCF.Chat # # @author Tim Düsterhus -# @copyright 2010-2011 Tim Düsterhus +# @copyright 2010-2012 Tim Düsterhus # @license Creative Commons Attribution-NonCommercial-ShareAlike # @package timwolla.wcf.chat ### diff --git a/file/lib/data/chat/message/ChatMessage.class.php b/file/lib/data/chat/message/ChatMessage.class.php index 1be0d03..011596b 100755 --- a/file/lib/data/chat/message/ChatMessage.class.php +++ b/file/lib/data/chat/message/ChatMessage.class.php @@ -6,7 +6,7 @@ * Represents a chat message. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage data.chat.message diff --git a/file/lib/data/chat/message/ChatMessageAction.class.php b/file/lib/data/chat/message/ChatMessageAction.class.php index 2423d31..4d6d4ff 100644 --- a/file/lib/data/chat/message/ChatMessageAction.class.php +++ b/file/lib/data/chat/message/ChatMessageAction.class.php @@ -5,7 +5,7 @@ * Executes message related actions. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage data.chat.message diff --git a/file/lib/data/chat/message/ChatMessageEditor.class.php b/file/lib/data/chat/message/ChatMessageEditor.class.php index b2f8a60..abad314 100644 --- a/file/lib/data/chat/message/ChatMessageEditor.class.php +++ b/file/lib/data/chat/message/ChatMessageEditor.class.php @@ -5,7 +5,7 @@ * Provides functions to edit chat messages. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage data.chat.message diff --git a/file/lib/data/chat/message/ChatMessageList.class.php b/file/lib/data/chat/message/ChatMessageList.class.php index 10f474f..2f3e01e 100644 --- a/file/lib/data/chat/message/ChatMessageList.class.php +++ b/file/lib/data/chat/message/ChatMessageList.class.php @@ -5,7 +5,7 @@ * Represents a list of chat messages. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage data.chat.room diff --git a/file/lib/data/chat/room/ChatRoom.class.php b/file/lib/data/chat/room/ChatRoom.class.php index 565d8ba..9193bf0 100644 --- a/file/lib/data/chat/room/ChatRoom.class.php +++ b/file/lib/data/chat/room/ChatRoom.class.php @@ -6,7 +6,7 @@ * Represents a chat room. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage data.chat.room diff --git a/file/lib/data/chat/room/ChatRoomEditor.class.php b/file/lib/data/chat/room/ChatRoomEditor.class.php index a928ad8..73e0a2a 100644 --- a/file/lib/data/chat/room/ChatRoomEditor.class.php +++ b/file/lib/data/chat/room/ChatRoomEditor.class.php @@ -5,7 +5,7 @@ * Provides functions to edit chat rooms. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage data.chat.room diff --git a/file/lib/data/chat/room/ChatRoomList.class.php b/file/lib/data/chat/room/ChatRoomList.class.php index 0c34470..6a311d7 100644 --- a/file/lib/data/chat/room/ChatRoomList.class.php +++ b/file/lib/data/chat/room/ChatRoomList.class.php @@ -5,7 +5,7 @@ * Represents a list of chat rooms. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage data.chat.room diff --git a/file/lib/form/ChatForm.class.php b/file/lib/form/ChatForm.class.php index 04503da..e5ffc54 100644 --- a/file/lib/form/ChatForm.class.php +++ b/file/lib/form/ChatForm.class.php @@ -10,7 +10,7 @@ * Inserts a message * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage form diff --git a/file/lib/page/ChatCopyrightPage.class.php b/file/lib/page/ChatCopyrightPage.class.php index 15bf231..cf4deea 100644 --- a/file/lib/page/ChatCopyrightPage.class.php +++ b/file/lib/page/ChatCopyrightPage.class.php @@ -6,7 +6,7 @@ * Shows information about Tims chat. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage page diff --git a/file/lib/page/ChatMessagePage.class.php b/file/lib/page/ChatMessagePage.class.php index d7f2fbf..873e95a 100644 --- a/file/lib/page/ChatMessagePage.class.php +++ b/file/lib/page/ChatMessagePage.class.php @@ -7,7 +7,7 @@ * Loads new messages. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage page diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index 5bab350..d7dbe78 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -8,7 +8,7 @@ * Shows the chat-interface * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage page diff --git a/file/lib/page/ChatRefreshRoomListPage.class.php b/file/lib/page/ChatRefreshRoomListPage.class.php index 56d0267..36f4156 100644 --- a/file/lib/page/ChatRefreshRoomListPage.class.php +++ b/file/lib/page/ChatRefreshRoomListPage.class.php @@ -8,7 +8,7 @@ * Shows the chat-interface * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage page diff --git a/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php b/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php index 9fca599..c21267f 100644 --- a/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php +++ b/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php @@ -5,7 +5,7 @@ * Caches all chat rooms. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage system.cache.builder diff --git a/file/lib/system/chat/commands/ChatCommandHandler.class.php b/file/lib/system/chat/commands/ChatCommandHandler.class.php index 6e24a6a..c5c93f3 100644 --- a/file/lib/system/chat/commands/ChatCommandHandler.class.php +++ b/file/lib/system/chat/commands/ChatCommandHandler.class.php @@ -6,7 +6,7 @@ * Inserts a message. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage system.chat.commands diff --git a/file/lib/system/chat/permissions/ChatPermissionHandler.class.php b/file/lib/system/chat/permissions/ChatPermissionHandler.class.php index c8ef28e..6251e1e 100644 --- a/file/lib/system/chat/permissions/ChatPermissionHandler.class.php +++ b/file/lib/system/chat/permissions/ChatPermissionHandler.class.php @@ -7,8 +7,8 @@ /** * Handles chat-permissions. * - * @author Tim Düsterhus, Marcel Werk - * @copyright 2010-2011 WoltLab GmbH + * @author Tim D�sterhus, Marcel Werk + * @copyright 2010-2012 WoltLab GmbH * @license GNU Lesser General Public License * @package timwolla.wcf.chat * @subpackage system.chat.permissions diff --git a/file/lib/system/event/listener/ChatRouteListener.class.php b/file/lib/system/event/listener/ChatRouteListener.class.php index 443a8cb..991bb35 100644 --- a/file/lib/system/event/listener/ChatRouteListener.class.php +++ b/file/lib/system/event/listener/ChatRouteListener.class.php @@ -5,7 +5,7 @@ * Adds a new route to RouteHandler * * @author Maximilian Mader - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage system.event.listener diff --git a/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php b/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php index 29e201f..978c956 100644 --- a/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php +++ b/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php @@ -6,7 +6,7 @@ * PageMenuItemProvider for chat. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage system.menu.page diff --git a/file/lib/system/option/TimeIntervalOptionType.class.php b/file/lib/system/option/TimeIntervalOptionType.class.php index 1fa6bb1..7f35c22 100644 --- a/file/lib/system/option/TimeIntervalOptionType.class.php +++ b/file/lib/system/option/TimeIntervalOptionType.class.php @@ -5,7 +5,7 @@ * TimeIntervalOptionType is an implementation of IOptionType for time intervals. * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage system.option diff --git a/file/lib/util/ChatUtil.class.php b/file/lib/util/ChatUtil.class.php index 3d03ba5..2cfde2c 100644 --- a/file/lib/util/ChatUtil.class.php +++ b/file/lib/util/ChatUtil.class.php @@ -8,7 +8,7 @@ * Chat utilities * * @author Tim Düsterhus - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat * @subpackage util diff --git a/file/style/timwolla.wcf.chat.scss b/file/style/timwolla.wcf.chat.scss index 5eea3a3..1625fda 100644 --- a/file/style/timwolla.wcf.chat.scss +++ b/file/style/timwolla.wcf.chat.scss @@ -2,7 +2,7 @@ * Chat-Styles * * @author Tim Düsterhus, Maximilian Mader - * @copyright 2010-2011 Tim Düsterhus + * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat */ From 58484b2ec035ef84e07ebeec09fb120295f065fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 17:51:35 +0100 Subject: [PATCH 10/17] Fixing UTF-8 issue --- .../lib/system/chat/permissions/ChatPermissionHandler.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file/lib/system/chat/permissions/ChatPermissionHandler.class.php b/file/lib/system/chat/permissions/ChatPermissionHandler.class.php index 6251e1e..d525b9e 100644 --- a/file/lib/system/chat/permissions/ChatPermissionHandler.class.php +++ b/file/lib/system/chat/permissions/ChatPermissionHandler.class.php @@ -7,7 +7,7 @@ /** * Handles chat-permissions. * - * @author Tim D�sterhus, Marcel Werk + * @author Tim Düsterhus, Marcel Werk * @copyright 2010-2012 WoltLab GmbH * @license GNU Lesser General Public License * @package timwolla.wcf.chat From d47ff71e49b42d7cc231f6f2fbf0739e765acf9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 21:48:06 +0100 Subject: [PATCH 11/17] Fixing automagically scroll disabler --- file/js/TimWolla.WCF.Chat.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index cbac210..d739f1f 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -136,7 +136,8 @@ TimWolla.WCF ?= {} $(this).removeClass('hot') if $(this).data 'status' $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() - + @oldScrollTop = $('.chatMessageContainer').scrollTop() + # Desktop Notifications unless typeof window.webkitNotifications is 'undefined' $('#chatNotify').click (event) -> @@ -237,7 +238,7 @@ TimWolla.WCF ?= {} handleMessages: (messages) -> # Disable scrolling automagically when user manually scrolled unless @oldScrollTop is null - if $('.chatMessageContainer').scrollTop() isnt @oldScrollTop + if $('.chatMessageContainer').scrollTop() < @oldScrollTop if $('#chatAutoscroll').data('status') is 1 $('#chatAutoscroll').click() $('#chatAutoscroll').addClass('hot').fadeOut('slow').fadeIn('slow') @@ -257,7 +258,7 @@ TimWolla.WCF ?= {} # Autoscroll down if $('#chatAutoscroll').data('status') is 1 $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() - @oldScrollTop = $('.chatMessageContainer').scrollTop() + @oldScrollTop = $('.chatMessageContainer').scrollTop() ### # Builds the userlist. # From 5684af0b1f241f035a837b97f0e1940e496454d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 29 Jan 2012 12:44:36 +0100 Subject: [PATCH 12/17] Bumping Version Number --- package.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.xml b/package.xml index 6a8f69f..7c3bf7b 100644 --- a/package.xml +++ b/package.xml @@ -5,7 +5,7 @@ 0 1 - 3.0.0 Alpha 2 + 3.0.0 Alpha 3 2011-11-26 com.woltlab.wcf.bbcode @@ -45,4 +45,4 @@ templatelistener.xml acloptions.xml - \ No newline at end of file + From 50ec5ad93fb63a0e84b2d039db22cc9ceecb338c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 29 Jan 2012 15:23:21 +0100 Subject: [PATCH 13/17] Fixing issue with scroll disabler --- file/js/TimWolla.WCF.Chat.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index d739f1f..6074ed3 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -116,6 +116,8 @@ TimWolla.WCF ?= {} $('#chatClear').click (event) -> event.preventDefault() $('.chatMessage').remove() + @oldScrollTop = $('.chatMessageContainer').scrollTop() + $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() $('#chatInput').focus() # Toggle Buttons @@ -343,7 +345,7 @@ TimWolla.WCF ?= {} notification.show() setTimeout(() -> notification.cancel() - , 5000) + , 5e3) ### # Refreshes the room-list. ### From 792e09afa0a474ddc1097fec022ea83740d3a0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 30 Jan 2012 17:03:49 +0100 Subject: [PATCH 14/17] Given size-parameter for icon-tag --- file/js/TimWolla.WCF.Chat.coffee | 2 +- template/chat.tpl | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 6074ed3..4d67405 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -32,7 +32,7 @@ TimWolla.WCF ?= {} newMessage: $.Callbacks() userMenu: $.Callbacks() init: () -> - console.log('[TimWolla.WCF.Chat] Initializing'); + console.log '[TimWolla.WCF.Chat] Initializing' @bindEvents() @events.newMessage.add $.proxy @notify, @ diff --git a/template/chat.tpl b/template/chat.tpl index aabd9d0..029b447 100755 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -154,27 +154,27 @@ From 29c982e75f2394ede5f1b617452aff1b91e967b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 30 Jan 2012 17:05:35 +0100 Subject: [PATCH 15/17] Use WCF.Template.Compiled --- template/chat.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/template/chat.tpl b/template/chat.tpl index 029b447..ecb684a 100755 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -168,12 +168,12 @@
  • - + {lang}wcf.chat.clear{/lang}
  • - + {lang}wcf.chat.mark{/lang}
  • @@ -189,9 +189,9 @@ // Date: Mon, 30 Jan 2012 17:31:54 +0100 Subject: [PATCH 16/17] 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'}