From edc1e08e65174c69db188894cd58e6e078f42716 Mon Sep 17 00:00:00 2001 From: Edward Shen <6173958+edward-shen@users.noreply.github.com> Date: Tue, 8 May 2018 15:34:36 -0400 Subject: [PATCH] Revert "added support for changing by a certain amount of pages" This reverts commit f4fc53fa193f7fe3fc9c1328c0c4d677f754826d. Update issue templates --- .github/ISSUE_TEMPLATE/Bug_report.md | 34 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/Feature_request.md | 17 ++++++++++++ MMM-pages.js | 13 ++------- readme.md | 7 ++--- 4 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/Bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/Feature_request.md diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md new file mode 100644 index 0000000..0eb1fd2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -0,0 +1,34 @@ +--- +name: Bug report +about: Thanks for helping us out! + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. If you believe you have aptly described your issue in words, feel free to ignore this section. + +**Please fill out the following information;** + - Node version: [This can be obtained by running `node --version`] + - Have you updated to the latest MagicMirror core? [yes/no] + - Please post the relevant part of your config file here: +```json +(Paste the part of the config file here) +``` + - Please post any errors you see about MMM-Pages in the console (Hit F12 > Console when the Magic Mirror window is focused), or write **None** if there aren't any: +``` +``` +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md new file mode 100644 index 0000000..5384295 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/MMM-pages.js b/MMM-pages.js index ea9097c..713f6b1 100644 --- a/MMM-pages.js +++ b/MMM-pages.js @@ -55,12 +55,11 @@ Module.register('MMM-pages', { * @param {number} payload the page to change to */ notificationReceived: function(notification, payload) { - const isValidPayload = typeof payload === 'number'; switch (notification) { case 'PAGE_CHANGED': Log.log(`${this.name} recieved a notification` + `to change to page ${payload} of type ${typeof payload}`); - if (isValidPayload) { + if (typeof payload === 'number') { this.curPage = payload; } else { Log.error('Was asked to change to an invalid number!'); @@ -71,18 +70,12 @@ Module.register('MMM-pages', { break; case 'PAGE_INCREMENT': Log.log(`${this.name} recieved a notification to increment pages!`); - this.curPage = this.mod( - this.curPage + (isValidPayload) ? payload : 1, - this.config.modules.length - ); + this.curPage = this.mod(this.curPage + 1, this.config.modules.length); this.updatePages(true); break; case 'PAGE_DECREMENT': Log.log(`${this.name} recieved a notification to decrement pages!`); - this.curPage = this.mod( - this.curPage - (isValidPayload) ? payload : 1, - this.config.modules.length - ); + this.curPage = this.mod(this.curPage - 1, this.config.modules.length); this.updatePages(true); break; case 'DOM_OBJECTS_CREATED': diff --git a/readme.md b/readme.md index ec7e718..9b9651a 100644 --- a/readme.md +++ b/readme.md @@ -76,10 +76,9 @@ this.sendNotification("PAGE_CHANGED", 2); ``` This would cause the module to change show that you are on page 3. -Sending a `PAGE_INCREMENT` or `PAGE_DECREMENT` without any parameters will -increase or decrease the page by one. Attaching a valid payload to the -aforementioned notifications will increase or decrease the pages by that amount. -Remember that this module **strictly checks** for a number. +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. 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