-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMM-RunningForecast.js
47 lines (39 loc) · 1.44 KB
/
MMM-RunningForecast.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
Module.register("MMM-RunningForecast", {
defaults: {
updateInterval: 3600000, // Update every hour
url: "https://weather.com/activity-hub/running/ff7365bc39d17586e7712568d30f5fc13663ab9db4b676b3f2eb80eeb3cad4c1",
title: "Running Forecast" // Add a title for the module
},
start: function() {
this.getData();
this.scheduleUpdate();
},
getData: function() {
this.sendSocketNotification("GET_RUNNING_FORECAST", this.config.url);
},
scheduleUpdate: function() {
var self = this;
setInterval(function() {
self.getData();
}, this.config.updateInterval);
},
getDom: function() {
var wrapper = document.createElement("div");
// Create the title element
var title = document.createElement("header");
title.className = "module-header";
title.innerHTML = this.config.title;
wrapper.appendChild(title);
// Add the running forecast
var forecastContent = document.createElement("div");
forecastContent.innerHTML = this.runningForecast || "Loading...";
wrapper.appendChild(forecastContent);
return wrapper;
},
socketNotificationReceived: function(notification, payload) {
if (notification === "RUNNING_FORECAST_DATA") {
this.runningForecast = payload;
this.updateDom();
}
}
});