Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (67 sloc) 2.64 KB
<!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>