Advertisement
Prohause

Bus Schedule

Jul 25th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. function solve() {
  2. let nextId = 'depot';
  3. const btnDepart = $('#depart');
  4. const btnArrive = $('#arrive');
  5. let info = $('#info>span');
  6. let name;
  7.  
  8. function startMoving(response) {
  9. name = response.name
  10. info.text(`Next stop ${name}`);
  11. nextId = response.next;
  12. btnDepart.attr('disabled', true);
  13. btnArrive.attr('disabled', false);
  14.  
  15. }
  16.  
  17. function depart() {
  18.  
  19. $.ajax({
  20. method: 'GET',
  21. url: `https://judgetests.firebaseio.com/schedule/${nextId}.json`
  22. }).then(startMoving).catch();
  23.  
  24.  
  25. }
  26.  
  27. function arrive() {
  28. info.text(`Arriving at ${name}`);
  29. btnDepart.attr('disabled', false);
  30. btnArrive.attr('disabled', true);
  31. }
  32.  
  33. return {
  34. depart,
  35. arrive
  36. };
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement