-
Notifications
You must be signed in to change notification settings - Fork 0
/
showoff.min.js
1 lines (1 loc) · 2.01 KB
/
showoff.min.js
1
var SHOWOFF={repos:null,div:null,inited:false,init:function(){$.ajaxSetup({cache:true});SHOWOFF.setStyles();SHOWOFF.inited=true},load:function(b,a){SHOWOFF.div=b;SHOWOFF.repos=a;if(!SHOWOFF.inited){SHOWOFF.init()}$("#"+b).hide();for(username in a){$.getScript("https://api.github.com/users/"+username+"/repos?callback=SHOWOFF.showRepos")}},setStyles:function(){var a=".repo { font-family: Helvetica,arial,freesans,clean,sans-serif; border: 1px solid; display: inline-block; border-color: #ccc #aaa #aaa #ccc; padding: 10px; margin: 5px; width: 350px; }.repo a { text-decoration: none; color: #4183C4; }.repo a.pname { font-size: 20px; font-weight: bold; }.repo a:hover { text-decoration: underline; }.repo div.lang { color: #666; font-size: 11px; font-weight: bold; }.repo div.lastupdate { font-size: 11px; color: #888; }.repo div.description { margin: 5px 0px 5px 0px; height: 36px; }.repo div.pull-right { float: right; }.repo img { float: left; width: 20px; height: 20px; margin-right: 5px; }";$("head").append('<style id="showoff-styles">'+a+"</style>")},showRepos:function(a){var c=a.data,b="";$.each(c,function(d,e){if(e.owner.login in SHOWOFF.repos&&$.inArray(e.name,SHOWOFF.repos[e.owner.login])!=-1){b+=SHOWOFF.buildHTML(e)}});document.getElementById(SHOWOFF.div).innerHTML+=b;$("span.timeago").timeago();$("#"+SHOWOFF.div).fadeIn()},truncate:function(b,a){return(b.length>a)?b.substring(0,a-3)+"...":b},buildHTML:function(b){var a=b.watchers+" Star"+(b.watchers==1?"":"s"),c=b.forks+" Fork"+(b.forks==1?"":"s");return'<div class="repo"><a href="https://github.com/'+b.owner.login+'" class="avatar"><img src="'+b.owner.avatar_url+'" /></a><div><a class="pname" href="'+b.html_url+'">'+b.name+'</a><div class="pull-right lang">'+b.language+' ● <a href="'+b.html_url+'/stargazers">'+a+'</a> ● <a href="'+b.html_url+'/network">'+c+'</a></div></div><div class="description">'+SHOWOFF.truncate(b.description,97)+'</div><div class="lastupdate">Last updated <span class="timeago" title="'+b.pushed_at+'">'+b.pushed_at+"</span></div></div>"}};