added basic functionality

pull/1/head
Edward Shen 2017-06-18 16:24:04 -04:00
commit 93621061bf
3 changed files with 80 additions and 0 deletions

19
LICENSE Normal file
View File

@ -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.

60
MMM-pages.js Normal file
View File

@ -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!") }
},
});

1
pages.css Normal file
View File

@ -0,0 +1 @@