Skip to content

Commit

Permalink
also handle page navs and still update data
Browse files Browse the repository at this point in the history
  • Loading branch information
albertkimjunior committed Jul 4, 2024
1 parent c1c6ac0 commit 51c91b0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions docs/v1/stars.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
window.addEventListener('load', function() {
function updateStars() {
fetch("https://api.github.com/repos/AgentOps-AI/agentops")
.then((response) => response.json())
.then((data) => {
const stars = Math.ceil(data.stargazers_count / 100) * 100 + 100;
const dataContainer = document.getElementById("stars-text");
dataContainer.innerHTML = `${stars.toLocaleString()}th`;

})
.catch((error) => {
console.error("Error:", error);
// console.error("Github Stars pull error:", error);
});
})
}

window.addEventListener('load', function() {
updateStars();
document.querySelectorAll('li, a').forEach(item => {
item.addEventListener('click', updateStars);
});
});

0 comments on commit 51c91b0

Please sign in to comment.