From 4401cb411b69f108bf2b24339d9220154b0b48ba Mon Sep 17 00:00:00 2001 From: Edward Shen <6173958+edward-shen@users.noreply.github.com> Date: Fri, 4 May 2018 11:09:53 -0400 Subject: [PATCH] For some reason it looks like node fixed the scoping of `this`. Removed instances of `self`. --- MMM-pages.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/MMM-pages.js b/MMM-pages.js index bd91f09..ce4e541 100644 --- a/MMM-pages.js +++ b/MMM-pages.js @@ -72,7 +72,7 @@ Module.register('MMM-pages', { break; case 'PAGE_DECREMENT': Log.log(`${this.name} recieved a notification to decrement pages!`); - this.curPage = this.mode(this.curPage - 1, this.config.modules.length); + this.curPage = this.mod(this.curPage - 1, this.config.modules.length); this.updatePages(true); break; case 'DOM_OBJECTS_CREATED': @@ -94,7 +94,6 @@ Module.register('MMM-pages', { updatePages(manuallyCalled) { if (this.config.modules.length !== 0) { Log.log(`updatePages was ${manuallyCalled ? '' : 'not'} manually called`); - const self = this; // Hides the current page's elements. MM.getModules() @@ -110,11 +109,11 @@ Module.register('MMM-pages', { // Shows the next page's elements setTimeout(() => { MM.getModules() - .withClass(self.config.modules[self.curPage]) + .withClass(this.config.modules[this.curPage]) .enumerate((module) => { module.show( - self.config.animationTime / 2, - { lockString: self.identifier }, + this.config.animationTime / 2, + { lockString: this.identifier }, ); }); }, this.config.animationTime / 2); @@ -125,18 +124,17 @@ Module.register('MMM-pages', { clearInterval(this.timer); setTimeout(() => { - self.timer = setInterval(() => { + this.timer = setInterval(() => { // Incrementing page this.curPage = this.mod( this.curPage + 1, this.config.modules.length, ); - self.sendNotification('PAGE_INCREMENT'); - self.updatePages(false); - }, self.config.rotationTime, false); + this.sendNotification('PAGE_INCREMENT'); + this.updatePages(false); + }, this.config.rotationTime, false); }, this.config.rotationDelay); } } else { Log.error("Pages aren't properly defined!"); } }, - });