Created
October 5, 2016 15:08
-
-
Save jefferythewind/307b544e7b43a4b785436620b414084a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> | |
</head> | |
<script type="text/javascript"> | |
jQuery(function($){ | |
$(document).ready(function () { | |
GetLatestReleaseInfo(); | |
}); | |
function GetLatestReleaseInfo() { | |
$.getJSON("https://api.github.com/repos/MrTheSoulz/NerdPack/releases/latest").done(function (release) { | |
var asset = release.assets[0]; | |
var downloadCount = 0; | |
for (var i = 0; i < release.assets.length; i++) { | |
downloadCount += release.assets[i].download_count; | |
} | |
var oneHour = 60 * 60 * 1000; | |
var oneDay = 24 * oneHour; | |
var dateDiff = new Date() - new Date(asset.updated_at); | |
var timeAgo; | |
if (dateDiff < oneDay) | |
{ | |
timeAgo = (dateDiff / oneHour).toFixed(1) + " hours ago"; | |
} | |
else | |
{ | |
timeAgo = (dateDiff / oneDay).toFixed(1) + " days ago"; | |
} | |
var releaseInfo = release.name + " was updated " + timeAgo + " and downloaded " + downloadCount.toLocaleString() + " times."; | |
$(".sharex-download").attr("href", asset.browser_download_url); | |
$(".release-info").text(releaseInfo); | |
$(".release-info").fadeIn("slow"); | |
}); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment