Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show latest version in HTML
<!-- Put the Maven coordinates in your HTML: -->
<pre class="prettyprint">&lt;dependency&gt;
&lt;groupId&gt;com.github.jitpack&lt;/groupId&gt;
&lt;artifactId&gt;android-example&lt;/artifactId&gt;
&lt;version&gt;<span id="latest_release">1.0</span>&lt;/version&gt;
&lt;/dependency&gt; </pre>
<!-- Add this script to update "latest_release" span to latest version -->
<script>
var user = 'jitpack'; // Replace with your user/repo
var repo = 'maven-simple'
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myArr = JSON.parse(xmlhttp.responseText);
populateRelease(myArr);
}
}
xmlhttp.open("GET", "https://api.github.com/repos/" user + "/" + repo + "/releases", true);
xmlhttp.send();
function populateRelease(arr) {
var release = arr[0].tag_name;
document.getElementById("latest_release").innerHTML = release;
}
</script>
@like5188

This comment has been minimized.

like5188 commented Jun 5, 2017

1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment