• 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
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Run JavaScript if a file is created

Scheduled Pinned Locked Moved General Discussion
25 Posts 3 Posters 12.3k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    ooom416354 @KirAsh4
    last edited by Jul 28, 2016, 8:54 PM

    @KirAsh4 Just out of curiosity, if I were to add the code you provided into the PHP file, would i need to bracket it with <?php then add the code here?>

    1 Reply Last reply Reply Quote 0
    • K Offline
      KirAsh4 Moderator
      last edited by Jul 28, 2016, 9:18 PM

      This is hard to answer because I don’t know what your PHP file looks like. I don’t know if you are echo-ing HTML data, or using HEREDOC? I’m flying blind here … (as much fun as that could be)

      A Life? Cool! Where can I download one of those from?

      O 1 Reply Last reply Jul 28, 2016, 11:25 PM Reply Quote 0
      • O Offline
        ooom416354 @KirAsh4
        last edited by Jul 28, 2016, 11:25 PM

        @KirAsh4 I had actually uploaded that file a few posts back. For reference here’s the entire thing (forgive the ugliness)

        <head>
        	<title>Magic Mirror</title>
        <html>
        	<style type="text/css">
        		<?php include('css/main.css') ?>
        		<?php include('css//mbta-icons.css') ?>
        	</style>
        	<link rel="stylesheet" type="text/css" href="css/weather-icons.css">
        	<script type="text/javascript">
        		var gitHash = '<?php echo trim(`git rev-parse HEAD`) ?>';
        	</script>
        	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        	<meta name="google" value="notranslate" />
         
        </head>
        <body>
        
            <div class="backgroundTint"></div>
        
        	<div class="top left">
        		<div class="date small dimmed"></div>
        		<div class="time"></div>
        		<div class="timeWarning xxsmall"></div>
        		<div class="holidays xxsmall dimmed"></div>
        		<div class="calendar xxsmall"></div>
        		<div class="mbta xxxsmall dimmed"></div>
        	</div>
        
        	<div class="top right">
        	    <div class="windsun small dimmed"></div>
        		<div class="temp"></div>
        		<div class="tempfeelslike xxsmall"></div>
        		<div class="spacer"></div>
        		<div class="tempgraph"></div>
        		<div class="weekgraph"></div>
        		<div class="summary xxsmall2 dimmed"></div>
        		<div class="weatheralerts xxsmall2 dimmed"></div>
        	</div>
        
        	<div class="lower-third center-hor">
        		<div class="compliment light"></div>
        		<div class="weatherCompliment small light"></div>
        	</div>
        
        	<div class="bottom center-hor">
        		<div class="newsTitle xsmall xxdimmed"></div>
        		<div class="news medium"></div>
        	</div>
        
        	<div class="farbottom center-hor">
        		<div class="newsDots xxxsmall"></div>
        	</div>
        
        	<div class="farbottom right">
        		<div class="lastupdated luWeather xxxsmall xxdimmed"></div>
        		<div class="lastupdated luMBTA xxxsmall xxdimmed"></div>
        		<div class="lastupdated luRSS xxxsmall xxdimmed"></div>
        		<div class="lastupdated luHolidays xxxsmall xxdimmed"></div>
        	</div>
        
        </div>
        
        <!-- Third Parties -->
        <script src="js/jquery.js"></script>
        <script src="js/ical_parser.js"></script>
        <script src="js/moment-with-locales.js"></script>
        <script src="js/config.js"></script>
        <script src="js/rrule.js"></script>
        <script src="js/d3.js"></script>
        
        <!-- Our Stuff -->
        <script src="js/main.js?nocache=<?php echo md5(microtime()) ?>"></script>
        <script src="js/mm-weather.js?nocache=<?php echo md5(microtime()) ?>"></script>
        <script src="js/mm-mbta.js?nocache=<?php echo md5(microtime()) ?>"></script>
        <script src="js/mm-mta.js?nocache=<?php echo md5(microtime()) ?>"></script>
        
        </html>
        </body>
        1 Reply Last reply Reply Quote 0
        • K Offline
          KirAsh4 Moderator
          last edited by Jul 29, 2016, 12:17 AM

          Then yes, write the proper PHP code and stick it in <?php ... ?> tags.

          A Life? Cool! Where can I download one of those from?

          O 1 Reply Last reply Jul 29, 2016, 1:19 AM Reply Quote 0
          • O Offline
            ooom416354 @KirAsh4
            last edited by Jul 29, 2016, 1:19 AM

            @KirAsh4 awesome, I will give it a shot. I can’t thank you enough! Much appreciated!

            1 Reply Last reply Reply Quote 0
            • E Offline
              EoF @KirAsh4
              last edited by Jul 29, 2016, 1:56 PM

              @KirAsh4 Ah I wasn’t aware this was for MM2. Thought he was still using MM1. Didn’t know you could run PHP scripts on MM2.

              K 1 Reply Last reply Jul 29, 2016, 4:24 PM Reply Quote 0
              • K Offline
                KirAsh4 Moderator @EoF
                last edited by Jul 29, 2016, 4:24 PM

                @EoF, you can, as an external process, just like everything else. :)

                A Life? Cool! Where can I download one of those from?

                1 Reply Last reply Reply Quote 0
                • 1
                • 2
                • 3
                • 3 / 3
                3 / 3
                • First post
                  23/25
                  Last post
                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