/*!
* jQuery Github Widgets
*
* Copyright 2012, Utensil
* https://github.com/utensil
*
* Released under the MIT licenses.
*
*/
!function(b){var p={createCaption:function(a){var t=a,e="https://www.github.com/"+t.login,p=e+"/repositories",s=e+"/followers",i=b("div.github-widget"),r=b('
'),n=b(''),d=b(''),l=b("").attr("href",e),o=b("
");o.attr("title",t.login),o.attr("alt",t.login),o.attr("src",t.avatar_url),l.append(o);var c=b(''),u=b("").attr("href",p),g=b("").text(t.public_repos),h=b(" public repos"),w=b(''),f=b("").attr("href",s),v=b("").text(t.followers),x=b(" followers");u.append(g).append(h),f.append(v).append(x),i.append(r.append(n.append(d.append(l)).append(c.append(u)).append(w.append(f))))},createReposList:function(a){var t=a;t=t.reverse();var e=b("div.github-widget"),p=b('');for(var s in t){var i=t[s],r=b(""),n=b("").text(i.name).attr("href",i.html_url),d=b("").append(n);i.fork&&d.addClass("fork-flag");var l=b(''),o=b('').text(i.language||""),c=b('').text(i.watchers).attr("href",i.html_url+"/watchers"),u=b("").append(c),g=b('').text(i.forks).attr("href",i.html_url+"/network"),h=b("").append(g);l.append(o).append(u).append(h);var w=b(''),f=b('').text(i.description),v=b('').text("Last updated: "+i.updated_at.replace("T"," ").replace("Z"," "));w.append(f).append(v),r.append(l).append(d).append(w),p.append(r)}e.append(p)}};b.fn.github_widget=function(t){var a={width:"95%","max-width":"450px",align:"center"},e=(t=b.extend(a,t),b("").addClass("github-widget"));return e.css({width:t.width,"max-width":t["max-width"],"margin-left":"left"==t.align?"5px":"auto","margin-right":"right"==t.align?"5px":"auto"}),this.append(e),b.ajax("https://api.github.com/users/"+t.user,{type:"get",dataType:"jsonp",crossDomain:!0,success:function(a){p.createCaption(a.data),b.ajax("https://api.github.com/users/"+t.user+"/repos",{type:"get",dataType:"jsonp",crossDomain:!0,success:function(a){p.createReposList(a.data)}})}}),this}}(jQuery);