aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skpdiff/diff_viewer.js
diff options
context:
space:
mode:
authorGravatar zachr@google.com <zachr@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-07 15:43:04 +0000
committerGravatar zachr@google.com <zachr@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-07 15:43:04 +0000
commit6f8e2c5e87bd6620ff5290a9a8b6d5b570366336 (patch)
tree0be8e8411705ba7bf2d1327a46785d30a4c81c1a /tools/skpdiff/diff_viewer.js
parent2865676b84ec77de7a8af34b0d919b29f8b1f836 (diff)
download and rebaseline images using server
BUG= R=epoger@google.com Review URL: https://codereview.chromium.org/20654006 git-svn-id: http://skia.googlecode.com/svn/trunk@10607 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/skpdiff/diff_viewer.js')
-rw-r--r--tools/skpdiff/diff_viewer.js37
1 files changed, 33 insertions, 4 deletions
diff --git a/tools/skpdiff/diff_viewer.js b/tools/skpdiff/diff_viewer.js
index 700bf4b0e4..e7156b359f 100644
--- a/tools/skpdiff/diff_viewer.js
+++ b/tools/skpdiff/diff_viewer.js
@@ -1,3 +1,5 @@
+var MAX_SWAP_IMG_SIZE = 400;
+
angular.module('diff_viewer', []).
config(['$routeProvider', function($routeProvider) {
// Show the list of differences by default
@@ -28,10 +30,10 @@ directive('swapImg', function() {
image = rightImage;
}
- // Make it so the maximum size of an image is 500, and the images are scaled
- // down in halves.
+ // Make it so the maximum size of an image is MAX_SWAP_IMG_SIZE, and the images are
+ // scaled down in halves.
var divisor = 1;
- while ((image.width / divisor) > 500) {
+ while ((image.width / divisor) > MAX_SWAP_IMG_SIZE) {
divisor *= 2;
}
@@ -74,7 +76,7 @@ directive('swapImg', function() {
};
});
-function DiffListController($scope) {
+function DiffListController($scope, $http, $timeout) {
// Label each kind of differ for the sort buttons.
$scope.differs = [
{
@@ -100,4 +102,31 @@ function DiffListController($scope) {
$scope.sortingDiffer = function(record) {
return record.diffs[$scope.sortIndex].result;
};
+
+ // Flash status indicators on the rows, and then remove them so the style can potentially be
+ // reapplied later.
+ $scope.flashRowStatus = function(success, record) {
+ var flashStyle = success ? "success-flash" : "failure-flash";
+ var flashDurationMillis = success ? 500 : 800;
+
+ // Store the style in the record. The row will pick up the style this way instead of through
+ // index because index can change with sort order.
+ record.cssClasses = flashStyle;
+
+ // The animation cannot be repeated unless the class is removed the element.
+ $timeout(function() {
+ record.cssClasses = "";
+ }, flashDurationMillis);
+ }
+
+ $scope.setHashOf = function(imagePath, record) {
+ $http.post("/set_hash", {
+ "path": imagePath
+ }).success(function(data) {
+ $scope.flashRowStatus(data.success, record);
+ }).error(function() {
+ $scope.flashRowStatus(false, record);
+ });
+
+ };
}