function messageBox(speakerName) {
    var $container = $('<div></div>', {class:'message'});
    var $speaker = $('<span></span>', {class: 'message_speaker'});
    var $text = $('<span></span>', {class:'message_text'});
    
    $speaker.text(speakerName + ': ');   
    $container.prepend($text);
    $container.prepend($speaker);
    
    /**
     * Prepend the messageBox to the specified
     * element
     */
    var attach = function ($el) {
        $el.prepend($container);
    };
    
    
    /**
     * given a character, write it in the text container
     * of the messageBox.
     */
    var write = function (char) {
        $text.prepend(char);
    };
    
    return {
        attach: attach,
        write: write
    }
}
/**
 * A container for a speakerBox containing a message
 */
A container for a speakerBox containing a message
A container for a speakerBox containing a message
function messageBox(speakerName) {
    var $container = $('<div></div>', {class:'message'});
    var $speaker = $('<span></span>', {class: 'message_speaker'});
    var $text = $('<span></span>', {class:'message_text'});
    $speaker.text(speakerName + ': ');   
    $container.prepend($text);
    $container.prepend($speaker);
    var attach = function ($el) {
        $el.prepend($container);
    };
    var write = function (char) {
        $text.prepend(char);
    };
    return {
        attach: attach,
        write: write
    }
}
function messageBox ( speakerName ) { var $container = $ ( '<div></div>' , { class : 'message' } ) ; var $speaker = $ ( '<span></span>' , { class : 'message_speaker' } ) ; var $text = $ ( '<span></span>' , { class : 'message_text' } ) ; $speaker . text ( speakerName + ': ' ) ; $container . prepend ( $text ) ; $container . prepend ( $speaker ) ; var attach = function ( $el ) { $el . prepend ( $container ) ; } ; var write = function ( char ) { $text . prepend ( char ) ; } ; return { attach : attach , write : write } }
A container for a speakerBox containing a message
A container for a speakerBox containing a message
/**
     * Prepend the messageBox to the specified
     * element
     */ /**
     * given a character, write it in the text container
     * of the messageBox.
     */