Skip to content
Myr

app.js

This file

Path

examples/chat/public/javascripts/app.js

28 lines · 686 bytes · JavaScript

Last changed by

More session workvisionmediabefore adoption047499d

History of this file

Take it

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption046bee8

lines 1–7why, one step back
1
2$(function(){3 // Send message4 $('form').submit(function(){5 var message = $('input[name=message]'),6 name = $('input[name=name]')7 if (message.val())

More session workvisionmediabefore adoption047499d

line 8why, one step back
8 $.post('/chat', { name: name.val(), message: message.val() }, function(){

Merge branch 'master' of git://github.com/visionmedia/expressciaranjbefore adoption046bee8

lines 9–28why, one step back
9 message.val('')
10 })11 else12 message.css('border', '1px solid red')13 return false14 })15 16 // Longpoll17 ;(function poll(){18 $.getJSON('/chat/messages', function(messages){19 $('#messages').empty()20 $.each(messages, function(i, msg){21 $('#messages')22 .append('<li>' + msg + '</li>')23 .get(0).scrollTop = $('#messages').get(0).scrollHeight24 })25 poll()26 })27 })()28})