Skip to content

Commit 6294ffb

Browse files
RolfKoendersMax Leiter
authored andcommitted
Add botPath setting to userdata config file (#112)
* Add botPath setting to userdata config file * Enable drawing on load
1 parent 259bee6 commit 6294ffb

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

config/userdata.js.example

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ var userInfo = {
55
userZoom: true,
66
zoom: 16,
77
userFollow: true,
8-
gMapsAPIKey: "YOUR_API_KEY_HERE"
9-
};
8+
gMapsAPIKey: "YOUR_API_KEY_HERE",
9+
botPath: true
10+
};

js/main.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,19 @@ var mapView = {
126126
});
127127
});
128128
},
129+
setBotPathOptions: function(checked) {
130+
var self = this;
131+
for (var i = 0; i < self.settings.users.length; i++) {
132+
self.user_data[self.settings.users[i]].trainerPath.setOptions({
133+
strokeOpacity: checked ? 1.0 : 0.0
134+
});
135+
}
136+
},
129137
bindUi: function() {
130138
var self = this;
131139
$('#switchPan').prop('checked', self.settings.userFollow);
132140
$('#switchZoom').prop('checked', self.settings.userZoom);
133-
$('#strokeOn').prop('checked', false);
141+
$('#strokeOn').prop('checked', self.settings.botPath);
134142

135143
$('#switchPan').change(function() {
136144
if (this.checked) {
@@ -149,11 +157,8 @@ var mapView = {
149157
});
150158

151159
$('#strokeOn').change(function() {
152-
for (var i = 0; i < self.settings.users.length; i++) {
153-
self.user_data[self.settings.users[i]].trainerPath.setOptions({
154-
strokeOpacity: this.checked ? 1.0 : 0.0
155-
});
156-
}
160+
self.settings.botPath = this.checked;
161+
self.setBotPathOptions(this.checked);
157162
});
158163

159164
$('#optionsButton').click(function() {
@@ -800,6 +805,7 @@ var mapView = {
800805
} else {
801806
self.user_data[self.settings.users[user_index]].trainerPath.setPath(self.pathcoords[self.settings.users[user_index]]);
802807
}
808+
self.setBotPathOptions(self.settings.botPath);
803809
}
804810
if (self.settings.users.length === 1 && self.settings.userZoom === true) {
805811
self.map.setZoom(self.settings.zoom);
@@ -833,7 +839,7 @@ var mapView = {
833839
xhr.open('GET', path, true);
834840
xhr.send();
835841
},
836-
842+
837843
/*
838844
loadJSON: function(path, success, error, successData) {
839845
$.getJSON({
@@ -848,7 +854,7 @@ var mapView = {
848854
});
849855
},
850856
*/
851-
857+
852858
// Adds events to log panel and if it's closed sends Toast
853859
log: function(log_object) {
854860
var currentDate = new Date();

0 commit comments

Comments
 (0)