Revert "changed some code to use modulo instead of the stupid thing I was doing before"

This reverts commit 248bd9b5cc.
This commit is contained in:
Edward Shen 2017-10-21 01:55:13 -04:00
parent 248bd9b5cc
commit 579fc24de8
No known key found for this signature in database
GPG key ID: 4E887A42793D0433

View file

@ -28,11 +28,12 @@ Module.register("MMM-pages", {
this.updatePages(true); this.updatePages(true);
} else if (notification === "PAGE_INCREMENT") { } else if (notification === "PAGE_INCREMENT") {
Log.log(this.name + " recieved a notification to increment pages!"); Log.log(this.name + " recieved a notification to increment pages!");
this.curPage = (this.curPage++) % this.config.modules.length; if (this.curPage === this.config.modules.length - 1) {
this.curPage = 0;
} else { this.curPage++ }
this.updatePages(true); this.updatePages(true);
} else if (notification === "PAGE_DECREMENT") { } else if (notification === "PAGE_DECREMENT") {
Log.log(this.name + " recieved a notification to decrement pages!"); Log.log(this.name + " recieved a notification to decrement pages!");
// Javascript doesn't support negative modulo (-1 % 5 != 4)
if (this.curPage === 0) { if (this.curPage === 0) {
this.curPage = this.config.modules.length - 1; this.curPage = this.config.modules.length - 1;
} else { this.curPage-- } } else { this.curPage-- }
@ -73,7 +74,9 @@ Module.register("MMM-pages", {
setTimeout(() => { setTimeout(() => {
self.timer = setInterval(() => { self.timer = setInterval(() => {
// Incrementing page // Incrementing page
self.curPage = (self.curPage++) % self.config.modules.length; if (self.curPage === self.config.modules.length - 1) {
self.curPage = 0;
} else { self.curPage++ }
self.sendNotification("PAGE_INCREMENT"); self.sendNotification("PAGE_INCREMENT");
self.updatePages(false); self.updatePages(false);
}, self.config.rotationTime, false); }, self.config.rotationTime, false);