                         </li>
                     """).appendTo container
                     message : message
+
+        #Reinitialize the scrollPane and scroll to its bottom
         do @scrollPane.reinitialise
         @scrollPane.scrollToPercentY 100, no
 

            @emitter.trigger 'chat.message', message

    newMessage : (event, message) =>
        message.time = do (new Date).getTime
        @messages.push message

    me : (user, data) =>

    constructor     : (emitter) ->
        super emitter

        #Define the Markdown interpretor
        @markdown     = new Showdown.converter { extensions : ['voicious'] }

        #Define accessor for DOM elements
        @content = ($ '#textChat')
        @content.messages = @content.find '#chatContent > ul'
        @content.form = @content.find 'form'
        @content.form.textarea = @content.form.find 'textarea'

        #Launch jScrollpane
        @scrollPane   = @content.messages.jScrollPane horizontalDragMaxWidth : 0
        @scrollPane   = @content.messages.data 'jsp'
        ($ window).resize () =>
            do @scrollPane.reinitialise

        #Define what's going on when and how the form is submitted
        @content.form.textarea.on 'keypress', (event) =>
            if event.keyCode is 13 and not event.shiftKey
                do event.preventDefault
                @content.form.trigger 'submit'
        @content.form.submit @submit

        #Initialize the message list and tis watcher
        (@messages = []).watch 'length', @update

        #Define chat's own commands
        @emitter.trigger 'cmd.register',
            name : 'me'
            callback : @me

        #Define event bindings
        @emitter.on 'chat.message', @newMessage
        @emitter.on 'peer.create', (event, data) =>
            @emitter.trigger 'chat.message', { text : "#{data.name} arrives in the room." }
        @emitter.on 'peer.remove', (event, data) =>
            @emitter.trigger 'chat.message', { text : "#{data.name} leaves the room. (#{data.reason})" }

    submit : (event) =>
        #Do not send the form
        do event.preventDefault
        #Translating line break to HTML <br />
        message = (do @content.form.textarea.val).replace /\n/g, '<br />'
        @content.form.textarea.val ''
        # We check if it's a command or a message
