/*! github-activity - v0.1.5 - Copyright 2015 Casey Scarborough */ function millisecondsToStr(a){"use strict";function b(a){return a>1?"s ago":" ago"}var c=Math.floor(a/1e3),d=Math.floor(c/31536e3);if(d)return d+" year"+b(d);var e=Math.floor((c%=31536e3)/2592e3);if(e)return e+" month"+b(e);var f=Math.floor((c%=2592e3)/86400);if(f)return f+" day"+b(f);var g=Math.floor((c%=86400)/3600);if(g)return"about "+g+" hour"+b(g);var h=Math.floor((c%=3600)/60);if(h)return h+" minute"+b(h);var i=c%60;return i?i+" second"+b(i):"just now"}function pluralize(a,b){return 1!==b?a+"s":a}function md5cycle(a,b){var c=a[0],d=a[1],e=a[2],f=a[3];c=ff(c,d,e,f,b[0],7,-680876936),f=ff(f,c,d,e,b[1],12,-389564586),e=ff(e,f,c,d,b[2],17,606105819),d=ff(d,e,f,c,b[3],22,-1044525330),c=ff(c,d,e,f,b[4],7,-176418897),f=ff(f,c,d,e,b[5],12,1200080426),e=ff(e,f,c,d,b[6],17,-1473231341),d=ff(d,e,f,c,b[7],22,-45705983),c=ff(c,d,e,f,b[8],7,1770035416),f=ff(f,c,d,e,b[9],12,-1958414417),e=ff(e,f,c,d,b[10],17,-42063),d=ff(d,e,f,c,b[11],22,-1990404162),c=ff(c,d,e,f,b[12],7,1804603682),f=ff(f,c,d,e,b[13],12,-40341101),e=ff(e,f,c,d,b[14],17,-1502002290),d=ff(d,e,f,c,b[15],22,1236535329),c=gg(c,d,e,f,b[1],5,-165796510),f=gg(f,c,d,e,b[6],9,-1069501632),e=gg(e,f,c,d,b[11],14,643717713),d=gg(d,e,f,c,b[0],20,-373897302),c=gg(c,d,e,f,b[5],5,-701558691),f=gg(f,c,d,e,b[10],9,38016083),e=gg(e,f,c,d,b[15],14,-660478335),d=gg(d,e,f,c,b[4],20,-405537848),c=gg(c,d,e,f,b[9],5,568446438),f=gg(f,c,d,e,b[14],9,-1019803690),e=gg(e,f,c,d,b[3],14,-187363961),d=gg(d,e,f,c,b[8],20,1163531501),c=gg(c,d,e,f,b[13],5,-1444681467),f=gg(f,c,d,e,b[2],9,-51403784),e=gg(e,f,c,d,b[7],14,1735328473),d=gg(d,e,f,c,b[12],20,-1926607734),c=hh(c,d,e,f,b[5],4,-378558),f=hh(f,c,d,e,b[8],11,-2022574463),e=hh(e,f,c,d,b[11],16,1839030562),d=hh(d,e,f,c,b[14],23,-35309556),c=hh(c,d,e,f,b[1],4,-1530992060),f=hh(f,c,d,e,b[4],11,1272893353),e=hh(e,f,c,d,b[7],16,-155497632),d=hh(d,e,f,c,b[10],23,-1094730640),c=hh(c,d,e,f,b[13],4,681279174),f=hh(f,c,d,e,b[0],11,-358537222),e=hh(e,f,c,d,b[3],16,-722521979),d=hh(d,e,f,c,b[6],23,76029189),c=hh(c,d,e,f,b[9],4,-640364487),f=hh(f,c,d,e,b[12],11,-421815835),e=hh(e,f,c,d,b[15],16,530742520),d=hh(d,e,f,c,b[2],23,-995338651),c=ii(c,d,e,f,b[0],6,-198630844),f=ii(f,c,d,e,b[7],10,1126891415),e=ii(e,f,c,d,b[14],15,-1416354905),d=ii(d,e,f,c,b[5],21,-57434055),c=ii(c,d,e,f,b[12],6,1700485571),f=ii(f,c,d,e,b[3],10,-1894986606),e=ii(e,f,c,d,b[10],15,-1051523),d=ii(d,e,f,c,b[1],21,-2054922799),c=ii(c,d,e,f,b[8],6,1873313359),f=ii(f,c,d,e,b[15],10,-30611744),e=ii(e,f,c,d,b[6],15,-1560198380),d=ii(d,e,f,c,b[13],21,1309151649),c=ii(c,d,e,f,b[4],6,-145523070),f=ii(f,c,d,e,b[11],10,-1120210379),e=ii(e,f,c,d,b[2],15,718787259),d=ii(d,e,f,c,b[9],21,-343485551),a[0]=add32(c,a[0]),a[1]=add32(d,a[1]),a[2]=add32(e,a[2]),a[3]=add32(f,a[3])}function cmn(a,b,c,d,e,f){return b=add32(add32(b,a),add32(d,f)),add32(b<>>32-e,c)}function ff(a,b,c,d,e,f,g){return cmn(b&c|~b&d,a,b,e,f,g)}function gg(a,b,c,d,e,f,g){return cmn(b&d|c&~d,a,b,e,f,g)}function hh(a,b,c,d,e,f,g){return cmn(b^c^d,a,b,e,f,g)}function ii(a,b,c,d,e,f,g){return cmn(c^(b|~d),a,b,e,f,g)}function md51(a){txt="";var b,c=a.length,d=[1732584193,-271733879,-1732584194,271733878];for(b=64;b<=a.length;b+=64)md5cycle(d,md5blk(a.substring(b-64,b)));a=a.substring(b-64);var e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(b=0;b>2]|=a.charCodeAt(b)<<(b%4<<3);if(e[b>>2]|=128<<(b%4<<3),b>55)for(md5cycle(d,e),b=0;16>b;b++)e[b]=0;return e[14]=8*c,md5cycle(d,e),d}function md5blk(a){var b,c=[];for(b=0;64>b;b+=4)c[b>>2]=a.charCodeAt(b)+(a.charCodeAt(b+1)<<8)+(a.charCodeAt(b+2)<<16)+(a.charCodeAt(b+3)<<24);return c}function rhex(a){for(var b="",c=0;4>c;c++)b+=hex_chr[a>>8*c+4&15]+hex_chr[a>>8*c&15];return b}function hex(a){for(var b=0;b>16)+(b>>16)+(c>>16);return d<<16|65535&c}var GitHubActivity=function(){"use strict";var a={},b={renderLink:function(a,b,c){return b||(b=a),"undefined"==typeof c&&(c=""),Mustache.render('{{{title}}}',{url:a,title:b})},renderGitHubLink:function(a,c,d){return c||(c=a),"undefined"==typeof d&&(d=""),b.renderLink("https://github.com/"+a,c,d)},getMessageFor:function(a){var c=a.payload;if(a.repoLink=b.renderGitHubLink(a.repo.name),a.userGravatar=Mustache.render('
',{url:a.actor.avatar_url}),c.ref&&(a.branch="refs/heads/"===c.ref.substring(0,11)?c.ref.substring(11):c.ref,a.branchLink=b.renderGitHubLink(a.repo.name+"/tree/"+a.branch,a.branch)+" at "),c.commits){var d=c.before+"..."+c.head,e=c.commits.length;2===e?a.commitsMessage=Mustache.render('View comparison for these 2 commits »',{repo:a.repo.name,shaDiff:d}):e>2&&(a.commitsMessage=Mustache.render('{{length}} more '+pluralize("commit",e-2)+" »",{repo:a.repo.name,shaDiff:d,length:c.size-2})),c.commits.forEach(function(d,e){return d.message.length>66&&(d.message=d.message.substring(0,66)+"..."),2>e?(d.shaLink=b.renderGitHubLink(a.repo.name+"/commit/"+d.sha,d.sha.substring(0,6),"gha-sha"),void(d.committerGravatar=Mustache.render('',{hash:md5(d.author.email)}))):(c.commits.splice(2,c.size),!1)})}if(c.issue){var f=a.repo.name+"#"+c.issue.number;a.issueLink=b.renderLink(c.issue.html_url,f),a.issueType="issue",c.issue.pull_request&&(a.issueType="pull request")}if(c.pull_request){var g=c.pull_request;if(a.pullRequestLink=b.renderLink(g.html_url,a.repo.name+"#"+g.number),a.mergeMessage="",c.pull_request.merged){c.action="merged";var h="{{c}} "+pluralize("commit",g.commits)+" with {{a}} "+pluralize("addition",g.additions)+" and {{d}} "+pluralize("deletion",g.deletions);a.mergeMessage=Mustache.render('
'+h+"",{c:g.commits,a:g.additions,d:g.deletions})}}if(c.comment&&c.comment.pull_request_url){var f=a.repo.name+"#"+c.comment.pull_request_url.split("/").pop();a.pullRequestLink=b.renderLink(c.comment.html_url,f)}if(c.comment&&c.comment.body&&(a.comment=c.comment.body,a.comment.length>150&&(a.comment=a.comment.substring(0,150)+"..."),c.comment.html_url&&c.comment.commit_id)){var f=a.repo.name+"@"+c.comment.commit_id.substring(0,10);a.commentLink=b.renderLink(c.comment.html_url,f)}if("ReleaseEvent"===a.type&&(a.tagLink=b.renderLink(c.release.html_url,c.release.tag_name),a.zipLink=b.renderLink(c.release.zipball_url,"Download Source Code (zip)")),"GollumEvent"===a.type){var i=c.pages[0];a.actionType=i.action,a.message=a.actionType.charAt(0).toUpperCase()+a.actionType.slice(1)+" ",a.message+=b.renderGitHubLink(i.html_url,i.title)}"FollowEvent"===a.type&&(a.targetLink=b.renderGitHubLink(c.target.login)),"ForkEvent"===a.type&&(a.forkLink=b.renderGitHubLink(c.forkee.full_name)),"MemberEvent"===a.type&&(a.memberLink=b.renderGitHubLink(c.member.login)),c.gist&&(a.actionType="fork"===c.action?c.action+"ed":c.action+"d",a.gistLink=b.renderLink(c.gist.html_url,"gist: "+c.gist.id));var j,h=Mustache.render(templates[a.type],a),k=millisecondsToStr(new Date-new Date(a.created_at));j="CreateEvent"==a.type&&["repository","branch","tag"].indexOf(c.ref_type)>=0?icons[a.type+"_"+c.ref_type]:icons[a.type];var l={message:h,icon:j,timeString:k,userLink:b.renderGitHubLink(a.actor.login)};return singleLineActivities.indexOf(a.type)>-1?Mustache.render(templates.SingleLineActivity,l):Mustache.render(templates.Activity,l)},getHeaderHTML:function(a){return a.name?a.userNameLink=b.renderLink(a.html_url,a.name):a.withoutName=" without-name",a.userLink=b.renderLink(a.html_url,a.login),a.gravatarLink=b.renderLink(a.html_url,''),Mustache.render(templates.UserHeader,a)},getActivityHTML:function(a,c){var d="",e=a.length;if(c&&c>e&&(c=e),c=c?c:e,0===c)return Mustache.render(templates.NoActivity,{});for(var f=0;c>f;f++)d+=b.getMessageFor(a[f]);return d},getOutputFromRequest:function(a,b){var c=new XMLHttpRequest;c.open("GET",a),c.setRequestHeader("Accept","application/vnd.github.v3+json"),c.onreadystatechange=function(){if(4===c.readyState)if(c.status>=200&&c.status<300){var d=JSON.parse(c.responseText);b(void 0,d)}else b("request for "+a+" yielded status "+c.status)},c.onerror=function(){b("An error occurred connecting to "+a)},c.send()},renderStream:function(a,b){b.innerHTML=Mustache.render(templates.Stream,{text:a,footer:templates.Footer}),b.style.position="relative"},writeOutput:function(a,c){var d="#"===a.charAt(0)?document.getElementById(a.substring(1)):document.getElementsByClassName(a.substring(1));if(d instanceof HTMLCollection)for(var e=0;e{{{text}}}
{{{footer}}}',Activity:'
{{{timeString}}}
{{{userLink}}} {{{message}}}
',SingleLineActivity:'
{{{timeString}}}
{{{userLink}}} {{{message}}}
',UserHeader:'
{{{userNameLink}}}

{{{userLink}}}

{{{gravatarLink}}}
',Footer:'