-
Notifications
You must be signed in to change notification settings - Fork 25
/
main.js
68 lines (63 loc) · 2.03 KB
/
main.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
$(document).ready(function () {
// Load Contributers
function appendContributor(element) {
$("#contributor").append(`
<div class="col-sm-12 col-md-4 col-lg-3">
<div class="contributor-wrap">
<a href="${element.html_url}" target="_blank">
<img src="${
element.avatar_url
}" alt="" class="image-wrap">
<h6 class="name-wrap">${
element.name == null
? element.login
: res.name
}</h6>
</a>
</div>
</div>
`);
}
$.ajax({
url: "https://api.github.com/repos/Tharindu37/ProSolutions/contributors",
type: "GET",
dataType: "json", // added data type
success: function (res) {
if (res.length > 8) {
for (let i = 0; i < 8; i++) {
appendContributor(res[i]);
}
$("#btnShowMore").css("display", "block");
$("#btnShowMore").click(function () {
for (let i = 8; i < res.length; i++) {
appendContributor(res[i]);
}
$("#btnShowMore").css("display", "none");
});
} else {
res.forEach((element) => {
appendContributor(element);
});
}
},
});
});
// Scroll up arrow
let scrollArrow = document.getElementById("scrollArrow");
window.onscroll = function () {
showScrollArrow();
};
scrollArrow.onclick = function () {
scrollToTop();
};
function showScrollArrow() {
if (document.body.scrollTop > 30 || document.documentElement.scrollTop > 30) {
scrollArrow.style.display = "block";
} else {
scrollArrow.style.display = "none";
}
}
function scrollToTop() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}