-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.js
121 lines (111 loc) · 4.56 KB
/
ui.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class Ui {
constructor() {
this.profileDiv = document.getElementById("profile");
this.repoDiv = document.getElementById("repos");
this.lastUsers = document.getElementById("last-users");
this.inputField = document.getElementById("githubname");
this.alert = document.getElementsByClassName("card-body");
}
clearInput() {
this.inputField.value = "";
}
showDiv(user) {
this.profileDiv.innerHTML = `
<div class="card card-body mb-3">
<div class="row">
<div class="col-md-4">
<a href="${user.html_url}" target = "_blank">
<img class="img-fluid mb-2" src="${user.avatar_url}"> </a>
<hr>
<div id="fullName"><strong> ${user.name}</strong></div>
<hr>
<div id="bio">${user.bio}</div>
</div>
<div class="col-md-8">
<button class="btn btn-secondary">
Takipçi <span class="badge badge-light">${user.followers}</span>
</button>
<button class="btn btn-info">
Takip Edilen <span class="badge badge-light">${user.following}</span>
</button>
<button class="btn btn-danger">
Repolar <span class="badge badge-light">${user.public_repos}</span>
</button>
<hr>
<li class="list-group">
<li class="list-group-item borderzero">
<img src="images/company.png" width="30px"> <span id="company">${user.company}</span>
</li>
<li class="list-group-item borderzero">
<img src="images/location.png" width="30px"> <span id = "location">${user.location}</a>
</li>
<li class="list-group-item borderzero">
<img src="images/mail.png" width="30px"> <span id="company">${user.email}</span>
</li>
</div>
</div>
</div>
`;
}
showRepo(user) {
this.repoDiv.innerHTML = "";
user.forEach(element => {
this.repoDiv.innerHTML += `
<div class="mb-2 card-body">
<div class="row">
<div class="col-md-2">
<a href="${element.html_url}" target = "_blank" id = "repoName">${element.name}</a>
</div>
<div class="col-md-6">
<button class="btn btn-secondary">
Starlar <span class="badge badge-light" id="repoStar">${element.stargazers_count}</span>
</button>
<button class="btn btn-info">
Forklar <span class="badge badge-light" id ="repoFork">${element.forks_count}</span>
</button>
<button class="btn btn-danger">
Detay <span class="badge badge-light" id ="repoDetay"></span>
</button>
</div>
</div>
</div>
`;
});
}
showAlert(alert, mesaage, classs) {
const div = document.createElement("div");
div.className = `alert alert-${alert}`;
div.textContent = `${mesaage}`;
classs.appendChild(div);
setTimeout(() => {
div.remove();
}, 2000);
}
addSearchedUserId(user) {
let users = Storage.getSearchedUsersFromStorage();
if (users.indexOf(user) === -1) {
lastUsers.innerHTML += `
<a href="" class="userID">
<li class="list-group-item" >${user}
<a href="#" class="delete-item" >
<i class="fa fa-remove" style="position:relative;float:right"></i>
</a>
</li>
</a>
`;
}
localStorage.setItem("search", JSON.stringify(users));
}
clearAllSearchedFromUı() {
while (this.lastUsers.firstElementChild !== null) {
this.lastUsers.removeChild(this.lastUsers.firstElementChild);
}
}
clearItem(e) {
if (e.target.className === "fa fa-remove") {
var selected = e.target.parentElement.parentElement.textContent.trim();
e.target.parentElement.parentElement.remove();
Storage.removeStorageItem(selected);
}
}
}