PDA

View Full Version : Moon Phases in Calendar Monthly


Ozy
06-03-2008, 11:43 PM
Hi,

I run a non-profit site for our Astronomy club. I want to add the current moon phase to each day in the calendar view. I can source JPG's for moon phase for the view. I can also provide the logic for calculating the phase for that day. I just don't know how to make these changes. Any help would be great.


// CREDITS:
// Moon Phase Clock
// by Urs Dudli and Peter Gehrig
// Copyright (c) 2002 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.24fun.com/fast/index.html
// info@24fun.com
// 6/25/2002

// IMPORTANT:
// If you add this script to a script-library or a script-archive
// you have to insert a link to http://www.24fun.com
// right into the webpage where the script will be displayed.

var pastdate
var pastyear=2002
var pastmonth=5
var pastday=11
var nowdate
var c
var pausenormal=50
var pausenowmoon=3000
var moonday
var i_mooncycle=1
var mooncycle=29.530589

var picture = new Array("moonitems/n1.gif","moonitems/n2.gif","moonitems/n3.gif","moonitems/n4.gif","moonitems/n5.gif","moonitems/n6.gif","moonitems/n7.gif","moonitems/n8.gif","moonitems/n9.gif","moonitems/n10.gif","moonitems/n11.gif","moonitems/n12.gif","moonitems/n13.gif","moonitems/n14.gif","moonitems/n15.gif","moonitems/n16.gif","moonitems/n17.gif","moonitems/n18.gif","moonitems/n19.gif","moonitems/n20.gif","moonitems/n21.gif","moonitems/n22.gif","moonitems/n23.gif","moonitems/n24.gif","moonitems/n25.gif","moonitems/n26.gif","moonitems/n27.gif","moonitems/n28.gif","moonitems/n29.gif")

var imgpreload=new Array()
for (i=0;i<=picture.length;i++) {
imgpreload[i]=new Image()
imgpreload[i].src=picture[i]
}

pastdate=new Date(pastyear,pastmonth,pastday,0,0,0)
nowdate=new Date()
resultdays=(Date.parse(nowdate)-Date.parse(pastdate))/1000/60/60/24
moonday=resultdays/mooncycle
moonday=(resultdays/mooncycle)-(Math.floor(resultdays/mooncycle))
moonday=Math.round(mooncycle*moonday)
c="<img src='moonitems/n"+moonday+".gif' name='moonimg'>"

window.onload=animatemoon

function animatemoon() {
if (i_mooncycle==moonday) {
var pause=pausenowmoon
}
else {
var pause=pausenormal
}
var mimg="moonitems/n"+i_mooncycle+".gif"
document.moonimg.src=mimg
i_mooncycle++
if (i_mooncycle>29) {i_mooncycle=1}
var timer=setTimeout("animatemoon()",pause)
}

StepOnFrog
07-23-2008, 01:20 AM
I am also interested in your idea....

I found this in the meantime --> https://vborg.vbsupport.ru/showthread.php?t=68090&highlight=moon+phases

;-D
step

Reeve of shinra
07-23-2008, 02:21 AM
The current Calendar isn't the best for tihs kind of stuff :(