Skip to content

Commit ce37afc

Browse files
committed
Code cleanup.
1 parent 522499b commit ce37afc

1 file changed

Lines changed: 13 additions & 27 deletions

File tree

MMM-BirdNET.js

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ Module.register("MMM-BirdNET", {
22
defaults: {
33
updateInterval: 60 * 60 * 1000, // one hour
44
popInterval: 30 * 1000, // thirty seconds
5-
dataUrl: 'https://birdnet.cornell.edu/map/requeststats',
6-
mapUrl: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
7-
mapMode: 'dark',
8-
lat: 42.453583743,
9-
lon: -76.47363144,
10-
zoomLevel: 7,
11-
markerDistance: 300,
12-
markerColor: 'LightGreen' // distance from map center to put markers
5+
dataUrl: 'https://birdnet.cornell.edu/map/requeststats', // where to pull data
6+
mapUrl: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', // where to pull map tiles
7+
mapMode: 'dark', // map tile appearance
8+
lat: 42.453583743, // latitude
9+
lon: -76.47363144, // longitude
10+
zoomLevel: 7, // Zoom level of map
11+
markerDistance: 300, // maximum distance from map center to plot markers
12+
markerColor: 'LightGreen' // color of plotted BirdNET submissions
1313
},
1414

1515
start: function () {
@@ -38,28 +38,19 @@ Module.register("MMM-BirdNET", {
3838
doubleClickZoom: false,
3939
attributionControl: false
4040
};
41-
42-
43-
this.mapSelector = "Jawg.Dark";
44-
45-
46-
47-
if (this.config.mapMode == 'dark') {
48-
} else {
49-
50-
}
5141

5242
this.loaded = false;
5343
},
5444

5545
getHeader: function() { return this.name;},
5646

57-
suspend: function() { clearInterval(this.updateTimer);},
47+
suspend: function() { clearInterval(this.updateTimer); clearInterval(this.updateTimer);},
5848

5949
resume: function() {
6050
this.updateTimer = setInterval(()=> {
6151
this.updateData();
6252
}, this.config.updateInterval);
53+
this.schedulePopInterval();
6354
},
6455

6556
getDom: function() {
@@ -94,16 +85,12 @@ Module.register("MMM-BirdNET", {
9485
var dataRequest = new XMLHttpRequest();
9586
dataRequest.open("GET", url, true);
9687
dataRequest.send();
97-
// dataRequest.onprogress = function(event) {
98-
// Log.info("Downloading bird data: " + event.total);
99-
// }
10088
dataRequest.onerror = function() {
10189
Log.error("Unable to download bird data");
10290
this.birdData = {};
10391
}
10492
dataRequest.onload = function() {
105-
Log.info(self.name + " - Bird observation data loaded.");
106-
// remove markers
93+
// Log.info(self.name + " - Bird observation data loaded.");
10794
if (dataRequest.status >= 200 && dataRequest.status < 300) {
10895
self.processBirdData(dataRequest.responseText);
10996
}
@@ -229,7 +216,7 @@ Module.register("MMM-BirdNET", {
229216

230217
buildMap: function() {
231218
if (this.birdMap != null) {
232-
Log.info("map already exists");
219+
// Log.info("map already exists");
233220
} else {
234221
var map = L.map('BirdNET-map', this.mapOptions);
235222
map.setView([this.config.lat, this.config.lon],this.config.zoomLevel); // create the map
@@ -257,14 +244,13 @@ Module.register("MMM-BirdNET", {
257244
L.tileLayer.provider('USGS.USImageryTopo',{maxZoom: 19}).addTo(map);
258245
break;
259246
case 'custom':
260-
L.tileLayer(this.config.mapUrl, {maxZoom: 19, attribution: 'Unknown'}).addTo(map); // add map tiles
247+
L.tileLayer(this.config.mapUrl, {maxZoom: 19, attribution: 'Unknown'}).addTo(map);
261248
} // end case statement
262249
L.control.attribution(this.attributionOptions);
263250
this.birdMap = map;
264251
}
265252

266253
if (this.markersLayer == null) {
267-
Log.info("Creating markers layer.");
268254
this.markersLayer = L.layerGroup().addTo(this.birdMap);
269255
} else {
270256
this.markersLayer.addTo(this.birdMap);

0 commit comments

Comments
 (0)