• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
  1. Home
  2. AdamBD
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
A
Offline
  • Profile
  • Following 0
  • Followers 0
  • Topics 1
  • Posts 3
  • Groups 0

AdamBD

@AdamBD

0
Reputation
210
Profile views
3
Posts
0
Followers
0
Following
Joined Sep 28, 2018, 4:08 AM
Last Online Sep 29, 2018, 6:14 AM

AdamBD Unfollow Follow

Latest posts made by AdamBD

  • RE: Help with inserting a script into a <div> element

    @sdetweil Hey sean, But then I need to have a ‘server’ running to pull this in. I would prefer just to keep it in another node file in the project. any thoughts on how to do that?

    posted in Development
    A
    AdamBD
    Sep 28, 2018, 6:51 PM
  • RE: Help with inserting a script into a <div> element

    Hi Sean, thanks for answering!

    tag.src = “EXTERNAL_SCRIPT_URL”;

    What should this point to? A local file on my machine?

    posted in Development
    A
    AdamBD
    Sep 28, 2018, 6:39 PM
  • Help with inserting a script into a <div> element

    Hi!

    I am working to create a custom module for the moovit transit service. Moovit has an out-of-the-box widget, which is a simple div with a script in it. The issue I am having is that the widget they provide is something thats supposed to be placed in the HTML directly:

    <div class="mv-wtp" data-metro="1" data-lang="en" style="width:900px; height:900px;" data-from="hakerem+4+tel" data-to="sarona" >
       
      <script>(function(d, s, id) {
    
          let js, fjs = d.getElementsByTagName(s)[0];
    
          js = d.createElement(s); js.id = id;
    
          js.src = "https://widgets.moovit.com/wtp/en";
    
          fjs.parentNode.insertBefore(js, fjs);
    
      }(document, 'script', 'moovit-jsw'));
    
    </script>
    </div>
    

    I dont know how to get a script to run if I am creating a div element from the document object in the module, for example:

    getDom: function() {
      var element = document.createElement("div")
      element.className = "myContent"
      element.innerHTML = "Hello, World! "
      return element
    },
    

    I understand that if you set innerHTML to be a script it will never evaluate in the browser.

    Anyone have suggestions on how to do this?

    posted in Development
    A
    AdamBD
    Sep 28, 2018, 4:34 AM
Enjoying MagicMirror? Please consider a donation!
MagicMirror created by Michael Teeuw.
Forum managed by Sam, technical setup by Karsten.
This forum is using NodeBB as its core | Contributors
Contact | Privacy Policy