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

MMM-Remote-Control # More files *.html (pages)

Scheduled Pinned Locked Moved Development
6 Posts 2 Posters 685 Views 2 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.
  • C Offline
    Ciastuus
    last edited by Sep 22, 2019, 12:51 PM

    Hi,

    I have a small problem because I can’t load more links in the form * .html to the MMM-Remote-Control module. When I try to do my own thing, only the same page loads, and by going manually to others, the same page still loads, and the name in the address bar changes.

    alt text

    This is what it looks like when trying to load the narzedzia.html page.
    (narzedzia - tools)
    It actually loads the lustro.html page
    (lustro - mirror)

    I did this:

        getDom: function() {
            var wrapper = document.createElement("div");
            if (this.addresses.length === 0) {
                this.addresses = ["ip-of-your-mirror"];
            }
            wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/index.html";
            wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/lustro.html";
            wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/narzedzia.html";
            wrapper.className = "normal xsmall";
            return wrapper;
        },
    
                this.expressApp.get("/index.html", function(req, res) {
                    if (self.template === "") {
                        res.send(503);
                    } else {
                        res.contentType("text/html");
                        var transformedData = self.fillTemplates(self.template);
                        res.send(transformedData);
                    }
                });
     
                this.expressApp.get("/lustro.html", function(req, res) {
                    if (self.template === "") {
                        res.send(503);
                    } else {
                        res.contentType("text/html");
                        var transformedData = self.fillTemplates(self.template);
                        res.send(transformedData);
                    }
                });
     
                this.expressApp.get("/narzedzia.html", function(req, res) {
                    if (self.template === "") {
                        res.send(503);
                    } else {
                        res.contentType("text/html");
                        var transformedData = self.fillTemplates(self.template);
                        res.send(transformedData);
                    }
                });
    
                fs.readFile(path.resolve(__dirname + "/index.html"), function(err, data) {
                    self.template = data.toString();
                });
     
                fs.readFile(path.resolve(__dirname + "/lustro.html"), function(err, data) {
                    self.template = data.toString();
                });
     
                fs.readFile(path.resolve(__dirname + "/narzedzia.html"), function(err, data) {
                    self.template = data.toString();
                });
    

    Unfortunately, I would like it to work properly as I would like. If someone can solve my problem, I can send something to paypal $$$.

    Thank you in advance for explaining how to do it correctly.

    S 1 Reply Last reply Sep 22, 2019, 2:15 PM Reply Quote 0
    • S Offline
      sdetweil @Ciastuus
      last edited by sdetweil Sep 22, 2019, 2:16 PM Sep 22, 2019, 2:15 PM

      @Ciastuus said in MMM-Remote-Control # More files *.html (pages):

          wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/index.html";
          wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/lustro.html";
          wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/narzedzia.html";
      

      1st… the html is not processed until you return the whole html block to mm…

      return wrapper;

      second, you set innerHtml

          wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/index.html";
      

      then overwrote it

          wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/lustro.html";
      

      then overwrote it.

          wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/narzedzia.html";
      

      and then returned the html content

              return wrapper;
      

      only the last

          wrapper.innerHTML =
      

      should work

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      C 1 Reply Last reply Sep 22, 2019, 4:48 PM Reply Quote 1
      • C Offline
        Ciastuus @sdetweil
        last edited by Sep 22, 2019, 4:48 PM

        @sdetweil

        So … After each wrapper.innerHTML I have to add

        return wrapper;
        

        e.g:

        wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/index.html";
        return wrapper;
        wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/lustro.html";
        return wrapper;
        wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/narzedzia.html";
        

        Is that way?

        wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/index.html";
        wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/lustro.html";
        wrapper.innerHTML = "http://" + this.addresses[0] + ":8080/narzedzia.html";
        return wrapper;
        
        S 1 Reply Last reply Sep 22, 2019, 6:43 PM Reply Quote 0
        • S Offline
          sdetweil @Ciastuus
          last edited by Sep 22, 2019, 6:43 PM

          @Ciastuus

          no… you can only have ONE innerHtml per return…

          last one u did wins…

          if u need more info in the html, you will need to add multiple elements with the additional html…

          if u did this manually, created a page to display ALL the html, what would it look like?
          what you do in MagicMirror is exactly the same

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          C 1 Reply Last reply Sep 22, 2019, 7:08 PM Reply Quote 1
          • C Offline
            Ciastuus @sdetweil
            last edited by Sep 22, 2019, 7:08 PM

            @sdetweil

            Can you explain it to me with any example? I don’t understand JavaScript very well … Maybe you can give discord on priv?

            S 1 Reply Last reply Sep 22, 2019, 8:03 PM Reply Quote 0
            • S Offline
              sdetweil @Ciastuus
              last edited by sdetweil Sep 23, 2019, 3:25 PM Sep 22, 2019, 8:03 PM

              @Ciastuus many html elements (p, div, span, … ) have an innerHtml attribute that will wrap text or raw html.

              a web page is made up of hundreds of html elements…

              the MagicMirror model is a single web page… and each module contributes a little bit of that content.

              the getDom() routine is MagicMirrors request to the module to supply the html for ITS content. (paragraph, table, … whatever)…

              BUT, until the getDom() routine returns, the stuff built is just in the modules memory space.

              the content provided to MagicMirror is then inserted into the dom in the appropriate location based on the ‘position’ you provided in config.js.

              the content can be built lots of different ways…

              hard coded html text (just like a html file)
              some hard coded and some built by building the little dom tree for the modules content
              or all apis…

              none of this is MagicMirror specific, as it uses the documented Document Object Model (dom) apis defined my the w3c standards.

              your module’s content starts with a

               < div>
                   innerHtml is here
               < /div>
              

              and then u set its div.innerHtml, or call div.appendChild(anotherElement)

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              1 / 1
              • First post
                1/6
                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