   WeatherProvider.setApiKey '$API_KEY'
   return
 ).config([
-  ''
-  () ->
-    .when('/',
+  '$routeProvider'
+  ($routeProvider) ->
+    $routeProvider.when('/',
       templateUrl: 'templates/home.html'
       controller: 'MainCtrl').when('/settings',
       templateUrl: 'templates/settings.html'
       controller: 'SettingsCtrl').otherwise redirectTo: '/'
     return
-]).directive('autoFill', (, Weather) ->
+]).directive('autoFill', ($timeout, Weather) ->
   {
     restrict: 'EA'
     scope:

          val = ele.val()
          if val.length < minKeyCount
            if timer
              .cancel timer
            scope.reslist = null
            return
          else
            if timer
              .cancel timer
            timer = ((->
              scope.autoFill()(val).then (data) ->
                if data and data.length > 0
                  scope.reslist = data

        # Hide the reslist on blur
        input.bind 'blur', (e) ->
          scope.reslist = null
          scope.$digest()
          return
        return

  }
).controller('MainCtrl', ($scope, $timeout, Weather, UserService) ->
  $scope.date = {}

  updateTime = ->
    $scope.date.tz = new Date((new Date).toLocaleString('en-US', timeZone: $scope.user.timezone))
    $timeout updateTime, 1000
    return

  $scope.weather = {}
  $scope.user = UserService.user
  Weather.getWeatherForecast($scope.user.location).then (data) ->
    $scope.weather.forecast = data
    return
  updateTime()
  return
).controller 'SettingsCtrl', ($scope, $location, Weather, UserService) ->
  $scope.user = UserService.user

  $scope.save = ->
    UserService.save()
    $location.path '/'
    return

  $scope.fetchCities = Weather.getCityDetails
  return

# ---
# generated by js2coffee 2.2.0
