'use strict';
app.controller('tokenDialogController', ['$scope', '$modalInstance', '$translate', 'token', function ($scope, $modalInstance, $translate, token) {

	$scope.token = token;
	$scope.message = null;

	$scope.copy = function () {
		$translate(['tkCopied', 'tkCannotCopy']).then(function (msgs) {
			document.getElementById('tokenTextarea').select();
			try {
				if (document.execCommand('copy')) {
					$scope.message = msgs.tkCopied;
				} else {
					$scope.message = msgs.tkCannotCopy;
				}
			} catch (e) {
				$scope.message = msgs.tkCannotCopy;
			}
		});
	};

	$scope.close = function () {
		$modalInstance.close();
	};

}]);
