mirror of
https://github.com/edward-shen/MMM-pages.git
synced 2024-11-22 02:04:29 -08:00
changed this to self in inner anonymous class
This commit is contained in:
parent
5549c484f1
commit
6ea3f13e7d
1 changed files with 11 additions and 17 deletions
26
MMM-pages.js
26
MMM-pages.js
|
@ -58,29 +58,25 @@ Module.register('MMM-pages', {
|
||||||
* @param {number} payload the page to change to/by
|
* @param {number} payload the page to change to/by
|
||||||
*/
|
*/
|
||||||
notificationReceived: function(notification, payload) {
|
notificationReceived: function(notification, payload) {
|
||||||
if (typeof payload !== 'number') {
|
|
||||||
Log.warn(`[Pages]: ${payload} is not a number!`);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (notification) {
|
switch (notification) {
|
||||||
case 'PAGE_CHANGED':
|
case 'PAGE_CHANGED':
|
||||||
Log.log(`${this.name} received a notification`
|
Log.log('[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(`${this.name} received a notification to increment pages!`);
|
Log.log('[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(`${this.name} received a notification to decrement pages!`);
|
Log.log('[Pages]: received a notification to decrement pages!');
|
||||||
this.changePageBy(payload, -1);
|
this.changePageBy(payload, -1);
|
||||||
this.updatePages();
|
this.updatePages();
|
||||||
break;
|
break;
|
||||||
case 'DOM_OBJECTS_CREATED':
|
case 'DOM_OBJECTS_CREATED':
|
||||||
Log.log(`${this.name} received that all objects are created;`
|
Log.log('[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.animatePageChange();
|
this.animatePageChange();
|
||||||
|
@ -104,6 +100,10 @@ Module.register('MMM-pages', {
|
||||||
* numbers.
|
* numbers.
|
||||||
*/
|
*/
|
||||||
changePageBy: function(amt, fallback) {
|
changePageBy: function(amt, fallback) {
|
||||||
|
if (typeof payload !== 'number') {
|
||||||
|
Log.warn(`[Pages]: ${amt} is not a number!`);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof amt === 'number') {
|
if (typeof amt === 'number') {
|
||||||
this.curPage = this.mod(
|
this.curPage = this.mod(
|
||||||
this.curPage + amt,
|
this.curPage + amt,
|
||||||
|
@ -124,15 +124,9 @@ Module.register('MMM-pages', {
|
||||||
updatePages: function() {
|
updatePages: function() {
|
||||||
// Update iff there's at least one page.
|
// Update iff there's at least one page.
|
||||||
if (this.config.modules.length !== 0) {
|
if (this.config.modules.length !== 0) {
|
||||||
// We need to use self because upstream uses an older electron and thus
|
|
||||||
// older version of node
|
|
||||||
|
|
||||||
this.animatePageChange();
|
this.animatePageChange();
|
||||||
|
|
||||||
if (this.config.rotationTime > 0) {
|
|
||||||
this.resetTimerWithDelay(this.config.rotationDelay);
|
this.resetTimerWithDelay(this.config.rotationDelay);
|
||||||
}
|
} else { Log.error("[Pages]: Pages aren't properly defined!"); }
|
||||||
} else { Log.error("Pages aren't properly defined!"); }
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,7 +149,7 @@ Module.register('MMM-pages', {
|
||||||
|
|
||||||
// Shows all modules meant to be on the current page, after a small delay.
|
// Shows all modules meant to be on the current page, after a small delay.
|
||||||
setTimeout(() => MM.getModules()
|
setTimeout(() => MM.getModules()
|
||||||
.withClass(this.config.modules[self.curPage])
|
.withClass(self.config.modules[self.curPage])
|
||||||
.enumerate(module => module.show(
|
.enumerate(module => module.show(
|
||||||
self.config.animationTime / 2,
|
self.config.animationTime / 2,
|
||||||
{ lockString: self.identifier },
|
{ lockString: self.identifier },
|
||||||
|
|
Loading…
Reference in a new issue