Read the statement by Michael Teeuw here.
Custom module bases helloworld
-
Hi everyone! Now i started to use magicMirror and want to build my simple custom module to indncate somrthing (traffic load at now).
I wrote a scryptvar text1 = ""; var text2 = ""; var text3 = ""; var htmlpage = 'https://www.yandex.ru'; var request = require('request'); var DomParser = require('dom-parser'); var parser = new DomParser(); var dom; setInterval(function() { request(htmlpage, function(error, response, body) { dom = parser.parseFromString(body); text1 = dom.getElementsByClassName('traffic i-bem')[0].innerHTML; dom = parser.parseFromString(text1); text2 = dom.getElementsByTagName('H1')[0].innerHTML; dom = parser.parseFromString(text2); text3 = dom.getElementsByClassName('link link_black_yes')[0].textContent }); }, 1000);request and dom-parser eas intalled.
Then i get text data string and i want to set it into the Hello world module next.I added my scrypt code into the module code here:
getDom: function() { var wrapper = document.createElement("div"); wrapper.innerHTML = this.config.text; return wrapper; }But it doesnt work (request and parser modules). Otherwise, just counting number works well(((.
Could not you help me, what i have to do to get my scrypt working inside helloworld module?
-
@roma-cezar you need to put your code into a node_helper as it is based on node dependencies. Then you can communicate via sockets between the helper and the module. you can have a look in other modules which have a node_helper file how the communication works. also you can have a look in the developer guide here https://github.com/MichMich/MagicMirror/blob/master/modules/README.md
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login