blueintegral / WaitOrWalk

The information you really want when waiting at the bus stop: is it quicker to wait or to walk? Only works for Georgia Tech right now.
9 stars 3 forks source link

script.js is really confusing. #31

Closed darkzeroman closed 11 years ago

darkzeroman commented 11 years ago

Needs to be cleaned up. I'm kind of lost what's going on. I'm no expert in js though.

BUG: If buses are not running, the current functionality just doesn't even update the UI when it gets a response.

function getWeather(success, failure) {
    var now = new Date();
    // Only check weather if buses are operating
    // Buses operate M-F from 7 AM to 10 PM
    if (now.getDay() >= 1 && now.getDay() <= 5) {
        if (now.getHours() > 7 && now.getHours() < 22) {
            console.log("stuff");
            // Buses are operating
            $.ajax({
                url: "/weather"
            }).done(function(result) {
                return success(result);
            }).fail(function() {
                return failure();
            });
        }
    }
}

Notice that nothing happens when the current time is when the buses aren't running. Neither of the success or failure functions are called.