-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
311 lines (260 loc) · 12 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GitHub Profile Explorer</title>
<link rel="icon" type="image/png" href="https://github.com/fluidicon.png"> <!-- GitHub Favicon -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<meta property="og:image" content="https://raw.githubusercontent.com/kamrullab/github/main/demo.jpg"> <!-- Replace with your actual image URL -->
<meta property="og:url" content="https://kamrullab.github.io/github/"> <!-- Replace with your actual website URL -->
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f8f9fa;
color: #333;
margin: 0;
padding: 0;
}
.header {
background-color: #24292e;
color: white;
padding: 15px;
text-align: center;
font-size: 2em;
}
.profile-section,
.org-section,
.user-repositories,
.org-repositories {
text-align: center;
padding: 20px;
margin: 20px;
}
.profile-image {
width: 150px;
border-radius: 50%;
margin-bottom: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
transition: transform 0.3s ease-in-out;
}
.profile-image:hover {
transform: scale(1.1);
}
.details-section {
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
margin-top: 20px;
}
.repository-list {
list-style: none;
padding: 0;
margin-top: 20px;
}
.repository-list-item {
margin: 10px 0;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease-in-out;
}
.repository-list-item:hover {
transform: scale(1.05);
}
.details-section p {
margin: 8px 0;
}
a {
color: #0366d6;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.section-title {
color: #24292e;
font-size: 1.5em;
margin-bottom: 15px;
}
.code-like {
font-family: 'Courier New', Courier, monospace;
color: green;
font-weight: bold;
}
.github-member-since {
color: red;
}
.location {
font-weight: normal;
}
.location-text {
color: green;
font-weight: bold;
}
#footer {
display: none;
text-align: center;
padding: 10px;
background-color: #24292e;
color: white;
}
#showDetailsBtn,
#showDetailsBtnFooter {
margin: 20px auto;
padding: 5px;
display: block;
}
</style>
</head>
<body>
<div class="header">
GitHub Profile Explorer
</div>
<div class="container">
<div class="row">
<div class="col-md-6 mx-auto profile-section" id="profileSection">
<h2 class="section-title">User Profile Details</h2>
</div>
</div>
<div class="row">
<div class="col-md-6 mx-auto user-repositories" id="userRepositories">
<h2 class="section-title">User Repositories</h2>
</div>
</div>
<div class="row">
<div class="col-md-6 mx-auto org-section" id="orgSection">
<h2 class="section-title">Organization Details</h2>
</div>
</div>
<div class="row">
<div class="col-md-6 mx-auto org-repositories" id="orgRepositories">
<h2 class="section-title">Organization Repositories</h2>
</div>
</div>
</div>
<button id="showDetailsBtn"> 😃 </button>
<div id="footer">
<p>
GitHub Profile Explorer<br>
Created by Kamrul Hossain<br>
<a href="https://github.com/kamrullab" target="_blank">GitHub</a><br>
<a href="https://m.me/elitekamrul" target="_blank">Facebook</a><br>
Version 0.1
</p>
<button id="showDetailsBtnFooter"> 😭 </button>
</div>
<script>
const username = 'kamrullab';
const orgName = 'google';
function createRedDateElement(dateString) {
const redDateElement = document.createElement('span');
redDateElement.textContent = new Date(dateString).toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
redDateElement.classList.add('github-member-since');
return redDateElement;
}
function createSection(container, data, isUser = true) {
const image = document.createElement('img');
image.src = data.avatar_url;
image.alt = `${isUser ? 'Profile' : 'Organization'} Image`;
image.className = 'profile-image img-fluid';
const nameElement = document.createElement('h1');
nameElement.textContent = data.name || data.login;
nameElement.classList.add('code-like');
const bioElement = document.createElement('p');
bioElement.textContent = data.bio !== null && data.bio !== undefined ? data.bio : `No ${
isUser ? 'user' : 'organization'
} bio available.`;
const locationElement = document.createElement('p');
locationElement.innerHTML = `Location: <span class="location-text">${data.location || 'Not specified.'}</span>`;
const websiteElement = document.createElement('p');
websiteElement.innerHTML = `Website: <a href="${data.blog || '#'}">${data.blog || 'Not specified.'}</a>`;
const createdAtElement = document.createElement('p');
createdAtElement.innerHTML = `<span style="color: black; font-weight: normal;">GitHub Member Since:</span> `;
createdAtElement.appendChild(createRedDateElement(data.created_at));
createdAtElement.classList.add('code-like');
const linkElement = document.createElement('a');
linkElement.href = data.html_url;
linkElement.textContent = `Visit GitHub ${isUser ? 'Profile' : 'Organization'}`;
const detailsContainer = document.createElement('div');
detailsContainer.className = 'details-section';
detailsContainer.appendChild(image);
detailsContainer.appendChild(nameElement);
detailsContainer.appendChild(bioElement);
detailsContainer.appendChild(locationElement);
detailsContainer.appendChild(websiteElement);
detailsContainer.appendChild(createdAtElement);
detailsContainer.appendChild(linkElement);
container.appendChild(detailsContainer);
}
function createRepositories(container, repos) {
repos.forEach(repo => {
const listItem = document.createElement('div');
listItem.className = 'repository-list-item';
listItem.innerHTML = `
<h3>${repo.name}</h3>
<p>${repo.description || 'No description available.'}</p>
<a href="${repo.html_url}" target="_blank">Visit Repository</a>
`;
container.appendChild(listItem);
});
}
Promise.all([
fetch(`https://api.github.com/users/${username}`).then(response => response.json()),
fetch(`https://api.github.com/orgs/${orgName}`).then(response => response.json()),
fetch(`https://api.github.com/users/${username}/repos`).then(response => response.json()),
fetch(`https://api.github.com/orgs/${orgName}/repos`).then(response => response.json())
])
.then(([userData, orgData, userReposData, orgReposData]) => {
createSection(document.getElementById('profileSection'), userData);
createRepositories(document.getElementById('userRepositories'), userReposData);
// Check if organization data is available
if (orgData.login) {
// Add GitHub organization information
const orgImage = document.createElement('img');
orgImage.src = orgData.avatar_url;
orgImage.alt = 'Organization Image';
orgImage.className = 'profile-image img-fluid';
const orgNameElement = document.createElement('h1');
orgNameElement.textContent = orgData.name || orgData.login;
orgNameElement.classList.add('code-like'); // Apply code-like styling
const orgDescription = document.createElement('p');
orgDescription.textContent = orgData.description !== null && orgData.description !== undefined ? orgData.description : `No organization bio available.`;
const orgLocationElement = document.createElement('p');
orgLocationElement.innerHTML = `Location: <span class="location-text">${orgData.location || 'Not specified.'}</span>`;
const orgContactElement = document.createElement('p');
orgContactElement.innerHTML = `Contact: <a href="mailto:${orgData.email || '#'}">${orgData.email || 'Not specified.'}</a>`;
const orgMemberSinceElement = document.createElement('p');
const orgMemberSinceDate = new Date(orgData.created_at);
orgMemberSinceElement.innerHTML = `<span style="color: black; font-weight: normal;">GitHub Member Since:</span> <span class="github-member-since">${orgMemberSinceDate.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}</span>`;
orgMemberSinceElement.classList.add('code-like'); // Apply code-like styling
const orgDetailsContainer = document.createElement('div');
orgDetailsContainer.className = 'details-section';
orgDetailsContainer.appendChild(orgImage);
orgDetailsContainer.appendChild(orgNameElement);
orgDetailsContainer.appendChild(orgDescription);
orgDetailsContainer.appendChild(orgLocationElement);
orgDetailsContainer.appendChild(orgContactElement);
orgDetailsContainer.appendChild(orgMemberSinceElement);
orgSection.appendChild(orgDetailsContainer);
}
createRepositories(document.getElementById('orgRepositories'), orgReposData);
})
.catch(error => console.error('Error fetching data:', error));
document.getElementById('showDetailsBtn').addEventListener('click', function () {
const footer = document.getElementById('footer');
footer.style.display = (footer.style.display === 'none' || footer.style.display === '') ? 'block' : 'none';
});
document.getElementById('showDetailsBtnFooter').addEventListener('click', function () {
const footer = document.getElementById('footer');
footer.style.display = (footer.style.display === 'none' || footer.style.display === '') ? 'block' : 'none';
});
</script>
</body>
</html>