MagicMirror² v2.5.0 is available! For more information about this release, check out this topic.

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;
        }
    

    });


  • Moderator

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

    1. Rename the folder itself to mmm-iframe
    2. Rename the helloworld.js file to mmm-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;
    	}
    });
    
    1. 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.



  • 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…