From 6f3ac28e69c6ac895c8dbbd8bad5cd532e12f171 Mon Sep 17 00:00:00 2001 From: Edward Shen <6173958+edward-shen@users.noreply.github.com> Date: Tue, 8 May 2018 15:32:20 -0400 Subject: [PATCH] Added more debug info, added clarifying parens --- MMM-pages.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/MMM-pages.js b/MMM-pages.js index 84d92ab..066ebca 100644 --- a/MMM-pages.js +++ b/MMM-pages.js @@ -55,7 +55,11 @@ Module.register('MMM-pages', { * @param {string} notification the notification ID * @param {number} payload the page to change to */ - notificationReceived: function (notification, payload) { + notificationReceived: function(notification, payload) { + const isValidPayload = typeof payload === 'number'; + + Log.log(`[Pages]:${payload} is a number? ${isValidPayload}`); + Log.log(`[Pages]:${this.curPage + (isValidPayload) ? payload : 1}`); switch (notification) { case 'PAGE_CHANGED': Log.log(`${this.name} received a notification` @@ -70,13 +74,19 @@ Module.register('MMM-pages', { this.updatePages(true); break; case 'PAGE_INCREMENT': - Log.log(`${this.name} received a notification to increment pages!`); - this.curPage = this.mod(this.curPage + 1, this.config.modules.length); + Log.log(`${this.name} recieved a notification to increment pages!`); + this.curPage = this.mod( + this.curPage + ((isValidPayload) ? payload : 1), + this.config.modules.length + ); this.updatePages(true); break; case 'PAGE_DECREMENT': - Log.log(`${this.name} received a notification to decrement pages!`); - this.curPage = this.mod(this.curPage - 1, this.config.modules.length); + Log.log(`${this.name} recieved a notification to decrement pages!`); + this.curPage = this.mod( + this.curPage - ((isValidPayload) ? payload : 1), + this.config.modules.length + ); this.updatePages(true); break; case 'DOM_OBJECTS_CREATED':