|
2. (50 points) The textarea to the left is named ta2 and is in a form named f2. It contains information to place icons on a map of Lake Lanier. Two icon types are used: (1) "boat.png" for the location of the patrol boats; and (2) "incident.png" for the location of any safety incident requiring the patrol boat's help. The format for the icon's five data values data is:
icon type boat or incident, codes are "B" or "I", followed by a comma;
sequence number an integer (boat number or incident number), followed by a comma;
top icon's vertical map position (top), followed by a comma;
left icon's horizontal map position (left), followed by a comma;
description text followed by a ";" (except for the last one)
The DIV with id="p2_out" contains:
- a 1000 pixel wide x 667 pixel map image of Lake Lanier (the id of this image is "map");
- a SPAN block with id="summary" (with a white background and 1 pixel black border)
- seven icon images with id values from "ic0" to "ic6".
All 8 of the images above have: position set to "absolute" and width set to zero (and are thus initially invisible). The SPAN block is also initially empty. When the "Execute p2" button is clicked, the function p2 is executed. It:
- sets the string os to the actual date/time. Use: os = new Date( ).toLocaleString( );
- sets the width of the image with id="map" to "1000px"
- retrieves the data from ta2 and splits it on the ";" character.
- For each icon:
1. if icon type is "B", sets the image's src property value to "boat.png" else sets it to "incident.png"
2. set icon's CSS property values of top and left to the 3rd and 4th value of this icon's string
3. set icon's CSS property values of height to 24 pixels and width to 36 pixels
4. adds to the string os:
a <br> tag
the word "Boat" OR "Incident", depending upon the icon type
the sequence number, followed by a hyphen
the description
- places the string os in the SPAN block with id="summary"
Show only the javascript for p2.
|