-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
52 lines (32 loc) · 1.18 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const github = new Github();
const ui = new UI();
const githubForm = document.querySelector(".arabtn")
const nameInput = document.getElementById("githubname")
const ClearLastUsers = document.getElementById("clear-last-users")
const lastUsers = document.getElementById("last-users")
eventListeners();
function eventListeners() {
githubForm.addEventListener("click", getData);
ClearLastUsers.addEventListener("click", clearAllSearched);
document.addEventListener("DOMContentLoaded", getAllSearched);
}
function getData(e) {
e.preventDefault();
let username = nameInput.value.trim();
if (username === "") {
alert("Kullanici adi giriniz");
} else {
github.getGithubData(username)
.then(res => {
if (res.user.message === "Not Found") {
ui.showErrorMessage("Kullanıcı Bulunamadı Doğru Girdiğinizden Emin Olun.")
} else {
ui.ShowUserInfo(res.user);
ui.showRepoInfo(res.repo)
ui.showorgs(res.orgs)
}
})
.catch(err => console.log(ui.showErrorMessage(err)))
}
ui.clearInput();
}