Web-Applications-with-Node.js/NodeJs-Homeworks & Exams/TelerikNodeJs/socket.io/examples/chat/public/main.js
// Adds the visual chat message to the message list
Adds the visual chat message to the message list
Adds the visual chat message to the message list
function addChatMessage(data, options) {
        let $typingMessages = getTypingMessages(data);
        options = options || {};
        if ($typingMessages.length !== 0) {
            options.fade = false;
            $typingMessages.remove();
        }
        let $usernameDiv = $('<span class="username"/>')
            .text(data.username)
            .css('color', getUsernameColor(data.username));
        let $messageBodyDiv = $('<span class="messageBody">')
            .text(data.message);
        let typingClass = data.typing ? 'typing' : '';
        let $messageDiv = $('<li class="message"/>')
            .data('username', data.username)
            .addClass(typingClass)
            .append($usernameDiv, $messageBodyDiv);
        addMessageElement($messageDiv, options);
    }
function addChatMessage ( data , options ) { let $typingMessages = getTypingMessages ( data ) ; options = options || { } ; if ( $typingMessages . length !== 0 ) { options . fade = false ; $typingMessages . remove ( ) ; } let $usernameDiv = $ ( '<span class="username"/>' ) . text ( data . username ) . css ( 'color' , getUsernameColor ( data . username ) ) ; let $messageBodyDiv = $ ( '<span class="messageBody">' ) . text ( data . message ) ; let typingClass = data . typing ? 'typing' : '' ; let $messageDiv = $ ( '<li class="message"/>' ) . data ( 'username' , data . username ) . addClass ( typingClass ) . append ( $usernameDiv , $messageBodyDiv ) ; addMessageElement ( $messageDiv , options ) ; }
Adds the visual chat message to the message list
Adds the visual chat message to the message list
// Don't fade the message in if there is an 'X was typing'