-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
63 lines (59 loc) · 2.15 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
<!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>Github API Test</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
.raw {
height: 300px;
overflow-y: scroll;
}
</style>
</head>
<body>
<nav class="navbar navbar-light bg-light">
<div class="container">
<h1>Github API Test</h1>
</div>
</nav>
<div class="container">
<h2 class="mt-5">Get all my public repos</h2>
<div id="repos">Loading...</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
$(function () {
$.ajax({
type: "get",
url: "https://api.github.com/users/wayneyen/repos",
dataType: "json",
success: function (response) {
$('#repos').html('')
response.forEach((value, index, array) => {
const raw = JSON.stringify(value, null, 4)
const repoCard = `
<div class="card bg-light mt-4 repo-card" style="display: none;">
<h3 class="card-header">#${index + 1} ${value.name}</h3>
<div class="card-body">
<p>Description: ${value.description || '沒有描述'}</p>
<pre class="raw bg-white p-3 mt-3">${raw}</pre>
</div>
</div>`
$('#repos').append(repoCard)
var delay = 500
$('.repo-card').each(function(i) {
setTimeout(() => {
$(this).fadeIn('fast')
}, delay)
delay += 500
})
})
}
});
})
</script>
</body>
</html>