WebTask-GitHub Repos Via Github API

WebTask-GitHub Repos Via Github API

by Joy George Kunjikkuru

HTML

<link rel="stylesheet" href="http://jsfiddle.net/css/elusive-webfont.css">
<link rel="stylesheet" href="http://pother.ca/CssBase/css/base.css">
<link rel="stylesheet" href="http://pother.ca/embed-jsfiddle-result-on-potherca.css">
<h1>My Github Repos</h1>
<ul id="list"></ul>

JavaScript

var $List = $('#list'),
    sUser ='joymon',
    repo ='Karel',
    //sUrl = 'https://api.github.com/repos/' + sUser + '/' + repo;
    sUrl='https://wt-3783c5da15777937ad9cc34515b2989f-0.run.webtask.io/api/joymon/'+repo;
    //@TODO: Once there are more than a hundred repos for a user this needs to be resolved by parsing the "Link" HTTP header send with the response

console.log(sUrl);

$.ajax({
    dataType: "json",
    url: sUrl,
    success: function(p_oRepo, p_sStatus, p_oRequest){
        {
            var sHomepageLink='';
                if(p_oRepo.homepage){
                    sRepoName = '<a href="' + p_oRepo.homepage + '" target="_blank">' + p_oRepo.name  + '</a> '
                } else {
                    sRepoName = '<a title="Click the Github icon to visit this repo" target="_blank">' + p_oRepo.name  + '</a> '
                }                    
                $List.append(
                      '<li>' 
                        + ' <a href="' + p_oRepo.html_url + '" class="icon icon-github" target="_blank"></a>'
                        + sRepoName
                        + '<span class="description">' + p_oRepo.description + '</span>'
                    + '</li>'
                );
        };
    },
    error: function(p_oJqXHR, p_sStatus, p_sError){
        $List.append('<li class="error">' + p_sError + ': ' + p_sStatus + '</li>');
    }
});

/*EOF*/