forked from dsjoerg/ggtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatch.js
More file actions
84 lines (72 loc) · 2.63 KB
/
match.js
File metadata and controls
84 lines (72 loc) · 2.63 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
gg.controller('MatchController', ['$scope', '$window', '$route', '$location', '$element', 'Match',
function($scope, $window, $route, $location, $element, Match) {
mb = $.parseJSON(gon.matchblob);
// console.log("yoooo", mb);
$scope.subreddit = function() {
subreddit = 'starcraft_strategy';
if (gon.user) {
ident_in_match = $scope.match.hasPlayers(gon.user.accounts);
if (ident_in_match) {
entity = $scope.match.entity(ident_in_match);
if (entity != null) {
return 'allthings' + entity.race_name;
}
}
}
return subreddit;
}
$scope.reddit = function($event) {
$event.preventDefault()
newloc = 'http://www.reddit.com/r/' + $scope.subreddit() + '/submit?title=Your%20Title%20Here&text=Hi%2c%20take%20a%20look%20at%20' + encodeURIComponent(window.location);
window.open(newloc, '_blank');
}
$('.noarmy').hide();
if ($window.gon.match.replays_count > 0 && (!mb || _.isUndefined(mb.armies_by_frame))) {
$('.top').hide();
$('.noarmy').show();
}
matchhash = $.extend($window.gon.match, mb);
// console.log("gon fun", mb, matchhash);
$scope.match = new Match(matchhash);
$scope.match.__init();
$scope.selected = 'overview';
window.__match = $scope.match;
// bound and updated by armychart for hover selection
$scope.current_frame = 0;
$scope.current_framee = 0;
// console.log("matchscope", $scope);
$scope.$watch('current_frame', function(v) {
if(v) {
$scope.current_time = Sc2.frameToTime(v);
$scope.time_has_been_set = true
}
});
// Condensing the match view by default, except for 1v1
$scope.condensed = ($scope.match.game_type != '1v1');
// $scope.toggleCondensedCalled = _.once(function() { mixpanel.track("match toggleCondensed"); });
$scope.toggleCondensed = function() {
// $scope.toggleCondensedCalled();
$scope.condensed = !$scope.condensed;
}
$scope.delete = function() {
var r = confirm("Are you sure you want to delete this match?");
if (r == true) {
$.ajax({
url: '/matches/' + $scope.match.id + '/userdelete',
type: 'POST',
success: function() {
alert("Match deleted.");
$('.deletelink').text("deleted").off("click");
history.back();
},
error: function() {
alert("Sorry, this match could not be deleted for some reason. Please contact hello@ggtracker.com and they'll take care of it for you.");
}
});
}
}
$scope.spoiled = false;
$scope.spoil = function() {
$scope.spoiled = !$scope.spoiled;
}
}]);