mirror of
https://github.com/edward-shen/MMM-pages.git
synced 2024-11-22 02:04:29 -08:00
changed some code to use modulo instead of the stupid thing I was doing before
fixed scope
This commit is contained in:
parent
ba0aa4696a
commit
248bd9b5cc
1 changed files with 3 additions and 6 deletions
|
@ -28,12 +28,11 @@ 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!");
|
||||||
if (this.curPage === this.config.modules.length - 1) {
|
this.curPage = (this.curPage++) % this.config.modules.length;
|
||||||
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-- }
|
||||||
|
@ -74,9 +73,7 @@ Module.register("MMM-pages", {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
self.timer = setInterval(() => {
|
self.timer = setInterval(() => {
|
||||||
// Incrementing page
|
// Incrementing page
|
||||||
if (self.curPage === self.config.modules.length - 1) {
|
self.curPage = (self.curPage++) % self.config.modules.length;
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue