Read the statement by Michael Teeuw here.
MMM-Remote-Control # More files *.html (pages)
-
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.
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.
-
@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
-
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;
-
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 -
Can you explain it to me with any example? I don’t understand JavaScript very well … Maybe you can give discord on priv?
-
@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)