WebHistoryView: Add a link to display changed images

This commit is contained in:
Pieter de Bie
2008-12-01 15:56:14 +01:00
parent 359346a2d3
commit 415ee91b50
2 changed files with 15 additions and 1 deletions
+1
View File
@@ -15,6 +15,7 @@
- (void) awakeFromNib
{
startFile = @"history";
repository = historyController.repository;
[super awakeFromNib];
[historyController addObserver:self forKeyPath:@"webCommit" options:0 context:@"ChangedCommit"];
}
+14 -1
View File
@@ -172,7 +172,20 @@ var showDiff = function() {
$("files").innerHTML += "<a href='#" + id + "'>" + name + "</a><br>";
}
highlightDiff(commit.diff, $("diff"), { "newfile" : newfile });
var binaryDiff = function(filename) {
if (filename.match(/\.(png|jpg|pdf|icns|psd)$/i))
return '<a href="#" onclick="return showImage(this, \'' + filename + '\')">Display image</a>';
else
return "Binary file differs";
}
highlightDiff(commit.diff, $("diff"), { "newfile" : newfile, "binaryFile" : binaryDiff });
}
var showImage = function(element, filename)
{
element.outerHTML = '<img src="GitX://' + commit.sha + '/' + filename + '">';
return false;
}
var loadExtendedCommit = function(commit)