Skip to content

Commit d3b7a83

Browse files
committed
Remove look up table in js
1 parent a9061b4 commit d3b7a83

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

docs/js/github-profiles.js

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
// GitHub handles mapping for team members
2-
const GITHUB_PROFILES = {
3-
"Test": "test"
4-
// Add more team members here in the format "Full Name": "github-username"
5-
};
6-
7-
// Function to get GitHub username by person's name
8-
function getGitHubUsername(fullName) {
9-
return GITHUB_PROFILES[fullName] || null;
10-
}
11-
12-
// Export the functions and data for use in other scripts
13-
if (typeof module !== 'undefined') {
14-
module.exports = {
15-
GITHUB_PROFILES,
16-
getGitHubUsername
17-
};
18-
}
19-
201
// GitHub Profile Renderer - Site-wide version
212
document.addEventListener('DOMContentLoaded', function() {
223
// Process GitHub handles in any element
234
const processGitHubHandles = function() {
5+
// Special handling for table cells with GitHub handles
6+
const tableCells = document.querySelectorAll('td');
7+
tableCells.forEach(function(cell) {
8+
const text = cell.textContent.trim();
9+
// Check if it's likely a GitHub handle cell
10+
if (text.startsWith('@')) {
11+
const username = text.substring(1);
12+
if (username && username.length > 0) {
13+
// Replace cell content with a profile link
14+
cell.innerHTML = `<span class="github-handle" data-username="${username}">@${username}</span>`;
15+
}
16+
}
17+
});
18+
2419
// Find all text content that might contain GitHub handles
25-
// This includes paragraphs, list items, table cells, headings, etc.
26-
const elements = document.querySelectorAll('p, li, td, th, h1, h2, h3, h4, h5, h6, span, div');
20+
// This includes paragraphs, list items, headings, etc.
21+
const elements = document.querySelectorAll('p, li, h1, h2, h3, h4, h5, h6, span, div');
2722

2823
elements.forEach(function(element) {
2924
// Skip elements that are within profile cards (to avoid reprocessing)
@@ -59,13 +54,17 @@ document.addEventListener('DOMContentLoaded', function() {
5954
cardContainer.className = 'github-profile-card';
6055

6156
// Add loading indicator
62-
cardContainer.innerHTML = `<div class="loading">Loading ${username}'s profile...</div>`;
57+
cardContainer.innerHTML = `<div class="loading">Loading @${username}'s profile...</div>`;
6358

6459
// Insert card after the handle
6560
handle.parentNode.insertBefore(cardContainer, handle.nextSibling);
6661

67-
// Fetch GitHub profile data - add error handling for rate limits
68-
fetch(`https://api.github.com/users/${username}`)
62+
// Fetch GitHub profile data
63+
const headers = {
64+
'Accept': 'application/vnd.github.v3+json'
65+
};
66+
67+
fetch(`https://api.github.com/users/${username}`, { headers })
6968
.then(response => {
7069
if (response.status === 403) {
7170
// Likely a rate limit issue
@@ -77,16 +76,16 @@ document.addEventListener('DOMContentLoaded', function() {
7776
return response.json();
7877
})
7978
.then(data => {
80-
// Create profile card with GitHub data
79+
// Create profile card with GitHub data - just use handle if no name
8180
cardContainer.innerHTML = `
8281
<div class="profile-card">
8382
<div class="profile-image">
8483
<a href="${data.html_url}" target="_blank">
85-
<img src="${data.avatar_url}" alt="${username}'s avatar">
84+
<img src="${data.avatar_url}" alt="@${username}'s avatar">
8685
</a>
8786
</div>
8887
<div class="profile-info">
89-
<h4><a href="${data.html_url}" target="_blank">${data.name || username}</a></h4>
88+
<h4><a href="${data.html_url}" target="_blank">@${username}</a></h4>
9089
${data.bio ? `<p class="bio">${data.bio}</p>` : ''}
9190
</div>
9291
</div>

0 commit comments

Comments
 (0)