Skip to content

Commit c6773d8

Browse files
author
Bacon_Space
authored
Update Project.html
1 parent de3b7fa commit c6773d8

File tree

1 file changed

+105
-26
lines changed

1 file changed

+105
-26
lines changed

Project.html

Lines changed: 105 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>TheBaconSpace's Profile</title>
88
<!-- Include Bootstrap 5.3.0 CSS -->
9-
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
9+
<link href="https://bootswatch.com/5/quartz/bootstrap.min.css" rel="stylesheet">
1010
<!-- Include Font Awesome 6.4.2 CSS -->
1111
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
1212
<!-- Custom CSS for styling -->
@@ -16,7 +16,7 @@
1616
background-color: #f5f5f5;
1717
margin: 0;
1818
padding: 0;
19-
text-align: center;
19+
text-align: -webkit-center;
2020
}
2121

2222
header {
@@ -50,26 +50,6 @@
5050
text-align: center;
5151
padding: 10px 0;
5252
}
53-
54-
/* Adjusted styling for the repository cards */
55-
.card {
56-
width: 18rem;
57-
height: 25rem;
58-
margin: 15px;
59-
display: inline-block;
60-
vertical-align: top;
61-
}
62-
63-
.card-header {
64-
background-color: #007bff;
65-
color: #fff;
66-
font-weight: bold;
67-
}
68-
69-
.card-footer {
70-
background-color: #f8f9fa;
71-
color: #6c757d;
72-
}
7353
</style>
7454
</head>
7555

@@ -87,7 +67,7 @@ <h1>TheBaconSpace</h1>
8767
<h1>TheBaconSpace's Repositories</h1>
8868

8969
<!-- Placeholder for the list of repositories -->
90-
<div id="repo-cards">
70+
<div id="repo-cards" class="row">
9171
<!-- Repository cards will be dynamically added here using JavaScript -->
9272
</div>
9373
</div>
@@ -100,6 +80,31 @@ <h1>TheBaconSpace's Repositories</h1>
10080
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
10181
<!-- JavaScript to fetch and display GitHub repositories -->
10282
<script>
83+
// Function to generate a random color excluding unreadable colors and white
84+
function getRandomColor() {
85+
const letters = '0123456789ABCDEF';
86+
let color = '#';
87+
do {
88+
color = '#';
89+
for (let i = 0; i < 6; i++) {
90+
color += letters[Math.floor(Math.random() * 16)];
91+
}
92+
} while (isUnreadableColor(color) || color === '#FFFFFF'); // Exclude unreadable and white colors
93+
return color;
94+
}
95+
96+
// Function to check if a color is unreadable
97+
function isUnreadableColor(hexColor) {
98+
// Check if the color is too bright (light text on light background) or too dark (dark text on dark background)
99+
const rgb = parseInt(hexColor.substring(1), 16);
100+
const r = (rgb >> 16) & 0xff;
101+
const g = (rgb >> 8) & 0xff;
102+
const b = (rgb >> 0) & 0xff;
103+
104+
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
105+
return brightness > 200 || brightness < 50; // Modify these thresholds as needed
106+
}
107+
103108
// Function to fetch social links from the specified JSON file
104109
function fetchAndRenderSocialLinks() {
105110
fetch("https://thebaconspace.github.io/links.json")
@@ -129,14 +134,88 @@ <h1>TheBaconSpace's Repositories</h1>
129134
});
130135
}
131136

132-
// Your existing JavaScript code here
137+
// Function to fetch repositories from GitHub API and render cards
138+
function fetchAndRenderRepositories() {
139+
fetch('https://api.github.com/users/TheBaconSpace/repos')
140+
.then(response => response.json())
141+
.then(repos => {
142+
// Select the container for repository cards
143+
const repoCards = document.getElementById('repo-cards');
144+
145+
// Clear existing repository cards
146+
repoCards.innerHTML = '';
147+
148+
// Iterate through the repositories and create cards
149+
repos.forEach(repo => {
150+
// Create card element
151+
const card = document.createElement('div');
152+
card.classList.add('card', 'mb-3', 'col-md-6');
153+
154+
// Include card header template
155+
card.innerHTML = `
156+
<h3 class="card-header">${repo.name}</h3>
157+
<div class="card-body">
158+
<h5 class="card-title">${repo.description || `Plugin For Fivem Server Called TheBaconSpace`}</h5>
159+
<h6 class="card-subtitle text-muted"></h6>
160+
<ul class="list-group">
161+
<li class="list-group-item d-flex justify-content-between align-items-center">
162+
Stars
163+
<span class="badge bg-primary rounded-pill">${repo.stargazers_count}</span>
164+
</li>
165+
<li class="list-group-item d-flex justify-content-between align-items-center">
166+
Watchers
167+
<span class="badge bg-primary rounded-pill">${repo.watchers_count}</span>
168+
</li>
169+
<li class="list-group-item d-flex justify-content-between align-items-center">
170+
Forks
171+
<span class="badge bg-primary rounded-pill">${repo.forks_count}</span>
172+
</li>
173+
</ul>
174+
</div>
175+
<svg xmlns="http://www.w3.org/2000/svg" class="d-block user-select-none" width="100%" height="200"
176+
aria-label="${repo.name}" focusable="false" role="img" preserveAspectRatio="xMidYMid slice"
177+
viewBox="0 0 318 180" style="font-size:1.125rem;text-anchor:middle">
178+
<rect width="100%" height="100%" fill="${getRandomColor()}"></rect>
179+
<text x="50%" y="50%" fill="#dee2e6" dy=".3em">${repo.name}</text>
180+
</svg>
181+
<ul class="list-group list-group-flush">
182+
<li class="list-group-item">${repo.description || `Plugin For Fivem Server Called TheBaconSpace`}</li>
183+
</ul>
184+
<div class="card-body">
185+
<a href="${repo.html_url}" class="card-link">Link</a>
186+
</div>
187+
<div class="card-footer text-muted" id="repo-created-at-${repo.id}"></div>
188+
`;
189+
190+
// Format and set the created_at timestamp using Moment.js
191+
const createdTimestamp = moment(repo.created_at).fromNow();
192+
const createdAtElement = card.querySelector(`#repo-created-at-${repo.id}`);
193+
createdAtElement.textContent = `Created ${createdTimestamp}`;
194+
195+
// Append the card to the container
196+
repoCards.appendChild(card);
197+
});
198+
})
199+
.catch(error => console.error('Error fetching repositories:', error));
200+
}
133201

134-
// Fetch and render repositories initially
135-
fetchAndRenderRepositories();
202+
// Function to update the current year in the specified timezone
203+
function updateCurrentYear() {
204+
const currentYearElement = document.getElementById('current-year');
205+
const timezone = 'America/Toronto'; // Specify your desired timezone here
206+
const currentYear = new Date().toLocaleString('en-US', { timeZone: timezone, year: 'numeric' });
207+
currentYearElement.textContent = `${currentYear}`;
208+
}
136209

137210
// Fetch and render social links initially
138211
fetchAndRenderSocialLinks();
139212

213+
// Fetch and render repositories initially
214+
fetchAndRenderRepositories();
215+
216+
// Automatically refresh social links every 3 minutes (180,000 milliseconds)
217+
setInterval(fetchAndRenderSocialLinks, 3 * 60 * 1000); // 3 minutes in milliseconds
218+
140219
// Update the current year
141220
updateCurrentYear();
142221
</script>

0 commit comments

Comments
 (0)