|
11 | 11 | function showHideTargetClassificationFields() { |
12 | 12 | const target_classification = document.getElementById('id_target_classification_choices').options[document.getElementById('id_target_classification_choices').selectedIndex].value; |
13 | 13 | switch (target_classification) { |
14 | | - case 'Other (please specify)': |
| 14 | + case 'Other (please specify)': // define as SWIFT_OTHER_CHOICE in swift_api.py |
15 | 15 | // in this case show the target_classification CharField |
16 | 16 | document.getElementById('div_id_target_classification').style.display = ''; |
17 | 17 | // and hide the grb_detector and grb_triggertime fields |
| 18 | + document.getElementById('div_id_grb_detector_choices').style.display = 'none'; |
18 | 19 | document.getElementById('div_id_grb_detector').style.display = 'none'; |
19 | 20 | document.getElementById('div_id_grb_triggertime').style.display = 'none'; |
20 | 21 | break; |
21 | 22 | case 'GRB': |
22 | 23 | // in this case show the grb_detector and grb_triggertime fields |
23 | | - document.getElementById('div_id_grb_detector').style.display = ''; |
| 24 | + document.getElementById('div_id_grb_detector_choices').style.display = ''; |
| 25 | + // we do the other-please-specify dance if they want an Other GRB Detector |
| 26 | + const grb_detector_choice = document.getElementById('id_grb_detector_choices').options[document.getElementById('id_grb_detector_choices').selectedIndex].value; |
| 27 | + if (grb_detector_choice == 'Other (please specify)') { |
| 28 | + // in this case show the grb_detector CharField |
| 29 | + document.getElementById('div_id_grb_detector').style.display = ''; |
| 30 | + } else { |
| 31 | + // in this case hide the grb_detector CharField |
| 32 | + document.getElementById('div_id_grb_detector').style.display = 'none'; |
| 33 | + } |
| 34 | + |
24 | 35 | document.getElementById('div_id_grb_triggertime').style.display = ''; |
25 | 36 | // and hide the target_classification CharField |
26 | 37 | document.getElementById('div_id_target_classification').style.display = 'none'; |
27 | 38 | break; |
28 | 39 | default: |
29 | 40 | // in this case hide all the extra fields |
30 | 41 | document.getElementById('div_id_target_classification').style.display = 'none'; |
| 42 | + document.getElementById('div_id_grb_detector_choices').style.display = 'none'; |
31 | 43 | document.getElementById('div_id_grb_detector').style.display = 'none'; |
32 | 44 | document.getElementById('div_id_grb_triggertime').style.display = 'none'; |
33 | 45 | break; |
|
57 | 69 | // show the xrt_mode field; hide the UVOT fields |
58 | 70 | document.getElementById('div_id_xrt_mode').style.display = ''; |
59 | 71 | document.getElementById('div_id_uvot_mode').style.display = 'none'; |
| 72 | + document.getElementById('div_id_uvot_mode_choices').style.display = 'none'; |
60 | 73 | document.getElementById('div_id_uvot_just').style.display = 'none'; |
61 | 74 | break; |
62 | 75 | case 'UVOT': |
63 | 76 | console.log('UVOT instrument selected'); |
64 | 77 | // show the uvot_mode and uvot_just fields; hide the xrt_mode fields |
65 | | - document.getElementById('div_id_uvot_mode').style.display = ''; |
| 78 | + const uvot_mode = document.getElementById('id_uvot_mode_choices').options[document.getElementById('id_uvot_mode_choices').selectedIndex].value; |
| 79 | + if (uvot_mode == 'Other (please specify)') { |
| 80 | + document.getElementById('div_id_uvot_mode').style.display = ''; |
| 81 | + } else { |
| 82 | + document.getElementById('div_id_uvot_mode').style.display = 'none'; |
| 83 | + } |
| 84 | + document.getElementById('div_id_uvot_mode_choices').style.display = ''; |
66 | 85 | document.getElementById('div_id_uvot_just').style.display = ''; |
67 | 86 | document.getElementById('div_id_xrt_mode').style.display = 'none'; |
68 | 87 | break; |
|
71 | 90 | // not sure what to show or hide here (hide everything?) |
72 | 91 | document.getElementById('div_id_xrt_mode').style.display = 'none'; |
73 | 92 | document.getElementById('div_id_uvot_mode').style.display = 'none'; |
| 93 | + document.getElementById('div_id_uvot_mode_choices').style.display = 'none'; |
74 | 94 | document.getElementById('div_id_uvot_just').style.display = 'none'; |
75 | 95 | break; |
76 | 96 | } |
|
108 | 128 | } |
109 | 129 | }; |
110 | 130 |
|
| 131 | +function showExposureAccordianOnError() { |
| 132 | + const exposureAccordion = document.getElementById('exposure-visit-information'); |
| 133 | + exposureAccordion.classList.add('show'); |
| 134 | +} |
111 | 135 | </script> |
112 | 136 |
|
113 | 137 | <script type="text/javascript"> |
|
120 | 144 | <!-- see also script element at end of file --> |
121 | 145 |
|
122 | 146 | {{ form|as_crispy_errors }} |
123 | | -<h1>Submit Request to Neil Gehrels Swift Observatory</h1> |
| 147 | +<h1>Submit Request to Neil Gehrels Swift Observatory for <a href="{% url 'targets:detail' pk=target.id %}">{{target.name}}</a></h1> |
124 | 148 |
|
125 | 149 |
|
126 | 150 | {% if target.type == 'SIDEREAL' %} |
@@ -150,7 +174,7 @@ <h4>Resolved Target Information ({{ resolver }})</h4> |
150 | 174 | </dl> |
151 | 175 | <hr> |
152 | 176 | <!-- display tom_swift Facility version --> |
153 | | - <p><em>TOM Toolit Facility (<a href="https://github.com/TOMToolkit/tom_swift">tom_swift</a>) version {{ version }}</em></p> |
| 177 | + <p><em>TOM Toolkit Facility (<a target="_blank" href="https://github.com/TOMToolkit/tom_swift">tom_swift</a>) version {{ version }}</em></p> |
154 | 178 | </div> |
155 | 179 | <!-- Column 2 --> |
156 | 180 | <div class="col-md-6"> |
@@ -180,19 +204,32 @@ <h4>Resolved Target Information ({{ resolver }})</h4> |
180 | 204 | --> |
181 | 205 | <script type="text/javascript"> |
182 | 206 | var el1 = document.getElementById("div_id_target_classification_choices"); |
183 | | - el1.addEventListener("click", showHideTargetClassificationFields); |
| 207 | + el1.addEventListener("change", showHideTargetClassificationFields); |
184 | 208 |
|
185 | 209 | var el2 = document.getElementById("div_id_instrument"); |
186 | | - el2.addEventListener("click", showHideInstrumentModeFields); |
| 210 | + el2.addEventListener("change", showHideInstrumentModeFields); |
| 211 | + |
| 212 | + var el7 = document.getElementById("div_id_uvot_mode_choices"); |
| 213 | + el7.addEventListener("change", showHideInstrumentModeFields); |
187 | 214 |
|
188 | 215 | var el3 = document.getElementById("div_id_num_of_visits"); |
189 | | - el3.addEventListener("click", showHideMonitoringFields); |
| 216 | + el3.addEventListener("change", showHideMonitoringFields); |
190 | 217 |
|
191 | 218 | var el4 = document.getElementById("div_id_tiling"); |
192 | | - el4.addEventListener("click", showHideTilingFields); |
| 219 | + el4.addEventListener("change", showHideTilingFields); |
193 | 220 |
|
194 | 221 | var el5 = document.getElementById("div_id_proposal"); |
195 | | - el5.addEventListener("click", showHideSwiftGIProposalFields); |
| 222 | + el5.addEventListener("change", showHideSwiftGIProposalFields); |
| 223 | + |
| 224 | + var el6 = document.getElementById("div_id_grb_detector_choices"); |
| 225 | + //el6.addEventListener("click", showHideGRBDetectionFields); |
| 226 | + el6.addEventListener("change", showHideTargetClassificationFields); |
| 227 | + |
| 228 | + var el7 = document.getElementById("id_exposure"); |
| 229 | + el7.addEventListener("invalid", showExposureAccordianOnError); |
| 230 | + |
| 231 | + var el8 = document.getElementById("id_exp_time_just"); |
| 232 | + el8.addEventListener("invalid", showExposureAccordianOnError); |
196 | 233 | </script> |
197 | 234 |
|
198 | 235 | {% endblock %} |
0 commit comments