Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  function solve() {
  2.         let nextId = "depot";
  3.         let nextStop = "";
  4.         function depart() {
  5.             $.ajax({
  6.                 method: 'GET',
  7.                 url: `https://judgetests.firebaseio.com/schedule/${nextId}/.json`,
  8.                 success: function (data) {
  9.                     console.log(data);
  10.                     $('#info span').text(`Next stop ${data.name}`);
  11.                     $('#depart').prop("disabled", true);
  12.                     $('#arrive').prop("disabled", false);
  13.                     nextId = data.next;
  14.                     nextStop = data.name;
  15.                 },
  16.                 error: function () {
  17.                     $('#info span').text(`Error`);
  18.                     $('#depart').prop("disabled", true);
  19.                     $('#arrive').prop("disabled", true);
  20.                 }
  21.             });
  22.         }
  23.  
  24.         function arrive() {
  25.             $('#info span').text(`Arriving at ${nextStop}`);
  26.             $('#depart').prop("disabled", false);
  27.             $('#arrive').prop("disabled", true);
  28.         }
  29.         return {
  30.             depart,
  31.             arrive
  32.         };
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement