forked from dsjoerg/ggtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuploads.js
More file actions
40 lines (38 loc) · 1.21 KB
/
uploads.js
File metadata and controls
40 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
gg.directive('uploads', function() {
return {
restrict: 'E',
template: JST['angular/templates/uploads'](),
transclude: true,
replace: true,
controller: ['$scope', function($scope) {
// see fadey.js
$scope.clearItem = function(item) {
var idx = $scope.creplays.indexOf(item);
if (idx !== -1) {
//injected into repeater scope by fadey directive
this.destroy(function() {
$scope.$apply( function() {
$scope.creplays = _.without($scope.creplays, item);
});
});
}
};
$scope.$watch('creplays.length == 0', function(allgone) {
// console.log("All gone", allgone, $scope);
if (allgone) {
thehref = urlAfterUploading($scope.allreplays);
// console.log("would go to:", thehref);
if (_.isNull(thehref)) {
if (!_.isUndefined(gg.settings.user_id)) {
document.location.href = '/replays';
} else {
document.location.href = '/replay_problems';
}
} else {
document.location.href = thehref;
}
}
});
}]
}
});