MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Refresh Hello World module

    Scheduled Pinned Locked Moved Troubleshooting
    3 Posts 2 Posters 4.9k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? Offline
      A Former User
      last edited by

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

      });

      1 Reply Last reply Reply Quote 0
      • yawnsY Offline
        yawns Moderator
        last edited by

        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.

        ? 1 Reply Last reply Reply Quote 0
        • ? Offline
          A Former User @yawns
          last edited by

          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…

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy