angular.module('sidewinder-app', ['ionic'])

.run(function($ionicPlatform) {
    $ionicPlatform.ready(function() {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        }
        if (window.StatusBar) {
            StatusBar.styleDefault();
        }
    });
})

.controller('StatusController', function($scope, GitHubRepo, RepoAssessor) {
    var repositories = [

        GitHubRepo('sidewinder-team', 'sidewinder-server'),
        GitHubRepo('sidewinder-team', 'sidewinder-ios'),
        GitHubRepo('greghaskins', 'sidewinder-app'),
        GitHubRepo('sidewinder-team', ' sidewinder-team.github.io'),

    ];
    $scope.repoStatuses = repositories.map(function(repo) {
        return {
            repo: repo,
            status: {
                state: 'pending',
            }
        }
    });
    $scope.refresh = function() {
        $scope.repoStatuses.forEach(function(repoStatus) {
            var repository = repoStatus.repo;
            RepoAssessor.assess(repository).then(function(assessment) {
                    repoStatus.status = assessment;
                },
                function(reason) {
                    console.error(reason);
                });

        });
    }
    $scope.refresh();

})

.factory('RepoAssessor', function($http, $q) {
    return {
        assess: function(repository) {
            var repo = repository.owner + "/" + repository.name;
            var url = "https://api.github.com/repos/" + repo + "/commits/master/status";

            var deferred = $q.defer();
            $http.get(url).success(function(data) {

                var state = data.state;
                if (state === 'pending' && data.statuses.length < 1) {
                    state = 'unknown';
                }
                deferred.resolve({
                    state: state,
                });

            }).error(function() {

                deferred.resolve({
                    state: 'unknown',
                });

            });

            return deferred.promise;
        }
    };
})

.factory('GitHubRepo', function() {
    function GitHubRepo(owner, name) {
        var repo = {
            owner: owner,
            name: name
        };
        Object.defineProperty(repo, 'fullName', {
            get: function() {
                return repo.owner + '/' + repo.name;
            },
        });
        return repo;
    };

    return GitHubRepo;
});

@@ -787,17 +787,16 @@
 team', '
- 
 sidewind
@@ -1542,73 +1542,8 @@
 ) %7B%0A
-            var repo = repository.owner + %22/%22 + repository.name;%0A
     
@@ -1598,16 +1598,31 @@
 %22 + repo
+sitory.fullName
  + %22/com

fix repo name typo