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