Question: Data Files needed for this Case Problem: sd _ map _ txt . html , sd _ mapper _ txt . js , 2 CSS
Data Files needed for this Case Problem: sdmaptxthtml sdmappertxtjs CSS
files, PNG files
Star Dust Stories Dr Andrew Weiss of Thomas & Lee College maintains an astronomy page
called Star Dusk Stories. One of the tools of the amateur stargazer is a planisphere, which
is a handheld device composed of two flat disks: one disk shows a map of the
constellations, and the other disk contains a window corresponding to the part of the sky
that is visible at a given time and date. When a user rotates the second disk to the current
date and time, the constellations that appear in the window correspond to the constellations
currently visible in the nighttime sky
Dr Weiss has asked for your help in writing a JavaScript program to display a planisphere
showing the constellations visible at the current date and time. He has created different
sky chart image files, named sdskypng through sdskypng that represent 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
Figure
Star Dust Stories planisphere
Patrick Carey
Complete the following:
Use your editor to open the sdmaptxthtml and sdmappertxtjs files
from the html case folder. Enter your name and the date in the
comment section of each file, and save them as sdmap.html and
sdmapper.js respectively.
Go to the sdmap.html file in your editor. Directly above the closing
tag, insert a script element that links the page to the sdmapper.js file.
Defer the loading of the script file until after the rest of the web page is loaded
by the browser.
Study the contents of the file and then save your changes.
Go to the sdmapper.js file in your editor. At the top of the file, insert a
statement to apply your JavaScript code with strict usage.
Declare a variable named thisTime containing a Date object for February
at :: am
Use the toLocaleString method to save the text of the thisTime variable
in the timeStr variable.
Change the inner HTML code of the page element with the ID timestamp to
the value of the timeStr variable.
Next, you will determine which sky map to show in the web page. First, create
a variable named thisHour, using the getHours method to extract the hour
value from the thisTime variable.
Create a variable named thisMonth using the getMonth method to extract
the month number from the thisTime variable.
The number of the map to use with the given hour and month is calculated
with the formula
times month hour
where month is the value of the thisMonth variable and hour is the value of
the thisHour variable. Store the value of this formula in the mapNum variable.
You will use JavaScript to write the HTML code for the inline element showing
the sky image to use in the web page. Create a variable named imgStr that
stores the following text string
where Map is the value of the mapNum variable. Hint: Use the operator to
combine text strings together and be sure to include the single quote
character within the text strings.
For the page element with the ID planisphere, use the
insertAdjancentHTML to insert the value of the imgStr variable directly
after the elements opening tag.
Add descriptive comments to the file, documenting your work.
Save your changes to the file and then open sdmap.html in your browser.
Verify that your planisphere map and date and time resemble that shown in
Figure
Return to the sdmapper.js file in your editor. Modify the command that
creates the thisTime variable so that it uses the current date and time,
whatever that may be
Reload sdmap.html in your browser and verify that it shows the current date
and time along with the star map for the sky at that moment.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
