Skip to content

Commit b677331

Browse files
Cleanup
1 parent f31f143 commit b677331

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

public/script.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ function updateFullString() {
5858
const fieldValues = {};
5959
inputs.forEach(input => {
6060
if (input.name === 'githubhandle') {
61-
fieldValues[input.name] = input.value ? `@${input.value}` : '';
61+
fieldValues[input.name] = input.value ? `@${input.value}`.trim() : '';
6262
} else {
63-
fieldValues[input.name] = input.value;
63+
fieldValues[input.name] = input.value.trim();
6464
}
6565
});
6666

@@ -81,7 +81,7 @@ function generateQRCode() {
8181
const qr = qrcode(0, 'L');
8282
qr.addData(fullStringInput.value);
8383
qr.make();
84-
qrcodeContainer.innerHTML = qr.createImgTag(5);
84+
qrcodeContainer.innerHTML = qr.createImgTag(2); // Reduced scale factor to fit 100px
8585
}
8686

8787
// Debounce function to limit API calls
@@ -96,13 +96,20 @@ function debounce(func, delay) {
9696
// Function to fetch GitHub user data
9797
async function fetchGitHubUser(username) {
9898
try {
99-
const response = await fetch(`https://api.github.com/users/${username}`);
100-
if (!response.ok) throw new Error('User not found');
101-
return await response.json();
99+
if (username.startsWith('@')) {
100+
username = username.slice(1);
101+
}
102+
if (username)
103+
{
104+
const response = await fetch(`https://api.github.com/users/${username}`);
105+
if (!response.ok) throw new Error('User not found');
106+
return await response.json();
107+
}
108+
102109
} catch (error) {
103110
console.error('Error fetching GitHub user:', error);
104-
return null;
105111
}
112+
return null;
106113
}
107114

108115
// Add this helper function before updateFormWithGitHubData
@@ -138,9 +145,6 @@ githubHandleInput.addEventListener('blur', handleGitHubInput);
138145
// Modify the input event listeners to clean job titles
139146
inputs.forEach(input => {
140147
input.addEventListener('input', (e) => {
141-
if (e.target.id === 'jobtitle') {
142-
e.target.value = cleanJobTitle(e.target.value);
143-
}
144148
updateFullString();
145149
});
146150
});

0 commit comments

Comments
 (0)