MIS 3371 Summer 2017 Exam 2 Parks

Last Name, First Name _____________________________________________________ Last 4 digits of PSID _____________

This is the DIV with id='p1_out'
1. (50 point) The textarea shown to the left contains data on the 440 U.S. House of Representatives members. The DTD for the data is shown below.
<?xml version="1.0"?>
<!DOCTYPE house_reps [      
<!ELEMENT house_reps(rep+)>
<!ELEMENT rep (fullname,web,state_dist,party,office,tel,com+)>
<!ELEMENT fullname (#PCDATA)>   [lastname , firstname and optional initial] 
<!ELEMENT web (#PCDATA)>        [web address]
<!ELEMENT state_dist (#PCDATA)> [state and district]
<!ELEMENT party (#PCDATA)>      ["R" = republican, "D" = democrat]  
<!ELEMENT office (#PCDATA)>     [office building and room number]
<!ELEMENT tel (#PCDATA)>        [telephone number]
<!ELEMENT com (#PCDATA)>]>      [committee name(s)]
When the "Execute p1" button is clicked, roll the data into a 440 row by 7 column table. Columns 1 through 6 contain: fullname through tel. Column 7 contains one or more committee names (com values) in a <ul> list.
the row loop is: for (i=0 ; i < root.childNodes.length ; i++)
fullname is: root.childNodes[i].childNodes[0].childNodes[0].nodeValue
web is: root.childNodes[i].childNodes[1].childNodes[0].nodeValue
state_dist is: root.childNodes[i].childNodes[2].childNodes[0].nodeValue
party is: root.childNodes[i].childNodes[3].childNodes[0].nodeValue
[nodeValue is either "R" or "D"]
office is: root.childNodes[i].childNodes[4].childNodes[0].nodeValue
tel is: root.childNodes[i].childNodes[5].childNodes[0].nodeValue
com values are: root.childNodes[i].childNodes[k].childNodes[0].nodeValue
where for (k=6 ; k < root.childNodes[i].childNodes.length ; k++)

Begin your code assuming root has already been defined in your code. Place the resulting table in the DIV with id="p1_out" and after the end of the table show the count of republican AND democratic representatives. Provide NO table heading row. Show only the javascript for p1.


2. (50 points) Create a display of a 58 key keyboard layout. The layout is made with 58 DIV blocks that each begin like this:
<div style="border:solid black 1px;font-size:13px;position:absolute;text-align:center;background-color:gray;color:white;width:22px;height:22px;...
row
key text values for each row
(shown comma separated)
keys
per
row
top
of
row
left
start
value
1
F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F1212013
2
~, 1,2,3,4,5,6,7,8,9,10,-,=13260
3
Q,W,E,R,T,Y,U,I,O,P,[,]125213
4
A,S,D,F,G,H,J,K,L,;,'117826
5
Z,X,C,V,B,N,M,<,>,?1010439
For the calculation of left, all keys (except the first one) are placed 26 pixels to the right of the previous key in the row.
For each if the 58 keys:
   1) add the CSS for top and left to the DIV shown above
   2) place the key's text inside the DIV
Place the resulting 58 key DIVs into the DIV with id="p2_out".
Show no HTML. Show only the javascript for p2.
 
Assume the following are defined in p2 (DO NOT WRITE these on your exam):
   1. keys = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12, ... ,Z,X,C,V,B,N,M,<,>,?";
      [keys is a string with the 58 key values separated by commas]
   2. keys_per_row = [12,13,12,11,10]; [use this for the interior loop counts]
   3. left_start = [13,0,13,26,39]; [this defines the initial left for each row]
   4. top_val = [0,26,52,78,104]; [this defines top for the row]

this is div with id="p2_out"