Skip to content

Instantly share code, notes, and snippets.

@koenbok
Created May 26, 2010 08:18
Show Gist options
  • Save koenbok/414208 to your computer and use it in GitHub Desktop.
Save koenbok/414208 to your computer and use it in GitHub Desktop.
var match = window.location.pathname.match(/([^/]+)\/([^/]+)\/commit\/([0-9a-f]{40,40})$/);
if (match == null)
console.log("Could not parse window name");
var user = match[1];
var repo = match[2];
var commit = match[3];
$.get("http://github.com/api/v2/json/commits/show/" + user + "/" + repo + "/" + commit, null, function(data) {
var filenames = data.commit.modified.map(function(x) { return x.filename })
$(filenames).each(function(i, filename) {
var file1 = "http://github.com/" + escape(user + "/" + repo + "/raw/" + data.commit.parents[0].id + "/" + filename);
var file2 = "http://github.com/" + escape(user + "/" + repo + "/raw/" + commit + "/" + filename);
var parameters = "url1=" + escape(file1) + "&url2=" + escape(file2);
var url = "kaleidoscope://compare?" + parameters;
(function(url) {
console.log(url);
setTimeout(function() { window.location.href = url; }, i * 50);
})(url);
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment