app.js
This file
Path
examples/chat/public/javascripts/app.js
28 lines · 686 bytes · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 3863a76 point at it.
Merge branch 'flash'visionmediabefore adoption3863a76
lines 1–28why, one step back12$(function(){3 // Send message4 $('form').submit(function(){5 var message = $('input[name=message]'),6 name = $('input[name=name]')7 if (message.val()) 8 $.post('/chat', { name: name.val(), message: message.val() }, function(){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})