Commit a74e06e9 authored by Danilo Woznica's avatar Danilo Woznica

feat(Github counter): Automate counter

parent e4c8a8bd
......@@ -16,8 +16,8 @@ version: 34
wpm: 160
# on GitHub project
stars: 16.4
forks: 3.5
stars: 17.8
forks: 3.8
# set default template for posts
defaults:
......
......@@ -97,7 +97,7 @@ layout: default
{% else %}
<span><img src="/images/default/star.svg" alt="GitHub Stars"></span>
{% endif %}
{{site.stars}}K
<span class="star-count">{{site.stars}}K</span>
</a>
<a class="app-footer_github" target="_blank" href="//github.com/RocketChat/Rocket.Chat/fork" rel="noopener noreferrer">
{% if page.theme == 'light' %}
......@@ -105,7 +105,7 @@ layout: default
{% else %}
<span><img src="/images/default/fork.svg" alt="GitHub forks"></span>
{% endif %}
{{site.forks}}K
<span class="fork-count">{{site.forks}}K</span>
</a>
<a class="app-footer_github-link" target="_blank" href="//github.com/RocketChat/Rocket.Chat" rel="noopener noreferrer">
{% if page.theme == 'light' %}
......
......@@ -80,11 +80,11 @@ redirect_from:
<p class="theme_type--grey">Join our community of 10 million users and chat to us on <a class="button--link" href="//open.rocket.chat/" target="_blank" rel="noopener noreferrer">open.rocket.chat</a></p>
<a class="home-community_github" target="_blank" rel="noopener noreferrer" href="//github.com/RocketChat/Rocket.Chat">
<span><img style="top: 0.1em;"src="/images/default/star.svg" alt="GitHub Stars">Star</span>
<span>{{site.stars}}K</span>
<span class="star-count">{{site.stars}}K</span>
</a>
<a class="home-community_github" target="_blank" rel="noopener noreferrer" href="//github.com/RocketChat/Rocket.Chat/fork">
<span><img src="/images/default/fork.svg" alt="GitHub forks">Fork</span>
<span>{{site.forks}}K</span>
<span class="fork-count">{{site.forks}}K</span>
</a>
<a class="home-community_github-link" target="_blank" rel="noopener noreferrer" href="//github.com/RocketChat/Rocket.Chat">
<span><img src="/images/default/github.svg" alt="GitHub"></span>
......
......@@ -304,4 +304,27 @@ if (document.querySelector(".js-download")) {
}
window.requestAnimationFrame(Animations);
}());
\ No newline at end of file
}());
(function () {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var data = JSON.parse(this.responseText);
var stars = Math.round( (data["stargazers_count"] / 1000) * 10 ) / 10;
var forks = Math.round( (data["forks_count"] / 1000) * 10 ) / 10;
var starsElements = document.getElementsByClassName("star-count")
var forksElements = document.getElementsByClassName("fork-count")
for (let i = 0; i < starsElements.length; i++) {
starsElements[i].innerHTML = stars + "k";
}
for (let i = 0; i < forksElements.length; i++) {
forksElements[i].innerHTML = forks + "k";
}
}
};
xhttp.open("GET", "https://api.github.com/repos/RocketChat/Rocket.Chat", true);
xhttp.send();
}())
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment