Начало
Сообщения
Лунные Фазы
Показывает текущую фазу луны и оценивает время следующей полной луны, используя вычисление вращения луны и даты.
Сохраните изображение "
JavaScript Messages: Лунные Фазы
<!-- ONE STEP TO INSTALL MOON PHASES: 1. Copy the coding into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the BODY of your HTML document --> <BODY> <SCRIPT LANGUAGE="JavaScript"> <! > <! > <!-- Begin // Save the two necessary images from our example page at: // http://messages.javascriptsource.com/moon-phases.html var black = "http://your-web-site-address-here.ru/images/moon-pics/black.gif"; var white = "http://your-web-site-address-here.ru/images/moon-pics/white.gif"; var height=1; var size = 50; var i; var currentDate = new Date(); var x = currentDate; currentDate.setTime(currentDate.getTime() + (currentDate.getTimezoneOffset()*60000)); var blueMoonDate = new Date(96, 1, 3, 16, 15, 0); var lunarPeriod = 29*(24*3600*1000) + 12*(3600*1000) + 44.05*(60*1000); var moonPhaseTime = (currentDate.getTime() - blueMoonDate.getTime()) % lunarPeriod; var percentRaw = (moonPhaseTime / lunarPeriod); var percent = Math.round(100*percentRaw) / 100; var percentBy2 = Math.round(200*percentRaw); var left = (percentRaw >= 0.5) ? black : white; var right = (percentRaw >= 0.5) ? white : black; var time = Math.round((lunarPeriod-moonPhaseTime)/(24*3600*1000)); document.write("<center>"); if (percentBy2 > 100) { percentBy2 = percentBy2 - 100; } for (i = -(size-1); i < size; ++i) { var wid=2*parseFloat(Math.sqrt((size*size)-(i*i))); if (percentBy2 != 100) document.write ("<img src="+left +" height=1 width="+(wid*((100-percentBy2)/100))+">"); if (percentBy2 != 0) document.write("<img src="+right+" height=1 width="+(wid*((percentBy2)/100))+">"); document.write("<br>"); } document.write("<BR><FONT SIZE=4>Next full moon is in about ",time," day"); if (time > 1) document.write("s"); document.write(""); // End --> </script> <!-- Script Size: 1.83 KB -->