Skip to content

Instantly share code, notes, and snippets.

@jsomers
Last active August 16, 2023 06:54
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsomers/18b928aee211ed7249f5707be89f79f0 to your computer and use it in GitHub Desktop.
Save jsomers/18b928aee211ed7249f5707be89f79f0 to your computer and use it in GitHub Desktop.
Dynamically created sky map using Fourmilab's Your Sky
<script>
var toUrlParam = function(date) {
return date.toISOString().split("T")[0].replaceAll("-", "%2F");
}
// https://stackoverflow.com/questions/563406/add-days-to-javascript-date
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
}
var date = new Date("1576-11-01");
var imgTag;
var updateImage = function() {
date = date.addDays(1);
imgTag.src = `https://www.fourmilab.ch/cgi-bin/Yoursky?date=1&utc=${toUrlParam(date)}+12%3A42%3A40&jd=2450851.02963&lat=56.0881&ns=North&lon=13.2322&ew=East&coords=on&moonp=on&deepm=2.5&limag=5.5&starnm=2.0&starbm=2.5&imgsize=640&dynimg=y&fontscale=0.75&scheme=1&elements=`;
}
document.addEventListener("DOMContentLoaded", function() {
imgTag = document.createElement("img")
updateImage()
document.querySelector("body").appendChild(imgTag);
setInterval(updateImage, 150);
})
</script>
@jsomers
Copy link
Author

jsomers commented Dec 23, 2020

I made the GIF that appears on https://observablehq.com/d/1838567c160ca917 by opening the above html page in a browser and taking a short screencap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment