From 7bc525d5a14a19c4dbbe89e71516372a5190c4b3 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 4 Dec 2014 14:59:57 -0500 Subject: [PATCH] 3781: Deobfuscate. --- .../javascripts/upload_to_collection.js | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/apps/workbench/app/assets/javascripts/upload_to_collection.js b/apps/workbench/app/assets/javascripts/upload_to_collection.js index 67c1b98f6a..89c6c3dc16 100644 --- a/apps/workbench/app/assets/javascripts/upload_to_collection.js +++ b/apps/workbench/app/assets/javascripts/upload_to_collection.js @@ -23,13 +23,18 @@ function UploadToCollection($scope, $filter, $q, $timeout, // Angular binding doesn't work its usual magic for file // inputs, so we need to $scope.$apply() this update. $scope.$apply(function(){ - var i; - var insertAt; - for (insertAt=0; (insertAt<$scope.uploadQueue.length && - $scope.uploadQueue[insertAt].state !== 'Done'); - insertAt++); + var i, nItemsTodo; + // Add these new files after the items already waiting + // in the queue -- but before the items that are + // 'Done' and have therefore been pushed to the + // bottom. + for (nItemsTodo = 0; + (nItemsTodo < $scope.uploadQueue.length && + $scope.uploadQueue[nItemsTodo].state !== 'Done'); ) { + nItemsTodo++; + } for (i=0; i0) - $scope.uploadQueue.push.apply($scope.uploadQueue, $scope.uploadQueue.splice(0, i)); + // Are there any Done things at the top of the queue? + for (nItemsDone = 0; + (nItemsDone < $scope.uploadQueue.length && + $scope.uploadQueue[nItemsDone].state === 'Done'); ) { + nItemsDone++; + } + // If so, push them down to the bottom of the queue. + if (nItemsDone > 0) { + $scope.uploadQueue.push.apply( + $scope.uploadQueue, + $scope.uploadQueue.splice(0, nItemsDone)); + } // If anything is not-done, do it. if ($scope.uploadQueue.length > 0 && $scope.uploadQueue[0].state !== 'Done') { -- 2.30.2