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
diff --git a/tools/skpdiff/diff_viewer.js b/tools/skpdiff/diff_viewer.js
index 700bf4b..e7156b3 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 @@
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 @@
};
});
-function DiffListController($scope) {
+function DiffListController($scope, $http, $timeout) {
// Label each kind of differ for the sort buttons.
$scope.differs = [
{
@@ -100,4 +102,31 @@
$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);
+ });
+
+ };
}