@KirAsh4
Thanks! I messed around a bit with it - here is what I came up with. (and yes, 99.999% is yours!)
Still, here it is for anyone else who wants to play with it. But ALL credit goes to @KirAsh4
This works best for me for MMM-Wunderground and MMM-Wunderlist - which I keep at top-right.
a) my config.js extract:
{
module: 'my_swap', // as supplied by KirAsh4
config: {
showsecs: 30, // seconds each module is shown (default =30)
// 30 is a "relaxed" speed
fadems: 4000, // fade time in ms (default = 4000)
// 4000 is also very relaxed - no coffee yet.
modA: 'MMM-WunderGround', // both modules need to be listed NEXT
modB: 'MMM-Wunderlist' // they should be of similar size,
// and in the same location.
// These two are _prefect_
}
},
{
module: 'MMM-WunderGround',
position: 'top_right',
config: {
apikey: '****',
pws: '****',
lang: 'EN',
fctext: '1',
fcdaycount: "5",
fcdaystart: "0",
hourly: '1',
hourlyinterval: "3",
hourlycount: "1",
alerttime: 10000,
alerttruncatestring: "english:",
fade: true
}
},
{
module: 'MMM-Wunderlist',
position: 'top_right',
config: {
accessToken: '****',
clientID: '****',
lists: [
'MagicMirror'
],
interval: 60,
fadePoint: 0.9,
fade: true
}
},
Then the file my_swap.js ( in \modules\my_swap) needs to look like this:
Module.register("my_swap",{
// Default module config.
defaults: {
modA: "MMM-NonExistA", // if we dont know the EXACT NAME, we don't do anything!
modB: "MMM-NonExistB", // ="=
showsecs: 30, // as in compliments
fadems: 4000 // ="=
},
// Define required scripts.
getScripts: function() {
return ["moment.js"];
},
start: function() {
Log.log("Starting module: " + this.name);
this.DOMloaded = 0;
this.isHidden = 0;
var self = this;
setInterval(function() {
self.swapModules();
}, 1000);
},
notificationReceived: function(notification, payload, sender) {
if (notification === 'DOM_OBJECTS_CREATED') {
this.DOMloaded = 1;
}
},
// swapModules.
swapModules: function() {
var now = moment();
var self = this;
var mod1 = this.config.modA // yank from config file
var mod2 = this.config.modB
var fadems = this.config.fadems
var showsecs = this.config.showsecs
if (!(now.seconds() % showsecs)) {
if (this.DOMloaded) {
if (self.isHidden) {
MM.getModules().exceptModule(this).enumerate(function(module) {
if (module.name === mod1) {
module.hide(fadems, function() {
MM.getModules().exceptModule(this).enumerate(function(module) {
if (module.name === mod2) {
module.show(fadems, function() {
});
}
});
});
}
});
self.isHidden = 0;
} else {
MM.getModules().exceptModule(this).enumerate(function(module) {
if (module.name === mod2) {
module.hide(fadems, function() {
MM.getModules().exceptModule(this).enumerate(function(module) {
if (module.name === mod1) {
module.show(fadems, function() {
});
}
});
});
}
});
self.isHidden = 1;
}
}
}
}
});
Works great for me! Thanks again for the clean code to play with. You should submit it as an official module.