question archive Case: Star Dust Stories Data Files needed for this Case Problem: sd_map_txt
Subject:Computer SciencePrice:3.87 Bought7
Case: Star Dust Stories Data Files needed for this Case Problem: sd_map_txt.html, sd_mapper_txt.js, 2 CSS files, 28 PNG files 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 24 different sky chart image files, named sd_sky0.png through sd_sky23.png, 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 below.
Steps:
Use your editor to open the sd_map_txt.html and sd_mapper_txt.js files from the html09 ? case1 folder. Enter your name and the date in the comment section of each file, and save them as sd_map.html and sd_mapper.js respectively.
Go to the sd_map.html file in your editor. Directly above the closing </head> tag, insert a script element that links the page to the sd_mapper.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 sd_mapper.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 3, 2018 at 3:15:28 a.m.
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
(2×month + hour) % 24
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 element’s opening tag.
Add descriptive comments to the file, documenting your work.
Save your changes to the file and then open sd_map.html in your browser. Verify that your planisphere map and date and time resemble that shown in Figure 9-41.
Return to the sd_mapper.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 sd_map.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.
Answer:
program code to copy
sd_map.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Star Dust Stories: Using a Planisphere</title>
<link href="sd_base.css" rel="stylesheet" />
<link href="sd_layout.css" rel="stylesheet" />
<script src="sd_mapper.js" defer></script> />
</head>
<body>
<header>
<nav class="horizontal">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Astronomers</a></li>
<li><a href="#">Moons</a></li>
<li><a href="#">Planets</a></li>
<li><a href="#">Stars</a></li>
<li><a href="#">Physics</a></li>
</ul>
</nav>
<img src="sd_logo.png" alt="SkyWeb" />
</header>
<section id="left">
<article>
<h1>The Planisphere</h1>
<p>A <strong>planisphere</strong> is a visual aid to astronomers and stargazers.
It consists of two disks: One displays all of the visible
constellations in the night sky, and the other covers the first
and contains a window that indicates the portion of the sky currently
visible. The second disk is then rotated to match the current date and
time. Planispheres come in a variety of sizes and types. The important
thing to remember is that you must have a planisphere that matches
the longitude of your stargazing location.
</p>
<p>On the right is an online planisphere. It consists of two images laid on
top of one another. The top image is the viewing disk of the planisphere. The
bottom image contains the sky map. This planisphere is
automatically rotated for you, displaying the current date and time
and visible constellations for observers at a longitude of
40<sup>°</sup> North. To use a planisphere, hold directly overhead with
the arrow facing north as indicated on the viewing disk.</p>
</article>
</section>
<section id="right">
<div id="planisphere">
<img id="mask" src="sd_mask.png" alt="" />
<div id="timeStamp">timeStr</div>
</div>
</section>
<footer>
Star Dust Stories © 2018 English (US) <span><a href="#">About</a>
<a href="#">Developers</a> <a href="#">Privacy</a>
<a href="#">Terms</a> <a href="#">Help</a></span>
</footer>
</body>
</html>
sd_layout.css
@charset "utf-8";
html {
background: url(sd_back.png) 100%/cover fixed;
}
strong {
font-weight: bold;
}
p a {
text-decoration: underline;
}
body {
background: url(sd_stars.png) rgb(51, 51, 51);
color: rgb(231, 231, 231);
float: none;
margin: 0px auto;
width: 90%;
max-width: 1000px;
min-width: 640px;
margin-top: 30px;
}
header {
width: 100%;
}
header nav.horizontal {
width: 100%;
}
header nav.horizontal li {
background-color: rgb(41, 41, 41);
display: block;
font-family: Tahoma, Geneva, sans-serif;
float: left;
width: 16.66%;
}
header nav.horizontal li a {
color: white;
display: block;
font-size: 0.8em;
height: 50px;
letter-spacing: 0.1em;
line-height: 50px;
text-align: center;
width: 100%;
}
header nav.horizontal li a:visited, header nav.horizontal li a:link {
color: white;
}
/* Navigation List Styles */
body > header a {
background-color: rgb(51, 51, 51);
border: 5px outset rgb(211, 211, 255);
}
body > header:active, body > header a:hover {
background-color: rgb(51, 51, 151);
}
header img {
clear: left;
display: block;
margin: 5px auto;
}
/* section layout */
section#left {
float: left;
width: 50%;
}
section#right {
float: left;
width: 50%;
}
footer {
clear: left;
width: 100%;
}
/* left section */
section#left article {
width: 95%;
margin: 0px auto;
}
section#left article h1 {
font-size: 34px;
font-family: 'Courier New', courier, monospace;
font-weight: bold;
margin: 20px 0px 20px 20px;
}
section#left article p {
margin: 0px 0px 20px 20px;
font-family: Verdana, Geneva, sans-serif;
}
/* right section */
div#planisphere {
position: relative;
width: 100%;
}
div#planisphere img {
display: block;
position: absolute;
top: 40px;
left: 10%;
width: 75%;
}
div#timeStamp {
position: absolute;
top: 5px;
left: 30%;
}
/* footer styles */
footer {
border-top: 2px solid rgb(171, 171, 171);
clear: left;
margin-top: 15px;
background-color: rgb(71, 71, 71);
text-align: right;
}
footer, footer span a {
color: rgb(231, 231, 231);
font-size: 11px;
padding: 10px;
}
sd_base.css
@charset "utf-8";
/* Basic styles to be used with all devices and under all conditions */
address, article, aside, blockquote, body, cite,
div, dl, dt, dd, em, figcaption, figure, footer,
h1, h2, h3, h4, h5, h6, header, html, img,
li, main, nav, nav a, ol, p, section, span, ul {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/* Set the default page element styles */
body {
margin: 0px;
width: 100%;
}
body {
font-family: Verdana, Geneva, sans-serif;
font-size: 100%;
font-weight: inherit;
line-height: 1.2em;
margin: 0px;
padding: 0px;
text-decoration: none;
vertical-align: baseline;
}
ul, ol {
list-style: none;
}
nav ul {
list-style: none;
list-style-image: none;
}
nav a {
text-decoration: none;
}
sd_mapper.js
"use strict"
var thisTime = new Date(2018, 2, 3,3,15,28); //(2018, 2, 3,3,15,28);
var timeStr = thisTime.toLocaleString();
document.getElementById("timeStamp").innerHTML = timeStr;
var thisHour = thisTime;
var thisHour = thisHour.getHours();
var thisMonth = thisTime;
var thisMonth = thisMonth.getMonth();
var mapNum = (2*thisMonth + thisHour) % 24;
var imgStr = "<img src='sd_sky" + mapNum +".png' >";
document.getElementById("planisphere").insertAdjacentHTML("afterbegin",imgStr);
please use this google drive link to download the answer file.
https://drive.google.com/file/d/1TJFEObTspzHTzsMvYp2nEcCxUeg-j-VG/view?usp=sharing
note: if you have any trouble in viewing/downloading the answer from the given link, please use this below guide to understand the whole process.
https://helpinhomework.org/blog/how-to-obtain-answer-through-google-drive-link