-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvueController.js
95 lines (91 loc) · 3.21 KB
/
vueController.js
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
86
87
88
89
90
91
92
93
94
95
var vueController = new Vue({
el: '#HeaderControls',
data: {
title: 'Map Lab',
routePoints: 'Locations Separate by ";" - Try read me link to learn how create BHTrans`s bus-line route',
color: '#FF776B',
showCapture: false,
class_button: ["btn", "btn-sm", "btn-primary"],
bhtrans: {
searchText: "Bus number (BHTrans)",
search: function(){
apiWS = new ApiWebScraping();
apiWS.getBHTrans(vueController.bhtrans.searchText, vueMapController.locations);
}
}
},
methods: {
loadLocations: function(){
if (this.routePoints.indexOf('to:') == -1 && this.routePoints.indexOf('\t') >-1 ){
var bhtrans = new BHTransIntegration(this.routePoints, vueMapController.locations.length+1);
bhtrans.afterAddressAdd = "Belo Horizonte. MG";
bhtrans.FromOldSiteVersionTable(vueMapController.locations);
}
else if (this.routePoints.indexOf('to:' ==-1)){
var arrayLocations = this.routePoints.split(';');
let initialIndex = vueMapController.locations.length+1;
for (var index in arrayLocations) {
var location = new Location(
initialIndex ++,
arrayLocations[index].replace(new RegExp('\\+', 'g'), ' ')
);
location.color = '#563d7c';
vueMapController.locations.push(location);
}
}
else {
var arrayLocations = this.routePoints.split('to:');
let initialIndex = vueMapController.locations.length+1;
for (var index in arrayLocations) {
var location = new Location(
initialIndex ++,
arrayLocations[index].replace(new RegExp('\\+', 'g'), ' ')
);
location.color = '#563d7c';
vueMapController.locations.push(location);
}
}
},
loadLocation: function(location){
var newLocation = new Location(vueMapController.locations.length+1, location.location);
newLocation.color = '#563d7c';
vueMapController.locations.push(newLocation);
},
markOnMap: function () {
var activatedItems = vueMapController.locations.filter(function (elem) { if (elem.active == true) return elem});
for (var index in activatedItems){
setMarkOnMap(map, activatedItems[index], this.color);
var start = new Date().getTime(); //Avoid Over query Limit (Temp...)
while (new Date().getTime() < start + 750);
}
},
setRoute: function(){
setDirections(vueMapController.locations, this.color);
},
clearMap: function(){
clearMap();
}
}
})
var vueMapController = new Vue({
el:'#sideArea',
data: {
locations: [],
newLocation: {
css: {class_button: vueController.class_button},
data: new Location(0,'Set Location'),
actionAdd: function(){
vueController.loadLocation(vueMapController.newLocation.data);
vueMapController.newLocation.data = new Location(0,'');
},
actionCheckAll (state){
for (var itemI in vueMapController.locations){
vueMapController.locations[itemI].active = state;
}
},
actionClear(){
vueMapController.locations = [];
}
}
}
})