-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.js
138 lines (98 loc) · 4.05 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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.cardBody = document.querySelector(".card-body");
}
clearInput(){
this.inputField.value = "";
}
showUserInfo(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="mail">${user.email}</span>
</li>
</div>
</div>
</div>
`;
}
showError(message) {
const div = document.createElement("div");
div.className = "alert alert-danger";
div.textContent = message;
this.cardBody.appendChild(div);
setTimeout(()=>{
div.remove();
},2000);
}
showRepoInfo(repos){
this.repoDiv.innerHTML = "";
repos.forEach(repo => {
this.repoDiv.innerHTML += `
<div class="mb-2 card-body">
<div class="row">
<div class="col-md-2">
<a href="${repo.html_url}" target = "_blank" id = "repoName">${repo.name}</a>
</div>
<div class="col-md-6">
<button class="btn btn-secondary">
Starlar <span class="badge badge-light" id="repoStar">${repo.stargazers_count}</span>
</button>
<button class="btn btn-info">
Forklar <span class="badge badge-light" id ="repoFork">${repo.forks_count}</span>
</button>
</div>
</div>
</div>
`;
});
}
addSearchedUserToUI(username) {
let users = Storage.getSearchedUsersFromStorage();
if (users.indexOf(username) === -1) {
// <li class="list-group-item">asdaskdjkasjkşdjşasjd</li>
const li = document.createElement("li");
li.className = "list-group-item";
li.textContent = username;
this.lastUsers.appendChild(li);
}
/*
*/
}
clearAllSearchedFromUI(){
while(this.lastUsers.firstElementChild !== null){
this.lastUsers.removeChild(this.lastUsers.firstElementChild);
}
}
}