Skip to content

Instantly share code, notes, and snippets.

@jadb
Created January 22, 2010 18:34
Show Gist options
  • Save jadb/284013 to your computer and use it in GitHub Desktop.
Save jadb/284013 to your computer and use it in GitHub Desktop.
/**
* GitTip for jQuery
*
* Originally inspired by:
* - TheChangelog [http://thechangelog.com]
*
* Requirements:
* - jQuery 1.3.2+ (http://jquery.com)
* - jQuery tipTip plugin (http://code.drewwilson.com/entry/tiptip-jquery-plugin)
*
* Usage example:
*
* $('body').gitTip();
*
* @copyright (c)2010, WDT Media Corp (http://wdtmedia.net)
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @link http://gist.github.com/gists/284013
* @author jadb
*/
(function($){
$.fn.gitTip = function(args) {
$.each($("a[href^=http://github.com]"), function() {
var link = $(this);
var url = link.attr('href');
var segments = url.split('/');
var repo = segments.pop();
var username = segments.pop();
$.getJSON("http://github.com/api/v2/json/repos/show/"+username+"/"+repo+"?callback=?", function(response, element){
var data = response.repository;
if(data) {
link.attr('title', "Forks: " + data.forks + " | Watchers: " + data.watchers).tipTip({delay:0});
}
});
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment