examples/chatty/public/js/app.js
function sendMessage(e) {
        var txt = $('#msgtxt').val().trim();

        if(!txt) return;

        $('#messages').append(createMsgBox(txt));

        socket.emit('sendmsg', txt, function(evtJson) {
            var evt = JSON.parse(evtJson),
            reply = evt['Reply-Text'].split(' '), //0 = +OK, 1 = uuid
            $elm = $('#messages').children().last().removeClass('sending');

            if(reply[0] == '+OK')
                $elm.addClass('sent').data('uuid', reply[1]);
            else
                $elm.addClass('failed').data('error', evt['Reply-Text']);
        });

        $('#msgtxt').val('');
    }
function sendMessage(e) {
        var txt = $('#msgtxt').val().trim();

        if(!txt) return;

        $('#messages').append(createMsgBox(txt));

        socket.emit('sendmsg', txt, function(evtJson) {
            var evt = JSON.parse(evtJson),
            reply = evt['Reply-Text'].split(' '), //0 = +OK, 1 = uuid
            $elm = $('#messages').children().last().removeClass('sending');

            if(reply[0] == '+OK')
                $elm.addClass('sent').data('uuid', reply[1]);
            else
                $elm.addClass('failed').data('error', evt['Reply-Text']);
        });

        $('#msgtxt').val('');
    }
function sendMessage ( e ) { var txt = $ ( '#msgtxt' ) . val ( ) . trim ( ) ; if ( ! txt ) return ; $ ( '#messages' ) . append ( createMsgBox ( txt ) ) ; socket . emit ( 'sendmsg' , txt , function ( evtJson ) { var evt = JSON . parse ( evtJson ) , reply = evt [ 'Reply-Text' ] . split ( ' ' ) , //0 = +OK, 1 = uuid $elm = $ ( '#messages' ) . children ( ) . last ( ) . removeClass ( 'sending' ) ; if ( reply [ 0 ] == '+OK' ) $elm . addClass ( 'sent' ) . data ( 'uuid' , reply [ 1 ] ) ; else $elm . addClass ( 'failed' ) . data ( 'error' , evt [ 'Reply-Text' ] ) ; } ) ; $ ( '#msgtxt' ) . val ( '' ) ; }
send a text
send a text