blob: 7dc1612aee8098b8a19f5fca6752cb625e153725 (
plain) (
blame)
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
|
angular.module('group').controller('groupFieldController', ['$scope', function groupFieldController($scope, $http) {
$scope.data = {id: 0, password: '', resolution: window.innerWidth + 'x' + window.innerHeight};
// Preselect the first location without a password
if ($scope.field && $scope.field.groups && Array.isArray($scope.field.groups)) {
for (let i in $scope.field.groups) {
let group = $scope.field.groups[i];
if (!group.password) $scope.data.id = group.id;
}
}
$scope.$watch('data', function(newValue) {
if (window.location.hash !== '#/') {
window.location.hash = '#/';
window.location.reload();
}
$scope.model = JSON.stringify(newValue);
}, true);
$scope.selectGroup = function selectGroup($event, id) {
if (angular.element($event.target).hasClass('bwlp-password-input')) return;
if ($scope.data.id !== id) $scope.data.password = '';
$scope.data.id = id;
};
$scope.submitGroup = function submitGroup($event, id) {
$scope.selectGroup($event, id);
angular.element($event.currentTarget.closest('form')).scope().login();
}
$scope.logout = function logout() {
window.localStorage.removeItem('GUAC_AUTH');
window.location.hash = '#/';
window.location.reload();
}
}]);
|