MIS 3371 Parks Spring 2016 Midterm Exam
this is the DIV with id='p1out'
 

 

 

 

 

 

 

 

 

 

Initial values: rc=255, gc=0, bc=0 for row 0.
from rowto rowrcgcbc
1 31 rc=rc-4 gc=0 bc=0
32 63 rc=rc-4 gc=gc+8bc=0
64 95 rc=0 gc=gc-8bc=bc+4
96 127 rc=0 gc=0 bc=bc+4
1. (50 points) When the button below labeled "execute p1" is clicked a javascript function named p1 is executed. A DIV block with id="p1out" is shown to the left. It is 256 pixels wide and 256 pixels tall. You are to add to this DIV block 128 SPAN blocks. The beginning of each span block is stored in a variable named span_start as a string like this:
  "<span style='position:absolute;width:256px;height:2px;"
The end of each span block is stored in a variable named span_end as a string like this:
  "border:none;margin:0px;display:inline;'></span>"
DO NOT WRITE these two strings in your answer. Assume they exist in your code.
Note that each span block is two pixels tall and 256 pixels wide.
You are to add two CSS properties to each span block (i.e., add them after the span_start string is added to os and before span_end string is added to os)

A. Create a string named os to accumulate the 128 SPAN blocks.
B. For each SPAN block:
   1. use the table to the left which shows how to set (for row 0) or change
      (for rows 1 to 127) the values of rc, gc and bc,
      to use for the background-color of the current row.
   2. add the span_start to os
   3. add the CSS property top to os.
      The first span block has: "top:0px;"; the second has "top:2px;";
      the third has "top:4px;"; etc.
   4. add the CSS background-color to os.
      Use the three variables (from step 1): rc,gc,bc to define the color.
      The general format for the CSS property is: "background-color:rgb(rc,gc,bc);"
   5. add the span_end to os.
C. When done, place the os string into the DIV with id="p1out"

Show no HTML, Show only the javascript for p1.

2. (50 points) The textarea to the left named ta2 is in a form named f2. The XML represents 358 famous passages from the Shakespeare play "Hamlet". Each passage occurs in an act (I,II,III,IV or V); scene is a number, startline is the line number in the script where the passage begins, and line tags contain the individual lines of the script. The DTD for the XML is:
      <?xml version="1.0"?>
      <!DOCTYPE hamlet [
      <!ELEMENT hamlet(passage+)
      <!ELEMENT passage (act,scene,startline,line+)>;
      <!ELEMENT act (#PCDATA)>
      <!ELEMENT scene (#PCDATA) >
      <!ELEMENT startline (#PCDATA)>
      <!ELEMENT line (#PCDATA)>]>
Assume root has been created in your code. Create a 358 rows - five column table containing: row number (begin at 1); act; scene; startline; and all the line values of the passage are the last column and each line is separated by a <br> tag)
number of rows is root.childNodes.length
act is root.childNodes[i].childNodes[0].childNodes[0].nodeValue
scene is root.childNodes[i].childNodes[1].childNodes[0].nodeValue
startline is root.childNodes[i].childNodes[2].childNodes[0].nodeValue
line is root.childNodes[i].childNodes[k].childNodes[0].nodeValue
where k = 3 to root.childNodes[i].childNodes.length
Count the number of line tags that contain "Horatio" at least once.
Place the table and the "Horatio" count into the DIV with id="p2out".
Show no HTML. Show NO heading row. Show only the javascript for p2
                                this is the DIV with id="p2out"