MagicMirror² v2.8.0 is available! For more information about this release, check out this topic.

Compliments module is killing my other module.



  • Hi,

    I am using compliments module and Widget module(MMM-Widget) together on the same screen. Compliments module basically refreshes every 30 sec. once 30 sec cycle ends(updateInterval), my module widget gets blank ☹

    Here is the widget module that I’m using. (this is the out of the box one that’s provided, I didn’t modify anything here. I changed the references in config.js file only).

    /* Magic Mirror
    * Module: MMM-Widget
    *
    * By eouia
    */
    
    const DefaultWidgetFormat = {
      url: "",
      position: "top_left",
      width: "200px",
      height: "200px",
      backgroundColor: "#000"
    }
    
    
    Module.register("MMM-Widget",{
      defaults: {
        widgets: []
      },
    
      start: function() {
        this.sendSocketNotification("INIT", this.config)
      },
    
      notificationReceived: function(noti, payload, sender) {
        if (noti == "DOM_OBJECTS_CREATED") {
          this.sendSocketNotification("START")
        }
      },
    
      socketNotificationReceived: function(noti, payload) {
        if (noti == "READY") {
          this.loadWidgets()
        }
      },
    
    
      loadWidgets: function() {
        var widgets = this.config.widgets
        for (i in widgets){
          var widget = Object.assign({}, DefaultWidgetFormat, widgets[i])
    
          var iFrame = document.createElement("iframe")
          iFrame.id = "WIDGET_" + i
          iFrame.className = "widget_item"
          iFrame.style.width = widget.width
          iFrame.style.height = widget.height
          iFrame.style.border = "none"
          iFrame.style.display = "block"
          iFrame.style.overflow = "hidden"
          iFrame.style.backgroundColor = widget.backgroundColor
          iFrame.scrolling = "no"
          iFrame.src = "/widget/" + i
          var position = "." + widget.position.replace("_", ".") + " > .container"
          var regionContainer = document.querySelector(position)
          regionContainer.appendChild(iFrame)
          if (regionContainer.style.display == "none") {
            regionContainer.style.display = "block"
          }
        }
      },
    
      suspend: function() {
        var doms = document.getElementsByClassName("widget_item")
        if (doms.length > 0) {
          for (let dom of doms) {
            dom.style.display = "none"
          }
        }
      },
    
      resume: function() {
        var doms = document.getElementsByClassName("widget_item")
        if (doms.length > 0) {
          for (let dom of doms) {
            dom.style.display = "block"
          }
        }
      }
    })
    

    the compliments module that I’m using is also one that is provided out of the box.

    Here is my config file.

    modules: [
    
    		{
    			module: "compliments",
    			position: "top_center"
    		},
    
    		{
    			module: "MMM-Widget",
    			config: {
    				widgets: [
    
    					{
    						html: `
    								<a href="https://twitter.com/adidas?ref_src=twsrc%5Etfw">Tweets by Salesforce</a> 
    								 
    				`,
    						position: "top_left",
    						width: "400px",
    						height: "500px",
    					},
    
    					{
    						html: `
    								
    		<div>
    		  
    		</div>
    		
    								`,
    						position: "bottom_left",
    						width: "400px",
    						height: "111px",
    						backgroundColor: "#FFF"
    					},
    				]
    			}
    		},
    

    please let me know on how can I fix this, this is very confusing.

    Also need some help on auto refreshing this MMM-Widget module for every 30 seconds to show latest feed.

    Thanks,
    Sunny



  • @sunnykeerthi change the single quotes to double… u have the backtic… instead of single quote…

    just make all quotes the same



  • Hey @sdetweil,

    Is that the real reason of this?

    Thanks



  • i do not know… it is a 1st step



  • Ah!!! Ohk @sdetweil , Thanks… I’ll update and post you back.

    Thanks!!!



  • Hi @sdetweil ,

    Here is my update config.js.

    {
    			module: "compliments",
    			position: "top_right"
    		},
    
    		{
    			module: "MMM-Widget",
    			config: {
    				widgets: [
    
    					{
    						html: "<a href="\&quot;https://twitter.com/adidas?ref_src=twsrc%5Etfw\&quot;">Tweets by Adidas</a> ",
    						position: "top_left",
    						width: "400px",
    						height: "500px",
    					},
    
    
    				]
    			}
    		},
    

    But still no luck ☹

    @Module-Developers , @Sean any help please.

    Thanks


  • Module Developer

    @sunnykeerthi
    I’ll look inside tomorrow.



  • Thanks very much @Sean 🙂


  • Module Developer

    @sunnykeerthi
    I think it is fixed. Update and try again.