-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
41 lines (31 loc) · 1.03 KB
/
main.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
35
36
37
38
39
40
41
// Instantiate github
const github = new Github;
// github.getProfile('mostafa')
// Instantiate ui
const ui = new UI;
document.getElementById('searchProfile').addEventListener('keyup', searchProfile);
function searchProfile(e) {
const searchText = e.target.value;
// Get profile data
// validation
if (searchText !== "") {
// Make http call
github.getProfile(searchText)
.then(data => {
if (data.mainData.message === 'Not Found') {
// Show alert message
ui.showAlert('Oops! User not found. Please try again.', 'alert alert-danger');
} else {
// Display basic profile
ui.paintProfile(data);
// console.log(data);
// Display repos data
ui.paintRepos(data.repos_data);
// console.log(data.repos_data);
}
})
} else {
// Clear Profile
ui.clearProfile();
}
}