From 614f6b9606b3155b715402cf53e1678f3b1c9bbd Mon Sep 17 00:00:00 2001 From: Edward Shen <6173958+edward-shen@users.noreply.github.com> Date: Tue, 16 Oct 2018 11:18:09 -0400 Subject: [PATCH] Fixed readme, added NaN check --- MMM-pages.js | 4 ++-- readme.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MMM-pages.js b/MMM-pages.js index 3f029fb..a35ac97 100644 --- a/MMM-pages.js +++ b/MMM-pages.js @@ -72,7 +72,7 @@ Module.register('MMM-pages', { break; case 'PAGE_DECREMENT': Log.log('[Pages]: received a notification to decrement pages!'); - this.changePageBy(payload, -1); + this.changePageBy(-payload, -1); this.updatePages(); break; case 'DOM_OBJECTS_CREATED': @@ -104,7 +104,7 @@ Module.register('MMM-pages', { Log.warn(`[Pages]: ${amt} is not a number!`); } - if (typeof amt === 'number') { + if (typeof amt === 'number' && !isNaN(amt)) { this.curPage = this.mod( this.curPage + amt, this.config.modules.length diff --git a/readme.md b/readme.md index 0f10ad9..23c501b 100644 --- a/readme.md +++ b/readme.md @@ -77,8 +77,8 @@ this.sendNotification("PAGE_CHANGED", 2); This would cause the module to change show that you are on page 3. You can also just send `PAGE_INCREMENT` or `PAGE_DECREMENT` without any payloads - (or with, but it will be ignored) to have the module change the displayed page - by one. +to have the module change the displayed page by one. If you attach a payload to +these commands, it will attempt to the nth next page or nth previous page. This module keeps internal track of how many pages you have, defined by your config in the config file. There is no way to dynamically change the pages you