bes  Updated for version 3.20.6
javascript.h
1 
2 // Automatically generated file. DO NOT EDIT!
3 // Edit www.js instead.
4 
5 const string java_code = "\n\
6 // $Id$\n\
7 \n\
8 var reflection_cgi = \"http://unidata.ucar.edu/cgi-bin/dods/posturl.pl\";\n\
9 \n\
10 // Event handlers for the disposition button.\n\
11 \n\
12 // The ascii_button handler sends data to a new window. The user can then \n\
13 // save the data to a file.\n\
14 \n\
15 function ascii_button() {\n\
16  var url = new String(document.forms[0].url.value);\n\
17 \n\
18  var url_parts = url.split(\"?\");\n\
19  /* handle case where constraint is null. */\n\
20  if (url_parts[1] != null) {\n\
21  var ascii_url = url_parts[0] + \".ascii?\" + url_parts[1];\n\
22  }\n\
23  else {\n\
24  var ascii_url = url_parts[0] + \".ascii?\";\n\
25  }\n\
26 \n\
27  window.open(encodeURI(ascii_url), \"ASCII_Data\");\n\
28 }\n\
29 \n\
30 /* The netcdf_button handler loads the data to the current window. Since it \n\
31  is netcdf/binary, Netscape will ask the user for a filename and save the data\n\
32  to that file. The parameter 'ext' should be 'nc'. */\n\
33 \n\
34 function netcdf_button(ext) {\n\
35  var url = new String(document.forms[0].url.value);\n\
36 \n\
37  var url_parts = url.split(\"?\");\n\
38  /* handle case where constraint is null. */\n\
39  if (url_parts[1] != null) {\n\
40  var binary_url = url_parts[0] + \".\" + ext + \"?\" + url_parts[1];\n\
41  }\n\
42  else {\n\
43  var binary_url = url_parts[0] + \".\" + ext + \"?\";\n\
44  }\n\
45 \n\
46  window.location = encodeURI(binary_url);\n\
47 }\n\
48 \n\
49 /* The binary_button handler loads the data to the current window. Since it \n\
50  is binary, Netscape will ask the user for a filename and save the data\n\
51  to that file. */\n\
52 \n\
53 function binary_button(ext) {\n\
54  var url = new String(document.forms[0].url.value);\n\
55 \n\
56  var url_parts = url.split(\"?\");\n\
57  /* handle case where constraint is null. */\n\
58  if (url_parts[1] != null) {\n\
59  var binary_url = url_parts[0] + \".\" + ext + \"?\" + url_parts[1];\n\
60  }\n\
61  else {\n\
62  var binary_url = url_parts[0] + \".\" + ext + \"?\";\n\
63  }\n\
64 \n\
65  window.location = encodeURI(binary_url);\n\
66 }\n\
67 \n\
68 \n\
69 \n\
70 var help = 0; // Our friend, the help window.\n\
71 \n\
72 function help_button() {\n\
73  // Check the global to keep from opening the window again if it is\n\
74  // already visible. I think Netscape handles this but I know it will\n\
75  // write the contents over and over again. This preents that, too.\n\
76  // 10/8/99 jhrg\n\
77  if (help && !help.closed)\n\
78  return;\n\
79 \n\
80  // Resize on Netscape 4 is hosed. When enabled, if a user resizes then\n\
81  // the root window's document gets reloaded. This does not happen on IE5.\n\
82  // regardless, with scrollbars we don't absolutely need to be able to\n\
83  // resize. 10/8/99 jhrg\n\
84  help = window.open(\"https://opendap.github.io/documentation/QuickStart.html#_an_easy_way_using_the_browser_based_opendap_server_dataset_access_form\",\n\
85  \"help\", \"scrollbars,dependent,width=600,height=400\");\n\
86 }\n\
87 \n\
88 //function open_dods_home() {\n\
89 // window.open(\"http://www.opendap.org/\", \"DODS_HOME_PAGE\");\n\
90 //}\n\
91 \n\
92 \n\
93 // Helper functions for the form.\n\
94 \n\
95 function describe_index() {\n\
96  window.status = \"Enter start, stride and stop for the array dimension.\";\n\
97  return true;\n\
98 }\n\
99 \n\
100 function describe_selection() {\n\
101  window.status = \"Enter a relational expression (e.g., <20). String variables may need values to be quoted\";\n\
102  return true;\n\
103 }\n\
104 \n\
105 function describe_operator() {\n\
106  window.status = \"Choose a relational operator. Use - to enter a function name).\";\n\
107  return true;\n\
108 }\n\
109 \n\
110 function describe_projection() {\n\
111  window.status = \"Add this variable to the projection.\";\n\
112  return true;\n\
113 }\n\
114 \n\
116 // The dods_url object.\n\
118 \n\
119 // CTOR for dods_url\n\
120 // Create the DODS URL object.\n\
121 function dods_url(base_url) {\n\
122  this.url = base_url;\n\
123  this.projection = \"\";\n\
124  this.selection = \"\";\n\
125  this.num_dods_vars = 0;\n\
126  this.dods_vars = new Array();\n\
127  \n\
128  this.build_constraint = build_constraint;\n\
129  this.add_dods_var = add_dods_var;\n\
130  this.update_url = update_url;\n\
131 }\n\
132 \n\
133 // Method of dods_url\n\
134 // Add the projection and selection to the displayed URL.\n\
135 function update_url() {\n\
136  this.build_constraint();\n\
137  var url_text = this.url;\n\
138  // Only add the projection & selection (and ?) if there really are\n\
139  // constraints! \n\
140  if (this.projection.length + this.selection.length > 0)\n\
141  url_text += \"?\" + this.projection + this.selection;\n\
142  document.forms[0].url.value = url_text;\n\
143 }\n\
144 \n\
145 // Method of dods_url\n\
146 // Scan all the form elements and pick out the various pieces of constraint\n\
147 // information. Add these to the dods_url instance.\n\
148 function build_constraint() {\n\
149  var p = \"\";\n\
150  var s = \"\";\n\
151  for (var i = 0; i < this.num_dods_vars; ++i) {\n\
152  if (this.dods_vars[i].is_projected == 1) {\n\
153  // The comma is a clause separator.\n\
154  if (p.length > 0)\n\
155  p += \",\";\n\
156  p += this.dods_vars[i].get_projection();\n\
157  }\n\
158  var temp_s = this.dods_vars[i].get_selection();\n\
159  if (temp_s.length > 0)\n\
160  s += \"&\" + temp_s; // The ampersand is a prefix to the clause.\n\
161  }\n\
162 \n\
163  this.projection = p;\n\
164  this.selection = s;\n\
165 }\n\
166 \n\
167 // Method of dods_url\n\
168 // Add the variable to the dods_var array of dods_vars. The var_index is the\n\
169 // number of *this particular* variable in the dataset, zero-based.\n\
170 function add_dods_var(dods_var) {\n\
171  this.dods_vars[this.num_dods_vars] = dods_var;\n\
172  this.num_dods_vars++;\n\
173 }\n\
174 \n\
176 // dods_var\n\
178 \n\
179 // CTOR for dods_var\n\
180 // name: the name of the variable from DODS' perspective.\n\
181 // js_var_name: the name of the variable within the form.\n\
182 // is_array: 1 if this is an array, 0 otherwise.\n\
183 function dods_var(name, js_var_name, is_array) {\n\
184  // Common members\n\
185  this.name = name;\n\
186  this.js_var_name = js_var_name;\n\
187  this.is_projected = 0;\n\
188  if (is_array > 0) {\n\
189  this.is_array = 1;\n\
190  this.num_dims = 0; // Holds the number of dimensions\n\
191  this.dims = new Array(); // Holds the length of the dimensions\n\
192 \n\
193  this.add_dim = add_dim;\n\
194  this.display_indices = display_indices;\n\
195  this.erase_indices = erase_indices;\n\
196  }\n\
197  else\n\
198  this.is_array = 0;\n\
199 \n\
200  this.handle_projection_change = handle_projection_change;\n\
201  this.get_projection = get_projection;\n\
202  this.get_selection = get_selection;\n\
203 }\n\
204 \n\
205 // Method of dods_var\n\
206 // Add a dimension to a DODS Array object.\n\
207 function add_dim(dim_size) {\n\
208  this.dims[this.num_dims] = dim_size;\n\
209  this.num_dims++;\n\
210 }\n\
211 \n\
212 // Method of dods_var\n\
213 // Add the array indices to the text widgets associated with this DODS\n\
214 // array object. The text widgets are names <var_name>_0, <var_name>_1, ...\n\
215 // <var_name>_n for an array with size N+1.\n\
216 function display_indices() {\n\
217  for (var i = 0; i < this.num_dims; ++i) {\n\
218  var end_index = this.dims[i]-1;\n\
219  var s = \"0:1:\" + end_index.toString();\n\
220  var text_widget = \"document.forms[0].\" + this.js_var_name + \"_\" + i.toString();\n\
221  eval(text_widget).value = s;\n\
222  }\n\
223 }\n\
224 \n\
225 // Method of dods_var\n\
226 // Use this to remove index information from a DODS array object.\n\
227 function erase_indices() {\n\
228  for (var i = 0; i < this.num_dims; ++i) {\n\
229  var text_widget = \"document.forms[0].\" + this.js_var_name + \"_\" + i.toString();\n\
230  eval(text_widget).value = \"\";\n\
231  }\n\
232 }\n\
233 \n\
234 // Method of dods_var\n\
235 function handle_projection_change(check_box) {\n\
236  if (check_box.checked) {\n\
237  this.is_projected = 1;\n\
238  if (this.is_array == 1)\n\
239  this.display_indices();\n\
240  }\n\
241  else {\n\
242  this.is_projected = 0;\n\
243  if (this.is_array == 1)\n\
244  this.erase_indices();\n\
245  }\n\
246 \n\
247  DODS_URL.update_url();\n\
248 }\n\
249 \n\
250 \n\
251 // Method of dods_var\n\
252 // Get the projection sub-expression for this variable.\n\
253 function get_projection() {\n\
254  var p = \"\";\n\
255  if (this.is_array == 1) {\n\
256  p = this.name; // ***\n\
257  for (var i = 0; i < this.num_dims; ++i) {\n\
258  var text_widget = \"document.forms[0].\" + this.js_var_name + \"_\" + i.toString();\n\
259  p += \"[\" + eval(text_widget).value + \"]\";\n\
260  }\n\
261  }\n\
262  else {\n\
263  p = this.name; // ***\n\
264  }\n\
265 \n\
266  return p;\n\
267 }\n\
268 \n\
269 // Method of dods_var\n\
270 // Get the selection (which is null for arrays).\n\
271 function get_selection() {\n\
272  var s = \"\";\n\
273  if (this.is_array == 1) {\n\
274  return s;\n\
275  }\n\
276  else {\n\
277  var text_widget = \"document.forms[0].\" + this.js_var_name + \"_selection\";\n\
278  if (eval(text_widget).value != \"\") {\n\
279  var oper_widget_name = \"document.forms[0].\" + this.js_var_name + \"_operator\";\n\
280  var oper_widget = eval(oper_widget_name);\n\
281  var operator = oper_widget.options[oper_widget.selectedIndex].value;\n\
282  // If the operator is `-' then don't prepend the variable name!\n\
283  // This provides a way for users to enter function names as\n\
284  // selection clauses. \n\
285  if (operator == \"-\")\n\
286  s = eval(text_widget).value;\n\
287  else\n\
288  s = this.name + operator + eval(text_widget).value; // ***\n\
289  }\n\
290  }\n\
291 \n\
292  return s;\n\
293 } \n\
294 ";