Tuesday, January 24, 2017

A widget to list Github repositories.

<div id="github-activity"></div>
<script type="text/javascript">
window.renderGitHubWidget = function(github) {
    console.log(github)
    var html = '<div class="widget"><ul>';
    for (var i=0; i<github.data.length; i++) {
        var item = github.data[i];
        var url = item.html_url;
        if(item.fork) continue; 
        var repo = '<a href="' + url + '" target="_blank">' + item.name + '</a>';
        html += "<li>" + repo + " <br/>" + item.description+ "</li>"
    }
    html += '</ul></div>';
    var el = document.createElement('div');
    el.innerHTML = html;
    document.getElementById('github-activity').appendChild(el);
};
{
    var URL = 'https://api.github.com/users/simonwittber/repos?callback=renderGitHubWidget';
    var script = document.createElement('script');
    script.setAttribute('type', 'text/javascript');
    script.setAttribute('src', URL);
    document.head.appendChild(script);
}
</script>

No comments:

Popular Posts