This repository was archived by the owner on Apr 16, 2023. It is now read-only.
forked from gfranko/GitHub-jQuery-Repo-Widget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.githubRepoWidget.js
More file actions
41 lines (40 loc) · 1.68 KB
/
jquery.githubRepoWidget.js
File metadata and controls
41 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
if(typeof window.App == 'undefined') window.App = new Object();
App.renderGitHubWidget = function(el) {
var $container = $(el);
var repo = $container.data('repo');
var id = $(el).attr('id');
var self = this;
$.ajax({
url: 'https://api.github.com/repos/' + repo,
dataType: 'jsonp',
context: self,
success: function(results){
var repo = results.data;
var date = new Date(repo.pushed_at);
var pushed_at = (date.getMonth()+1) + '-' + date.getDate() + '-' + date.getFullYear();
var $widget =
$('<div class="github-box repo"> \
<div class="github-box-title"> \
<h3> \
<a class="owner" href="' + repo.owner.url.replace('api.','').replace('users/','') + '">' + repo.owner.login + '</a> \
/ \
<a class="repo" href="' + repo.url.replace('api.','').replace('repos/','') + '">' + repo.name + '</a> \
</h3> \
<div class="github-stats"> \
<a class="watchers" href="' + repo.url.replace('api.','').replace('repos/','') + '/watchers">' + repo.watchers + '</a> \
<a class="forks" href="' + repo.url.replace('api.','').replace('repos/','') + '/forks">' + repo.forks + '</a> \
</div> \
</div> \
<div class="github-box-content"> \
<p class="description">' + repo.description + ' — <a href="' + repo.url.replace('api.','').replace('repos/','') + '#readme">Read More</a></p> \
<p class="link"><a href="' + repo.homepage + '">' + repo.homepage + '</a></p> \
</div> \
<div class="github-box-download"> \
<p class="updated">Latest commit to the <strong>master</strong> branch on ' + pushed_at + '</p> \
<a class="download" href="' + repo.url.replace('api.','').replace('repos/','') + '/zipball/master">Download as zip</a> \
</div> \
</div>');
$("#"+id).append($widget);
}
});
};