Yes I’m new to this and I’ve been trying to figure this out for 3 days…it’s a script that shows football scores but it only shows them one at a time and I would like it to show 2 at a time…here’s what I have so far…
I have tried to change the this.activeItem++ to this.actitiveitem+2 but that didn’t do it…I’m a bit lost here…think I’ve been staring at it too long…
// Define start sequence.
start: function() {
Log.info("Starting module: " + this.name);
this.sendSocketNotification('CONFIG', this.config);
this.config.lang = this.config.lang || config.language;
// Set locale.
this.today = "";
this.espn = [];
this.gw = [];
this.getESPN();
this.updateInterval = null;
this.activeItem = 0;
this.rotateInterval = null;
this.scheduleUpdate();
},
getDom: function() {
var espn = this.espn;
var gw = this.gw;
espn.forEach(function(o, i){
o.weather = gw[i];
});
var wrapper = document.createElement("div");
wrapper.classList.add("container");
var keys = Object.keys(this.espn);
if(keys.length > 0){
if(this.activeItem >= keys.length){
this.activeItem = 0;
}
espn = this.espn[keys[this.activeItem]];
var scores = document.createElement("span");
if (espn.q == 'F' ) {
scores.classList.add("xsmall", "bright", "game3");
if (espn.vs > espn.hs){
scores.innerHTML = "<font color = #FF4500>"+espn.v + "</font> " + espn.vs + "<br>" + espn.h + " " + espn.hs+"<BR>"+"Final";
} else {
scores.innerHTML = espn.v + " " + espn.vs +"<br><font color = #FF4500>" + espn.h + "</font> " + espn.hs+"<BR>Final"; }
} else {
if (espn.q != 'H') {
if (espn.d != moment().format("ddd") || espn.q == "P"){
scores.classList.add("xsmall", "bright", "game");
scores.innerHTML = espn.v + " @ " + espn.h + "<br>" + espn.d + " @ " + espn.t+"<BR>Temp : "+espn.weather.high+"°<br>"+espn.weather.forecast;
} else {
scores.classList.add("xsmall", "bright", "game2");
scores.innerHTML = espn.v + " @ " + espn.h + "<br>" + espn.vs + " : " + espn.hs+"<BR>"+"Q: "+espn.q;
}
} else {
scores.classList.add("xsmall", "bright", "game2");
scores.innerHTML = espn.v + " @ " + espn.h + "<br>" + espn.vs + " : " + espn.hs+"<BR>"+"Q: HALF TIME";
}
}
wrapper.appendChild(scores);
}
return wrapper;
},
scheduleCarousel: function() {
this.rotateInterval = setInterval(() => {
this.activeItem++;
this.updateDom(this.config.animationSpeed);
}, this.config.rotateInterval);
},
processESPN: function(data) {
this.today = data.Today;
this.espn = data;
},
processGW: function(data) {
this.today = data;
this.gw = data;
},
scheduleUpdate: function() {
console.log(espn);
setInterval(() => {
this.getESPN();
}, this.config.updateInterval);
this.getESPN(this.config.initialLoadDelay);
},
getESPN: function() {
this.sendSocketNotification('GET_ESPN','GET_GAMES');
},
socketNotificationReceived: function(notification, payload) {
if (notification === "ESPN_RESULT") {
this.processESPN(payload);
}
if (notification === "WEATHER_RESULT") {
this.processGW(payload);
this.updateDom(this.config.animationSpeed);
}
if(this.rotateInterval == null){
this.scheduleCarousel();
}
this.updateDom(this.config.initialLoadDelay);
},
});