flowerbox/lib/assets/javascripts/flowerbox.js.coffee

40 lines
854 B
CoffeeScript
Raw Normal View History

2012-03-13 17:21:32 +00:00
#= require_self
#= require flowerbox/result
#= require flowerbox/exception
#
2012-03-02 18:28:52 +00:00
Flowerbox =
debug: false
2012-03-13 17:21:32 +00:00
ping: ->
Flowerbox.contact('ping')
2012-03-15 15:57:35 +00:00
messageQueue: []
2012-03-02 18:28:52 +00:00
contact: (url, data...) ->
Flowerbox.started = true
2012-03-21 22:43:45 +00:00
if !Flowerbox.debug
message = [ url, data ]
Flowerbox.messageQueue.push(message)
Flowerbox.queuePuller() if Flowerbox.socket
2012-03-24 14:17:33 +00:00
2012-03-15 15:57:35 +00:00
started: false
done: false
queuePuller: ->
if Flowerbox.messageQueue.length > 0
message = Flowerbox.messageQueue.shift()
Flowerbox.socket.send JSON.stringify(message), {}, ->
if message[0] == 'results'
if __$instrument?
Flowerbox.socket.send JSON.stringify(['instrument', __$instrument]) {}, ->
Flowerbox.done = true
else
Flowerbox.done = true
Flowerbox.queuePuller()
2012-03-03 16:28:03 +00:00
fail: ->
2012-03-13 17:21:32 +00:00