-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_repo.html
71 lines (64 loc) · 2.13 KB
/
user_repo.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>User Repo Page</title>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>
<style>
img {
height: 70px;
width: 70px;
}
</style>
</head>
<body>
<div class="container">
<div class="row p-5">
<!-- <button onclick="getUserRepoPromise()">Get Selected User Repos</button> -->
<h3 class="text-secondary">Below is/are the repos of requested user <small>(click on the repo name to explore it)</small></h3>
<table id='tbody' class="table table-bordered table-secondary table-striped text-center">
</table>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
// user repos api
var gitUserReposAPI = localStorage.user_repos;
// Onload calling getUserRepoPromise function to populate repos
window.onload(getUserRepoPromise())
// Populating selected user repos in table
function getUserRepoPromise(){
var user = gitUserReposAPI;
// console.log(user)
fetch(user)
.then(response=>response.json())
//
.then(response=>{
let noOfRepoLinks = response.length
if(noOfRepoLinks===0){
alert("No Repos found for requested user!!")
}
else{
for (var i=0; i<noOfRepoLinks; i++){
$('#tbody').append(
`
<tr>
<td>
<a href='${Object.values(response[i]['html_url']).join('')}'>${Object.values(response[i]['name']).join('')}</a>
</td>
<tr>
`
)
}
}})
}
</script>
</body>
</html>