Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let nextId = 'depot';
- const btnDepart = $('#depart');
- const btnArrive = $('#arrive');
- let info = $('#info>span');
- let name;
- function startMoving(response) {
- name = response.name
- info.text(`Next stop ${name}`);
- nextId = response.next;
- btnDepart.attr('disabled', true);
- btnArrive.attr('disabled', false);
- }
- function depart() {
- $.ajax({
- method: 'GET',
- url: `https://judgetests.firebaseio.com/schedule/${nextId}.json`
- }).then(startMoving).catch();
- }
- function arrive() {
- info.text(`Arriving at ${name}`);
- btnDepart.attr('disabled', false);
- btnArrive.attr('disabled', true);
- }
- return {
- depart,
- arrive
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement