update gitter for GitHub API v3

This commit is contained in:
Sami Samhuri 2012-06-12 22:10:24 -07:00
parent 174d6ddf7f
commit 950461cc79
3 changed files with 733 additions and 610 deletions

File diff suppressed because it is too large Load diff

View file

@ -57,9 +57,9 @@
function updateBranches(name, branches) {
function branchLink(b) {
return '<a href=https://github.com/samsonjs/' + name + '/tree/' + b + '>' + b + '</a>'
return '<a href=https://github.com/samsonjs/' + name + '/tree/' + b.name + '>' + b.name + '</a>'
}
html('branches', listify(Object.keys(branches).map(branchLink)))
html('branches', listify(branches.map(branchLink)))
}
function updateContributors(contributors) {
@ -82,8 +82,8 @@
if (!t || +new Date() - t > 3600 * 1000) {
console.log('stale ' + String(t))
data.set('t-' + name, +new Date())
GITR.repo('samsonjs/' + name)
.getBranches(function(err, branches) {
GITR.repo('samsonjs', name)
.fetchBranches(function(err, branches) {
if (err) {
text('branches', '(oops)')
} else {
@ -91,7 +91,7 @@
updateBranches(name, branches)
}
})
.getLanguages(function(err, langs) {
.fetchLanguages(function(err, langs) {
if (err) {
text('langs', '(oops)')
return
@ -99,7 +99,7 @@
data.set('langs', langs)
updateLangs(langs)
})
.getContributors(function(err, users) {
.fetchContributors(function(err, users) {
if (err) {
text('contributors', '(oops)')
} else {
@ -107,7 +107,7 @@
updateContributors(users)
}
})
.getWatchers(function(err, users) {
.fetchWatchers(function(err, users) {
if (err) {
text('nwatchers', '?')
} else {
@ -115,7 +115,7 @@
updateN('watchers', users)
}
})
.getNetwork(function(err, repos) {
.fetchForks(function(err, repos) {
if (err) {
text('nforks', '?')
} else {

View file

@ -40,12 +40,12 @@
</p>
<table align="center" id="stats">
<tr>
<td align="right"><span id="nrepos"><img src="../images/spinner@2x.gif" width="16" height="16"></span> projects</td>
<td align="right"><span id="npublicRepos"><img src="../images/spinner@2x.gif" width="16" height="16"></span> projects</td>
<td>&mdash;</td>
<td align="left"><span id="nfollowers"><img src="../images/spinner@2x.gif" width="16" height="16"></span> followers</td>
</tr>
<tr>
<td align="right">watching <span id="nwatched"><img src="../images/spinner@2x.gif" width="16" height="16"></span>
<td align="right"><span id="npublicGists"><img src="../images/spinner@2x.gif" width="16" height="16"> gists</span>
<td>&mdash;</td>
<td align="left">following <span id="nfollowing"><img src="../images/spinner@2x.gif" width="16" height="16"></span></td>
</tr>
@ -122,30 +122,32 @@ if (typeof console === 'undefined') {
document.getElementById(id).className = ' highlight'
}
function updateN(name, things) {
textHighlight('n' + name, things.length)
textHighlight('n' + name, things)
}
var data = createObjectStore('proj')
, t = data.get('t-proj')
, names = ['followers', 'following', 'repos', 'watched']
, user = GITR.user('samsonjs')
, names = ['followers', 'following', 'publicRepos', 'publicGists']
if (!t || +new Date() - t > 3600 * 1000) {
console.log('stale ' + String(t))
data.set('t-proj', +new Date())
names.forEach(function(name) {
GITR[name]('samsonjs', function(err, things) {
user.fetch(function(err, user) {
if (user) {
data.set('user', user)
}
names.forEach(function(name) {
if (err) {
text('n' + name, '?')
} else {
data.set(name, things)
updateN(name, things)
updateN(name, '?')
}
else {
updateN(name, user[name])
}
})
})
} else {
console.log('hit ' + t + ' (' + (+new Date() - t) + ')')
names.forEach(function(name) {
updateN(name, data.get(name))
})
names.forEach(function(name) { updateN(name, data.get('user')[name]) })
}
}
}())