Create a gist now
Instantly share code, notes, and snippets.
HTTPS clone URL
Subversion checkout URL
A simple sinatra app which serves a /num_calls route returning the number of calls in queue, and some CoffeeScript which polls for this information and updates a span with the result every 5 seconds.
|updateNumCalls() # You should call this function when the user navigates|
|# to the queue page.|
|updateNumCalls = ->|
|# Get the number of calls.|
|$.getJSON('/num_calls').then (result) ->|
|$num_calls = $('#num_calls') # Fetch the element that contains the number.|
|if $num_calls.length # Make sure it still exists on the page.|
|$num_calls.html(result.num_calls) # And if so, update the element,|
|setTimeout updateNumCalls, 5000 # and queue up another query in 5 secs.|