Skip to content

Commit

Permalink
Added download counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Rush authored and Ben Rush committed May 11, 2016
1 parent a9683f2 commit cc4b9a9
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen">
</head>
<body>
<body onload="getDownloadCount()">
<section class="page-header">
<h1 class="project-name">KeeChallenge</h1>
<h2 class="project-tagline">A plugin for KeePass2 to add Yubikey challenge-response capability.</h2>
Expand Down Expand Up @@ -49,8 +49,36 @@ <h3><a id="common-errors" class="anchor" href="#common-errors" aria-hidden="true
<footer class="site-footer">
<span class="site-footer-owner"><a href="https://github.com/brush701/keechallenge">KeeChallenge</a> is maintained by <a href="https://github.com/brush701">brush701</a>.</span>

<span class="site-footer-credits">This page is based on the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by Jason Long.</span>
<span class="site-footer-credits">
<p>This page is based on the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by Jason Long.</p>
<p id="DownloadCount"></p>
</span>

</footer>
</section>

<script>
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}

function getDownloadCount() {
httpGetAsync("https://api.github.com/repos/brush701/keechallenge/releases/latest",function(response) {
var release = JSON.parse(response);
for (i = 0; i < release.assets.length; i++) {
if(release.assets[i].content_type = "application/x-zip-compressed") {
document.getElementById("DownloadCount").innerHTML = release.assets[i].download_count + " downloads of " + release.assets[i].name;
}
}
});
}
</script>
</body>
</html>

0 comments on commit cc4b9a9

Please sign in to comment.