5-1-jquery.coffee 733 B

1234567891011121314151617181920212223242526272829
  1. # Based on the example in the jQuery Air course example.
  2. $("#tabs ul li a").bind
  3. click: changeTab
  4. mouseenter: showNumberOfFlights
  5. mouseleave: hideNumberOfFlights
  6. showFlights = (activeDiv) ->
  7. $("#tabs div").hide()
  8. if fetchingFlights
  9. fetchingFlights.abort()
  10. fetchingFlights = $.ajax '/flights',
  11. data:
  12. date: activeDiv
  13. cache: false
  14. error: (result) ->
  15. if result.statusText isnt "abort"
  16. $("#tabs #error").show()
  17. filteredFlights = []
  18. currentFlights.forEach (index, flight) ->
  19. if stops is '2+' or flight.routing is 0
  20. filteredFlights.push flight
  21. # Better, using a list comprehension
  22. filteredFlights = (flight for flight in currentFlights when stops is '2+' or flight.routing is 0)