-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (32 loc) · 1.19 KB
/
Copy pathindex.js
File metadata and controls
37 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var app = angular.module('githubApp', []);
app.controller('ListController', ['$scope', function($scope) {
$scope.len = 0;
$scope.repos = []
$scope.submit = function(usr) {
var requrl = 'https://api.github.com/users/' + usr + '/repos';
$.ajax({
method: 'GET',
url: requrl,
success: function(repositories) {
$('.row-content').hide(200);
var usrVal = $('#username-input').val();
$scope.repos = repositories;
$scope.len = repositories.length;
$scope.usr = usr;
if ($scope.len == 0) {
$('#no-results').show(200);
} else if (usrVal === '') {
$('#invalid').show(200);
} else {
$('#results').show(200);
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log("Status code: " + jqXHR.status + " - " + errorThrown);
$('.row-content').hide(200);
$('#invalid').show(200);
},
async: false
})
};
}]);