forked from tjsnell/angularjs-githubapi-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
80 lines (67 loc) · 2.64 KB
/
index.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!doctype html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html">
<title>Github API Webapp using AngularJS - Not So Clever Demo</title>
<link rel="stylesheet" type="text/css" media="all" href="css/styles.css">
</head>
<body ng-controller="GitHubCtrl">
<div id="w">
<div>
<h1>Simple Github API Webapp</h1>
<p>Enter a single Github username below and click the button to display profile info.</p>
<input type="text" id="ghusername" ng-model="username" placeholder="Github username...">
<a href="#" id="ghsubmitbtn" ng-click="getGitInfo()">Pull User Data</a>
<div id="ghapidata" class="clearfix"></div>
</div>
<div ng-show="userNotFound">
<h2>No User Info Found</h2>
</div>
<div ng-show="loaded">
<h2> {{user.name}}
<span class="smallname">(@<a href="{{user.html_url}}" target="_blank"> {{user.login}} </a>)</span>
</h2>
<div class="ghcontent">
<div class="avi">
<a href="{{ user.html_url }}" target="_blank">
<img src="{{ user.avatar_url }}" width="80" height="80" alt="{{ user.login }}"></a>
</div>
Followers: {{ user.followers }} - Following: {{ user.following }}<br>Repos: {{ user.public_repos }}</p>
</div>
<div class="repolist clearfix">
<p ng-hide="reposFound">No repos!</p>
<div ng-show="reposFound">
<p><strong>Repos List:</strong></p>
<ul ng-repeat="repo in repos">
<li><a href="{{repo.html_url}}" target="_blank"> {{repo.name}} </a></li>
</ul>
</div>
</div>
</div>
<a href="http://code.notsoclever.cc/simple-github-api-webapp-angularjs-style/">http://code.notsoclever.cc/simple-github-api-webapp-angularjs-style/</a>
</div>
<script>
function GitHubCtrl($scope, $http) {
$scope.getGitInfo = function () {
$scope.userNotFound = false;
$scope.loaded = false;
$http.get("https://api.github.com/users/" + $scope.username)
.success(function (data) {
if (data.name == "") data.name = data.login;
$scope.user = data;
$scope.loaded = true;
})
.error(function () {
$scope.userNotFound = true;
});
$http.get("https://api.github.com/users/" + $scope.username + "/repos").success(function (data) {
$scope.repos = data;
$scope.reposFound = data.length > 0;
});
}
}
</script>
</body>
</html>