-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (32 loc) · 1014 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
35
36
37
const nameinput = document.querySelector('.search-bar'),
profile = document.querySelector('#profile'),
github_btn= document.querySelector('.github-btn');
const github = new Github;
const ui = new UI;
loadEventListeners();
function loadEventListeners(){
nameinput.addEventListener("keyup",searchName);
}
github_btn.addEventListener("click",function(){
github_btn.style.backgroundColor = 'green';
github_btn.id = 1
github_btn.innerHTML = "Github Database Activated! Able To Locate Users Now!"
})
function searchName(){
if (nameinput.value !== ''){
github.getUser(nameinput.value)
.then(data => {
if(data.data.message !== "Not Found"){
ui.clearAlert();
ui.displayUser(data)
}
else{
ui.showAlert();
}
})
.catch(error => console.log(error))
}
else{
profile.innerHTML='';
}
}