Page 1 of 1

Moon Ditty

Posted: Wed 07 Jun 2017 5:41 am
by Warrandyte
Just a quick little something to replace the moon image
it uses the MoonPercent Webtag and gets an appropriate image for that phase of the moon
like so:
Image
theres a bit of code to go in the placeholder for the image, and the moon images need to be in the images/moon/directory relative to the page.
I've kept the code verbose so people can see and change
hope someone finds it useful.
Theres also a large script animated moon at http://www.warrandytefarm.com/moon_large.htm
all the files are in Image
http://www.warrandytefarm.com/resources/moon.zip
Rob

Code: Select all

<script type="text/javascript">
var MoonPC=-<#MoonPercent>/100;
var ImageNum=0;
ImageNum=Math.round((1+MoonPC)*12);
if(ImageNum<10){
ImageNum=String(0)+String(ImageNum);
}
document.write("<img src=\"images/moon/moon_"+ImageNum+".png\"width=\"150px\" height=\"150px\"/>");
</script>