Вы находитесь на странице: 1из 5

<script language=JavaScript SRC=feedback.js></script> <script language=JavaScript> <!

-- hide var var var var var var var var n0 = parseInt( "0" ); f0 = parseFloat( "0.0" ); AG = f0; // Moon's age DI = f0; // Moon's distance in earth radii LA = f0; // Moon's ecliptic latitude LO = f0; // Moon's ecliptic longitude Phase = " "; Zodiac = " ";

function initialize() { var d = new Date(); document.calc.year.value = d.getFullYear(); document.calc.month.value = d.getMonth() + 1; document.calc.day.value = d.getDate(); } function calculate() { var year = parseInt( document.calc.year.value, 10 ); var month = parseInt( document.calc.month.value, 10 ); var day = parseInt( document.calc.day.value, 10 ); if( !isdayofmonth( year, month, day ) ) { alert( "Invalid date" ); return; } moon_posit( year, month, day ); document.calc.age.value document.calc.dst.value document.calc.faz.value document.calc.lat.value document.calc.lon.value document.calc.sgn.value } var var var var ); n28 n30 n31 dim = = = = parseInt( "28" ); parseInt( "30" ); parseInt( "31" ); new Array( n31, n28, n31, n30, n31, n30, n31, n31, n30, n31, n30, n31 = = = = = = round2( round2( Phase; round2( round2( Zodiac; AG ); DI ); LA ); LO );

function isdayofmonth( y, m, d ) { if( m != 2 ) { if( 1 <= d && d <= dim[m-1] ) return true; else return false; }

var feb = dim[1]; if( isleapyear( y ) ) feb += 1; if( 1 <= d && d <= feb ) return true; return false; } function isleapyear( y ) { var x = Math.floor( y - 4*Math.floor( y/4 ) ); var w = Math.floor( y - 100*Math.floor( y/100 ) ); var z = Math.floor( y - 400*Math.floor( y/400 ) ); if( x == 0 ) { if( w == 0 && z != 0 ) return false; else return true; } return false; } function backup( n ) { var year = parseInt( document.calc.year.value, 10 ); var month = parseInt( document.calc.month.value, 10 ); var day = parseInt( document.calc.day.value, 10 ); switch( n ) { case 1: document.calc.year.value = year - 1; calculate(); break; case 2: if( month < 2 ) { document.calc.month.value = 12; document.calc.year.value = year - 1; } else document.calc.month.value = month - 1; calculate(); break; case 3: if( day < 2 ) { if( month < 2 ) { document.calc.month.value = 12; document.calc.year.value = year - 1; } else // possible leap year // not leap year // is leap year // is leap year

document.calc.month.value = month - 1; month = parseInt( document.calc.month.value, 10 ); if( month == 2 && isleapyear( year ) ) document.calc.day.value = 29; else document.calc.day.value = dim[month-1]; } else document.calc.day.value = day - 1; calculate(); break; } } function advance( n ) { var year = parseInt( document.calc.year.value, 10 ); var month = parseInt( document.calc.month.value, 10 ); var day = parseInt( document.calc.day.value, 10 ); switch( n ) { case 1: document.calc.year.value = year + 1; calculate(); break; case 2: if( month < 12 ) document.calc.month.value = month + 1; else { document.calc.month.value = 1; document.calc.year.value = year + 1; } calculate(); break; case 3: if( isdayofmonth( year, month, day + 1 ) ) document.calc.day.value = day + 1; else { if( month < 12 ) document.calc.month.value = month + 1; else { document.calc.month.value = 1; document.calc.year.value = year + 1; } document.calc.day.value = 1; } calculate(); break; } } // compute moon position and phase function moon_posit( Y, M, D ) {

var var var var var var var var var var

YY MM K1 K2 K3 JD IP DP NP RP

= = = = = = = = = =

n0; n0; n0; n0; n0; n0; f0; f0; f0; f0;

// calculate the Julian date at 12h UT YY = Y - Math.floor( ( 12 - M ) / 10 ); MM = M + 9; if( MM >= 12 ) MM = MM - 12; K1 = Math.floor( 365.25 * ( YY + 4712 ) ); K2 = Math.floor( 30.6 * MM + 0.5 ); K3 = Math.floor( Math.floor( ( YY / 100 ) + 49 ) * 0.75 ) - 38; JD = K1 + K2 + D + 59; if( JD > 2299160 ) JD = JD - K3; // for dates in Julian calendar // for Gregorian calendar

// calculate moon's age in days IP = normalize( ( JD - 2451550.1 ) / 29.530588853 ); AG = IP*29.53; if( else else else else else else else else if( if( if( if( if( if( if( AG AG AG AG AG AG AG AG < < < < < < < < 1.84566 5.53699 9.22831 12.91963 16.61096 20.30228 23.99361 27.68493 ) ) ) ) ) ) ) ) Phase Phase Phase Phase Phase Phase Phase Phase Phase = = = = = = = = = "NEW"; "Evening crescent"; "First quarter"; "Waxing gibbous"; "FULL"; "Waning gibbous"; "Last quarter"; "Morning crescent"; "NEW"; // Convert phase to radians

IP = IP*2*Math.PI;

// calculate moon's distance DP = 2*Math.PI*normalize( ( JD - 2451562.2 ) / 27.55454988 ); DI = 60.4 - 3.3*Math.cos( DP ) - 0.6*Math.cos( 2*IP - DP ) - 0.5*Math.cos( 2 *IP ); // calculate moon's ecliptic latitude NP = 2*Math.PI*normalize( ( JD - 2451565.2 ) / 27.212220817 ); LA = 5.1*Math.sin( NP ); // calculate moon's ecliptic longitude RP = normalize( ( JD - 2451555.8 ) / 27.321582241 ); LO = 360*RP + 6.3*Math.sin( DP ) + 1.3*Math.sin( 2*IP - DP ) + 0.7*Math.sin( 2*IP ); if( else else else else else else if( if( if( if( if( if( LO LO LO LO LO LO LO < < < < < < < 33.18 51.16 93.44 119.48 135.30 173.34 224.17 ) ) ) ) ) ) ) Zodiac Zodiac Zodiac Zodiac Zodiac Zodiac Zodiac = = = = = = = "Pisces"; "Aries"; "Taurus"; "Gemini"; "Cancer"; "Leo"; "Virgo";

else else else else else else

if( if( if( if( if(

LO LO LO LO LO

< < < < <

242.57 271.26 302.49 311.72 348.58

) ) ) ) )

Zodiac Zodiac Zodiac Zodiac Zodiac Zodiac

= = = = = =

"Libra"; "Scorpio"; "Sagittarius"; "Capricorn"; "Aquarius"; "Pisces";

// so longitude is not greater than 360! if ( LO > 360 ) LO = LO - 360; } // round to 2 decimal places function round2( x ) { return ( Math.round( 100*x )/100.0 ); } // normalize values to range 0...1 function normalize( v ) { v = v - Math.floor( v ); if( v < 0 ) v = v + 1; return v; } // clear input function allclear() { document.calc.year.value='0'; document.calc.month.value='0'; document.calc.day.value='0'; } // unhide --> </script>

Вам также может понравиться