-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ExploShot
committed
Apr 11, 2021
1 parent
b2178a1
commit 097648e
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters