Nt1330 Unit 5 Functions Research Paper

865 Words4 Pages

function printFunction(stations_json) { console.log(stations_json); } /* * Displays the stations in the select tags */ function displayStations(stations_json) { if (stations_json == null) { alert("Error retrieving the stations!"); } else { $.each(stations_json, function(key, value) { $('#departure_stations') .append($("") .attr("value",key) .text(value)); $('#arrival_stations') .append($("") .attr("value",key) .text(value)); }); } } /* * userInfo closure to display the number of visits made by the user. */ function userInfo() { var countVisits = function (){ …show more content…

error: function(xml) { console.log("Could not get stations"); stations_json = null; printFunction(stations_json); displayStations(stations_json) } }); }; /* Internal function used to keep a note of the previous station origin location and start time and date */ var _setPrevLocAndTime = function (station_orig, station_dest, train_date, train_time) { prev_loc_time_values['start_lat'] = station_orig['lat']; prev_loc_time_values['start_lng'] = station_orig['lng']; prev_loc_time_values['dest_lat'] = station_dest['lat']; prev_loc_time_values['dest_lng'] = station_dest['lng']; prev_loc_time_values['start_date'] = train_date; prev_loc_time_values['start_time'] = train_time; }; /* It gets the details of all the trains from orig till dest along with the fare*/ var getTrainDetails = function (orig, dest) { var trains = []; $.ajax({ type: "GET", url: "http://api.bart.gov/api/sched.aspx?cmd=depart&orig="+orig+"&dest="+dest+"&date=now&key=MW9S-E7SL-26DU-VV8V&b=0&a=4&l=1", dataType:"xml", success: …show more content…

return {'getStations': getStations, 'getTrainDetails': getTrainDetails, 'show_error_msg': _show_error_msg, 'clearLiveTimer': clearLiveTimer, 'clearLiveTimerSection': clearLiveTimerSection}; } function bartGmapsAPI() { //var api_key = "AIzaSyCKsx7kjIMVtc1Sip_hl7haZD_PD71mk78"; /* Initialize the Google Map with the start and end values of the stations obtained used BART api */ function initMap(start_long_lat, end_long_lat) { var directionsService = new google.maps.DirectionsService; var directionsDisplay = new google.maps.DirectionsRenderer; var map = new google.maps.Map(document.getElementById('map'), { zoom: 7, center: {lat: 41.85, lng: -87.65} }); directionsDisplay.setMap(map); calculateAndDisplayRoute(directionsService, directionsDisplay, start_long_lat, end_long_lat); } /* Display the Google Map with the route highlighted from the start station to the destination station */ function calculateAndDisplayRoute(directionsService, directionsDisplay, origin_latlng, destination_latlng) {

More about Nt1330 Unit 5 Functions Research Paper