HTML and CSS Reference
In-Depth Information
Dr. Weiss has asked for your help in constructing an online planisphere for his Web site.
He has created 24 different sky chart image files, named
sky0.jpg
through
sky23.jpg
,
that represent 24 different rotations of the nighttime sky. He has also created an image
containing a transparent window through which a user can view a selected sky chart. A
preview of the completed Web page is shown in Figure 10-37.
Figure 10-37
skyWeb planisphere page
Dr. Weiss has designed the page layout. He needs your help in creating JavaScript code
to display the current date and time and to display the correct sky chart for that date and
time. To do this, you've been provided with two functions:
• The showDateTime() function returns the current date and time in the text string
MonthƒDay
,ƒ
Year
,ƒ
hour
:
minute
ƒam/pmƒ
where
Month
is the name of the current month,
Day
is the current day,
Year
is the
current year,
hour
is the current hour,
minute
is the current minute, and
am/pm
changes based on the current time.
• The getMap() function returns a number from 0 to 23. The number matches the num-
ber of the sky map image to show based on the current date and time.
Both functions have been placed in an external JavaScript file named
datetime.js
.
Complete the following:
1. Use your text editor to open the
skymaptxt.htm
file from the tutorial.10\case1 folder
included with your Data Files. Enter
your name
and
the date
in the comment sec-
tion of the file. Save the file as
skymap.htm
in the same folder.
2. Directly below the
link
element in the head section, insert a
script
element
accessing the
datetime.js
file.