Read the statement by Michael Teeuw here.
Refresh Hello World module
-
I am using the Hello World module to display an iFrame on my Magic Mirror. Now I need to refresh the frame every minute, but its not working and my js skills are not really good. It only needs to refresh this:
Thanks for every help!Module.register(“helloworld”,{
// Default module config. defaults: { text: "Hello World!" }, // Override dom generator. getDom: function() { var wrapper = document.createElement("div"); wrapper.innerHTML = this.config.text; return wrapper; }
});
-
Hi,
simplest way is to create a new module. So you don’t run into update problems in the future if someone changes the original hello world module.
Copy the whole helloworld folder from modules/default/ to modules/ and rename it to something different, lets say “mmm-iframe”.
- Rename the folder itself to
mmm-iframe
- Rename the
helloworld.js
file tommm-iframe.js
Then overwrite the content of
mmm-iframe.js
with this:/* global Module */ /* Magic Mirror * Module: mmm-iframe * * By Michael Teeuw http://michaelteeuw.nl * MIT Licensed. */ Module.register("mmm-iframe",{ // Default module config. defaults: { text: "Hello World!", animationSpeed: 1000, }, start: function() { Log.info('Starting module: ' + this.name); var self = this; setInterval(function() { self.updateDom(); }, this.config.animationSpeed); }, // Override dom generator. getDom: function() { var wrapper = document.createElement("div"); wrapper.innerHTML = this.config.text; return wrapper; } });
- Now update your config file and replace the helloworld entry to load the mmm-iframe module instead.
I did not test this, I don’t have a magicmirror available currently, but this should get you going.
- Rename the folder itself to
-
Thanks for your answer,
I think there is a problem with the MMM-ModuleScheduler. When the frame is hidden your version is refreshing good, but when it is visible, it is stopping. Maybe it will not work together…