<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Trying to fix my module]]></title><description><![CDATA[<p dir="auto">Hello, I come to you because I started trying to create my own module. Because I didn’t know anything about javascript, html and css 2 weeks ago and not much in programmation either, I pretty much learned everything in 2 weeks so please, be indulgent :p</p>
<p dir="auto">The module I’m creating is supposed to display the data from a french public transport API. I worked on the display using a local server, just to test things out, I made it work, then I tried to implement it to my magic mirror, but here started the problems, I used the default modules as a guide and tried to move the diffrents pieces where they should be and now, I have this, but when I start my mirror, the screen stays black and it doesn’t start:</p>
<p dir="auto">Module.register(“schedules”, {</p>
<pre><code>        defaults: {
            updateInterval: 20000
            fadeSpeed: 4000
        },

        getScripts: function() {
            return ["moment.js"]
        },

        getStyles: function() {
            return ["font-awesome.css", "schedules.css"]

        },

        start: function() {
            Log.info("Starting module: " + this.name);


            var self = this;
            setInterval(function() {
                self.updateDom(self.config.fadeSpeed);
            }, this.config.updateInterval);
        },

        getDom: function() {

            dataDirSM = loadJSON("https://api-ratp.pierre-grimaud.fr/v2/rers/B/stations/les+baconnets?destination=robinson+saint+remy+les+chevreuse&amp;endingstation=les+baconnets")
            data = loadJSON("https://api-ratp.pierre-grimaud.fr/v2/rers/B/stations/les+baconnets?destination=charles+de+gaulle+mitry+claye&amp;endingstation=les+baconnets");

            setTimeout(function() {

                var wrapper = document.createElement("div")


                var realtable = document.createElement('table');

                realtable.appendChild(this.createUpperRow());

                var row1 = document.createElement('tr')
                row1.appendChild(this.boxHeader(data.response.schedules[0].message))
                row1.appendChild(this.boxHeader(data.response.schedules[0].id))
                row1.appendChild(this.boxHeader(dataDirSM.response.schedules[0].id))
                row1.appendChild(this.boxHeader(dataDirSM.response.schedules[0].message))
                realtable.appendChild(row1)

                var row2 = document.createElement('tr')
                row2.appendChild(this.boxHeader(data.response.schedules[1].message))
                row2.appendChild(this.boxHeader(data.response.schedules[1].id))
                row2.appendChild(this.boxHeader(dataDirSM.response.schedules[1].id))
                row2.appendChild(this.boxHeader(dataDirSM.response.schedules[1].message))
                realtable.appendChild(row2)

                var row3 = document.createElement('tr')
                row3.appendChild(this.boxHeader(data.response.schedules[2].message))
                row3.appendChild(this.boxHeader(data.response.schedules[2].id))
                row3.appendChild(this.boxHeader(dataDirSM.response.schedules[2].id))
                row3.appendChild(this.boxHeader(dataDirSM.response.schedules[2].message))
                realtable.appendChild(row3)


                wrapper.appendChild(realtable)

                return wrapper

            }, (5 * 1000));

        },

        createUpperRow: function() {

            function createUpperRow() {

                var firstTableRow = document.createElement('tr');

                var tableh1 = document.createElement('th');
                tableh1.classList.add('align-left');
                var tx1 = document.createTextNode('Time');

                tableh1.appendChild(tx1);
                firstTableRow.appendChild(tableh1);

                var tableh2 = document.createElement('th');
                tableh2.classList.add('align-left');
                var tx2 = document.createTextNode('Paris');

                tableh2.appendChild(tx2);
                firstTableRow.appendChild(tableh2);

                // deuxième moitier

                var tableh3 = document.createElement('th');
                tableh3.classList.add('align-right');
                var tx3 = document.createTextNode('Sud');

                tableh3.appendChild(tx3);
                firstTableRow.appendChild(tableh3);

                var tableh4 = document.createElement('th');
                tableh4.classList.add('align-right');
                var tx4 = document.createTextNode('Time');

                tableh4.appendChild(tx4);
                firstTableRow.appendChild(tableh4);

                return firstTableRow;

            },

            boxHeader: function(inside) {

                if (inside == 'Train à l\'approche' || inside == 'Train à quai') {

                    inside = 'no way'
                } else if (inside == 'Train retardé') {

                    inside = 'retard'
                }



                var fillNode = document.createTextNode(inside);
                var realBox = document.createElement('td')
                realBox.appendChild(fillNode);
                return realBox;
            }


        })
</code></pre>
<p dir="auto">and my css file :</p>
<p dir="auto">.schedules .logo {<br />
margin-right: 5px;<br />
}</p>
<p dir="auto">.schedules .centered {<br />
text-align: center;<br />
}</p>
<p dir="auto">.schedules .table     {<br />
border-spacing: 10px 0px;<br />
border-collapse: separate;<br />
}</p>
<p dir="auto">(I don’t know why it doesn’t auto format)</p>
<p dir="auto">if you guys had little hints for me to fix my mistakes, I’ll be highly thankful.</p>
]]></description><link>https://forum.magicmirror.builders/topic/1258/trying-to-fix-my-module</link><generator>RSS for Node</generator><lastBuildDate>Wed, 12 Aug 2026 17:21:45 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/1258.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Dec 2016 20:07:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Trying to fix my module on Sun, 25 Dec 2016 21:59:29 GMT]]></title><description><![CDATA[<p dir="auto">Oh you are right, I also forget a curly brace after the ‘else’, I changed all that but it still doesn’t work<br />
I paste the code again if you want to see it clear</p>
<p dir="auto">Module.register(“schedules”, {</p>
<pre><code>defaults: {
    updateInterval: 20000
    fadeSpeed: 4000
},

getScripts: function() {
    return ["moment.js"]
},

getStyles: function() {
    return ["font-awesome.css", "schedules.css"]

},

start: function() {
    Log.info("Starting module: " + this.name);


    setInterval(() =&gt; {
        this.getData();
        this.updateDom();
    }, 20 * 1000); //calls getData every 20 seconds
},

getDom: function() {


    var wrapper = document.createElement("div")
    if (this.dataDirSM &amp;&amp; this.data) {

        var realtable = document.createElement('table');

        realtable.appendChild(this.createUpperRow());

        for (var i = 0; i &lt; Math.min(this.data.response.schedules.length, this.dataDirSM.response.schedules.length); i++) {
            var row = document.createElement('tr')
            row.appendChild(this.boxHeader(this.data.response.schedules[i].message))
            row.appendChild(this.boxHeader(this.data.response.schedules[i].id))
            row.appendChild(this.boxHeader(this.dataDirSM.response.schedules[i].id))
            row.appendChild(this.boxHeader(this.dataDirSM.response.schedules[i].message))
            realtable.appendChild(row)
        }
        wrapper.appendChild(realtable)
    } else {
        wrapper.innerHTML = "NO DATA";
    };
    return wrapper

},


getData: function() {

    this.dataDirSM = loadJSON("https://api-ratp.pierre-grimaud.fr/v2/rers/B/stations/les+baconnets?destination=robinson+saint+remy+les+chevreuse&amp;endingstation=les+baconnets");
    this.data = loadJSON("https://api-ratp.pierre-grimaud.fr/v2/rers/B/stations/les+baconnets?destination=charles+de+gaulle+mitry+claye&amp;endingstation=les+baconnets");

},

createUpperRow: function() {


    var firstTableRow = document.createElement('tr');

    var tableh1 = document.createElement('th');
    tableh1.classList.add('align-left');
    var tx1 = document.createTextNode('Time');

    tableh1.appendChild(tx1);
    firstTableRow.appendChild(tableh1);

    var tableh2 = document.createElement('th');
    tableh2.classList.add('align-left');
    var tx2 = document.createTextNode('Paris');

    tableh2.appendChild(tx2);
    firstTableRow.appendChild(tableh2);

    // deuxième moitier

    var tableh3 = document.createElement('th');
    tableh3.classList.add('align-right');
    var tx3 = document.createTextNode('Sud');

    tableh3.appendChild(tx3);
    firstTableRow.appendChild(tableh3);

    var tableh4 = document.createElement('th');
    tableh4.classList.add('align-right');
    var tx4 = document.createTextNode('Time');

    tableh4.appendChild(tx4);
    firstTableRow.appendChild(tableh4);

    return firstTableRow;

},

boxHeader: function(inside) {

    if (inside == 'Train à l\'approche' || inside == 'Train à quai') {

        inside = 'no way'
    } else if (inside == 'Train retardé') {

        inside = 'retard'
    }



    var fillNode = document.createTextNode(inside);
    var realBox = document.createElement('td')
    realBox.appendChild(fillNode);
    return realBox;
}
</code></pre>
<p dir="auto">})</p>
]]></description><link>https://forum.magicmirror.builders/post/9841</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/9841</guid><dc:creator><![CDATA[skoz]]></dc:creator><pubDate>Sun, 25 Dec 2016 21:59:29 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to fix my module on Sun, 25 Dec 2016 21:53:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/skoz" aria-label="Profile: skoz">@<bdi>skoz</bdi></a> you forgot to return wrapper at the end of getDom and remove <code>function createUpperRow() {</code> in vreateUpperRow</p>
]]></description><link>https://forum.magicmirror.builders/post/9838</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/9838</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Sun, 25 Dec 2016 21:53:07 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to fix my module on Sun, 25 Dec 2016 21:49:09 GMT]]></title><description><![CDATA[<p dir="auto">Well at least, this time, something happened, the mirror boot up but where the table should be, its written :</p>
<p dir="auto"><strong>schedules</strong><br />
module_5_schedules</p>
<p dir="auto">Module.register(“schedules”, {</p>
<pre><code>        defaults: {
            updateInterval: 20000
            fadeSpeed: 4000
        },

        getScripts: function() {
            return ["moment.js"]
        },

        getStyles: function() {
            return ["font-awesome.css", "schedules.css"]

        },

        start: function() {
            Log.info("Starting module: " + this.name);


            setInterval(() =&gt; {
                this.getData();
                this.updateDom();
            }, 20 * 1000); //calls getData every 20 second
        },

        getDom: function() {


            var wrapper = document.createElement("div")
            if (this.dataDirSM &amp;&amp; this.data) {

                var realtable = document.createElement('table');

                realtable.appendChild(this.createUpperRow());

                for (var i = 0; i &lt; Math.min(this.data.response.schedules.length, this.dataDirSM.response.schedules.length); i++) {
                    var row = document.createElement('tr')
                    row.appendChild(this.boxHeader(this.data.response.schedules[i].message))
                    row.appendChild(this.boxHeader(this.data.response.schedules[i].id))
                    row.appendChild(this.boxHeader(this.dataDirSM.response.schedules[i].id))
                    row.appendChild(this.boxHeader(this.dataDirSM.response.schedules[i].message))
                    realtable.appendChild(row)
                }
                wrapper.appendChild(realtable)
            } else {
                wrapper.innerHTML = "NO DATA";

            },


            getData: function() {

                    this.dataDirSM = loadJSON("https://api-ratp.pierre-grimaud.fr/v2/rers/B/stations/les+baconnets?destination=robinson+saint+remy+les+chevreuse&amp;endingstation=les+baconnets");
                    this.data = loadJSON("https://api-ratp.pierre-grimaud.fr/v2/rers/B/stations/les+baconnets?destination=charles+de+gaulle+mitry+claye&amp;endingstation=les+baconnets");

                },

                createUpperRow: function() {

                    function createUpperRow() {

                        var firstTableRow = document.createElement('tr');

                        var tableh1 = document.createElement('th');
                        tableh1.classList.add('align-left');
                        var tx1 = document.createTextNode('Time');

                        tableh1.appendChild(tx1);
                        firstTableRow.appendChild(tableh1);

                        var tableh2 = document.createElement('th');
                        tableh2.classList.add('align-left');
                        var tx2 = document.createTextNode('Paris');

                        tableh2.appendChild(tx2);
                        firstTableRow.appendChild(tableh2);

                        // deuxième moitier

                        var tableh3 = document.createElement('th');
                        tableh3.classList.add('align-right');
                        var tx3 = document.createTextNode('Sud');

                        tableh3.appendChild(tx3);
                        firstTableRow.appendChild(tableh3);

                        var tableh4 = document.createElement('th');
                        tableh4.classList.add('align-right');
                        var tx4 = document.createTextNode('Time');

                        tableh4.appendChild(tx4);
                        firstTableRow.appendChild(tableh4);

                        return firstTableRow;

                    },

                    boxHeader: function(inside) {

                        if (inside == 'Train à l\'approche' || inside == 'Train à quai') {

                            inside = 'no way'
                        } else if (inside == 'Train retardé') {

                            inside = 'retard'
                        }



                        var fillNode = document.createTextNode(inside);
                        var realBox = document.createElement('td')
                        realBox.appendChild(fillNode);
                        return realBox;
                    }


                })
</code></pre>
<p dir="auto">and here is what I got from your advices</p>
]]></description><link>https://forum.magicmirror.builders/post/9836</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/9836</guid><dc:creator><![CDATA[skoz]]></dc:creator><pubDate>Sun, 25 Dec 2016 21:49:09 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to fix my module on Sun, 25 Dec 2016 21:34:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/skoz" aria-label="Profile: skoz">@<bdi>skoz</bdi></a> yes, but it’s not tested i just wrote it down to give you an idea. if you get in trouble feel free to wite me a pn or check out the other module</p>
]]></description><link>https://forum.magicmirror.builders/post/9833</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/9833</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Sun, 25 Dec 2016 21:34:26 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to fix my module on Sun, 25 Dec 2016 21:26:41 GMT]]></title><description><![CDATA[<p dir="auto">oh, i’m blind xD I had never seen this module, thanks for pointing it out !<br />
You fixed the for loop, i had trouble with this one, I refused to work and i still don’t know why so i decided to bypass it. Thanks alot for fixing my code, if I understand right, the getDom function will check if data has arrived and if True, it will display the table, if False, it will display the"NO DATA" ? and each reload, the program will reload the data and display it ?<br />
I’ll just have to shorten the time between each refresh because train pass by a bit more regularly so it wont be up to date if i wait 30 minutes each time.</p>
<p dir="auto">Thank you alot, I will try this new code now :)</p>
]]></description><link>https://forum.magicmirror.builders/post/9832</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/9832</guid><dc:creator><![CDATA[skoz]]></dc:creator><pubDate>Sun, 25 Dec 2016 21:26:41 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to fix my module on Sun, 25 Dec 2016 21:18:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/skoz" aria-label="Profile: skoz">@<bdi>skoz</bdi></a> the link is above</p>
<p dir="auto">to give you an idea i wrote something little quick to give you an idea how it can be</p>
<p dir="auto">set an interval in start()</p>
<pre><code>setInterval(() =&gt; {
  this.getData();
  this.updateDom();
}, 30*60*1000); //calls getData every 30 mins
</code></pre>
<p dir="auto">getData()</p>
<pre><code>this.dataDirSM = loadJSON("https://api-ratp.pierre-grimaud.fr/v2/rers/B/stations/les+baconnets?destination=robinson+saint+remy+les+chevreuse&amp;endingstation=les+baconnets");
this.data = loadJSON("https://api-ratp.pierre-grimaud.fr/v2/rers/B/stations/les+baconnets?destination=charles+de+gaulle+mitry+claye&amp;endingstation=les+baconnets");
</code></pre>
<p dir="auto">getDom()</p>
<pre><code>var wrapper = document.createElement("div")
if(this.dataDirSM &amp;&amp; this.data){

                var realtable = document.createElement('table');

                realtable.appendChild(this.createUpperRow());

for(var i = 0; i &lt; Math.min(this.data.response.schedules.length, this.dataDirSM.response.schedules.length); i++){
                var row = document.createElement('tr')
                row.appendChild(this.boxHeader(this.data.response.schedules[i].message))
                row.appendChild(this.boxHeader(this.data.response.schedules[i].id))
                row.appendChild(this.boxHeader(this.dataDirSM.response.schedules[i].id))
                row.appendChild(this.boxHeader(this.dataDirSM.response.schedules[i].message))
                realtable.appendChild(row)
}
                wrapper.appendChild(realtable)
} else {
wrapper.innerHTML = "NO DATA";
}
                return wrapper
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/9830</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/9830</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Sun, 25 Dec 2016 21:18:03 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to fix my module on Sun, 25 Dec 2016 21:05:12 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for your reply, I didn’t know about this synchronous problem. But I think I saw that the start function is only called once, not each reload, so in which function should I get the data ?</p>
<p dir="auto">I couldn’t find the ratp module you told me about, if you could send me a link, that would be cool :)</p>
]]></description><link>https://forum.magicmirror.builders/post/9828</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/9828</guid><dc:creator><![CDATA[skoz]]></dc:creator><pubDate>Sun, 25 Dec 2016 21:05:12 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to fix my module on Sun, 25 Dec 2016 20:58:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/skoz" aria-label="Profile: skoz">@<bdi>skoz</bdi></a></p>
<p dir="auto">what jumped on my eyes on the first look,</p>
<p dir="auto">the getDom function requires a synchronous answer, but with the timeout it’s asynchronous, you should load your data outside of this function and in getdom check if the data is there otherwise display a placeholder, then when you received data in the other function you call updateDom to refresh your display</p>
<p dir="auto">and there is a ratp module out there, maybe you will extend this one instead of creating a new one <a href="https://github.com/lgmorand/MMM-Ratp" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/lgmorand/MMM-Ratp</a></p>
]]></description><link>https://forum.magicmirror.builders/post/9826</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/9826</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Sun, 25 Dec 2016 20:58:09 GMT</pubDate></item></channel></rss>