Javascript Sharing

Discussion of the Meteohub software package

Moderator: Mattk

Post Reply
cbhiii
Gold Boarder
Gold Boarder
Posts: 306
Joined: Fri Feb 15, 2008 2:02 am
Location: Michigan, USA
Contact:

Javascript Sharing

Post by cbhiii »

Here are some java scripts that others might be interested for their websites. Feel free to copy them and use as you like.

MONTH NUMBER to TEXT
The script turn the month number into text:
<script type="text/javascript">
var mn = "[actual_date0_month_local]";
if (mn==01)
{
document.write("January");
}
else if (mn==02)
{
document.write("February");
}
else if (mn==03)
{
document.write("March");
}
else if (mn==04)
{
document.write("April");
}
else if (mn==05)
{
document.write("May");
}
else if (mn==06)
{
document.write("June");
}
else if (mn==07)
{
document.write("July");
}
else if (mn==08)
{
document.write("August");
}
else if (mn==09)
{
document.write("September");
}
else if (mn==10)
{
document.write("October");
}
else if (mn==11)
{
document.write("November");
}
else if (mn==12)
{
document.write("December");
}
</script>
Station: Davis Vantage Pro2 Plus
Hardware: Raspberry Pi 2 (Meteohub status)
cbhiii
Gold Boarder
Gold Boarder
Posts: 306
Joined: Fri Feb 15, 2008 2:02 am
Location: Michigan, USA
Contact:

Re:Javascript Sharing

Post by cbhiii »

This script takes time text and coverts it to 12 hour AM/PM format
<script type="text/javascript">
var ao="[actual_date0_time_local]";
aoo=ao.substring(0,2);
if (aoo<12)
{
aooo=aoo-1+1;
document.write(aooo,ao.substring(2,5),"am");
}
else if (aoo==12)
{
aooo=aoo;
document.write(aooo,ao.substring(2,5),"pm");
}
else if (aoo>12)
{
aooo=aoo-12;
document.write(aooo,ao.substring(2,5),"pm");
}
</script>

This script convert the time text into an hour and minute format for somthing like the length of day display
<script type="text/javascript">var cs = "[actual_daylength_civiltwilight_hh:mm]";document.write(cs.substring(0,2),"h ",cs.substring(3,5),"m");</script>
Station: Davis Vantage Pro2 Plus
Hardware: Raspberry Pi 2 (Meteohub status)
Post Reply