-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
166 lines (145 loc) · 5.92 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
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<body>
<div id="app" class="container">
<div>
<div class="form-group">
<br>
<div style="text-align: center">
<label for="username">GitHub Username</label>
</div>
<input class="form-control" placeholder="Enter the GitHub Username" id="username">
</div>
<div style="text-align: center">
<button id="submit" class="btn btn-primary">Get Details</button>
</div>
</div>
<br>
<div class="alert alert-danger" role="alert" id="Fill_Username" style="display: none">
<div style="text-align: center">
Fill Username
</div>
</div>
<div class="alert alert-danger" role="alert" id="Wrong_Username" style="display: none">
<div style="text-align: center">
Wrong Username
</div>
</div>
<div style="text-align: center">
<div class="spinner-border" role="status" id="loader" style="display: none">
</div>
</div>
<div id="information" style="display: none">
<div style="text-align: center">
<img :src="img" alt="profile" class="img-fluid rounded-circle">
</div>
<br>
<br>
<table class="table table-bordered">
<thead>
<tr>
<th>{{key}}</th>
<th>{{value}}</th>
</tr>
</thead>
<tbody>
<tr v-for="x in Object.keys(data)">
<td>{{x}}</td>
<td v-html="data[x]"></td>
</tr>
</tbody>
</table>
</div>
</div>
<script>
const myObject = new Vue({
el: '#information',
data: {
data: [],
img: "",
key: "Key",
value: "Value"
}
})
function add_more_data(username) {
$("#loader").css("display", "")
$.get(`https://api.github.com/users/${username}`, function(data){
console.log(data)
$("#Wrong_Username").css("display", "none")
myObject.$data.img = data['avatar_url'];
let final_data = {};
final_data['Name'] = data['name'];
final_data['HTML Url'] = `<a href="${data['html_url']}" target="_blank">See Profile</a>`;
const bio = data['bio'];
let final_bio = "";
let char = "";
for (char of bio.split(" ")){
if (char[0] === "@"){
final_bio = final_bio + `<a href="https://github.com/${char.slice(1)}" target="_blank">${char} </a>`;
} else{
final_bio = final_bio + char + " "
}
}
final_data['Bio'] = final_bio;
final_data['Number of Followers'] = String(data['followers']);
final_data['Following'] = String(data['following']);
final_data['Location'] = data['location'];
const hire_able = data['hireable'];
if (hire_able){
final_data['Can be hired'] = "Yep!" ;
}else {
final_data['Can be hired'] = "Nope";
}
final_data['Twitter Username'] = `<a href="https://twitter.com/${data['twitter_username']}" target="_blank">@${data['twitter_username']}</a>`;
final_data['Public Repos'] = String(data['public_repos']);
final_data['Public Gists'] = String(data['public_gists']);
final_data['Joined GitHub at'] = data['created_at'];
final_data['Last Account Update'] = data['updated_at'];
myObject.$data.data = final_data;
$("#loader").css("display", "none")
document.getElementById("information").style.display = "";
}).fail(function() {
console.log("Problem")
$('#Wrong_Username').css("display", "")
$("#loader").css("display", "none")
});
}
$("#submit").on("click", function (){
const username = $("#username").val();
if (username.replace(" ", "") === ""){
$("#Fill_Username").css("display", "")
$("#Wrong_Username").css("display", "none")
}else {
$("#Fill_Username").css("display", "none")
$("#Wrong_Username").css("display", "none")
add_more_data(username)
}
})
document.getElementsByTagName("html")[0].addEventListener("keydown", function(event){
const keycode = (event.keyCode ? event.keyCode : event.which);
console.log(keycode)
if (keycode === 191){
event.preventDefault();
document.getElementById("username").focus();
document.getElementById("username").value = "";
}
})
$('#username').keypress(function(event){
const keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
$("#submit").click();
}
});
</script>
</body>
</html>