JavaScript JavaScript, PHP Array help for Webcam Images,

I really did not want to have to post but I am at my wits end.

I have a camera that I will be using to show visitors the current weather conditions.

I have a powershell script saving snapshots from the camera and PSFTP uploading them to my ftp. The files names are as follows 'MMddyyyyhhmmss'HBGCWeatherCam.jpeg.

These files reside in the /images folder

Request: I need to read all of the files in the images folder, sortby date in descending order, then pass it to my javascript array called by 'var images = [], x = -1;'

But for the life of me I can't seem to get it to work.

Any help would be greatly appreciated.

EDIT-- Below is the full working Code, MANY Thanks to Digital_Chris

<html>
   <head>
      <title>Weather Cam</title>
	  


<br/>
<br/>

	  
      <script type = "text/javascript">
          function displayPreviousImage() {
              x = (x === images.length - 1) ? 0 : x + 1;
              document.getElementById("img").src = images[x];
          }

          function displayNextImage() {
              x = (x <= 0) ? images.length - 1 : x - 1;
              document.getElementById("img").src = images[x];
          }

          //function startTimer() {
             // setInterval(displayNextImage, 500);
			 //clearInterval(startTimer);
          //}

		  
		  var images = [], x = -1;
<?php 
	$my_files = glob("images/*.jpeg");
    $counter = 0;
    foreach(array_reverse(glob("images/*.jpeg")) as $file) {
        echo "images[" . $counter . "] = '" . $file . "'; ";
        $counter++;
    }
?>
</script>


   </head>

   <body onload = "displayPreviousImage()">
   <div align="center">
       <img id="img" src="images/loading.gif" style="width: 500px; height: 500px;"/>
	   <br/>
       <button style="width: 100;" onclick="displayPreviousImage()">&#60; Previous</button>
		View Other Snapshots
       <button style="width: 100;" onclick="displayNextImage()">Next &#62;</button>
	   <br/>
	   <button style="width: 100;" onClick="window.location.reload()">View Current</button>
	   </div>
   </body>
</html>
Answer:1

I am using the following code to allow line breaks in the JQuery UI tooltip function. $(function() { $( document ).tooltip(); $('.linebreak').tooltip({ content: function(callback) {...

I am using the following code to allow line breaks in the JQuery UI tooltip function. $(function() { $( document ).tooltip(); $('.linebreak').tooltip({ content: function(callback) {...

  1. .replace only replacing first instance
  2. .replace only replacing first instance javascript
  3. jquery replace only replacing first instance
  4. js replace only replacing first instance
  5. javascript replace only replacing first occurrence
  6. javascript replace only replacing first value

In my Angular app the following sequence of events needs to happen: User clicks a button A previously hidden div is shown by flipping a boolean scope variable to which an ng-show is bound The newly ...

In my Angular app the following sequence of events needs to happen: User clicks a button A previously hidden div is shown by flipping a boolean scope variable to which an ng-show is bound The newly ...

Often I have maps with a whole lot of markers (let's say representing shops). I have infowindows that display basic info on the shop represented by the marker, then, on the infoWindow HTML I like to ...

Often I have maps with a whole lot of markers (let's say representing shops). I have infowindows that display basic info on the shop represented by the marker, then, on the infoWindow HTML I like to ...

I want to create a html5 audioplayer for my band's website. The audiofiles are stored in the database as mp3, ogg and wav files to support all major browsers on their current versions. First, all ...

I want to create a html5 audioplayer for my band's website. The audiofiles are stored in the database as mp3, ogg and wav files to support all major browsers on their current versions. First, all ...