Load contributors from GitHub API

This commit is contained in:
=
2012-07-12 10:56:18 -04:00
parent f662a0152d
commit 0e1b4505e3
2 changed files with 29 additions and 3 deletions

26
scripts/setup.js Normal file
View File

@@ -0,0 +1,26 @@
(function ($) {
// Load contributors
var $contributors = $('#contributors');
if ( $contributors.length ) {
var fail = function () {
$contributors.html('<p>This project would not be possible without the help of <a href="https://github.com/codeguy/php-the-right-way/graphs/contributors">our amazing contributors</a> on GitHub.</p>');
};
$.ajax({
cache: false,
dataType: 'jsonp',
timeout: 3000,
type: 'GET',
url: 'https://api.github.com/repos/codeguy/php-the-right-way/contributors'
}).done(function (data) {
if ( data.data && data.data.length ) {
var $ul = $('<ul></ul>'), dataLength = data.data.length;
for ( var i = 0; i < dataLength; i++ ) {
$ul.append(['<li><a href="https://github.com/', data.data[i].login, '" target="_blank">', data.data[i].login, '</a></li>'].join(''));
}
$contributors.html($ul);
} else {
fail();
}
}).fail(fail);
}
})(jQuery);