mirror of
https://github.com/edward-shen/MMM-pages.git
synced 2024-12-22 00:35:09 -08:00
parent
ec62411c17
commit
79e132b007
2 changed files with 26 additions and 12 deletions
17
MMM-pages.js
17
MMM-pages.js
|
@ -15,7 +15,8 @@ Module.register('MMM-pages', {
|
|||
animationTime: 1000,
|
||||
rotationTime: 0,
|
||||
rotationFirstPage: 0,
|
||||
rotationDelay: 10000
|
||||
rotationDelay: 10000,
|
||||
homePage: 0
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -41,7 +42,11 @@ Module.register('MMM-pages', {
|
|||
* and sets the default current page to 0.
|
||||
*/
|
||||
start: function () {
|
||||
this.curPage = 0;
|
||||
// Clamp homePage value to [0, num pages).
|
||||
if (this.config.homePage >= this.config.modules.length || this.config.homePage < 0) {
|
||||
this.config.homePage = 0;
|
||||
}
|
||||
this.curPage = this.config.homePage;
|
||||
this.rotationPaused = false;
|
||||
|
||||
// Compatibility
|
||||
|
@ -63,6 +68,9 @@ Module.register('MMM-pages', {
|
|||
* 'PAGE_DECREMENT' - Move to the previous page.
|
||||
* 'DOM_OBJECTS_CREATED' - Starts the module.
|
||||
* 'QUERY_PAGE_NUMBER' - Requests the current page number
|
||||
* 'PAUSE_ROTATION' - Stops rotation
|
||||
* 'RESUME_ROTATION' - Resumes rotation
|
||||
* 'HOME_PAGE' - Calls PAGED_CHANGED with the default home page.
|
||||
*
|
||||
* @param {string} notification the notification ID
|
||||
* @param {number} payload the page to change to/by
|
||||
|
@ -116,6 +124,9 @@ Module.register('MMM-pages', {
|
|||
Log.warn('[Pages]: Was asked to resume but rotation was not paused!');
|
||||
}
|
||||
break;
|
||||
case 'HOME_PAGE':
|
||||
this.notificationReceived('PAGE_CHANGED', this.config.homePage);
|
||||
break;
|
||||
default: // Do nothing
|
||||
}
|
||||
},
|
||||
|
@ -228,6 +239,6 @@ Module.register('MMM-pages', {
|
|||
self.updatePages();
|
||||
}, self.config.rotationFirstPage);
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
21
readme.md
21
readme.md
|
@ -50,15 +50,16 @@ modules: [
|
|||
|
||||
## Configuration options
|
||||
|
||||
| Option | Type | Default Value | Description |
|
||||
| ------------------ | ------------------ | ------------------------ | --------- |
|
||||
| `modules` | `[[String...]...]` | `[]` | A 2D String array of what each module should be on which page. Notethat 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. |
|
||||
| `excludes` | *None* | *None* | **Deprecated** Use `fixed` instead. |
|
||||
| `fixed` | `[String...]` | `["MMM-page-indicator"]` | Which modules should show up all the time. |
|
||||
| `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. |
|
||||
| `rotationDelay` | `int` | `0` | 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. |
|
||||
| `rotationFirstPage`| `int` | `0` | Time, in milliseconds, before automatically returning to the first page. |
|
||||
| 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. |
|
||||
| `excludes` | *None* | *None* | **Deprecated** Use `fixed` instead. |
|
||||
| `fixed` | `[String...]` | `["MMM-page-indicator"]` | Which modules should show up all the time. |
|
||||
| `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. |
|
||||
| `rotationDelay` | `int` | `0` | 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. |
|
||||
| `rotationFirstPage` | `int` | `0` | Time, in milliseconds, before automatically returning to the first page. |
|
||||
| `homePage` | `int` | `0` | Which page index is the home page. |
|
||||
|
||||
For the `module` configuration option, the first element of the outer array
|
||||
should consist of elements that should be on the first page. The second element
|
||||
|
@ -103,6 +104,8 @@ separate notification tag is used for compatibility reasons.
|
|||
If you wish to pause the auto rotation, send a `PAUSE_ROTATION` event. Likewise,
|
||||
you can send a `RESUME_ROTATION` event to resume it.
|
||||
|
||||
If you want to return to the home page, simply send a `HOME_PAGE` notification.
|
||||
|
||||
## FAQ
|
||||
|
||||
- Help! My module is (above/below) another module in the same region but I want
|
||||
|
|
Loading…
Reference in a new issue