Skip to content

Commit

Permalink
Auto get release Info test
Browse files Browse the repository at this point in the history
  • Loading branch information
ExploShot committed Apr 11, 2021
1 parent b2178a1 commit 097648e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
34 changes: 34 additions & 0 deletions get/getReleaseInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function getLatestReleaseInfo(releaseType) {
$.getJSON("https://api.github.com/repos/qwertycoin-org/qwertycoin-gui/releases/latest").done((data) => {
var downloadUrl;
var downloads;
var lastUpdate;
var assetName;
var releaseName = data.name;

for (asset in data.assets) {
if (asset.name.indexOf(releaseType) !== -1) {
downloadUrl = asset.browser_download_url;
downloads = asset.download_count;
lastUpdate = asset.updated_at;
assetName = asset.name
}
}

var hour = 60 * 60 * 1000;
var day = 24 * hour;
var timeDiff = new Date() - new Date(lastUpdate);
var timeAgo;

if (timeDiff < day) {
timeAgo = (timeDiff / hour).toFixed(1) + " hours ago";
} else {
timeAgo = (timeDiff / day).toFixed(1) + " days ago";
}

var relInfo = `${assetName} was updated ${timeAgo} and downloaded ${downloads} times`;
$(".download").attr("href", downloadUrl);
$(".release-info").text(relInfo);

})
}
5 changes: 5 additions & 0 deletions get/gui/latest/linux/rpm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<p>
<h1>Redirecting to: https://github.com/qwertycoin-org/qwertycoin-gui/releases/download/v6.0.2/qwertycoin-gui-v6.0.2-linux.rpm</h1>
</p>
<a class="download" href="https://github.com/qwertycoin-org/qwertycoin-gui/releases/latest">Download</a>
<p class="release-info"></p>

</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="../../../../getReleaseInfo.js"></script>
<script>getLatestReleaseInfo("rpm")</script>
</html>

0 comments on commit 097648e

Please sign in to comment.