Skip to content

Instantly share code, notes, and snippets.

@LukasGasior1
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LukasGasior1/1de52db3ba21e527bb71 to your computer and use it in GitHub Desktop.
Save LukasGasior1/1de52db3ba21e527bb71 to your computer and use it in GitHub Desktop.
module.controller('StartGameController', function($scope, $rootScope, commandService) {
$scope.playersCount = 6;
$scope.loading = false;
$scope.hidePopoverTimeout = null;
$scope.startGame = function() {
$scope.loading = true;
commandService.startGame($scope.gameId, $scope.playersCount, function(data) {
$scope.loading = false;
if (data.message) {
if ($scope.hidePopoverTimeout != null) {
clearTimeout($scope.hidePopoverTimeout);
}
$('#start-game').popover({
content: data.message,
placement: 'left',
trigger: 'manual'
}).popover('show');
$scope.hidePopoverTimeout = setTimeout(function() {
$('#start-game').popover('hide');
}, 1500);
} else {
alert('Unexpected error occurred, try again later.');
}
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment