Skip to content

Instantly share code, notes, and snippets.

@davidguttman
Created May 10, 2011 04:52
Show Gist options
  • Save davidguttman/963917 to your computer and use it in GitHub Desktop.
Save davidguttman/963917 to your computer and use it in GitHub Desktop.
TwitterChimes Part 2 - 01
#/public/js/script.coffee
# Let's create an empty object to store our stuff
TC = {}
# A method to setup our socket
TC.init_socket = ->
@socket = new io.Socket "localhost", port: 3010
@socket.on "message", @handle_message
@socket.connect()
# A method to handle our socket messages
TC.handle_message = (message) ->
# just to make sure it's still working
console.log message
# Ready, fire
$(document).ready ->
TC.init_socket()
# Our ajax button from last time
$('#track_button').click ->
track_words = $('#track_words').val()
$.get('/track?q=' + track_words)
return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment