-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (27 loc) · 828 Bytes
/
app.js
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
// init github
const github = new Github;
// init ui class
const ui = new UI;
// serarch input
const searchUser = document.getElementById('searchUser');
// search input event listener
searchUser.addEventListener('keyup', (e) => {
// get input text
const userText = e.target.value;
if (userText !== '') {
// make http call
github.getUser(userText)
.then(data => {
if (data.profile.message === 'Not Found') {
// show alert
ui.showalert('User Not Found', 'alert alert-danger');
} else {
// show profile
ui.showproifle(data.profile);
}
});
} else {
// clear profile
ui.clearProfile();
}
});