• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

module develop help!

Scheduled Pinned Locked Moved Development
11 Posts 3 Posters 5.5k 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.
  • W Offline
    wireshark
    last edited by Nov 27, 2017, 1:21 PM

    This post is deleted!
    ? 1 Reply Last reply Nov 27, 2017, 3:04 PM Reply Quote 0
    • ? Offline
      A Former User @wireshark
      last edited by Nov 27, 2017, 3:04 PM

      @wireshark
      You have not understood the structure of MagicMirror module and basic javascript syntax.
      I suggest you study more with other modules.

      1 Reply Last reply Reply Quote 0
      • ? Offline
        A Former User
        last edited by Nov 27, 2017, 3:10 PM

        Usually, a MagicMirror module should have several method implementations.

        .start() : called when module is loaded on bootup. (and after all modules are loaded.) You could use this function for initialization.
        .getDom() : called when view of modules is needed to refresh You could use this function to draw your content on Mirror.

        And there are many points to study.
        See this. https://github.com/MichMich/MagicMirror/tree/develop/modules

        W 1 Reply Last reply Nov 27, 2017, 8:31 PM Reply Quote 0
        • W Offline
          wireshark @Guest
          last edited by Nov 27, 2017, 8:31 PM

          This post is deleted!
          ? 1 Reply Last reply Nov 27, 2017, 8:46 PM Reply Quote 0
          • ? Offline
            A Former User @wireshark
            last edited by Nov 27, 2017, 8:46 PM

            @wireshark I didn’t look inside deeply.
            But in getDom() didn’t you draw anything. You just try to alert something on success.
            Ok, maybe you are just in developing stage. It’s ok.
            So, You should invoke getDom() with updateDom() when it is needed.
            By example, in your start(), you can update your dom like this.

            start: function() {
              var self = this
              setInterval(function(){
                self.updateDom()
              }, 60*1000)
            },
            

            After loaded, this module function start() would set interval timer to execute updateDom() for refreshing view. every time when updateDom() is called, getDom() will be executed. So, your getDom() will be executed every 60*1000 milsec.

            1 Reply Last reply Reply Quote 0
            • ? Offline
              A Former User
              last edited by A Former User Nov 27, 2017, 8:55 PM Nov 27, 2017, 8:51 PM

              But this is not so good, because, start() could be executed before DOM created. This could give your module unintended errors. My recommendation is starting your job after DOM_OBJECTS_CREATED notification received. This notification would be fired when all modules are loaded and draw their first DOM view.

              notificationReceived: function(noti, payload, sender) {
                if (noti == "DOM_OBJECTS_CREATED") {
                  //do your job
                  // e.g) set Timer to refreshing data and update view with updateDom()
                }
              },
              
              1 Reply Last reply Reply Quote 0
              • ? Offline
                A Former User
                last edited by Nov 27, 2017, 8:58 PM

                And the last, you SHOULD DRAW YOUR DOM for real rendering.

                getDom: function() {
                  // do your job...
                  yourDOM = document.createElement("div")
                  yourDOM.innerHTML = "Something"
                  return yourDOM // DOM which has your content inside, should be returned.
                },
                
                
                
                W 1 Reply Last reply Nov 28, 2017, 12:41 AM Reply Quote 0
                • W Offline
                  wireshark @Guest
                  last edited by Nov 28, 2017, 12:41 AM

                  This post is deleted!
                  ? 1 Reply Last reply Nov 28, 2017, 12:53 AM Reply Quote 0
                  • ? Offline
                    A Former User @wireshark
                    last edited by Nov 28, 2017, 12:53 AM

                    @wireshark
                    Run with npm start dev. And see the logs and errors. They tell you what are real problems. And even for us, without exact information, we couldn’t help.
                    Anyway, what it means ‘doesn’t work’? It has errors? Black screen?
                    I think if it works, just alert window would be popped up. (Return value of xhr.send() might be not what you really want.) You’d better to investigate codes around alert().

                    W 1 Reply Last reply Nov 29, 2017, 1:17 PM Reply Quote 0
                    • W Offline
                      wireshark @Guest
                      last edited by Nov 29, 2017, 1:17 PM

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        1/11
                        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