Created
August 24, 2020 01:32
-
-
Save ahmetozer/ddae9fa259280e5437df57413504212a to your computer and use it in GitHub Desktop.
Embed Docker repositories to your page.
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> | |
<table> | |
<thead> | |
<tr> | |
<th scope="col">Name</th> | |
<th scope="col">Description</th> | |
<th scope="col">Last Update</th> | |
<th scope="col">Pull Count</th> | |
</tr> | |
</thead> | |
<tbody id="userContainers"> | |
</tbody> | |
</table> | |
<script> | |
function containerTableBuild(data) { | |
for (i in data.results) { | |
let tableHTML = '<tr>' | |
tableHTML += '<th scope="row" ><a href="https://hub.docker.com/r/'+data.results[i].user+'/'+data.results[i].name+'">'+data.results[i].name+'</th>' | |
tableHTML += '<td style="text-align: center">'+data.results[i].description+'</td>' | |
const date = new Date(Date.parse(data.results[i].last_updated)); | |
const dateTimeFormat = new Intl.DateTimeFormat('en', { year: 'numeric', month: 'short', day: '2-digit' }) | |
const [{ value: month },,{ value: day },,{ value: year }] = dateTimeFormat .formatToParts(date) | |
tableHTML += '<td style="text-align: center">'+`${day} ${month} ${year}`+'</td>' | |
tableHTML += '<td style="text-align: center">'+data.results[i].pull_count+'</td>' | |
tableHTML += '</tr>' | |
$("#userContainers").append(tableHTML) | |
} | |
} | |
$.ajax({ | |
url: "https://you-cors-proxy.example.com/https://hub.docker.com/v2/repositories/ahmetozer/?page_size=1000", | |
success: function (data) { | |
containerTableBuild(data) | |
}, | |
error: function (data) { | |
$("#userContainers").append("While getting container info, error occurred.\nLook developer console for more details.") | |
console.log(data) | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment