5-1-jquery.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Based on the example in the jQuery Air course example.
  2. var filteredFlights, flight, showFlights;
  3. $("#tabs ul li a").bind({
  4. click: changeTab,
  5. mouseenter: showNumberOfFlights,
  6. mouseleave: hideNumberOfFlights
  7. });
  8. showFlights = function(activeDiv) {
  9. var fetchingFlights;
  10. $("#tabs div").hide();
  11. if (fetchingFlights) {
  12. fetchingFlights.abort();
  13. }
  14. return fetchingFlights = $.ajax('/flights', {
  15. data: {
  16. date: activeDiv
  17. },
  18. cache: false,
  19. error: function(result) {
  20. if (result.statusText !== "abort") {
  21. return $("#tabs #error").show();
  22. }
  23. }
  24. });
  25. };
  26. filteredFlights = [];
  27. currentFlights.forEach(function(index, flight) {
  28. if (stops === '2+' || flight.routing === 0) {
  29. return filteredFlights.push(flight);
  30. }
  31. });
  32. // Better, using a list comprehension
  33. filteredFlights = (function() {
  34. var i, len, results;
  35. results = [];
  36. for (i = 0, len = currentFlights.length; i < len; i++) {
  37. flight = currentFlights[i];
  38. if (stops === '2+' || flight.routing === 0) {
  39. results.push(flight);
  40. }
  41. }
  42. return results;
  43. })();
  44. //# sourceMappingURL=5-1-jquery.js.map