Guest User

Untitled

a guest
Oct 27th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require('zappa') ->
  2.   use 'bodyParser',
  3.     'methodOverride',
  4.     app.router,
  5.  
  6.   enable 'serve jquery'
  7.  
  8.   configure
  9.     development: -> use errorHandler: {dumpExceptions: on}
  10.     production: -> use 'errorHandler'
  11.  
  12.   view layout: ->
  13.     doctype 5
  14.     html ->
  15.       head ->
  16.         title 'nmedia - node.js media server'
  17.         script src: '/socket.io/socket.io.js'
  18.         script src: '/zappa/jquery.js'
  19.         script src: '/zappa/zappa.js'
  20.         script src: '/layout.js'
  21.       body ->
  22.         @body
  23.  
  24.   view index: ->
  25.     h1 @foo
  26.     input type: 'text', name: 'shout', id: 'shouthere'
  27.     ul id: 'msgs'
  28.  
  29.   get '/bar/:foo': ->
  30.     @foo += 'bar'
  31.     render 'index'
  32.  
  33.   client '/layout.js': ->
  34.     at shout: ->
  35.       $('#msgs').append("<li>#{@text}</li>")
  36.  
  37.     $('#shouthere').blur ->
  38.       emit("shout", { text: @value })
  39.       @value = ''
  40.  
  41.     alert 'Sweet!'
  42.  
  43.   at shout: ->
  44.     broadcast 'shout', {text: @text}
Add Comment
Please, Sign In to add comment