Showing more than 1 item at a time

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+"&deg<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);
    },

});

What you are posting looks like Java, to me, not JavaScript.

V/r,

^ _ ^

YOU Sir are correct… that is my mistake LOL Being new to this well…truly shows doesn’t it?
I’m good with PHP but just starting doing this 30 days ago…and well while it works it still doesn’t give me what I was after…

Hi @jwade, this would only skip one active item; you’d also have to call updateDom() for each increment. For example:

{
  // ...
  updateDom: function () {/* ... */},
  updateDomTimes: function (count) {
    while (count > 0) {
      this.activeItem++
      this.updateDom(this.config.animationSpeed)
      count--
    },
  },
  scheduleCarousel: function () {
    this.rotateInterval = setInterval(() => {
      this.updateDomTimes(2)
    }, this.config.rotateInterval)
  }
}

(It’s JavaScript BTW.) :-)

3 Likes

Thank you LOL Yeah I figured that out… it’s learning new things … ALL the time :wink: But Thank you for the help despite my error in posting!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.