-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.js
More file actions
73 lines (70 loc) · 2.57 KB
/
Copy pathui.js
File metadata and controls
73 lines (70 loc) · 2.57 KB
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
class UI {
showProfile(data) {
const userProfile = document.querySelector('.githubProfile'),
location = document.querySelector('.location'),
website = document.querySelector('.website'),
twitter = document.querySelector('.twitter'),
company = document.querySelector('.company'),
profileImageLink = document.querySelector('.profile-link');
userProfile.style.display = 'block';
document.querySelector('.followers').textContent =
data.profileData.followers;
document.querySelector('.repos').textContent =
data.profileData.public_repos;
document.querySelector('.following').textContent =
data.profileData.following;
document.querySelector('.profile-fullName').textContent =
data.profileData.name;
document.querySelector('.profileImage').src = data.profileData.avatar_url;
profileImageLink.href = `https://github.com/${data.profileData.login}`;
document.querySelector('.profile-userName').textContent =
data.profileData.login;
document.querySelector('.timeCreated').textContent = new Date(
data.profileData.created_at
).toLocaleDateString('en-US');
if (data.profileData.location !== null) {
location.textContent = data.profileData.location;
} else {
location.textContent = 'Not available';
}
if (data.profileData.blog !== '') {
website.textContent = data.profileData.blog;
website.href = data.profileData.blog;
} else {
website.textContent = 'Not available';
}
if (data.profileData.twitter_username !== null) {
twitter.textContent = data.profileData.twitter_username;
twitter.href = `https://twitter.com/${data.profileData.twitter_username}`;
} else {
twitter.textContent = 'Not available';
}
if (data.profileData.company !== null) {
company.textContent = data.profileData.company;
} else {
company.textContent = 'Not available';
}
}
clearProfile() {
const userProfile = document.querySelector('.githubProfile');
userProfile.style.display = 'none';
}
showAlert() {
this.clearAlert();
const div = document.createElement('div');
const input = document.querySelector('input[type="text"]');
const container = document.querySelector('.container');
div.className = 'alert';
div.appendChild(document.createTextNode('User not found'));
container.insertBefore(div, input);
setTimeout(() => {
this.clearAlert();
}, 2000);
}
clearAlert() {
const currentAlert = document.querySelector('.alert');
if (currentAlert) {
currentAlert.remove();
}
}
}