D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
darrenjaworski
Full window
Github gist
Last 30 days of astronomy pic of the day.
<html> <head> <style> .gallery { clear: both; } .apod_img_class { width: 23%; margin: 1%; float: left; } body { margin: auto; max-width: 95%; } iframe { border: none; } </style> </head> <body> <div class="gallery"> </div> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script> var today = new Date(); //for loop to go back a day for a set number of days for (var dayBack = 0; dayBack < 30; dayBack++) { var requestDate = new Date(); requestDate.setDate(today.getDate() - dayBack); var queryString = requestDate.getFullYear()+"-"+parseInt(requestDate.getMonth()+1)+"-"+requestDate.getDate() getImage(queryString); } function getImage(date) { var url = "https://api.nasa.gov/planetary/apod?concept_tags=True&date="+ date +"&hd=True&api_key=NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo"; $.ajax({ url: url, success: handleResult }); function handleResult(result){ if(result.media_type != "video") { $( ".gallery" ).append( "<img class='apod_img_class' src='"+ result.url +"' alt='"+ result.explanation +"'>" ); } } } </script>
https://code.jquery.com/jquery-2.1.4.min.js