1234567891011121314151617181920212223242526272829 |
- # Based on the example in the jQuery Air course example.
- $("#tabs ul li a").bind
- click: changeTab
- mouseenter: showNumberOfFlights
- mouseleave: hideNumberOfFlights
- showFlights = (activeDiv) ->
- $("#tabs div").hide()
- if fetchingFlights
- fetchingFlights.abort()
- fetchingFlights = $.ajax '/flights',
- data:
- date: activeDiv
- cache: false
- error: (result) ->
- if result.statusText isnt "abort"
- $("#tabs #error").show()
- filteredFlights = []
- currentFlights.forEach (index, flight) ->
- if stops is '2+' or flight.routing is 0
- filteredFlights.push flight
- # Better, using a list comprehension
- filteredFlights = (flight for flight in currentFlights when stops is '2+' or flight.routing is 0)
|