From acf468651f100263fb78b512d66bd931b8e5a824 Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Sun, 23 Mar 2025 22:56:01 +0100 Subject: [PATCH] Use timings object --- MMM-pages.js | 17 +++++++++++------ README.md | 8 ++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/MMM-pages.js b/MMM-pages.js index 6e26900..712315d 100644 --- a/MMM-pages.js +++ b/MMM-pages.js @@ -12,7 +12,7 @@ Module.register('MMM-pages', { hiddenPages: {}, animationTime: 1000, rotationTime: 0, - individualRotationTimes: [], + timings: { default: 0 }, rotationFirstPage: 0, // Keep for compatibility rotationHomePage: 0, rotationDelay: 10000, @@ -53,8 +53,13 @@ Module.register('MMM-pages', { this.config.rotationHomePage = this.config.rotationFirstPage; } + if (this.config.rotationTime) { + Log.warn('[MMM-pages] The config option "rotationTime" is deprecated. Please used "rotationHomePage" instead.'); + this.config.timings.default = this.config.rotationTime; + } + // Disable rotation if an invalid input is given - this.config.rotationTime = Math.max(this.config.rotationTime, 0); + this.config.timings.default = Math.max(this.config.timings.default, 0); this.config.rotationDelay = Math.max(this.config.rotationDelay, 0); this.config.rotationHomePage = Math.max(this.config.rotationHomePage, 0); @@ -222,14 +227,14 @@ Module.register('MMM-pages', { * @param {number} delay the delay, in milliseconds. */ resetTimerWithDelay(delay) { - if (this.config.rotationTime > 0 || this.config.individualRotationTimes.length) { + if (this.config.timings.default > 0 || Object.keys(this.config.timings).length > 1) { // This timer is the auto rotate function. clearInterval(this.timer); // This is delay timer after manually updating. clearInterval(this.delayTimer); - let currentRotationTime = this.config.rotationTime; - if (this.config.individualRotationTimes[this.curPage]) { - currentRotationTime = this.config.individualRotationTimes[this.curPage]; + let currentRotationTime = this.config.timings.default; + if (this.config.timings[this.curPage]) { + currentRotationTime = this.config.timings[this.curPage]; } const self = this; diff --git a/README.md b/README.md index c8ca109..793d156 100644 --- a/README.md +++ b/README.md @@ -158,15 +158,15 @@ You have to add the class name to the config of the module you want to show on a ### Configuration options -| Option | Type | Default Value | Description | -| --- | --- | --- | --- | +| Option | Type | Default Value | Description | +| ------------------- | -------------------------- | ------------------------ | ----------- | | `modules` | `[[String...]...]` | `[]` | A 2D String array of what each module should be on which page. Note that all entries must take their class name (e.g. this module's class name is `MMM-pages`, while the default modules may just have `newsfeed`, without the `MMM-` prefix. | | `fixed` | `[String...]` | `["MMM-page-indicator"]` | Which modules should show up all the time. | | `excludes` | *NA* | *NA* | **Deprecated**. Use `fixed` instead. | | `hiddenPages` | `{String: [String...]...}` | `{}` | An Object defining special `hiddenPages` which are not available on the normal page rotation and only accessible via a notification. Modules defined in `fixed` are ignored and need to be also added if you wish to have them on any hidden page. | | `animationTime` | `int` | `1000` | Fading animation time. Set to `0` for instant change. Value is in milliseconds (1 second = 1000 milliseconds). | -| `rotationTime` | `int` | `0` | Time, in milliseconds, between automatic page changes. | -| `individualRotationTimes` | `[int, int, int...]` | `[]` | An array of integers (milliseconds) that define the rotation time of each page. If the array is shorter than the number of pages, `rotationTime` will be used for the remaining pages. You only need this if you want different rotation times for each page. | +| `rotationTime` | `int` | `0` | **Deprecated**. Use `timings` instead. | +| `timings` | `object` | `{ default: 0 }` | An object whose keys define the rotation time of the pages in milliseconds.
Example, where each page is 3 seconds, except page 3 which is 20 seconds:
`{ default: 3000, 2: 20000 }`
If a page is not defined, it will use the `default` value.
*Note:* Remember that the numbering starts at 0, so the first page is `0`, the second page is `1`, and so forth. | | `rotationDelay` | `int` | `10000` | Time, in milliseconds, of how long should a manual page change linger before returning to automatic page changing. In other words, how long should the timer wait for after you manually change a page. This does include the animation time, so you may wish to increase it by a few seconds or so to account for the animation time. | | `rotationHomePage` | `int` | `0` | Time, in milliseconds, before automatically returning to the home page. If a home page is not set, this returns to the leftmost page instead. | | `rotationFirstPage` | *NA* | *NA* | **Deprecated**. Use `rotationHomePage` instead. |