Skip to content

Commit 804d6c4

Browse files
authored
Update script.js
1 parent c3a5f75 commit 804d6c4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

js/script.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
document.addEventListener("DOMContentLoaded", function () {
1+
document.addEventListener("DOMContentLoaded", function () {
22
const contributorsList = document.querySelector("#contributorsList");
33
const toggleContributorsLink = document.getElementById("toggleContributors");
44
const maxVisibleContributors = 5;
@@ -10,6 +10,7 @@ document.addEventListener("DOMContentLoaded", function () {
1010
function toggleContributors() {
1111
const isShowingAll = toggleContributorsLink.textContent === "View Less";
1212

13+
// Show or hide contributors based on the toggle state
1314
contributors.forEach((contributor, index) => {
1415
if (isShowingAll || index < maxVisibleContributors) {
1516
contributor.classList.remove("d-none");
@@ -18,17 +19,19 @@ document.addEventListener("DOMContentLoaded", function () {
1819
}
1920
});
2021

22+
// Toggle the link text based on the current state
2123
if (isShowingAll) {
2224
toggleContributorsLink.textContent = `+${totalContributors - maxVisibleContributors} more Contributors`;
2325
} else {
2426
toggleContributorsLink.textContent = "View Less";
2527
}
2628
}
2729

30+
// Click event for the "View More / View Less" link
2831
if (toggleContributorsLink) {
2932
toggleContributorsLink.addEventListener("click", function (e) {
3033
e.preventDefault();
31-
toggleContributors();
34+
toggleContributors(); // Toggle the contributors and text
3235
});
3336
}
3437
});

0 commit comments

Comments
 (0)