mirror of
https://github.com/edward-shen/MMM-pages.git
synced 2024-11-24 03:04:29 -08:00
commit
5e018ed78f
7 changed files with 1736 additions and 130 deletions
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "airbnb-base",
|
|
||||||
"globals": {
|
|
||||||
"Module": true,
|
|
||||||
"Log": true,
|
|
||||||
"MM": true
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"comma-dangle": "off",
|
|
||||||
"object-shorthand": "off",
|
|
||||||
"func-names": "off",
|
|
||||||
"space-before-function-paren": "off"
|
|
||||||
}
|
|
||||||
}
|
|
15
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
15
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
|
@ -10,6 +10,7 @@ A clear and concise description of what the bug is.
|
||||||
**To Reproduce**
|
**To Reproduce**
|
||||||
Steps to reproduce the behavior:
|
Steps to reproduce the behavior:
|
||||||
(Please paste any information on reproducing the issue, for example:)
|
(Please paste any information on reproducing the issue, for example:)
|
||||||
|
|
||||||
1. Go to '...'
|
1. Go to '...'
|
||||||
2. Click on '....'
|
2. Click on '....'
|
||||||
3. Scroll down to '....'
|
3. Scroll down to '....'
|
||||||
|
@ -23,14 +24,16 @@ If applicable, add screenshots to help explain your problem. If you believe you
|
||||||
have aptly described your issue in words, feel free to ignore/delete this section.
|
have aptly described your issue in words, feel free to ignore/delete this section.
|
||||||
|
|
||||||
**Please fill out the following information;**
|
**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]
|
- Node version: [This can be obtained by running `node --version`]
|
||||||
- Please post the relevant part of your config file here:
|
- Have you updated to the latest MagicMirror core? [yes/no]
|
||||||
|
- Please post the relevant part of your config file here:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
(Paste the part of the config file here)
|
(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:
|
|
||||||
```
|
- Please post any errors you see about MMM-pages in the console (Hit F12 > Console when the MagicMirror window is focused), or write **None** if there aren't any:
|
||||||
```
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
Add any other context about the problem here.
|
Add any other context about the problem here.
|
||||||
|
|
60
MMM-pages.js
60
MMM-pages.js
|
@ -27,7 +27,7 @@ Module.register('MMM-pages', {
|
||||||
/**
|
/**
|
||||||
* Apply any styles, if we have any.
|
* Apply any styles, if we have any.
|
||||||
*/
|
*/
|
||||||
getStyles: function () {
|
getStyles () {
|
||||||
return ['pages.css'];
|
return ['pages.css'];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ Module.register('MMM-pages', {
|
||||||
* @param {number} x The dividend
|
* @param {number} x The dividend
|
||||||
* @param {number} n The divisor
|
* @param {number} n The divisor
|
||||||
*/
|
*/
|
||||||
mod: function (x, n) {
|
mod (x, n) {
|
||||||
return ((x % n) + n) % n;
|
return ((x % n) + n) % n;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ Module.register('MMM-pages', {
|
||||||
* Pseudo-constructor for our module. Makes sure that values aren't negative,
|
* Pseudo-constructor for our module. Makes sure that values aren't negative,
|
||||||
* and sets the default current page to 0.
|
* and sets the default current page to 0.
|
||||||
*/
|
*/
|
||||||
start: function () {
|
start () {
|
||||||
// Clamp homePage value to [0, num pages).
|
// Clamp homePage value to [0, num pages).
|
||||||
if (this.config.homePage >= this.config.modules.length || this.config.homePage < 0) {
|
if (this.config.homePage >= this.config.modules.length || this.config.homePage < 0) {
|
||||||
this.config.homePage = 0;
|
this.config.homePage = 0;
|
||||||
|
@ -56,12 +56,12 @@ Module.register('MMM-pages', {
|
||||||
|
|
||||||
// Compatibility
|
// Compatibility
|
||||||
if (this.config.excludes.length) {
|
if (this.config.excludes.length) {
|
||||||
Log.warn('[Pages]: The config option "excludes" is deprecated. Please use "fixed" instead.');
|
Log.warn('[MMM-pages]: The config option "excludes" is deprecated. Please use "fixed" instead.');
|
||||||
this.config.fixed = this.config.excludes;
|
this.config.fixed = this.config.excludes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.config.rotationFirstPage) {
|
if (this.config.rotationFirstPage) {
|
||||||
Log.warn('[Pages]: The config option "rotationFirstPage" is deprecated. Please used "rotationHomePage" instead.');
|
Log.warn('[MMM-pages]: The config option "rotationFirstPage" is deprecated. Please used "rotationHomePage" instead.');
|
||||||
this.config.rotationHomePage = this.config.rotationFirstPage;
|
this.config.rotationHomePage = this.config.rotationFirstPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ Module.register('MMM-pages', {
|
||||||
this.config.rotationHomePage = Math.max(this.config.rotationHomePage, 0);
|
this.config.rotationHomePage = Math.max(this.config.rotationHomePage, 0);
|
||||||
|
|
||||||
if (!this.config.useLockString) {
|
if (!this.config.useLockString) {
|
||||||
Log.log('[Pages]: User opted to not use lock strings!');
|
Log.log('[MMM-pages]: User opted to not use lock strings!');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -93,28 +93,28 @@ Module.register('MMM-pages', {
|
||||||
* @param {string} notification the notification ID
|
* @param {string} notification the notification ID
|
||||||
* @param {number|string} payload the page to change to/by
|
* @param {number|string} payload the page to change to/by
|
||||||
*/
|
*/
|
||||||
notificationReceived: function (notification, payload) {
|
notificationReceived (notification, payload) {
|
||||||
switch (notification) {
|
switch (notification) {
|
||||||
case 'PAGE_CHANGED':
|
case 'PAGE_CHANGED':
|
||||||
Log.log('[Pages]: received a notification '
|
Log.log('[MMM-pages]: received a notification '
|
||||||
+ `to change to page ${payload} of type ${typeof payload}`);
|
+ `to change to page ${payload} of type ${typeof payload}`);
|
||||||
this.curPage = payload;
|
this.curPage = payload;
|
||||||
this.updatePages();
|
this.updatePages();
|
||||||
break;
|
break;
|
||||||
case 'PAGE_INCREMENT':
|
case 'PAGE_INCREMENT':
|
||||||
Log.log('[Pages]: received a notification to increment pages!');
|
Log.log('[MMM-pages]: received a notification to increment pages!');
|
||||||
this.changePageBy(payload, 1);
|
this.changePageBy(payload, 1);
|
||||||
this.updatePages();
|
this.updatePages();
|
||||||
break;
|
break;
|
||||||
case 'PAGE_DECREMENT':
|
case 'PAGE_DECREMENT':
|
||||||
Log.log('[Pages]: received a notification to decrement pages!');
|
Log.log('[MMM-pages]: received a notification to decrement pages!');
|
||||||
// We can't just pass in -payload for situations where payload is null
|
// We can't just pass in -payload for situations where payload is null
|
||||||
// JS will coerce -payload to -0.
|
// JS will coerce -payload to -0.
|
||||||
this.changePageBy(payload ? -payload : payload, -1);
|
this.changePageBy(payload ? -payload : payload, -1);
|
||||||
this.updatePages();
|
this.updatePages();
|
||||||
break;
|
break;
|
||||||
case 'DOM_OBJECTS_CREATED':
|
case 'DOM_OBJECTS_CREATED':
|
||||||
Log.log('[Pages]: received that all objects are created;'
|
Log.log('[MMM-pages]: received that all objects are created;'
|
||||||
+ ' will now hide things!');
|
+ ' will now hide things!');
|
||||||
this.sendNotification('MAX_PAGES_CHANGED', this.config.modules.length);
|
this.sendNotification('MAX_PAGES_CHANGED', this.config.modules.length);
|
||||||
this.sendNotification('NEW_PAGE', this.curPage);
|
this.sendNotification('NEW_PAGE', this.curPage);
|
||||||
|
@ -134,12 +134,12 @@ Module.register('MMM-pages', {
|
||||||
this.notificationReceived('PAGE_CHANGED', this.config.homePage);
|
this.notificationReceived('PAGE_CHANGED', this.config.homePage);
|
||||||
break;
|
break;
|
||||||
case 'SHOW_HIDDEN_PAGE':
|
case 'SHOW_HIDDEN_PAGE':
|
||||||
Log.log(`[Pages]: received a notification to change to the hidden page "${payload}" of type "${typeof payload}"`);
|
Log.log(`[MMM-pages]: received a notification to change to the hidden page "${payload}" of type "${typeof payload}"`);
|
||||||
this.setRotation(false);
|
this.setRotation(false);
|
||||||
this.showHiddenPage(payload);
|
this.showHiddenPage(payload);
|
||||||
break;
|
break;
|
||||||
case 'LEAVE_HIDDEN_PAGE':
|
case 'LEAVE_HIDDEN_PAGE':
|
||||||
Log.log("[Pages]: received a notification to leave the current hidden page ");
|
Log.log("[MMM-pages]: received a notification to leave the current hidden page ");
|
||||||
this.animatePageChange();
|
this.animatePageChange();
|
||||||
this.setRotation(true);
|
this.setRotation(true);
|
||||||
break;
|
break;
|
||||||
|
@ -157,9 +157,9 @@ Module.register('MMM-pages', {
|
||||||
* @param {number} fallback the fallback value to use. Accepts negative
|
* @param {number} fallback the fallback value to use. Accepts negative
|
||||||
* numbers.
|
* numbers.
|
||||||
*/
|
*/
|
||||||
changePageBy: function (amt, fallback) {
|
changePageBy (amt, fallback) {
|
||||||
if (typeof amt !== 'number' && typeof fallback === 'undefined') {
|
if (typeof amt !== 'number' && typeof fallback === 'undefined') {
|
||||||
Log.warn(`[Pages]: ${amt} is not a number!`);
|
Log.warn(`[MMM-pages]: ${amt} is not a number!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof amt === 'number' && !Number.isNaN(amt)) {
|
if (typeof amt === 'number' && !Number.isNaN(amt)) {
|
||||||
|
@ -179,15 +179,15 @@ Module.register('MMM-pages', {
|
||||||
* Handles hiding the current page's elements and showing the next page's
|
* Handles hiding the current page's elements and showing the next page's
|
||||||
* elements.
|
* elements.
|
||||||
*/
|
*/
|
||||||
updatePages: function () {
|
updatePages () {
|
||||||
// Update iff there's at least one page.
|
// Update if there's at least one page.
|
||||||
if (this.config.modules.length !== 0) {
|
if (this.config.modules.length !== 0) {
|
||||||
this.animatePageChange();
|
this.animatePageChange();
|
||||||
if (!this.rotationPaused) {
|
if (!this.rotationPaused) {
|
||||||
this.resetTimerWithDelay(0);
|
this.resetTimerWithDelay(0);
|
||||||
}
|
}
|
||||||
this.sendNotification('NEW_PAGE', this.curPage);
|
this.sendNotification('NEW_PAGE', this.curPage);
|
||||||
} else { Log.error("[Pages]: Pages aren't properly defined!"); }
|
} else { Log.error("[MMM-pages]: Pages aren't properly defined!"); }
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,7 +198,7 @@ Module.register('MMM-pages', {
|
||||||
* @param {string} [targetPageName] the name of the hiddenPage we want to show.
|
* @param {string} [targetPageName] the name of the hiddenPage we want to show.
|
||||||
* Optional and only used when we want to switch to a hidden page
|
* Optional and only used when we want to switch to a hidden page
|
||||||
*/
|
*/
|
||||||
animatePageChange: function (targetPageName) {
|
animatePageChange (targetPageName) {
|
||||||
let lockStringObj = { lockString: this.identifier };
|
let lockStringObj = { lockString: this.identifier };
|
||||||
if (!this.config.useLockString) {
|
if (!this.config.useLockString) {
|
||||||
// Passing in an undefined object is equivalent to not passing it in at
|
// Passing in an undefined object is equivalent to not passing it in at
|
||||||
|
@ -235,7 +235,7 @@ Module.register('MMM-pages', {
|
||||||
*
|
*
|
||||||
* @param {number} delay the delay, in milliseconds.
|
* @param {number} delay the delay, in milliseconds.
|
||||||
*/
|
*/
|
||||||
resetTimerWithDelay: function (delay) {
|
resetTimerWithDelay (delay) {
|
||||||
if (this.config.rotationTime > 0) {
|
if (this.config.rotationTime > 0) {
|
||||||
// This timer is the auto rotate function.
|
// This timer is the auto rotate function.
|
||||||
if(this.timer){
|
if(this.timer){
|
||||||
|
@ -247,11 +247,11 @@ Module.register('MMM-pages', {
|
||||||
clearTimeout(this.delayTimer);
|
clearTimeout(this.delayTimer);
|
||||||
this.delayTimer=null
|
this.delayTimer=null
|
||||||
}
|
}
|
||||||
let rotation_timeout=this.config.rotationTime
|
let rotationTimeout=this.config.rotationTime
|
||||||
if(this.config.pageTimeout.length){
|
if(this.config.pageTimeout.length){
|
||||||
for(let pageInfo of this.config.pageTimeout){
|
for(let pageInfo of this.config.pageTimeout){
|
||||||
if((pageInfo.pageNumber) -1 == this.curPage){
|
if((pageInfo.pageNumber) -1 == this.curPage){
|
||||||
rotation_timeout= pageInfo.timeout
|
rotationTimeout= pageInfo.timeout
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ Module.register('MMM-pages', {
|
||||||
// message, so we need to trigger it for ourselves.
|
// message, so we need to trigger it for ourselves.
|
||||||
self.sendNotification('PAGE_INCREMENT');
|
self.sendNotification('PAGE_INCREMENT');
|
||||||
self.notificationReceived('PAGE_INCREMENT');
|
self.notificationReceived('PAGE_INCREMENT');
|
||||||
}, rotation_timeout);
|
}, rotationTimeout);
|
||||||
}, delay, this);
|
}, delay, this);
|
||||||
} else if (this.config.rotationHomePage > 0) {
|
} else if (this.config.rotationHomePage > 0) {
|
||||||
// This timer is the auto rotate function.
|
// This timer is the auto rotate function.
|
||||||
|
@ -277,11 +277,11 @@ Module.register('MMM-pages', {
|
||||||
clearTimeout(this.delayTimer);
|
clearTimeout(this.delayTimer);
|
||||||
this.delayTimer=null
|
this.delayTimer=null
|
||||||
}
|
}
|
||||||
let rotation_timeout=this.config.rotationHomePage
|
let rotationTimeout=this.config.rotationHomePage
|
||||||
if(this.config.pageTimeout.length){
|
if(this.config.pageTimeout.length){
|
||||||
for(let pageInfo of this.config.pageTimeout){
|
for(let pageInfo of this.config.pageTimeout){
|
||||||
if((pageInfo.pagenumber) -1 == this.curPage){
|
if((pageInfo.pagenumber) -1 == this.curPage){
|
||||||
rotation_timeout= pageInfo.timeout
|
rotationTimeout= pageInfo.timeout
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ Module.register('MMM-pages', {
|
||||||
// message, so we need to trigger it for ourselves.
|
// message, so we need to trigger it for ourselves.
|
||||||
self.sendNotification('PAGE_CHANGED', 0);
|
self.sendNotification('PAGE_CHANGED', 0);
|
||||||
self.notificationReceived('PAGE_CHANGED', self.config.homePage);
|
self.notificationReceived('PAGE_CHANGED', self.config.homePage);
|
||||||
}, rotation_timeout);
|
}, rotationTimeout);
|
||||||
}, delay);
|
}, delay);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -308,12 +308,12 @@ Module.register('MMM-pages', {
|
||||||
*
|
*
|
||||||
* @param {boolean} isRotating the parameter, if you want to pause or resume.
|
* @param {boolean} isRotating the parameter, if you want to pause or resume.
|
||||||
*/
|
*/
|
||||||
setRotation: function (isRotating) {
|
setRotation (isRotating) {
|
||||||
const stateBaseString = (isRotating) ? "resum" : "paus";
|
const stateBaseString = (isRotating) ? "resum" : "paus";
|
||||||
if (isRotating === this.rotationPaused) {
|
if (isRotating === this.rotationPaused) {
|
||||||
Log.warn(`[Pages]: Was asked to ${stateBaseString}e but rotation is already ${stateBaseString}ed!`);
|
Log.warn(`[MMM-pages]: Was asked to ${stateBaseString}e but rotation is already ${stateBaseString}ed!`);
|
||||||
} else {
|
} else {
|
||||||
Log.log(`[Pages]: ${stateBaseString}ing rotation`);
|
Log.log(`[MMM-pages]: ${stateBaseString}ing rotation`);
|
||||||
if (!isRotating) {
|
if (!isRotating) {
|
||||||
if(this.timer){
|
if(this.timer){
|
||||||
this.timer_clear_function(this.timer);
|
this.timer_clear_function(this.timer);
|
||||||
|
@ -335,7 +335,7 @@ Module.register('MMM-pages', {
|
||||||
*
|
*
|
||||||
* @param {string} name the name of the hiddenPage we want to show
|
* @param {string} name the name of the hiddenPage we want to show
|
||||||
*/
|
*/
|
||||||
showHiddenPage: function (name) {
|
showHiddenPage (name) {
|
||||||
// Only proceed if the named hidden page actually exists
|
// Only proceed if the named hidden page actually exists
|
||||||
if (name in this.config.hiddenPages) {
|
if (name in this.config.hiddenPages) {
|
||||||
this.animatePageChange(name);
|
this.animatePageChange(name);
|
||||||
|
|
56
eslint.config.mjs
Normal file
56
eslint.config.mjs
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import eslintPluginJs from "@eslint/js";
|
||||||
|
import eslintPluginStylistic from "@stylistic/eslint-plugin";
|
||||||
|
import globals from "globals";
|
||||||
|
|
||||||
|
const config = [
|
||||||
|
{
|
||||||
|
files: ["**/*.js", "**/*.mjs"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.node,
|
||||||
|
Log: "readonly",
|
||||||
|
MM: "readonly",
|
||||||
|
Module: "readonly",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
...eslintPluginStylistic.configs["all-flat"].plugins,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...eslintPluginJs.configs.all.rules,
|
||||||
|
...eslintPluginStylistic.configs["all-flat"].rules,
|
||||||
|
"@stylistic/array-element-newline": "off",
|
||||||
|
"@stylistic/brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
||||||
|
"@stylistic/comma-dangle": ["error", "only-multiline"],
|
||||||
|
"@stylistic/dot-location": ["error", "property"],
|
||||||
|
"@stylistic/function-call-argument-newline": "off",
|
||||||
|
"@stylistic/indent": ["error", 2],
|
||||||
|
"@stylistic/max-statements-per-line": ["error", { max: 2 }],
|
||||||
|
"@stylistic/object-curly-spacing": "off",
|
||||||
|
"@stylistic/padded-blocks": "off",
|
||||||
|
"@stylistic/quote-props": ["error", "consistent-as-needed"],
|
||||||
|
"init-declarations": "off",
|
||||||
|
"@stylistic/quotes": ["error", "double"],
|
||||||
|
"@stylistic/multiline-comment-style": "off",
|
||||||
|
"@stylistic/multiline-ternary": "off",
|
||||||
|
"capitalized-comments": "off",
|
||||||
|
"consistent-this": "off",
|
||||||
|
"max-lines": "off",
|
||||||
|
"max-lines-per-function": "off",
|
||||||
|
"max-statements": "off",
|
||||||
|
"no-empty-function": "off",
|
||||||
|
"no-inline-comments": "off",
|
||||||
|
"no-magic-numbers": "off",
|
||||||
|
"no-negated-condition": "off",
|
||||||
|
"no-ternary": "off",
|
||||||
|
"no-undefined": "off",
|
||||||
|
"one-var": "off",
|
||||||
|
"sort-keys": "off",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export default config;
|
1543
package-lock.json
generated
Normal file
1543
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
32
package.json
Normal file
32
package.json
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
"name": "mmm-pages",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Add pages to your MagicMirror².",
|
||||||
|
"main": "MMM-pages.js",
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint .",
|
||||||
|
"lint:fix": "eslint . --fix",
|
||||||
|
"test": "npm run lint"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/sdetweil/MMM-pages.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"MagicMirror",
|
||||||
|
"pages",
|
||||||
|
"slides"
|
||||||
|
],
|
||||||
|
"author": "Edward Shen",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/sdetweil/MMM-pages/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/sdetweil/MMM-pages#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.10.0",
|
||||||
|
"@stylistic/eslint-plugin": "^2.8.0",
|
||||||
|
"eslint": "^9.10.0",
|
||||||
|
"globals": "^15.9.0"
|
||||||
|
}
|
||||||
|
}
|
136
readme.md
136
readme.md
|
@ -1,27 +1,6 @@
|
||||||
# Maintainer needed
|
|
||||||
|
|
||||||
Hello, it's been 5 years since I've written this! While I'm happy to see it
|
|
||||||
thriving, it's also about time I step away. I haven't had a MagicMirror up
|
|
||||||
in years, and to be frank, I'm hoping someone else will be willing to take
|
|
||||||
up maintainership of the project.
|
|
||||||
|
|
||||||
I find this project to be in a near complete form. Other than a few mishaps of
|
|
||||||
me not having proper testing before pushing out code, more often than not any
|
|
||||||
problems that people have usually isn't often because of this project. The few
|
|
||||||
issues that do exist aren't very hard to fix nor are they severe that they
|
|
||||||
impact the project in any large manner. It's just I haven't had the time nor
|
|
||||||
motivation to fix them.
|
|
||||||
|
|
||||||
I don't think there are expectations for this project to have new features, so
|
|
||||||
a maintainer should really only need to just make sure people are getting help
|
|
||||||
when they raise issues and fix the rare bug that pops out every so often. If
|
|
||||||
you're interested, please don't hesitate to reach out.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# MMM-pages
|
# MMM-pages
|
||||||
|
|
||||||
This [MagicMirror²][mm] Module allows you to have pages in your MagicMirror!
|
This [MagicMirror²][mm] module allows you to have pages in your MagicMirror!
|
||||||
Want to have more modules in your MagicMirror, but want to keep the format?
|
Want to have more modules in your MagicMirror, but want to keep the format?
|
||||||
Or, want to have grouped modules that are themed together? Look no further!
|
Or, want to have grouped modules that are themed together? Look no further!
|
||||||
|
|
||||||
|
@ -31,9 +10,11 @@ Note that this module does not provide any method of manually changing the page!
|
||||||
You should ask other developers to add a notification to their modules, or add
|
You should ask other developers to add a notification to their modules, or add
|
||||||
one yourself!
|
one yourself!
|
||||||
|
|
||||||
|
To display what page you're on, check out the [page indicator module][page indicator].
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
In your terminal, go to your MagicMirror's Module folder:
|
In your terminal, go to your MagicMirror's module folder:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ~/MagicMirror/modules
|
cd ~/MagicMirror/modules
|
||||||
|
@ -42,68 +23,73 @@ cd ~/MagicMirror/modules
|
||||||
Clone this repository:
|
Clone this repository:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/sdetweil/MMM-pages.git
|
git clone https://github.com/sdetweil/MMM-pages
|
||||||
```
|
```
|
||||||
|
|
||||||
Configure the module in your config.js file.
|
## Update
|
||||||
|
|
||||||
*\<self-promotion>*
|
Go to the module’s folder inside your MagicMirror's module folder and pull the latest version:
|
||||||
|
|
||||||
To display what page you're on, I'd highly recommend checking out my
|
```bash
|
||||||
[page indicator module][page indicator].
|
cd ~/MagicMirror/modules/MMM-pages
|
||||||
|
git pull
|
||||||
|
```
|
||||||
|
|
||||||
*\<\\self-promotion>*
|
## Configuration
|
||||||
|
|
||||||
## Using the module
|
|
||||||
|
|
||||||
To use this module, add it to the modules array in the `config/config.js` file.
|
To use this module, add it to the modules array in the `config/config.js` file.
|
||||||
|
|
||||||
Note: module names used in the following example are fictitious.
|
Note: module names used in the following example are fictitious.
|
||||||
|
|
||||||
this approach uses the module names as the page organization technique, as the modulename is added as a css class in the MM page content.
|
This approach uses the module names as the page organization technique, as the modulename is added as a CSS class in the MM page content.
|
||||||
|
|
||||||
Because the modulename is used, this approach does not support multiple instances of the same module with data
|
Because the modulename is used, this approach does not support multiple instances of the same module with data
|
||||||
on different pages. (like your calendar on page 1, and someone elses on page 2)
|
on different pages (like your calendar on page 1, and someone elses on page 2).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
module: 'MMM-pages',
|
module: "MMM-pages",
|
||||||
config: {
|
config: {
|
||||||
modules:
|
modules: [
|
||||||
[[ "newsfeed" ],
|
["newsfeed"],
|
||||||
[ "calendar", "compliments" ]],
|
["calendar", "compliments"]
|
||||||
fixed: [ "clock", "weather", "MMM-page-indicator" ],
|
],
|
||||||
hiddenPages: {
|
fixed: ["clock", "weather", "MMM-page-indicator"],
|
||||||
"screenSaver": [ "clock", "MMM-SomeBackgroundImageModule" ],
|
hiddenPages: {
|
||||||
"admin": [ "MMM-ShowMeSystemStatsModule", "MMM-AnOnScreenMenuModule" ],
|
"screenSaver": ["clock", "MMM-SomeBackgroundImageModule"],
|
||||||
},
|
"admin": ["MMM-ShowMeSystemStatsModule", "MMM-AnOnScreenMenuModule"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
and alternative approach, is to define a fixed MMM-pages config
|
and alternative approach, is to define a fixed MMM-pages config
|
||||||
|
|
||||||
```js
|
```js
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
module: 'MMM-pages',
|
module: "MMM-pages",
|
||||||
config: {
|
config: {
|
||||||
modules:
|
modules: [
|
||||||
[[ "page1" ],
|
["page1"],
|
||||||
[ "page2" ],
|
["page2"],
|
||||||
[ "page3" ],
|
["page3"]
|
||||||
],
|
],
|
||||||
fixed: [ "fixed_page" ],
|
fixed: ["fixed_page"],
|
||||||
hiddenPages: {
|
hiddenPages: {
|
||||||
"screenSaver": [ "screensaver_page" ],
|
"screenSaver": ["screensaver_page"],
|
||||||
"admin": [ "admin_page" ],
|
"admin": ["admin_page"]
|
||||||
},
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
and then at each module, add a classes: property to indicate the page(s) this module is supposed to appear on
|
and then at each module, add a classes: property to indicate the page(s) this module is supposed to appear on
|
||||||
```
|
|
||||||
|
```js
|
||||||
{
|
{
|
||||||
module:"newsfeed",
|
module:"newsfeed",
|
||||||
classes:"page1",
|
classes:"page1",
|
||||||
|
@ -117,10 +103,12 @@ and then at each module, add a classes: property to indicate the page(s) this mo
|
||||||
classes:"page2",
|
classes:"page2",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
etc
|
|
||||||
|
|
||||||
if u want a modules content on multiple pages the classes would list those page names
|
etc.
|
||||||
```
|
|
||||||
|
If u want a modules content on multiple pages the classes would list those page names
|
||||||
|
|
||||||
|
```js
|
||||||
{
|
{
|
||||||
module:"newsfeed",
|
module:"newsfeed",
|
||||||
classes:"page1",
|
classes:"page1",
|
||||||
|
@ -139,7 +127,7 @@ if u want a modules content on multiple pages the classes would list those page
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration options
|
### Configuration options
|
||||||
|
|
||||||
| Option | Type | Default Value | Description |
|
| Option | Type | Default Value | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
|
@ -153,13 +141,11 @@ if u want a modules content on multiple pages the classes would list those page
|
||||||
| `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. |
|
| `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. |
|
| `rotationFirstPage` | *NA* | *NA* | **Deprecated**. Use `rotationHomePage` instead. |
|
||||||
| `homePage` | `int` | `0` | Which page index is the home page. If none is set, this returns to the leftmost page instead. |
|
| `homePage` | `int` | `0` | Which page index is the home page. If none is set, this returns to the leftmost page instead. |
|
||||||
| `useLockString` | `bool` | `true` | Whether or not to use a lock string to show or hide pages. If disabled, other modules may override when modules may be shown. _Advanced users only. Only override this if you know what you're doing._
|
| `useLockString` | `bool` | `true` | Whether or not to use a lock string to show or hide pages. If disabled, other modules may override when modules may be shown. *Advanced users only. Only override this if you know what you're doing.* |
|
||||||
| `pageTimeout ` | `[]` | `{pageNumber:x,timeout:nnnn}`| array of structures, enable different timeouts for different pages
|
| `pageTimeout` | `[]` | `{pageNumber:x,timeout:nnnn}`| array of structures, enable different timeouts for different pages. |
|
||||||
|||| pageNumber starts at 1 for the first page, timeout is in milliseconds
|
|||| `pageNumber` starts at 1 for the first page, timeout is in milliseconds. |
|
||||||
|
|
||||||
For the `module` configuration option, the first element of the outer array
|
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 should consist of elements that should be on the second page, and so forth.
|
||||||
should consist of elements that should be on the first page. The second element
|
|
||||||
should consist of elements that should be on the second page, and so forth.
|
|
||||||
|
|
||||||
## Notifications
|
## Notifications
|
||||||
|
|
||||||
|
@ -197,7 +183,7 @@ index of 1, and the page to the right of that has an index of 2. Thus, to change
|
||||||
to the third page, your module should send out:
|
to the third page, your module should send out:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
this.sendNotification("PAGE_CHANGED", 2);
|
this.sendNotification("PAGE_CHANGED", 2);
|
||||||
```
|
```
|
||||||
|
|
||||||
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
|
||||||
|
@ -209,8 +195,8 @@ MMM-pages notifications.
|
||||||
|
|
||||||
### Initialization
|
### Initialization
|
||||||
|
|
||||||
_This section provides documentation on what notifications the module sends on
|
*This section provides documentation on what notifications the module sends on
|
||||||
startup. This section isn't necessary to read for most users._
|
startup. This section isn't necessary to read for most users.*
|
||||||
|
|
||||||
MMM-pages doesn't activate until we receive the `DOM_OBJECTS_CREATED`
|
MMM-pages doesn't activate until we receive the `DOM_OBJECTS_CREATED`
|
||||||
notification, as that notification ensures all modules have been loaded. On this
|
notification, as that notification ensures all modules have been loaded. On this
|
||||||
|
|
Loading…
Reference in a new issue