Skip to content

Instantly share code, notes, and snippets.

/ya.js
Created Oct 8, 2016

Embed
What would you like to do?
//MODAL CONTROLLER
function PlayerReadyVerificationCtrl($scope, $rootScope, queueId, tournamentName, verificationDuration, $http, TOURNAMENT_API_ENDPOINT, tabService, SECONDARY_VIEWS, close) {
$scope.vm = {};
$scope.vm.close = close;
$scope.vm.queueId = queueId;
$scope.vm.tournamentName = tournamentName;
$scope.vm.verificationDuration = verificationDuration;
// Checks the player in.
$scope.vm.ready = function() {
$http.patch(TOURNAMENT_API_ENDPOINT + 'queues/verify/' + $scope.vm.queueId)
.then(success, error);
function success(result) {
// Communicate to anything listening for verification.
console.log("EMITTING READY!!!!!!");
$rootScope.$emit("player_verified", $scope.vm.queueId);
close();
}
function error(error) {
console.log(error);
close(error);
}
};
// Cancels the ready and removes the player.
$scope.vm.cancel = function() {
$http.patch(TOURNAMENT_API_ENDPOINT + 'queues/scheduled/' + $scope.vm.queueId)
.then(success, error);
function success(result) {
// Communicate to anything listening for canceled verification.
$rootScope.$emit("player_verification_canceled", $scope.vm.queueId);
close();
}
function error(error) {
console.log(error);
close(error);
}
};
}
})();
//VIEW
<h3 class="content_tournament_name">
{{vm.tournamentName}}
</h3>
<h3 class="content_verification_timer">
<timer countdown="vm.verificationDuration" interval="1000" finish-callback="vm.cancel()">
{{minutes}} minute{{minutesS}}, {{seconds}} second{{secondsS}}
</timer>
</h3>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.