Skip to content

Instantly share code, notes, and snippets.

@Jxck
Created September 24, 2011 07:01
Show Gist options
  • Save Jxck/1239063 to your computer and use it in GitHub Desktop.
Save Jxck/1239063 to your computer and use it in GitHub Desktop.
show repository status of modules listed on https://github.com/joyent/node/wiki/modules
for(var i=0;;){var today=new Date,a=$("div#template li a")[i],$a=$(a);i++;if(a.rel!=="nofollow"&&a.href.match(/^https:\/\/github.com\/.*/)&&!$a.html().match(/^<del>.*/)){var href=a.href;$.ajax({url:href,cache:!1,success:function(c){var b=$(c),c=b.find("div.authorship time.js-relative-date").text();today-new Date(c)<2592E6&&(c='<strong style="color:blue">'+c+"</strong>");b=b.find("ul.repo-stats");b=$(b);b.prepend($("<li>").html(c));b.find(".watchers a").text()>100&&b.find(".watchers a").wrap("<strong>").css("color",
"blue");b.find(".forks a").text()>20&&b.find(".forks a").wrap("<strong>").css("color","blue");c=this.url.split("?")[0];$('a[href="'+c+'"]').after(b)},error:function(){return!1}});if($a.text()==="node-clucene")break}};
var i = 0;
while (true) {
var today = new Date();
var a = $('div#template li a')[i];
var $a = $(a);
i++;
if (a.rel === 'nofollow') continue;
// not on github
if (!a.href.match(/^https:\/\/github.com\/.*/)) continue;
// <del>
if ($a.html().match(/^<del>.*/)) continue;
var href = a.href;
$.ajax({
url: href,
cache: false,
success: function(data) {
var $data = $(data);
var lastupdate = $data.find('div.authorship time.js-relative-date').text();
var date = new Date(lastupdate);
// if updated in last one month
if (today - date < 1000 * 60 * 60 * 24 * 30) {
lastupdate = '<strong style="color:blue">' + lastupdate + '</strong>';
}
var repo_stats = $data.find('ul.repo-stats');
var $repo_stats = $(repo_stats);
$repo_stats.prepend($('<li>').html(lastupdate));
// if more than 100 people watches this repo
if ($repo_stats.find('.watchers a').text() > 100) {
$repo_stats.find('.watchers a').wrap('<strong>').css('color', 'blue');
}
// if more than 20 people forks this repo
if ($repo_stats.find('.forks a').text() > 20) {
$repo_stats.find('.forks a').wrap('<strong>').css('color', 'blue');
}
var tar = this.url.split('?')[0];
$('a[href="' + tar + '"]').after($repo_stats);
},
error: function() {
return false;
}
});
// end
if ($a.text() === 'node-clucene') {
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment