Картинки к коду находятся в папке ../images/lunar/...
Сам скрипт находится в lunar.php
файле, я скопировал всё содержимое файла.
Код должен отображать дату, время и в зависимости от неё выводить предложение и соответствующую картинку Луны. Но при запуске кода не отоброжается ничего вообще.
Помогите пожалуйста разобраться.
<SCRIPT>
function getMoonAge(year, month, day)
{
d = Math.floor(year/20)
r = year-(d*20) //r is the remainder of (year/20)
while (r>9)
{
r = r-19
}
r = r*11
while (r>29)
{
r = r-30
}
if (month<3)
{
month = month+2
}
r = r+month+day
if (year<100)
{
r = r-4
}
else
{
r = r-8.3
}
while(r>29)
{
r = r-30
}
while(r<0)
{
r = r+30
}
return r
}
function getMoonPhase(moonAge)
{
if (moonAge<1) return "New"
if (moonAge<6) return "Waxing Cresent"
if (moonAge<9) return "First Quarter"
if (moonAge<13) return "Waxing Gibbous"
if (moonAge<16) return "Full"
if (moonAge<20) return "Waning Gibbous"
if (moonAge<23) return "Last Quarter"
if (moonAge<25) return "Waning Cresent"
if (moonAge<29) return "Waning Cresent"
if (moonAge<1) return "New"
}
function getMoonPhaseImg(moonAge)
{
if (moonAge<1) return "New"
if (moonAge<5) return "Waxing_Cresent"
if (moonAge<9) return "First_Quarter"
if (moonAge<13) return "Waxing_Gibbous"
if (moonAge<16) return "Full"
if (moonAge<20) return "Waning_Gibbous"
if (moonAge<22) return "Last_Quarter"
if (moonAge<25) return "Waning_Cresent"
if (moonAge<29) return "Waning_Cresent"
if (moonAge<30) return "New"
}
monthNames = new Array(13)
monthNames[1] = "Jan"
monthNames[2] = "Feb"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "Sept"
monthNames[10] = "Oct"
monthNames[11] = "Nov"
monthNames[12] = "Dec"
dayNames = new Array(8)
dayNames[1] = "Sunday"
dayNames[2] = "Monday"
dayNames[3] = "Tuesday"
dayNames[4] = "Wednesday"
dayNames[5] = "Thursday"
dayNames[6] = "Friday"
dayNames[7] = "Saturday"
function getLongDate(dateObj)
{
theDay = dayNames[dateObj.getDay()+1]
theMonth = monthNames[dateObj.getMonth()+1]
theDate = dateObj.getDate()
return ""+theDay+", "+theMonth+" "+theDate
}
function getNextFull(moonAge)
{
currMilSecs = (new Date()).getTime()
daysToGo = 15 - moonAge
while(daysToGo<2)
{
daysToGo = daysToGo+29
}
milSecsToGo = daysToGo*24*60*60*1000
nextMoonTime = currMilSecs+milSecsToGo
nextMoonDate = new Date(nextMoonTime)
return nextMoonDate
}
function getNextNew(moonAge)
{
currMilSecs = (new Date()).getTime()
daysToGo = 29 - moonAge
while(daysToGo<2)
{
daysToGo = daysToGo+29
}
milSecsToGo = daysToGo*24*60*60*1000
nextMoonTime = currMilSecs+milSecsToGo
nextMoonDate = new Date(nextMoonTime)
return nextMoonDate
}
</SCRIPT>
<?php
function phpblock_getMoon()
{
// The "Moon Type" Calendar
$today = getdate();
$month = $today['month'];
$day = $today['mday'];
$year = $today['year'];
$doy = $today['yday'];
// January
if ($month == "January")
{
$moon = "This is the Wolf Moon";
}
// February
if ($month == "Fe8bruary")
{
$moon = "This is the Snow Moon";
}
// March
if ($month == "March")
{
$moon = "This is the Storm Moon";
}
// April
if ($month == "April")
{
$moon = "This is the Growing Moon";
}
// May
if ($month == "May")
{
$moon = "This is the Hare Moon";
}
// June
if ($month == "June")
{
$moon = "This is the Mead Moon";
}
// July
if ($month == "July")
{
$moon = "This is the Hay Moon";
}
// August
if ($month == "August")
{
$moon = "This is the Corn Moon";
}
// September
if ($month == "September")
{
$moon = "This is the Harvest Moon";
}
// October
if ($month == "October")
{
$moon = "This is the Blood Moon";
}
// November
if ($month == "November")
{
$moon = "This is the Snow Moon";
}
// December
if ($month == "December")
{
$moon = "This is the Cold Moon";
}
$imgstring = "<script>
theDate = new Date();
theYear = theDate.getYear();
theMonth = theDate.getMonth()+1;theDay = theDate.getDate();
theMoonAge = getMoonAge(theYear, theMonth, theDay);
theMoonPhase = getMoonPhase(theMoonAge);
theMoonPhase = getMoonPhaseImg(theMoonAge);
theNextFullMoon = getNextFull(theMoonAge);
theNextNewMoon = getNextNew(theMoonAge);
document.write('<div align=center><img src=/images/lunar/age_'+escape(Math.round(theMoonAge))+'d.gif>');</script></div>";
$b4string = "
<div align='center'>
<A class=reverse_headertext HREF='http://tycho.usno.navy.mil/vphase.html' target='_blank'>Current Lunar Phase</A>
<br>
<A class=reverse_headertext HREF='http://home.hiwaay.net/~krcool/Astro/moon/' target='_blank'>$moon</a>
<br><br>
<SCRIPT>
theDate = new Date();
theYear = theDate.getYear();theMonth = theDate.getMonth()+1;
theDay = theDate.getDate();
theMoonAge = getMoonAge(theYear, theMonth, theDay);
theMoonPhase = getMoonPhase(theMoonAge);
document.write('The moon is <strong>'+theMoonPhase+'<br>');
document.write('Next <strong>full</strong> moon: ');
document.write(getLongDate( getNextFull(theMoonAge)));
document.write('<br>');
document.write('Next new moon: ');
document.write(getLongDate( getNextNew(theMoonAge) )+' ');
document.write('<br>');
</SCRIPT>";
$endstring = "</font></div>";
$lbreak = "<br><div align='center'>";
$ediv = "</div>";
$moontable_start = "<table width='175' border=0><tr><td bgcolor=black>";
$moontable_end = "</td></tr></table>";
$retval = $moontable_start . $imgstring . "</td></tr><tr><td><font face=Arial size=1>" . $b4string . $endstring . $lbreak . "<font face='Arial' class=reverse_headertext>" . $lphase . "</div>" . $ediv . $moontable_end;
return $retval;
}
?>
Перед ?>
вставь echo phpblock_getMoon();
Код работает. Пример:
Виртуальный выделенный сервер (VDS) становится отличным выбором
Ребят подскажите как реализовать, есть у меня в бд записи, все выводятся списком через php на сайтЕсть у меня так же определенная запись со значением...
Возникла такая задача: при выборе элемента из dropdownlist значение id нужно передать в два action, но onchange выполняет только первый запросКод запроса:
Вкратце: страница зависает (js перестает работать, не перезагружается), когда скрипт доходит до следующей части (JS):
Custom Field Suite Именно этим плагином нужно вывести картинку и ссылку на картинкуПри выводе через визуальны редактор оборачивается в тег P