Skip to content

Instantly share code, notes, and snippets.

@jsomers
Last active October 20, 2024 21:55
Show Gist options
  • 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>
@okjuan
Copy link

okjuan commented Oct 20, 2024

Neat!

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