-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithubproject.html
69 lines (67 loc) · 3.84 KB
/
githubproject.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Github Profile Finder</title>
<!-- CSS only -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<style>
img{
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<form id="userForm">
<div class="form-group">
<label >Github Username:</label>
<input type="text" id="username" class="form-control">
</div>
</form>
<div id="profile"></div>
</div>
<script>
function getProfile(e){
e.preventDefault();
var username =document.getElementById("username").value;
if(!username|| username=="null"){
username='kumarshubham01';
}
var xhttp= new XMLHttpRequest();
xhttp.onreadystatechange=function(){
if(xhttp.readyState==4 && xhttp.status==200){
var user =JSON.parse(xhttp.responseText);
document.getElementById('profile').innerHTML=`<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">${user.name}</h3>
</div>
<div class="panel-body">
<div class='row'>
<div class="col-md-3">
<img src=${user.avatar_url}"">
</div>
<div class="col-md-9">
<span class="label label-primary ">Public Repos ${user.public_repos}</span>
<span class="label label-danger">Gists ${user.public_gist}</span>
<br><br>
<ul class="list-group">
<li class="list-group-item">Website:${user.blog}</li>
<li class="list-group-item">Email:${user.email}</li>
</ul>
<a href="${user.html_url}" class="btn btn-default" target="_blank">Visit Github</a>
</div>
</div>
</div>`;
}
}
xhttp.open('GET','https://api.github.com/users/'+username,true);
xhttp.send();
}
document.getElementById("userForm").addEventListener("submit",getProfile,false);
</script>
</body>
</html>