{"size": 2004, "ext": "js", "max_stars_repo_path": "assets/javascript/check-out-profile.js", "max_stars_repo_name": "jpimentel45/LASafeParking", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assets/javascript/check-out-profile.js", "max_issues_repo_name": "jpimentel45/LASafeParking", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/javascript/check-out-profile.js", "max_forks_repo_name": "jpimentel45/LASafeParking", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 37.8113207547, "max_line_length": 121, "alphanum_fraction": 0.618762475}
var lotNumber = localStorage.getItem('lotNumber');
var licensePlateNumber = localStorage.getItem('checkoutLicensePlate');
$(document).ready(function () {
    var storageRef = firebase.storage();


    storageRef.ref('plateImages/' + lotNumber + '/' + licensePlateNumber + '.jpg').getDownloadURL().then(function (url) {


        // Or inserted into an <img> element:
        $('#plateImageUpload').html('<img id="imageUpload" src=' + url + ' />');
    }).catch(function (error) {
        // Handle any errors
    });


    // On click event...user clicks on check out button and is re-routed to check-out-confirm.html
    return firebase.database().ref('/' + lotNumber + '/' + licensePlateNumber).once('value').then(function (snapshot) {
        console.log(snapshot.val().license_plate_number);
        $("#name").text(snapshot.val().first_name + " " + snapshot.val().last_name);
        $("#plateAnswer").text(snapshot.val().license_plate_number);
        $("#makeAnswer").html(snapshot.val().car_make);

        $("#modelAnswer").text(snapshot.val().car_model);
        $("#dateAnswer").text(snapshot.val().Date);
        $("#timeAnswer").text(snapshot.val().Time);
        $("#driverId").text(snapshot.val().SafeStayID);
    });
});

$("#checkOutBtn").on("click", function () {

    var date = new Date();

    var time = new Date().toLocaleTimeString();
    var date = new Date().toLocaleDateString();

    var updates = {};

    updates['/' + lotNumber + '/' + licensePlateNumber + '/' + 'checked'] = "N/A";
    updates['/' + lotNumber + '/' + licensePlateNumber + '/' + 'Time'] = time;
    updates['/' + lotNumber + '/' + licensePlateNumber + '/' + 'Date'] = date;
    firebase.database().ref().update(updates);
    window.location.href = "./check-out-confirm.html";

});

// On click event listener for logout button to take you back to login page.
$("#logout").on("click", function logout() {
    firebase.auth().signOut();
    window.location.href = "./login.html"
    localStorage.clear();
});