src/main/resources/static/application.js
/**
 * Web socket on message event handler. Removes the oldest message if the thread
 * is too long and appends the new message. Also scrolls to the bottom of the
 * thread.
 * 
 * @param event
 *            the event
 */
Web socket on message event handler. Removes the oldest message if the thread
is too long and appends the new message. Also scrolls to the bottom of the
thread.

@param event
the event
Web socket on message event handler . Removes the oldest message if the thread is too long and appends the new message . Also scrolls to the bottom of the thread . @param event the event
function webSocketOnMessage(event) {
    let message = JSON.parse(event.data);
    if ($(".message-thread").children().length >= 50) {
        $(".message-thread").find(".message").first().remove();
    }
    let $messageDiv = $(document.createElement("div"));
    $messageDiv.text(message.message);
    $messageDiv.addClass("message");
    if (message.messageType === "SYSTEM") {
        $messageDiv.addClass("system-message");
    }
    $(".message-thread").append($messageDiv);
    $(".message-thread").animate({
        scrollTop : $(".message-thread")[0].scrollHeight
    }, 200);
}
function webSocketOnMessage ( event ) { let message = JSON . parse ( event . data ) ; if ( $ ( ".message-thread" ) . children ( ) . length >= 50 ) { $ ( ".message-thread" ) . find ( ".message" ) . first ( ) . remove ( ) ; } let $messageDiv = $ ( document . createElement ( "div" ) ) ; $messageDiv . text ( message . message ) ; $messageDiv . addClass ( "message" ) ; if ( message . messageType === "SYSTEM" ) { $messageDiv . addClass ( "system-message" ) ; } $ ( ".message-thread" ) . append ( $messageDiv ) ; $ ( ".message-thread" ) . animate ( { scrollTop : $ ( ".message-thread" ) [ 0 ] . scrollHeight } , 200 ) ; }
Web socket on message event handler.
Web socket on message event handler .
// Remove the first message if the message thread is too long
 // Append the new message
 // Add an extra class if this is a system message
 // Scroll to the bottom of the thread
