-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
203 lines (183 loc) · 5.9 KB
/
index.html
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.css" />
<style>
.success, .error {
color: white;
padding: 5px;
margin: 5px 0 15px 0;
}
.success {
background: green;
}
.error {
background: red;
}
.card {
position: relative;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
}
.ueserProfile {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 20px;
}
.card-body {
-ms-flex: 1 1 auto;
flex: 1 1 auto;
padding: 1.25rem;
}
.nav {
background-color: green;
color: #fff;
font-size: 20px;
}
body{
margin: 0;
padding: 0;
background-color: ;
}
*{
padding: 0;
margin: 0;
}
.nav p {
margin: 0;
padding: 20px 0;
}
.mid {
text-align: center;
padding: 100px;
}
.cont {
border: 3px solid rebeccapurple;
margin: 50px 0;
padding: 20px;
}
.cont input {
width: 100%;
box-sizing: border-box;
}
@media only screen and (max-width: 780px){
.ueserProfile{
grid-template-columns: auto;
}
}
</style>
<title>Book List</title>
</head>
<body>
<div class="nav">
<div class="container">
<p>GitHub Finder</p>
</div>
</div>
<section>
<div class="container aalets">
<div class="cont">
<h1>Search GitHub User</h1>
<p>Enter user name to fetch a user profile nad repos</p>
<div class="searchArea">
<input id="search" type="text" placeholder=" Search Github User">
<button id="searchBtn" >search</button>
</div>
</div>
</div>
</section>
<section>
<div class="container">
<div class="ueserProfile">
</div>
</div>
</section>
<section>
<div class="container">
<div class="mid">
<p>GitHub Finder @</p>
</div>
</div>
</section>
<script>
// javascript opp call
class Ui{
constructor(){
this.User = document.querySelector('.ueserProfile');
}
userProfile(profile){
this.User.innerHTML += `
<div class="card">
<img class="card-img-top" src="${profile.avatar_url}" alt="Card image">
<div class="card-body">
<div>
<button><a href="${profile.url}">View Profile</a></button>
</div>
<h4 class="card-title">${profile.name}</h4>
<ul>
<li>User Company : ${profile.company}</li>
<li>User Blog : ${profile.blog}</li>
<li>User Location : ${profile.location}</li>
<li>User Email : ${profile.email}</li>
<li>Bio : ${profile.bio}</li>
<button>public repo:${profile.public_repos}</button>
<button>public gists:${profile.public_gists}</button>
<button>followers:${profile.followers}</button>
<button>following:${profile.following}</button>
</ul>
</div>
</div>
`;
}
showAlert(massage,alert){
let div = document.createElement('div');
div.className = alert;
let before = document.querySelector('.aalets');
let after = document.querySelector('.cont');
div.appendChild(document.createTextNode(massage));
before.insertBefore(div,after);
setTimeout(() => {
document.querySelector('.alert').remove();
},3000);
}
profileEmpty(){
this.User.innerHTML = '';
}
}
//get ing ui element
let searchBtn = document.querySelector('#searchBtn');
let search = document.querySelector('#search');
let ui = new Ui();
searchBtn.addEventListener('click', () => {
let searchValue = search.value;
if(searchValue != ""){
fetch(`https://api.github.com/users/${searchValue}`)
.then(res => res.json())
.then(data => {
if(data.message == 'Not Found'){
ui.showAlert('Not Found Try to Again','alert error');
ui.profileEmpty();
}else{
ui.userProfile(data);
ui.showAlert('successfully user profile search','alert success');
}
});
}else{
ui.showAlert('this is field empty try to Again','alert error');
ui.profileEmpty();
}
search.value = "";
});
</script>
</body>
</html>