-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMM-Metar.js
35 lines (34 loc) · 1.06 KB
/
MMM-Metar.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
Module.register("MMM-Metar", {
defaults: {
icaoList: ['YBAF', 'YBBN', 'YAMB', 'YBCG', 'YBOK','YBNA', 'YSTW']
},
start: function() {
this.results = [];
this.getResults();
},
getStyles: function() {
return ['MMM-Metar.css'];
},
getResults: function() {
var self = this;
this.config.icaoList.forEach(function(icao) {
var url = 'http://metar.online/metar/' + icao + "/*";
self.sendSocketNotification('MMM_METAR', url);
});
},
getDom: function() {
var wrapper = document.createElement('div');
var self = this;
this.results.forEach(function(entry) {
var entryDiv = document.createElement('div');
entryDiv.innerHTML = entry;
entryDiv.className = "entrydiv";
wrapper.appendChild(entryDiv);
});
return wrapper;
},
socketNotificationReceived: function(notification, payload) {
this.results.push(payload);
this.updateDom();
}
});