-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (30 loc) · 919 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
34
// init Github class
const github = new Github();
// init ui
const ui = new UI();
// Search for input
const searchUser = document.getElementById('searchUser');
// Search for user, using input text
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 js file
// prikazi poruku ako user nije pronadjen, poruku i klasa
ui.showAlert('User not found', 'alert alert-danger');
} else {
// Show github profile -> UI js file
ui.showProfile(data.profile);
// console.log(data.profile);
ui.showRepos(data.repos);
// console.log(data.repos);
}
});
} else {
// Clear profile when input text is empty
ui.clearProfile();
}
});