From 82b6aebb8fcd2cc7d3b2202f2563c774ea52076d 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 1/6] Add `individualRotationTimes`
---
MMM-pages.js | 9 +++++++--
README.md | 1 +
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/MMM-pages.js b/MMM-pages.js
index 7e1ece5..6e26900 100644
--- a/MMM-pages.js
+++ b/MMM-pages.js
@@ -12,6 +12,7 @@ Module.register('MMM-pages', {
hiddenPages: {},
animationTime: 1000,
rotationTime: 0,
+ individualRotationTimes: [],
rotationFirstPage: 0, // Keep for compatibility
rotationHomePage: 0,
rotationDelay: 10000,
@@ -221,11 +222,15 @@ Module.register('MMM-pages', {
* @param {number} delay the delay, in milliseconds.
*/
resetTimerWithDelay(delay) {
- if (this.config.rotationTime > 0) {
+ if (this.config.rotationTime > 0 || this.config.individualRotationTimes.length) {
// 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];
+ }
const self = this;
this.delayTimer = setTimeout(() => {
@@ -235,7 +240,7 @@ Module.register('MMM-pages', {
// message, so we need to trigger it for ourselves.
self.sendNotification('PAGE_INCREMENT');
self.notificationReceived('PAGE_INCREMENT');
- }, self.config.rotationTime);
+ }, currentRotationTime);
}, delay);
} else if (this.config.rotationHomePage > 0) {
// This timer is the auto rotate function.
diff --git a/README.md b/README.md
index 29394ef..c8ca109 100644
--- a/README.md
+++ b/README.md
@@ -166,6 +166,7 @@ You have to add the class name to the config of the module you want to show on a
| `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. |
| `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. |
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 2/6] 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. |
From de2ddfb80637bd841374522794fd9f70473a1040 Mon Sep 17 00:00:00 2001
From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Date: Tue, 25 Mar 2025 08:02:17 +0100
Subject: [PATCH 3/6] Fix deprecation message
Co-authored-by: Edward Shen
---
MMM-pages.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MMM-pages.js b/MMM-pages.js
index 712315d..ecb13f4 100644
--- a/MMM-pages.js
+++ b/MMM-pages.js
@@ -54,7 +54,7 @@ Module.register('MMM-pages', {
}
if (this.config.rotationTime) {
- Log.warn('[MMM-pages] The config option "rotationTime" is deprecated. Please used "rotationHomePage" instead.');
+ Log.warn('[MMM-pages] The config option "rotationTime" is deprecated. Please used "timings" instead.');
this.config.timings.default = this.config.rotationTime;
}
From 571e0235395b65ec3db6cdef6c7cbe6bb131fb7b Mon Sep 17 00:00:00 2001
From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Date: Tue, 25 Mar 2025 08:03:09 +0100
Subject: [PATCH 4/6] Update doc about rotationTime
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 793d156..e6ab3f3 100644
--- a/README.md
+++ b/README.md
@@ -165,7 +165,7 @@ You have to add the class name to the config of the module you want to show on a
| `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` | **Deprecated**. Use `timings` instead. |
+| `rotationTime` | *NA* | *NA* | **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. |
From 03fde2a4a6a6e3de699db3be5f980fcffb7a3f64 Mon Sep 17 00:00:00 2001
From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Date: Tue, 25 Mar 2025 08:03:50 +0100
Subject: [PATCH 5/6] Fix typo
---
MMM-pages.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MMM-pages.js b/MMM-pages.js
index ecb13f4..86d6e05 100644
--- a/MMM-pages.js
+++ b/MMM-pages.js
@@ -49,12 +49,12 @@ Module.register('MMM-pages', {
}
if (this.config.rotationFirstPage) {
- Log.warn('[MMM-pages] The config option "rotationFirstPage" is deprecated. Please used "rotationHomePage" instead.');
+ Log.warn('[MMM-pages] The config option "rotationFirstPage" is deprecated. Please use "rotationHomePage" instead.');
this.config.rotationHomePage = this.config.rotationFirstPage;
}
if (this.config.rotationTime) {
- Log.warn('[MMM-pages] The config option "rotationTime" is deprecated. Please used "timings" instead.');
+ Log.warn('[MMM-pages] The config option "rotationTime" is deprecated. Please use "timings" instead.');
this.config.timings.default = this.config.rotationTime;
}
From 16228728675a39ee373de27a8c9729875048b8ac Mon Sep 17 00:00:00 2001
From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Date: Tue, 25 Mar 2025 08:32:13 +0100
Subject: [PATCH 6/6] Adapt examples to new timings option
---
README.md | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
index e6ab3f3..c646b23 100644
--- a/README.md
+++ b/README.md
@@ -71,10 +71,13 @@ The first element of the array is the first page, the second element is the seco
{
module: "MMM-pages",
config: {
- rotationTime: 1000 * 20, // rotate every 20 seconds
+ timings: {
+ default: 5000, // rotate every 5 seconds
+ 0: 20000 // page 0 rotates every 20 seconds
+ },
modules: [
- ["newsfeed"], // page 1
- ["calendar", "compliments"], // page 2
+ ["newsfeed"], // page 0
+ ["calendar", "compliments"], // page 1
],
fixed: [ // modules that are always shown
"clock",
@@ -103,11 +106,14 @@ Instead of using the module name, you can also use a class name for each page. T
{
module: "MMM-pages",
config: {
- rotationTime: 1000 * 20, // rotate every 20 seconds
+ timings: {
+ default: 20000, // rotate every 20 seconds
+ 2: 30000 // page 2 rotates every 30 seconds
+ },
modules: [
+ ["page0"], // class name for page 0
["page1"], // class name for page 1
["page2"], // class name for page 2
- ["page3"], // class name for page 3
],
fixed: ["fixed_page"],
hiddenPages: {
@@ -121,15 +127,23 @@ Instead of using the module name, you can also use a class name for each page. T
You have to add the class name to the config of the module you want to show on a specific page. You can even add more than one class name to show a module instance on multiple pages.
```js
- { // newsfeed on page 1
+ { // newsfeed on page 0
module: "newsfeed",
+ classes: "page0",
+ position: "...",
+ config: {
+ ...
+ }
+ },
+ { // first calendar instance on page 1
+ module: "calendar",
classes: "page1",
position: "...",
config: {
...
}
},
- { // first calendar instance on page 2
+ { // second calendar instance on page 2
module: "calendar",
classes: "page2",
position: "...",
@@ -137,17 +151,9 @@ You have to add the class name to the config of the module you want to show on a
...
}
},
- { // second calendar instance on page 3
- module: "calendar",
- classes: "page3",
- position: "...",
- config: {
- ...
- }
- },
- { // this compliments instance appears on page 1 and 3
+ { // this compliments instance appears on page 0 and 2
module: "compliments",
- classes: "page1 page3",
+ classes: "page0 page2",
position: "...",
config: {
...