Skip to content

Commit 02c61a2

Browse files
committed
Added repo support
1 parent 8239459 commit 02c61a2

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

repos.html

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
1111
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
1212
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
13+
<style>
14+
body {
15+
word-break: break-all;
16+
}
17+
</style>
1318
<body>
1419

1520
<div id="app" class="container">
@@ -44,24 +49,54 @@
4449
<div id="information">
4550
<ul class="list-group mx-auto mb-5">
4651
<li class="list-group-item" v-for="x in data">
47-
<p><strong>Repo:</strong>{{x['Repos']}}</p>
48-
<p><strong>Description:</strong>{{x['description']}}</p>
49-
<p><strong>URL:</strong> <a href="{{x['html_url']}}">{{x['html_url']}}</a></p>
52+
<p><strong>Repo:</strong> {{x['name']}}</p>
53+
<p><strong>Description:</strong> {{x['description']}}</p>
54+
<p><strong>URL:</strong> <a :href="x['html_url']" target="_blank">{{x['html_url']}}</a></p>
5055
</li>
5156
</ul>
52-
57+
<h3 style="text-align: center;display: none" id="no_more">
58+
No more repos
59+
</h3>
60+
<br>
5361
</div>
5462

5563

5664
</div>
5765

5866
<script>
5967
window.page = 0;
68+
window.username = undefined;
69+
window.max = false;
6070
function get_repos(username) {
61-
$.get(`https://api.github.com/users/${username}/repos?page=${window.page + 1}`, function(data){
71+
if (window.username === username){
6272
window.page += 1;
63-
console.log(data)
64-
$("#Wrong_Username").css("display", "none")
73+
if (window.max){
74+
75+
return ;
76+
}
77+
78+
}else {
79+
window.page = 0;
80+
window.username = username;
81+
window.max = false;
82+
}
83+
84+
$.get(`https://api.github.com/users/${username}/repos?page=${window.page + 1}`, function(data){
85+
console.log(data);
86+
87+
if (data.length === 0){
88+
$("#no_more").css("display", "");
89+
window.max = true;
90+
}else {
91+
$("#no_more").css("display", "none");
92+
}
93+
94+
if (window.page === 0){
95+
myObject.$data.data = data;
96+
}else {
97+
myObject.$data.data = myObject.$data.data.concat(data);
98+
}
99+
$("#Wrong_Username").css("display", "none");
65100
}).fail(function() {
66101
console.log("Problem")
67102
$('#Wrong_Username').css("display", "")
@@ -74,6 +109,17 @@
74109
data: [],
75110
}
76111
})
112+
113+
$(window).scroll(function() {
114+
if(Math.ceil($(window).scrollTop()) === Math.ceil(($(document).height() - $(window).height()))) {
115+
get_repos(window.username)
116+
}
117+
});
118+
119+
$('#submit').on("click", function (){
120+
const username = $("#username").val();
121+
get_repos(username)
122+
})
77123
</script>
78124

79125
</body>

0 commit comments

Comments
 (0)