Created
May 14, 2011 05:26
-
-
Save chrisberkhout/971942 to your computer and use it in GitHub Desktop.
Github's code for generating participation graphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ParticipationGraph.prototype = { | |
readData: function () { | |
var a = this.data.split("\n"); | |
this.allCommits = a[0] ? this.base64BytesToIntArray(a[0]) : ""; | |
this.ownerCommits = a[1] ? this.base64BytesToIntArray(a[1]) : "" | |
}, | |
// ... | |
base64ByteToInt: function (a) { | |
// This is known as modified Base64 for regexps: http://en.wikipedia.org/wiki/Base64#Regular_expressions | |
var d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!-"; | |
return d.indexOf(a) | |
}, | |
base64BytesToIntArray: function (a) { | |
for (var d = [], c, b = 0; b < a.length; b++) if (b % 2 == 0) c = 64 * this.base64ByteToInt(a.charAt(b)); | |
else { | |
c += this.base64ByteToInt(a.charAt(b)); | |
d.push(c) | |
} | |
return d | |
} | |
// ... | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment