-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexx.html
110 lines (96 loc) · 2.55 KB
/
indexx.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Repo Cards</title>
<style>
/* CSS untuk styling container dan card */
#repos {
display: flex;
flex-wrap: wrap;
gap: 16px;
padding: 10px;
justify-content: center;
}
.repo {
width: calc(50% - 16px); /* 2 kolom */
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
padding: 16px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.2s;
}
.repo:hover {
transform: scale(1.05); /* efek hover */
}
.repo h3 {
font-size: 1.25em;
margin-bottom: 8px;
}
.repo p {
font-size: 0.9em;
color: #555;
}
.repo small {
font-size: 0.8em;
color: #888;
}
/* Responsive: satu kolom di layar kecil */
@media (max-width: 600px) {
.repo {
width: 100%;
}
}
</style>
</head>
<body>
<div id="repos"></div>
<script>
const username = 'fatkhurrhn';
const repoContainer = document.getElementById('repos');
async function fetchAllRepositories() {
let page = 1;
let repos = [];
let fetchMore = true;
while (fetchMore) {
try {
const response = await fetch(`https://api.github.com/users/${username}/repos?page=${page}&per_page=100&sort=updated`);
const data = await response.json();
if (data.length === 0) {
fetchMore = false;
} else {
repos = repos.concat(data);
page++;
}
} catch (error) {
console.error('Fetch error:', error);
fetchMore = false;
}
}
return repos;
}
function displayRepositories(repos) {
repos.sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at));
repoContainer.innerHTML = '';
repos.forEach(repo => {
const repoElement = document.createElement('div');
repoElement.className = 'repo';
repoElement.innerHTML = `
<h3><a href="${repo.html_url}" target="_blank">${repo.name}</a></h3>
<p>${repo.description || 'No description'}</p>
<small>Updated at: ${new Date(repo.updated_at).toLocaleString()}</small>
`;
repoContainer.appendChild(repoElement);
});
}
async function loadRepositories() {
const repos = await fetchAllRepositories();
displayRepositories(repos);
}
loadRepositories();
setInterval(loadRepositories, 60000);
</script>
</body>
</html>