Day Month Year Scripts
Purpose: Acquire code that will allow day, month and year (yy) values to retrieve graphics with filenames that include these values. Example: the 500 mb Upper Air Map has a filename (for August 2, 2008) of:
http://www.spc.noaa.gov/obswx/maps/500_080802_00.gif
Note: For this graphic the needed value would be "500_" + yy + mm + dd + "_00.gif"
In both examples below, the year value is a four digit number. To get a useable value, we'd need to subtract 2000 (this trick will work until the year 2100). Test to determine whether or not the result is a one or two digit value.
End resulting code was based on script from JavaScript Kit
http://www.javascriptkit.com
|
Cut & Paste Current Date I
|
Directions
Insert the below into the <body> section of the page that will show the date:
Code:
<script>
/*YYMMDD script adapted from a script from:
JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/
var mydate=new Date()
var yy=mydate.getYear()
yy=yy-2000
if (yy<10)
yy="0"+yy
var mm=mydate.getMonth()+1
if (mm<10)
mm="0"+mm
var dd=mydate.getDate()
if (dd<10)
dd="0"+dd
document.write(yy+mm+dd)
</script>
<p align="center"><font face="arial" size="-2">This free script provided
by</font><br>
<font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
Kit</a></font></p>
End Code
Displays Script:
This free script provided by
JavaScript
Kit
End Display of Script
Further expansion is to add URL and map data:
First half: "http://www.spc.noaa.gov/obswx/maps/500_"
Then the yymmdd code
Finally: "_00.gif"
Code:
<script>
/*YYMMDD script adapted from a script from:
JavaScript Kit (www.javascriptkit.com)
*/
var mydate=new Date()
var yy=mydate.getYear()
yy=yy-2000
if (yy<10)
yy="0"+yy
var mm=mydate.getMonth()+1
if (mm<10)
mm="0"+mm
var dd=mydate.getDate()
if (dd<10)
dd="0"+dd
var mapfive = "http://www.spc.noaa.gov/obswx/maps/500_"+yy+mm+dd+"_00.gif"
document.write(mapfive)
</script>
End Code
Displays Script:
End Display of Script
Additional map variables:
var mapnine = "http://www.spc.noaa.gov/obswx/maps/925_"+yy+mm+dd+"_00.gif"
var maptwo = "http://www.spc.noaa.gov/obswx/maps/250_"+yy+mm+dd+"_00.gif"
National
Forecast Map
Storm Prediction Center, NOAA
Hydrometeorological Prediction Center, NOAA
500 mb Upper Air Map
Storm Prediction Center, NOAA
http://www.spc.noaa.gov/obswx/maps/
Unable to display the URL of the map, either within the script or outside of the script. More work needed. Will remain on hold until I can get access to my JavaScript books (currently in storage).
Doug Anderson
Huntsville, AL
NWS Storm Spotter / Amateur Radio ARES
W4DDA
Email: w4dda at arrl dot net