<?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[Trouble with non-broken &quot;broken&quot; images]]></title><description><![CDATA[<p dir="auto">im working on a super basic tarot draw module that draws three cards at random out of seventy eight at random with the chance of inversion of each card.  not being a javascript or any other kind of real coder(i am a script kitty at best and not afraid to admit it).  i had chat gpt write me a module, which seems well written, ive had it correct itself and i just dont see where the errors are, if anyone would be willing to take a look i would be stoked. thanks in advance<code> code_text ...</code><br />
code_text</p>
<pre><code>MMM_Tarot.css

.tarot-card {
    max-width: 300px; /* Set maximum width */
    max-height: 400px; /* Set maximum height */
    width: auto; /* Maintain aspect ratio */
    height: auto; /* Maintain aspect ratio */
}

.inverted {
    transform: scaleY(-1);
}


code_text
MMM_Tarot.js

Module.register("MMM_Tarot", {
    defaults: {
        updateHour: 5, // Update hour (5 am)
        updateMinute: 0, // Update minute
        updateInterval: 24 * 60 * 60 * 1000, // Update every day
    },

    start: function() {
        var self = this;
        this.tarotData = {};
        this.scheduleUpdate();
        setInterval(function() {
            self.scheduleUpdate();
        }, 60 * 1000); // Check every minute if it's time to update
    },

    scheduleUpdate: function() {
        var self = this;
        var now = new Date();
        var scheduledTime = new Date(
            now.getFullYear(),
            now.getMonth(),
            now.getDate(),
            this.config.updateHour,
            this.config.updateMinute,
            0,
            0
        );

        var delay = scheduledTime.getTime() - now.getTime();
        if (delay &lt; 0) {
            delay += this.config.updateInterval;
        }

        setTimeout(function() {
            self.getTarotData();
            setInterval(function() {
                self.getTarotData();
            }, self.config.updateInterval);
        }, delay);
    },

    getStyles: function() {
        return ["MMM_Tarot.css"];
    },

    getTarotData: function() {
        this.sendSocketNotification("GET_TAROT_DATA");
    },

    socketNotificationReceived: function(notification, payload) {
        if (notification === "TAROT_DATA") {
            this.tarotData = payload;
            this.updateDom();
        }
    },

    getDom: function() {
        const wrapper = document.createElement("div");

        if (this.tarotData.images) {
            for (let i = 0; i &lt; this.tarotData.images.length; i++) {
                const cardImg = document.createElement("img");
                cardImg.src = this.tarotData.images[i].image;
                cardImg.className = "tarot-card"; // Add class to set max-width

                // If the card is inverted, add a class to flip it
                if (this.tarotData.images[i].inverted) {
                    cardImg.classList.add("inverted");
                }

                wrapper.appendChild(cardImg);
            }
        } else {
            wrapper.innerHTML = "Loading...";
        }



        return wrapper;
    }
});

</code></pre>
<p dir="auto">code_text</p>
<p dir="auto">node_helper.js</p>
<p dir="auto">const NodeHelper = require(“node_helper”);<br />
const fs = require(“fs”);<br />
const path = require(“path”);</p>
<p dir="auto">module.exports = NodeHelper.create({<br />
start: function() {<br />
console.log(“Starting node_helper for MMM_Tarot”);<br />
},</p>
<pre><code>socketNotificationReceived: function(notification) {
    if (notification === "GET_TAROT_DATA") {
        this.getTarotData();
    }
},

getTarotData: function() {
    // Array of available card images
    const cardImages = fs.readdirSync(path.join(__dirname, "..", "MMM_Tarot", "cards"));

    // Randomly select three card images
    const selectedCards = [];
    for (let i = 0; i &lt; 3; i++) {
        const randomIndex = Math.floor(Math.random() * cardImages.length);
        selectedCards.push(cardImages[randomIndex]);
    }

    // Determine if each card should be inverted
    const invertedCards = [];
    for (let i = 0; i &lt; 3; i++) {
        invertedCards.push(Math.random() &lt; 0.5); // 50% chance of being inverted
    }

    // Construct the file paths for the selected cards
    const cardPaths = selectedCards.map((card, index) =&gt; ({
        image: path.join(__dirname, "..", "cards", card),
        inverted: invertedCards[index],
    }));

    // Send the selected cards data back to the main module
    this.sendSocketNotification("TAROT_DATA", { images: cardPaths });
}
</code></pre>
<p dir="auto">});</p>
]]></description><link>https://forum.magicmirror.builders/topic/18500/trouble-with-non-broken-broken-images</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 12:42:31 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/18500.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 Feb 2024 00:17:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 23:07:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> that was my issue, I had assumed :8080/ what my main directory…  fixed it.  Thanks a bunch!</p>
]]></description><link>https://forum.magicmirror.builders/post/115558</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115558</guid><dc:creator><![CDATA[jedilkeme]]></dc:creator><pubDate>Mon, 12 Feb 2024 23:07:36 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 22:37:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jedilkeme" aria-label="Profile: jedilkeme">@<bdi>jedilkeme</bdi></a> path to images</p>
<pre><code class="language-text">http://localhost:8080
</code></pre>
<p dir="auto">is the MagicMirror folder</p>
<p dir="auto">so files in a module would be</p>
<pre><code class="language-text">http://localhost:8080/modules/modulename/xxx.jpg  (or whatever)
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/115557</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115557</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 12 Feb 2024 22:37:05 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 22:28:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jedilkeme" aria-label="Profile: jedilkeme">@<bdi>jedilkeme</bdi></a> said in <a href="/post/115555">Trouble with non-broken "broken" images</a>:</p>
<blockquote>
<p dir="auto">I ran npm start dev and I found an EADDRINUSE error</p>
</blockquote>
<p dir="auto">pm2 already has an instance running… only one at a time please on the same port</p>
<p dir="auto">pm2 status to see what pm2 manages<br />
pm2 --help<br />
to see all the things it CAN do<br />
pm2 stop name or row number or all<br />
pm2 stop all</p>
<p dir="auto">then you can do the npm start …</p>
<p dir="auto">when u are happy , then ctrl-q or ctrl-c to stop the npm start and pm2 start or restart row or name<br />
then on reboot it will come back up…</p>
<p dir="auto">pm2’s JOB is to keep its managed apps running…</p>
]]></description><link>https://forum.magicmirror.builders/post/115556</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115556</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 12 Feb 2024 22:28:23 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 22:19:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> ah, it wasn’t showing errors because I had it written to load at 5am…  I set it to run in one minute, and I did receive a 404 for the images, permissions are all groovy but I noticed I can’t view the images from localhost:8080/path-to-images in the browser, but if I just put in the file path in the address bar I can see the images…   then I ran npm start dev and I found an EADDRINUSE error.  Stumped.  Thanks your you assistance so far!</p>
]]></description><link>https://forum.magicmirror.builders/post/115555</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115555</guid><dc:creator><![CDATA[jedilkeme]]></dc:creator><pubDate>Mon, 12 Feb 2024 22:19:21 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 21:35:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jedilkeme" aria-label="Profile: jedilkeme">@<bdi>jedilkeme</bdi></a> and if you look at the html for the image, it is as you expected. and if you use that url.i  a browser, the image is displayed?</p>
]]></description><link>https://forum.magicmirror.builders/post/115552</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115552</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 12 Feb 2024 21:35:03 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 15:30:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> no 404 errors or anything else that pops out at me…</p>
]]></description><link>https://forum.magicmirror.builders/post/115549</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115549</guid><dc:creator><![CDATA[jedilkeme]]></dc:creator><pubDate>Mon, 12 Feb 2024 15:30:51 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 02:55:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jedilkeme" aria-label="Profile: jedilkeme">@<bdi>jedilkeme</bdi></a> in the console tab, you might see a 404 error, not found<br />
in the elements tab you can see the actual html used.</p>
]]></description><link>https://forum.magicmirror.builders/post/115532</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115532</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 12 Feb 2024 02:55:47 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 02:53:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jedilkeme" aria-label="Profile: jedilkeme">@<bdi>jedilkeme</bdi></a> what should I be looking for from there?</p>
]]></description><link>https://forum.magicmirror.builders/post/115531</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115531</guid><dc:creator><![CDATA[jedilkeme]]></dc:creator><pubDate>Mon, 12 Feb 2024 02:53:13 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 02:45:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jedilkeme" aria-label="Profile: jedilkeme">@<bdi>jedilkeme</bdi></a> I’m sorry, brain fart,  ctrl-shift-i</p>
]]></description><link>https://forum.magicmirror.builders/post/115530</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115530</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 12 Feb 2024 02:45:29 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 02:41:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> ctrl-alt-i has no effect???</p>
]]></description><link>https://forum.magicmirror.builders/post/115529</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115529</guid><dc:creator><![CDATA[jedilkeme]]></dc:creator><pubDate>Mon, 12 Feb 2024 02:41:06 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble with non-broken &quot;broken&quot; images on Mon, 12 Feb 2024 00:33:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jedilkeme" aria-label="Profile: jedilkeme">@<bdi>jedilkeme</bdi></a> what do I mean broken?</p>
<p dir="auto">did u look in the developers window console and elements tab?</p>
<p dir="auto">ctrl-alt-i</p>
<p dir="auto">tar in the filter field to see messages from,/about your module</p>
<p dir="auto">elements tab can see the html being used</p>
]]></description><link>https://forum.magicmirror.builders/post/115528</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/115528</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 12 Feb 2024 00:33:53 GMT</pubDate></item></channel></rss>