Fixed readme, added NaN check

This commit is contained in:
Edward Shen 2018-10-16 11:18:09 -04:00
parent 6ea3f13e7d
commit 614f6b9606
No known key found for this signature in database
GPG key ID: 4E887A42793D0433
2 changed files with 4 additions and 4 deletions

View file

@ -72,7 +72,7 @@ Module.register('MMM-pages', {
break; break;
case 'PAGE_DECREMENT': case 'PAGE_DECREMENT':
Log.log('[Pages]: received a notification to decrement pages!'); Log.log('[Pages]: received a notification to decrement pages!');
this.changePageBy(payload, -1); this.changePageBy(-payload, -1);
this.updatePages(); this.updatePages();
break; break;
case 'DOM_OBJECTS_CREATED': case 'DOM_OBJECTS_CREATED':
@ -104,7 +104,7 @@ Module.register('MMM-pages', {
Log.warn(`[Pages]: ${amt} is not a number!`); Log.warn(`[Pages]: ${amt} is not a number!`);
} }
if (typeof amt === 'number') { if (typeof amt === 'number' && !isNaN(amt)) {
this.curPage = this.mod( this.curPage = this.mod(
this.curPage + amt, this.curPage + amt,
this.config.modules.length this.config.modules.length

View file

@ -77,8 +77,8 @@ this.sendNotification("PAGE_CHANGED", 2);
This would cause the module to change show that you are on page 3. 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 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 to have the module change the displayed page by one. If you attach a payload to
by one. 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 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 config in the config file. There is no way to dynamically change the pages you