1 | <?php |
---|
2 | |
---|
3 | include_once("../includes/bccdPage.php"); |
---|
4 | |
---|
5 | $page = new bccdPage(); |
---|
6 | |
---|
7 | $page->setSection(2); |
---|
8 | $page->setBasePath(".."); |
---|
9 | |
---|
10 | $left = file_get_contents("includes/left.php"); |
---|
11 | |
---|
12 | if (isset($_POST['submit'])) { |
---|
13 | $rightHTML = "<pre>" . print_r($_POST, true) . "</pre>"; |
---|
14 | } else { |
---|
15 | $page->setSlot('Head', '<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>'); |
---|
16 | |
---|
17 | $js = <<<JAVASCRIPT |
---|
18 | // Select all |
---|
19 | function Check(control, formName, table) { |
---|
20 | form = document.forms[formName]; |
---|
21 | |
---|
22 | for (i = 0; i < form.elements.length; i++) { |
---|
23 | chk = form.elements[i]; |
---|
24 | |
---|
25 | if (chk.type == 'checkbox') { |
---|
26 | chk.checked = control.checked; |
---|
27 | } |
---|
28 | } |
---|
29 | |
---|
30 | if (control.checked) |
---|
31 | $('#'+ table + ' tr.row').addClass('selected'); |
---|
32 | else |
---|
33 | $('#'+ table + ' tr.row').removeClass('selected'); |
---|
34 | } |
---|
35 | |
---|
36 | // function(s) for selecting checkbox by clicking within the row |
---|
37 | $(document).ready(function() { |
---|
38 | $('#bccdSoftware tr.row') |
---|
39 | .filter(':has(:checkbox:checked)') |
---|
40 | .addClass('selected') |
---|
41 | .end() |
---|
42 | .click(function(event) { |
---|
43 | $(this).toggleClass('selected'); |
---|
44 | if (event.target.type !== 'checkbox') { |
---|
45 | $(':checkbox', this).attr('checked', function() { |
---|
46 | return !this.checked; |
---|
47 | }); |
---|
48 | } |
---|
49 | }); |
---|
50 | }); |
---|
51 | JAVASCRIPT; |
---|
52 | $page->addJS($js); |
---|
53 | |
---|
54 | $css = <<<CSS |
---|
55 | table { |
---|
56 | border-width:0px; |
---|
57 | border-spacing:0; |
---|
58 | border-collapse:collapse; |
---|
59 | } |
---|
60 | table td { |
---|
61 | border-width:0px; |
---|
62 | padding:4px; |
---|
63 | } |
---|
64 | table tr:hover { |
---|
65 | background-color: #AFD4F1; |
---|
66 | } |
---|
67 | table tr.meta:hover { |
---|
68 | background-color: transparent; |
---|
69 | } |
---|
70 | .selected { |
---|
71 | background-color: #FFFFAA; |
---|
72 | } |
---|
73 | CSS; |
---|
74 | $page->addCSS($css); |
---|
75 | |
---|
76 | $software = array( |
---|
77 | "gcc" => "GNU Compiler Suite", |
---|
78 | "c3" => "Cluster Command and Control (C3) Tools", |
---|
79 | "cuda" => "CUDA Libraries", |
---|
80 | "icc" => "Intel Compilers", |
---|
81 | "java" => "Java", |
---|
82 | "mcell" => "MCell", |
---|
83 | "mpich2" => "MPICH2", |
---|
84 | "openmpi" => "OpenMPI", |
---|
85 | "papi" => "PAPI", |
---|
86 | "torque" => "Torque/PBS Job Scheduler" |
---|
87 | ); |
---|
88 | |
---|
89 | $rightHTML = ' |
---|
90 | <strong>Tell us about the software you use on the BCCD</strong> |
---|
91 | <hr> |
---|
92 | <form method="POST" action="" name="softwareList"> |
---|
93 | <table id="bccdSoftware"> |
---|
94 | '; |
---|
95 | |
---|
96 | foreach ($software as $short => $long) { |
---|
97 | $rightHTML .= ' |
---|
98 | <tr class="row"> |
---|
99 | <td><input type="checkbox" name="'.$short.'" class="bccdSoftware"></td> |
---|
100 | <td>'.$long.'</td> |
---|
101 | </tr>'; |
---|
102 | } |
---|
103 | $rightHTML .= <<<HTML |
---|
104 | <tr class="meta"> |
---|
105 | <td></td> |
---|
106 | <td> |
---|
107 | <label for="checkAllSoftware" style="font-size: 8pt;"> |
---|
108 | <input id="checkAllSoftware" type="checkbox" name="checkall" value="yes" onClick="Check(this, 'softwareList', 'bccdSoftware')"> |
---|
109 | Select All |
---|
110 | </label> |
---|
111 | </td> |
---|
112 | </tr> |
---|
113 | </table> |
---|
114 | <br /><br /> |
---|
115 | <strong>What additional software would you like to see?</strong> |
---|
116 | <hr> |
---|
117 | |
---|
118 | <table id="addSoftware"> |
---|
119 | <tbody> |
---|
120 | <tr><td><input name="addSoft[]" style="width:150px;" type="textarea"></td></tr> |
---|
121 | </tbody> |
---|
122 | </table> |
---|
123 | <a href="#" onClick="$('#addSoftware > tbody:last').append('<tr><td><input name=\'addSoft[]\' style=\'width:150px;\' type=\'textarea\'></td></tr>'); return false;"> |
---|
124 | + Add another</a> |
---|
125 | <br /><br /> |
---|
126 | <input type="submit" name="submit" style="border: 2px solid #225B92; color: #941426; background-color: #B7C0C0;"> |
---|
127 | </form> |
---|
128 | HTML; |
---|
129 | } |
---|
130 | |
---|
131 | $page->setSlot('LeftContent', $left); |
---|
132 | $page->setSlot('RightContent', $rightHTML); |
---|
133 | |
---|
134 | $page->render(); |
---|
135 | ?> |
---|