Permalink
Browse files

Live preview.

  • Loading branch information...
1 parent 806385a commit cd01069a5575010f95e1b5bac414ed82cc119e8b Avdi Grimm committed Mar 26, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 app/assets/javascripts/cow.js.coffee
@@ -0,0 +1,20 @@
+jQuery ($) ->
+ handleNewCowText = (text) ->
+ $('#cow-view').text(text)
+
+ updateCowText = ->
+ return unless $('#new_cow_message').data('changed')
+
+ message = $('#cow_message_message').val()
+ cowfile = $('#cow_message_cowfile').val()
+ params = {message, cowfile}
+ $.get '/cowsay', params, handleNewCowText, 'text'
+ $('#new_cow_message').data('changed', false)
+
+ $('#new_cow_message').change (event) ->
+ $('#new_cow_message').data('changed', true)
+
+ $('#new_cow_message').keyup (event) ->
+ $('#new_cow_message').data('changed', true)
+
+ setInterval(updateCowText, 1000)

0 comments on commit cd01069

Please sign in to comment.