Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let nextId = "depot";
- let nextStop = "";
- function depart() {
- $.ajax({
- method: 'GET',
- url: `https://judgetests.firebaseio.com/schedule/${nextId}/.json`,
- success: function (data) {
- console.log(data);
- $('#info span').text(`Next stop ${data.name}`);
- $('#depart').prop("disabled", true);
- $('#arrive').prop("disabled", false);
- nextId = data.next;
- nextStop = data.name;
- },
- error: function () {
- $('#info span').text(`Error`);
- $('#depart').prop("disabled", true);
- $('#arrive').prop("disabled", true);
- }
- });
- }
- function arrive() {
- $('#info span').text(`Arriving at ${nextStop}`);
- $('#depart').prop("disabled", false);
- $('#arrive').prop("disabled", true);
- }
- return {
- depart,
- arrive
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement