-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathauth.js
More file actions
85 lines (70 loc) · 2.11 KB
/
auth.js
File metadata and controls
85 lines (70 loc) · 2.11 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
84
85
(function() {
'use strict';
angular.module('botConfApp')
.controller('AuthCtrl', AuthCtrl);
AuthCtrl.$inject = ['$scope', 'NgMap'];
/**
* @ngdoc function
* @name botConfApp.controller:AuthCtrl
* @description
* # AuthCtrl
* Controller of the botConfApp
*/
function AuthCtrl($scope, NgMap) {
var vm = this;
vm.updateActiveLocationCoords = updateActiveLocationCoords;
vm.updateActiveLocationName = updateActiveLocationName;
vm.setActiveLocation = setActiveLocation;
vm.addLocation = addLocation;
vm.removeLocation = removeLocation;
init();
function init() {
NgMap.getMap().then(function(map) {
vm.map = map;
});
vm.setActiveLocation(0);
}
function updateMap(coords) {
vm.mapLocation = coords;
};
function updateLocation(location) {
$scope.config.location = location;
};
function updateActiveLocationCoords(e) {
var coords;
if (typeof e === 'number') {
if (e === vm.activeLocation) {
coords = $scope.config.favorite_locations[e].coords;
}
} else {
coords = e.latLng.lat() + ',' + e.latLng.lng();
}
$scope.config.favorite_locations[vm.activeLocation].coords = coords;
updateMap(coords);
};
function updateActiveLocationName(i) {
if (i === vm.activeLocation) {
updateLocation($scope.config.favorite_locations[i].name);
}
};
function setActiveLocation(i) {
var location = $scope.config.favorite_locations[i];
vm.activeLocation = i;
updateMap(location.coords);
updateLocation(location.name);
}
function addLocation() {
$scope.config.favorite_locations.push({
"name": "New location",
"coords": "52.39037297896968,4.828920364379883"
});
vm.setActiveLocation($scope.config.favorite_locations.length - 1);
}
function removeLocation(i) {
if ($scope.config.favorite_locations.length > 1) {
$scope.config.favorite_locations.splice(i, 1);
vm.setActiveLocation($scope.config.favorite_locations.length - 1);
}
}
}
})();