commit 93621061bff390bf46905d2abeaabb26328ef176 Author: Edward Shen Date: Sun Jun 18 16:24:04 2017 -0400 added basic functionality diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..19d6368 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2017 Edward Shen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MMM-pages.js b/MMM-pages.js new file mode 100644 index 0000000..d305e96 --- /dev/null +++ b/MMM-pages.js @@ -0,0 +1,60 @@ +Module.register("MMM-pages", { + defaults: { + modules: [], + excludes: ["MMM-page-indicator"], + animationTime: 1000, + + }, + + getStyles: function() { + return ["pages.css"]; + }, + + start: function() { + this.curPage = 0; + }, + + notificationReceived: function(notification, payload, sender) { + if (notification === "PAGE_CHANGED") { + Log.log(this.name + " recieved a notification to change to page " + payload); + this.curPage = payload; + this.updatePages(); + } else if (notification === "PAGE_INCREMENT") { + Log.log(this.name + " recieved a notification to increment pages!"); + if (this.curPage === this.config.modules.length - 1) { + this.curPage = 0; + } else { this.curPage++ } + this.updatePages(); + } else if (notification === "PAGE_DECREMENT") { + Log.log(this.name + " recieved a notification to decrement pages!"); + if (this.curPage === 0) { + this.curPage = this.config.modules.length - 1; + } else { this.curPage-- } + this.updatePages(); + } else if (notification === "DOM_OBJECTS_CREATED") { + Log.log(this.name + " recieved that all objects are created; will now hide things!"); + this.updatePages(); + + this.sendNotification("MAX_PAGES_CHANGED", this.config.modules.length); + } + }, + + + // TODO: Add animation + updatePages: function() { + if (this.config.modules.length !== 0) { + MM.getModules() + .exceptWithClass(this.config.excludes) + .exceptWithClass(this.config.modules[this.curPage]) + .enumerate(module => { module.hide(this.config.animationTime / 2, { lockstring: this.identifier }) }); + + let self = this; + setTimeout(function() { + MM.getModules() + .withClass(self.config.modules[self.curPage]) + .enumerate(module => { module.show(self.config.animationTime / 2, { lockstring: self.identifier }) }); + }, this.config.animationTime / 2); + } else { Log.error("Pages aren't properly defined!") } + }, + +}); diff --git a/pages.css b/pages.css new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/pages.css @@ -0,0 +1 @@ +