|
1 |
function getParams() {
|
|
2 |
var paramsArray = document.location.href.split('?')[1].split('&');
|
|
3 |
for (var i = 0; i < paramsArray.length; i++) {
|
|
4 |
var temp = paramsArray[i].split('=');
|
|
5 |
alert(unescape(temp[0]) + '=' + unescape(temp[1]));
|
|
6 |
}
|
|
7 |
}
|
|
8 |
|
|
9 |
function addParagraph() {
|
|
10 |
var newParaWidget = document.createElement("textarea");
|
|
11 |
newParaWidget.setAttribute("rows", "6");
|
|
12 |
newParaWidget.className="longwidth";
|
|
13 |
newParaWidget.setAttribute("name", "methodPara");
|
|
14 |
|
|
15 |
var TR = document.createElement("tr");
|
|
16 |
TR.className='sectbody';
|
|
17 |
var TD = createTD("5","left");
|
|
18 |
var emptyTD = createTD("","right");
|
|
19 |
TD.appendChild(newParaWidget);
|
|
20 |
TR.appendChild(emptyTD);
|
|
21 |
TR.appendChild(TD);
|
|
22 |
var addParaButton = document.getElementById("addparabutton1");
|
|
23 |
var parent = addParaButton.parentNode;
|
|
24 |
parent.insertBefore(TR, addParaButton);
|
|
25 |
}
|
|
26 |
|
|
27 |
function addMethod() {
|
|
28 |
var index = incrementCount('methodCount');
|
|
29 |
var methodButton = document.getElementById("addmethodbutton");
|
|
30 |
var parent = methodButton.parentNode;
|
|
31 |
|
|
32 |
parent.insertBefore(createHRRow(), methodButton);
|
|
33 |
parent.insertBefore(addMethodTitle(), methodButton);
|
|
34 |
parent.insertBefore(addMethodDescription(index), methodButton);
|
|
35 |
parent.insertBefore(addMethodButton(index), methodButton);
|
|
36 |
}
|
|
37 |
|
|
38 |
function addMethodButton(index) {
|
|
39 |
var TR = document.createElement("tr");
|
|
40 |
var buttonId = 'addparabutton' + index;
|
|
41 |
TR.className='sectbody';
|
|
42 |
TR.setAttribute("id", buttonId);
|
|
43 |
var labelTD = createTD("","right");
|
|
44 |
var TD = createTD("5","left");
|
|
45 |
var button = document.createElement("input");
|
|
46 |
button.setAttribute("type", "button");
|
|
47 |
button.setAttribute("value", "Add Paragraph to Method Description");
|
|
48 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
49 |
button.attachEvent("onclick", new Function("addParagraph("+ index + ", '" + buttonId + "')"));
|
|
50 |
} else {
|
|
51 |
button.setAttribute("onclick", "addParagraph("+ index +", '" + buttonId + "')");
|
|
52 |
}
|
|
53 |
TD.appendChild(button);
|
|
54 |
TR.appendChild(labelTD);
|
|
55 |
TR.appendChild(TD);
|
|
56 |
return TR;
|
|
57 |
}
|
|
58 |
|
|
59 |
function addMethodTitle() {
|
|
60 |
var TR = document.createElement("tr");
|
|
61 |
TR.className='sectbody';
|
|
62 |
var labelTD = createTD("","right");
|
|
63 |
labelTD.appendChild(document.createTextNode("Method Title"));
|
|
64 |
var TD = createTD("5","left");
|
|
65 |
var textField = document.createElement("input");
|
|
66 |
textField.setAttribute("type", "text");
|
|
67 |
textField.setAttribute("name", "methodTitle");
|
|
68 |
textField.className="longwidth";
|
|
69 |
TD.appendChild(textField);
|
|
70 |
TR.appendChild(labelTD);
|
|
71 |
TR.appendChild(TD);
|
|
72 |
return TR;
|
|
73 |
}
|
|
74 |
|
|
75 |
function addMethodDescription(index) {
|
|
76 |
var TR = document.createElement("tr");
|
|
77 |
TR.className='sectbody';
|
|
78 |
var labelTD = createTD("","right");
|
|
79 |
labelTD.setAttribute("vAlign","top");
|
|
80 |
labelTD.appendChild(document.createTextNode("Method Description"));
|
|
81 |
var TD = createTD("5","left");
|
|
82 |
var textArea = document.createElement("textarea");
|
|
83 |
textArea.setAttribute("name", "methodPara"+index);
|
|
84 |
textArea.setAttribute("rows", 6);
|
|
85 |
textArea.className="longwidth";
|
|
86 |
TD.appendChild(textArea);
|
|
87 |
TR.appendChild(labelTD);
|
|
88 |
TR.appendChild(TD);
|
|
89 |
return TR;
|
|
90 |
}
|
|
91 |
|
|
92 |
function createTextField(name, size, value) {
|
|
93 |
var newField = document.createElement("input");
|
|
94 |
newField.setAttribute("type", "text");
|
|
95 |
newField.setAttribute("name", name);
|
|
96 |
newField.setAttribute("size", size);
|
|
97 |
newField.value = value;
|
|
98 |
return newField;
|
|
99 |
}
|
|
100 |
|
|
101 |
function createTextRow(count, varName, labelText, value) {
|
|
102 |
var textField = createTextField(varName + count, "30", value);
|
|
103 |
var row = createRow(count, textField, labelText);
|
|
104 |
return row;
|
|
105 |
}
|
|
106 |
|
|
107 |
function createRow(count, elem, labelText) {
|
|
108 |
var textTD = createTD("5");
|
|
109 |
textTD.appendChild(elem);
|
|
110 |
|
|
111 |
var labelTD = createTD("","right");
|
|
112 |
|
|
113 |
var labelSpan = document.createElement("span");
|
|
114 |
labelSpan.className = 'label';
|
|
115 |
|
|
116 |
var label = document.createTextNode(labelText);
|
|
117 |
labelSpan.appendChild(label);
|
|
118 |
labelTD.appendChild(labelSpan);
|
|
119 |
|
|
120 |
var TR = document.createElement("tr");
|
|
121 |
TR.className='sectbody';
|
|
122 |
TR.appendChild(labelTD);
|
|
123 |
TR.appendChild(textTD);
|
|
124 |
|
|
125 |
return TR;
|
|
126 |
}
|
|
127 |
|
|
128 |
function createHRRow() {
|
|
129 |
var hrCell = createTD("6");
|
|
130 |
var hr = document.createElement("hr");
|
|
131 |
hr.setAttribute("width", "85%");
|
|
132 |
hrCell.appendChild(hr);
|
|
133 |
|
|
134 |
var hrTR = document.createElement("tr");
|
|
135 |
hrTR.className = 'sectbody';
|
|
136 |
hrTR.appendChild(hrCell);
|
|
137 |
|
|
138 |
return hrTR;
|
|
139 |
}
|
|
140 |
|
|
141 |
function createHiddenInput(name, value) {
|
|
142 |
var elem = document.createElement("input");
|
|
143 |
elem.setAttribute("type", "hidden");
|
|
144 |
elem.setAttribute("name", name);
|
|
145 |
elem.setAttribute("value", value);
|
|
146 |
return elem
|
|
147 |
}
|
|
148 |
|
|
149 |
function sortInputTags() {
|
|
150 |
sortTagWithAttributeName("aoFirstName", "addAssociatedParty");
|
|
151 |
sortTagWithAttributeName("aoLastName", "addAssociatedParty");
|
|
152 |
sortTagWithAttributeName("aoRole", "addAssociatedParty", "select");
|
|
153 |
|
|
154 |
sortTagWithAttributeName("taxonName", "addTaxon");
|
|
155 |
sortTagWithAttributeName("taxonRank", "addTaxon");
|
|
156 |
|
|
157 |
sortTagWithAttributeName("keyword", "addKeyword");
|
|
158 |
sortTagWithAttributeName("keywordType", "addKeyword");
|
|
159 |
sortTagWithAttributeName("keywordTh", "addKeyword");
|
|
160 |
}
|
|
161 |
|
|
162 |
|
|
163 |
function sortTagWithAttributeName(tag, afterTag, parentTag) {
|
|
164 |
var elem = document.getElementById(afterTag);
|
|
165 |
|
|
166 |
elem = elem.nextSibling.nextSibling;
|
|
167 |
while (elem.nodeName == "TR") {
|
|
168 |
var nodes = elem.getElementsByTagName("input");
|
|
169 |
for(var i = 0; i < nodes.length; i++) {
|
|
170 |
var node = nodes.item(i);
|
|
171 |
if (node.getAttribute("name")==tag) {
|
|
172 |
var parent = node.parentNode;
|
|
173 |
var clone = node.cloneNode(true);
|
|
174 |
parent.removeChild(node);
|
|
175 |
parent.appendChild(clone);
|
|
176 |
}
|
|
177 |
}
|
|
178 |
if (parentTag != null) {
|
|
179 |
var nodes = elem.getElementsByTagName(parentTag);
|
|
180 |
for(var i = 0; i < nodes.length; i++) {
|
|
181 |
var node = nodes.item(i);
|
|
182 |
if (node.getAttribute("name")==tag) {
|
|
183 |
var parent = node.parentNode;
|
|
184 |
var clone = node.cloneNode(true);
|
|
185 |
clone.value = node.value;
|
|
186 |
parent.removeChild(node);
|
|
187 |
parent.appendChild(clone);
|
|
188 |
}
|
|
189 |
}
|
|
190 |
}
|
|
191 |
elem = elem.nextSibling;
|
|
192 |
}
|
|
193 |
}
|
|
194 |
|
|
195 |
function incrementCount(_count) {
|
|
196 |
var countField = document.getElementById(_count);
|
|
197 |
var count = countField.getAttribute("value");
|
|
198 |
count++;
|
|
199 |
countField.setAttribute("value", count);
|
|
200 |
return count;
|
|
201 |
}
|
|
202 |
|
|
203 |
function decrementCount(_count) {
|
|
204 |
var countField = document.getElementById(_count);
|
|
205 |
var count = countField.getAttribute("value");
|
|
206 |
count--;
|
|
207 |
countField.setAttribute("value", count);
|
|
208 |
return count;
|
|
209 |
}
|
|
210 |
|
|
211 |
function setCount(_count, val) {
|
|
212 |
var countField = document.getElementById(_count);
|
|
213 |
var count = countField.getAttribute("value");
|
|
214 |
countField.setAttribute("value", val);
|
|
215 |
return count;
|
|
216 |
}
|
|
217 |
|
|
218 |
function createImageLink(imgSrc, imgAlt, imgOnClick, cursor) {
|
|
219 |
var link = document.createElement("a");
|
|
220 |
var img = document.createElement("img");
|
|
221 |
img.setAttribute("src", imgSrc);
|
|
222 |
img.setAttribute("alt", imgAlt);
|
|
223 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
224 |
link.style.setAttribute("cursor", cursor);
|
|
225 |
img.attachEvent("onclick", new Function(imgOnClick));
|
|
226 |
} else {
|
|
227 |
link.setAttribute("style", "cursor:"+cursor);
|
|
228 |
img.setAttribute("onClick", imgOnClick);
|
|
229 |
}
|
|
230 |
img.setAttribute("border", "0");
|
|
231 |
link.appendChild(img);
|
|
232 |
return link;
|
|
233 |
}
|
|
234 |
|
|
235 |
|
|
236 |
function createTD(colSpan, align, cursor) {
|
|
237 |
var td = document.createElement("td");
|
|
238 |
if (colSpan != "")
|
|
239 |
td.setAttribute("colSpan", colSpan);
|
|
240 |
td.setAttribute("align", align);
|
|
241 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
242 |
td.style.setAttribute("cursor", cursor);
|
|
243 |
} else {
|
|
244 |
td.setAttribute("style", "cursor:"+cursor);
|
|
245 |
}
|
|
246 |
return td;
|
|
247 |
}
|
|
248 |
|
|
249 |
|
|
250 |
function cleanTextNodes(startTagId, endTagId) {
|
|
251 |
var startTag = document.getElementById(startTagId);
|
|
252 |
|
|
253 |
var bro = startTag.nextSibling;
|
|
254 |
|
|
255 |
while(bro) {
|
|
256 |
if (bro.nodeName == "#text") {
|
|
257 |
var temp = bro.nextSibling;
|
|
258 |
bro.parentNode.removeChild(bro);
|
|
259 |
bro = temp;
|
|
260 |
} else {
|
|
261 |
var id = bro.getAttribute("id");
|
|
262 |
if (id == endTagId) {
|
|
263 |
return;
|
|
264 |
}
|
|
265 |
bro = bro.nextSibling;
|
|
266 |
}
|
|
267 |
}
|
|
268 |
|
|
269 |
}
|
|
270 |
|
|
271 |
function delRow(evt) {
|
|
272 |
evt = (evt) ? evt : ((window.event) ? window.event : null);
|
|
273 |
if (evt) {
|
|
274 |
// equalize W3C/IE models to get event target reference
|
|
275 |
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
|
|
276 |
if (elem) {
|
|
277 |
try {
|
|
278 |
var table = elem.parentNode.parentNode.parentNode.parentNode;
|
|
279 |
var row = elem.parentNode.parentNode.parentNode;
|
|
280 |
|
|
281 |
table.removeChild(row);
|
|
282 |
}
|
|
283 |
catch(e) {
|
|
284 |
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
|
|
285 |
alert("Error:\n" + msg);
|
|
286 |
return;
|
|
287 |
}
|
|
288 |
}
|
|
289 |
}
|
|
290 |
}
|
|
291 |
|
|
292 |
function moveUpRow(evt) {
|
|
293 |
evt = (evt) ? evt : ((window.event) ? window.event : null);
|
|
294 |
if (evt) {
|
|
295 |
// equalize W3C/IE models to get event target reference
|
|
296 |
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
|
|
297 |
if (elem) {
|
|
298 |
try {
|
|
299 |
var table = elem.parentNode.parentNode.parentNode.parentNode;
|
|
300 |
var row = elem.parentNode.parentNode.parentNode;
|
|
301 |
|
|
302 |
var bro = row.previousSibling;
|
|
303 |
if (bro != null && bro.previousSibling.nodeName =="TR") {
|
|
304 |
clone = row.cloneNode(true);
|
|
305 |
table.insertBefore(clone, bro);
|
|
306 |
table.removeChild(row);
|
|
307 |
}
|
|
308 |
}
|
|
309 |
catch(e) {
|
|
310 |
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
|
|
311 |
alert("Error:\n" + msg);
|
|
312 |
return;
|
|
313 |
}
|
|
314 |
}
|
|
315 |
}
|
|
316 |
}
|
|
317 |
|
|
318 |
function moveDownRow(evt, lastTR) {
|
|
319 |
evt = (evt) ? evt : ((window.event) ? window.event : null);
|
|
320 |
if (evt) {
|
|
321 |
// equalize W3C/IE models to get event target reference
|
|
322 |
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
|
|
323 |
if (elem) {
|
|
324 |
try {
|
|
325 |
var table = elem.parentNode.parentNode.parentNode.parentNode;
|
|
326 |
var row = elem.parentNode.parentNode.parentNode;
|
|
327 |
|
|
328 |
var _test = row.nextSibling;
|
|
329 |
if (_test.getAttribute("id") == lastTR) {
|
|
330 |
return;
|
|
331 |
}
|
|
332 |
var bro = row.nextSibling.nextSibling;
|
|
333 |
if (bro != null && bro.nodeName =="TR") {
|
|
334 |
clone = row.cloneNode(true);
|
|
335 |
table.insertBefore(clone, bro);
|
|
336 |
table.removeChild(row);
|
|
337 |
}
|
|
338 |
}
|
|
339 |
catch(e) {
|
|
340 |
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
|
|
341 |
alert("Error:\n" + msg);
|
|
342 |
return;
|
|
343 |
}
|
|
344 |
}
|
|
345 |
}
|
|
346 |
}
|
|
347 |
|
|
348 |
function addAssociatedParty() {
|
|
349 |
var AOLN = document.getElementById("AONameLast");
|
|
350 |
var AOFN = document.getElementById("AONameFirst");
|
|
351 |
var AORole = document.getElementById("AORole");
|
|
352 |
|
|
353 |
if (AOLN.value != "") {
|
|
354 |
var aoCount = incrementCount("aoCount");
|
|
355 |
|
|
356 |
try {
|
|
357 |
var aoRow = createAORow(aoCount, AOLN.value, AOFN.value, AORole.options[AORole.selectedIndex].text);
|
|
358 |
} catch(e) {
|
|
359 |
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
|
|
360 |
alert("Error:\n" + msg);
|
|
361 |
return;
|
|
362 |
}
|
|
363 |
|
|
364 |
var aoRowMarker = document.getElementById("addaorow");
|
|
365 |
var parent = aoRowMarker.parentNode;
|
|
366 |
|
|
367 |
var aoHR = document.getElementById("aoHRRow");
|
|
368 |
if (aoHR == null) {
|
|
369 |
var aoHRRow = createHRRow();
|
|
370 |
aoHRRow.setAttribute("id", "aoHRRow");
|
|
371 |
parent.insertBefore(aoHRRow, aoRowMarker);
|
|
372 |
}
|
|
373 |
|
|
374 |
parent.insertBefore(aoRow, aoRowMarker);
|
|
375 |
|
|
376 |
AOFN.value = "";
|
|
377 |
AOLN.value = "";
|
|
378 |
AORole.selectedIndex = 0;
|
|
379 |
} else {
|
|
380 |
alert("Enter the last name of the associated party");
|
|
381 |
}
|
|
382 |
}
|
|
383 |
|
|
384 |
function createAORow(aoCount, AOLN, AOFN, AORole){
|
|
385 |
var TR = document.createElement("tr");
|
|
386 |
TR.className='sectbody';
|
|
387 |
var labelTD = createTD("5","left", "pointer");
|
|
388 |
|
|
389 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
390 |
labelTD.attachEvent("onclick", new Function("aoEditRow(event, 0, \"" + AOFN + "\",\""
|
|
391 |
+ AOLN + "\",\"" + AORole + "\")"));
|
|
392 |
} else {
|
|
393 |
labelTD.setAttribute("onClick","aoEditRow(event, 0, \"" + AOFN + "\",\""
|
|
394 |
+ AOLN + "\",\"" + AORole + "\")");
|
|
395 |
}
|
|
396 |
|
|
397 |
var text = AOFN + " " + AOLN + " (Role: " + AORole + ")";
|
|
398 |
var label = document.createTextNode(text);
|
|
399 |
|
|
400 |
labelTD.appendChild(label);
|
|
401 |
labelTD.appendChild(createHiddenInput("aoFirstName", AOFN));
|
|
402 |
labelTD.appendChild(createHiddenInput("aoLastName", AOLN));
|
|
403 |
labelTD.appendChild(createHiddenInput("aoRole", AORole));
|
|
404 |
|
|
405 |
var imgTD = createTD("","right");
|
|
406 |
imgTD.className = 'rightCol';
|
|
407 |
|
|
408 |
imgTD.appendChild(createImageLink(contextUrl + "/style/images/previous.gif",
|
|
409 |
"Move Up","moveUpRow(event)","pointer"));
|
|
410 |
imgTD.appendChild(document.createTextNode(" "));
|
|
411 |
imgTD.appendChild(createImageLink(contextUrl + "/style/images/next.gif",
|
|
412 |
"Move Down", "moveDownRow(event, \"addaorow\")",
|
|
413 |
"pointer"));
|
|
414 |
imgTD.appendChild(document.createTextNode(" "));
|
|
415 |
imgTD.appendChild(createImageLink(contextUrl + "/style/images/delete.gif",
|
|
416 |
"Delete", "delRow(event)",
|
|
417 |
"pointer"));
|
|
418 |
|
|
419 |
TR.appendChild(imgTD);
|
|
420 |
TR.appendChild(labelTD);
|
|
421 |
|
|
422 |
return TR;
|
|
423 |
}
|
|
424 |
|
|
425 |
function aoEditRow(evt, num, AOFN , AOLN , AORole) {
|
|
426 |
evt = (evt) ? evt : ((window.event) ? window.event : null);
|
|
427 |
if (evt) {
|
|
428 |
// equalize W3C/IE models to get event target reference
|
|
429 |
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
|
|
430 |
if (elem && elem.nodeName == "TD") {
|
|
431 |
try {
|
|
432 |
var table = elem.parentNode;
|
|
433 |
if (num == 0) {
|
|
434 |
table.removeChild(elem);
|
|
435 |
var TD = createTD("5","left", "pointer");
|
|
436 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
437 |
TD.attachEvent("onclick", new Function("aoEditRow(event, 1, \"" + AOFN + "\",\""
|
|
438 |
+ AOLN + "\",\"" + AORole + "\")"));
|
|
439 |
} else {
|
|
440 |
TD.setAttribute("onClick","aoEditRow(event, 1, \"" + AOFN + "\",\""
|
|
441 |
+ AOLN + "\",\"" + AORole + "\")");
|
|
442 |
}
|
|
443 |
TD.appendChild(createTextField("aoFirstName", 15, AOFN));
|
|
444 |
TD.appendChild(document.createTextNode(" "));
|
|
445 |
TD.appendChild(createTextField("aoLastName", 15, AOLN));
|
|
446 |
TD.appendChild(document.createTextNode(" Role: "));
|
|
447 |
TD.appendChild(createAORoleTypeSelect("aoRole", AORole));
|
|
448 |
table.appendChild(TD);
|
|
449 |
} else {
|
|
450 |
var child = elem.childNodes;
|
|
451 |
AOFN = child.item(0).value;
|
|
452 |
AOLN = child.item(2).value;
|
|
453 |
var _AORole = child.item(4);
|
|
454 |
AORole = _AORole.options[_AORole.selectedIndex].text;
|
|
455 |
table.removeChild(elem);
|
|
456 |
|
|
457 |
var TD = createTD("5","left", "pointer");
|
|
458 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
459 |
TD.attachEvent("onclick", new Function("aoEditRow(event, 0, \"" + AOFN + "\",\""
|
|
460 |
+ AOLN + "\",\"" + AORole + "\")"));
|
|
461 |
} else {
|
|
462 |
TD.setAttribute("onClick","aoEditRow(event, 0, \"" + AOFN + "\",\""
|
|
463 |
+ AOLN + "\",\"" + AORole + "\")");
|
|
464 |
}
|
|
465 |
var text = AOFN + " " + AOLN + " (Role: " + AORole + ")";
|
|
466 |
var label = document.createTextNode(text);
|
|
467 |
TD.appendChild(label);
|
|
468 |
TD.appendChild(createHiddenInput("aoFirstName", AOFN));
|
|
469 |
TD.appendChild(createHiddenInput("aoLastName", AOLN));
|
|
470 |
TD.appendChild(createHiddenInput("aoRole", AORole));
|
|
471 |
table.appendChild(TD);
|
|
472 |
}
|
|
473 |
} catch(e) {
|
|
474 |
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
|
|
475 |
alert("Error:\n" + msg);
|
|
476 |
return;
|
|
477 |
}
|
|
478 |
}
|
|
479 |
}
|
|
480 |
}
|
|
481 |
|
|
482 |
function createAORoleTypeSelect(name, value) {
|
|
483 |
var newField = document.createElement("select");
|
|
484 |
newField.setAttribute("name", name);
|
|
485 |
var option1 = document.createElement("option");
|
|
486 |
var text1 = document.createTextNode("Co-owner");
|
|
487 |
option1.appendChild(text1);
|
|
488 |
newField.appendChild(option1);
|
|
489 |
var option2 = document.createElement("option");
|
|
490 |
var text2 = document.createTextNode("Custodian/Steward");
|
|
491 |
option2.appendChild(text2);
|
|
492 |
newField.appendChild(option2);
|
|
493 |
var option3 = document.createElement("option");
|
|
494 |
var text3 = document.createTextNode("Metadata Provider");
|
|
495 |
option3.appendChild(text3);
|
|
496 |
newField.appendChild(option3)
|
|
497 |
var option4 = document.createElement("option");
|
|
498 |
var text4 = document.createTextNode("User");
|
|
499 |
option4.appendChild(text4);
|
|
500 |
newField.appendChild(option4);
|
|
501 |
|
|
502 |
if (value == "Co-owner") {
|
|
503 |
newField.selectedIndex = 0;
|
|
504 |
} else if (value == "Custodian/Steward") {
|
|
505 |
newField.selectedIndex = 1;
|
|
506 |
} else if (value == "Metadata Provider") {
|
|
507 |
newField.selectedIndex = 2;
|
|
508 |
} else if (value == "User") {
|
|
509 |
newField.selectedIndex = 3;
|
|
510 |
}
|
|
511 |
|
|
512 |
return newField;
|
|
513 |
}
|
|
514 |
|
|
515 |
function addTaxon() {
|
|
516 |
var taxonRank = document.getElementById("taxonRank");
|
|
517 |
var taxonName = document.getElementById("taxonName");
|
|
518 |
|
|
519 |
if (taxonRank.value !="" && taxonName.value != "") {
|
|
520 |
var taxonCount = incrementCount("taxaCount");
|
|
521 |
var row = createTaxonRow(taxonCount, taxonRank.value, taxonName.value);
|
|
522 |
var taxonRowMarker = document.getElementById("addtaxarow");
|
|
523 |
var parent = taxonRowMarker.parentNode;
|
|
524 |
|
|
525 |
var taxonHR = document.getElementById("taxonHRRow");
|
|
526 |
if (taxonHR == null) {
|
|
527 |
var taxonHRRow = createHRRow();
|
|
528 |
taxonHRRow.setAttribute("id", "taxonHRRow");
|
|
529 |
parent.insertBefore(taxonHRRow, taxonRowMarker);
|
|
530 |
}
|
|
531 |
|
|
532 |
parent.insertBefore(row, taxonRowMarker);
|
|
533 |
|
|
534 |
taxonRank.value = "";
|
|
535 |
taxonName.value = "";
|
|
536 |
} else {
|
|
537 |
alert("Enter complete taxonomic information");
|
|
538 |
}
|
|
539 |
}
|
|
540 |
|
|
541 |
function createTaxonRow(taxonCount, taxonRank, taxonName){
|
|
542 |
var TR = document.createElement("tr");
|
|
543 |
TR.className='sectbody';
|
|
544 |
|
|
545 |
var labelTD = createTD("5","left", "pointer");
|
|
546 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
547 |
labelTD.attachEvent("onclick",new Function("taxonEditRow(event, 0, \"" + taxonName
|
|
548 |
+ "\",\"" + taxonRank + "\")"));
|
|
549 |
} else {
|
|
550 |
labelTD.setAttribute("onClick","taxonEditRow(event, 0, \"" + taxonName
|
|
551 |
+ "\",\"" + taxonRank + "\")");
|
|
552 |
}
|
|
553 |
|
|
554 |
var text = "Rank: " + taxonRank + ", Name: " + taxonName;
|
|
555 |
var label = document.createTextNode(text);
|
|
556 |
|
|
557 |
labelTD.appendChild(label);
|
|
558 |
labelTD.appendChild(createHiddenInput("taxonName", taxonName));
|
|
559 |
labelTD.appendChild(createHiddenInput("taxonRank", taxonRank));
|
|
560 |
|
|
561 |
var imgTD = createTD("","right");
|
|
562 |
imgTD.className = 'rightCol';
|
|
563 |
|
|
564 |
imgTD.appendChild(createImageLink(contextUrl + "/style/images/previous.gif",
|
|
565 |
"Move Up", "moveUpRow(event)",
|
|
566 |
"pointer"));
|
|
567 |
imgTD.appendChild(document.createTextNode(" "));
|
|
568 |
imgTD.appendChild(createImageLink(contextUrl + "/style/images/next.gif",
|
|
569 |
"Move Down", "moveDownRow(event, 'addtaxarow')",
|
|
570 |
"pointer"));
|
|
571 |
imgTD.appendChild(document.createTextNode(" "));
|
|
572 |
imgTD.appendChild(createImageLink(contextUrl + "/style/images/delete.gif",
|
|
573 |
"Delete", "delRow(event)",
|
|
574 |
"pointer"));
|
|
575 |
|
|
576 |
TR.appendChild(imgTD);
|
|
577 |
TR.appendChild(labelTD);
|
|
578 |
|
|
579 |
return TR;
|
|
580 |
}
|
|
581 |
|
|
582 |
function taxonEditRow(evt, num, taxonName , taxonRank) {
|
|
583 |
evt = (evt) ? evt : ((window.event) ? window.event : null);
|
|
584 |
if (evt) {
|
|
585 |
// equalize W3C/IE models to get event target reference
|
|
586 |
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
|
|
587 |
if (elem && elem.nodeName == "TD") {
|
|
588 |
try {
|
|
589 |
var table = elem.parentNode;
|
|
590 |
if (num == 0) {
|
|
591 |
table.removeChild(elem);
|
|
592 |
var TD = createTD("5","left", "pointer");
|
|
593 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
594 |
TD.attachEvent("onclick",new Function("taxonEditRow(event, 1, \"" + taxonName
|
|
595 |
+ "\",\"" + taxonRank + "\")"));
|
|
596 |
} else {
|
|
597 |
TD.setAttribute("onClick","taxonEditRow(event, 1, \"" + taxonName
|
|
598 |
+ "\",\"" + taxonRank + "\")");
|
|
599 |
}
|
|
600 |
|
|
601 |
TD.appendChild(document.createTextNode("Rank: "));
|
|
602 |
TD.appendChild(createTextField("taxonName", 15, taxonName));
|
|
603 |
TD.appendChild(document.createTextNode(" Name: "));
|
|
604 |
TD.appendChild(createTextField("taxonRank", 15, taxonRank));
|
|
605 |
table.appendChild(TD);
|
|
606 |
} else {
|
|
607 |
var child = elem.childNodes;
|
|
608 |
taxonName = child.item(1).value;
|
|
609 |
taxonRank = child.item(3).value;
|
|
610 |
table.removeChild(elem);
|
|
611 |
|
|
612 |
var TD = createTD("5","left", "pointer");
|
|
613 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
614 |
TD.attachEvent("onclick",new Function("taxonEditRow(event, 0, \"" + taxonName
|
|
615 |
+ "\",\"" + taxonRank + "\")"));
|
|
616 |
} else {
|
|
617 |
TD.setAttribute("onClick","taxonEditRow(event, 0, \"" + taxonName
|
|
618 |
+ "\",\"" + taxonRank + "\")");
|
|
619 |
}
|
|
620 |
var text = "Rank: " + taxonName + ", Name: " + taxonRank;
|
|
621 |
var label = document.createTextNode(text);
|
|
622 |
TD.appendChild(label);
|
|
623 |
TD.appendChild(createHiddenInput("taxonName", taxonName));
|
|
624 |
TD.appendChild(createHiddenInput("taxonRank", taxonRank));
|
|
625 |
table.appendChild(TD);
|
|
626 |
}
|
|
627 |
} catch(e) {
|
|
628 |
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
|
|
629 |
alert("Error:\n" + msg);
|
|
630 |
return;
|
|
631 |
}
|
|
632 |
}
|
|
633 |
}
|
|
634 |
}
|
|
635 |
|
|
636 |
function addKeyword() {
|
|
637 |
var keyword = document.getElementById("keyword");
|
|
638 |
var keywordType = document.getElementById("keywordType");
|
|
639 |
var keywordTh = document.getElementById("keywordTh");
|
|
640 |
|
|
641 |
if (keyword.value !="") {
|
|
642 |
var keyCount = incrementCount("keyCount");
|
|
643 |
var keyRow = createKeywordRow(keyCount, keyword.value,
|
|
644 |
keywordType.options[keywordType.selectedIndex].text,
|
|
645 |
keywordTh.options[keywordTh.selectedIndex].text);
|
|
646 |
var keyRowMarker = document.getElementById("addkeyrow");
|
|
647 |
var parent = keyRowMarker.parentNode;
|
|
648 |
|
|
649 |
var keyHR = document.getElementById("keywordHRRow");
|
|
650 |
if (keyHR == null) {
|
|
651 |
var keyHRRow = createHRRow();
|
|
652 |
keyHRRow.setAttribute("id", "keywordHRRow");
|
|
653 |
parent.insertBefore(keyHRRow, keyRowMarker);
|
|
654 |
}
|
|
655 |
|
|
656 |
parent.insertBefore(keyRow, keyRowMarker);
|
|
657 |
|
|
658 |
keyword.value = "";
|
|
659 |
keywordType.selectedIndex = 0;
|
|
660 |
keywordTh.selectedIndex = 0;
|
|
661 |
} else {
|
|
662 |
alert("Enter keyword");
|
|
663 |
}
|
|
664 |
}
|
|
665 |
|
|
666 |
function createKeywordRow(keyCount, keyword, keywordType, keywordTh){
|
|
667 |
var TR = document.createElement("tr");
|
|
668 |
TR.className='sectbody';
|
|
669 |
|
|
670 |
var labelTD = createTD("5","left", "pointer");
|
|
671 |
|
|
672 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
673 |
labelTD.attachEvent("onclick", new Function("keywordEditRow(event, 0, \"" + keyword
|
|
674 |
+ "\",\"" + keywordType + "\",\"" + keywordTh + "\")"));
|
|
675 |
} else {
|
|
676 |
labelTD.setAttribute("onClick","keywordEditRow(event, 0, \"" + keyword
|
|
677 |
+ "\",\"" + keywordType + "\",\"" + keywordTh + "\")");
|
|
678 |
}
|
|
679 |
|
|
680 |
var text = keyword + " (Type: " + keywordType + ", Thesaurus: " + keywordTh + ")";
|
|
681 |
var label = document.createTextNode(text);
|
|
682 |
|
|
683 |
labelTD.appendChild(label);
|
|
684 |
labelTD.appendChild(createHiddenInput("keyword", keyword));
|
|
685 |
labelTD.appendChild(createHiddenInput("keywordType", keywordType));
|
|
686 |
labelTD.appendChild(createHiddenInput("keywordTh", keywordTh));
|
|
687 |
|
|
688 |
var imgTD = createTD("","right");
|
|
689 |
imgTD.className = 'rightCol';
|
|
690 |
|
|
691 |
imgTD.appendChild(createImageLink(contextUrl + "/style/images/previous.gif",
|
|
692 |
"Move Up", "moveUpRow(event)",
|
|
693 |
"pointer"));
|
|
694 |
imgTD.appendChild(document.createTextNode(" "));
|
|
695 |
imgTD.appendChild(createImageLink(contextUrl + "/style/images/next.gif",
|
|
696 |
"Move Down", "moveDownRow(event, 'addkeyrow')",
|
|
697 |
"pointer"));
|
|
698 |
imgTD.appendChild(document.createTextNode(" "));
|
|
699 |
imgTD.appendChild(createImageLink(contextUrl + "/style/images/delete.gif",
|
|
700 |
"Delete", "delRow(event)",
|
|
701 |
"pointer"));
|
|
702 |
|
|
703 |
TR.appendChild(imgTD);
|
|
704 |
TR.appendChild(labelTD);
|
|
705 |
|
|
706 |
return TR;
|
|
707 |
}
|
|
708 |
|
|
709 |
function keywordEditRow(evt, num, keyword, keywordType, keywordTh) {
|
|
710 |
evt = (evt) ? evt : ((window.event) ? window.event : null);
|
|
711 |
if (evt) {
|
|
712 |
// equalize W3C/IE models to get event target reference
|
|
713 |
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
|
|
714 |
if (elem && elem.nodeName == "TD") {
|
|
715 |
try {
|
|
716 |
var table = elem.parentNode;
|
|
717 |
if (num == 0) {
|
|
718 |
table.removeChild(elem);
|
|
719 |
var TD = createTD("5","left", "pointer");
|
|
720 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
721 |
TD.attachEvent("onclick", new Function("keywordEditRow(event, 1, \"" + keyword
|
|
722 |
+ "\",\"" + keywordType + "\",\"" + keywordTh + "\")"));
|
|
723 |
} else {
|
|
724 |
TD.setAttribute("onClick","keywordEditRow(event, 1, \"" + keyword
|
|
725 |
+ "\",\"" + keywordType + "\",\"" + keywordTh + "\")");
|
|
726 |
}
|
|
727 |
|
|
728 |
TD.appendChild(createTextField("keyword", 15, keyword));
|
|
729 |
TD.appendChild(document.createTextNode(" Type: "));
|
|
730 |
TD.appendChild(createKeyTypeSelect("keywordType", keywordType));
|
|
731 |
TD.appendChild(document.createTextNode(" Thesaurus: "));
|
|
732 |
TD.appendChild(createKeyThSelect("keywordTh", keywordTh));
|
|
733 |
table.appendChild(TD);
|
|
734 |
} else {
|
|
735 |
var child = elem.childNodes;
|
|
736 |
keyword = child.item(0).value;
|
|
737 |
var _keywordType = child.item(2);
|
|
738 |
keywordType = _keywordType.options[_keywordType.selectedIndex].text;
|
|
739 |
var _keywordTh = child.item(4);
|
|
740 |
keywordTh = _keywordTh.options[_keywordTh.selectedIndex].text;
|
|
741 |
table.removeChild(elem);
|
|
742 |
|
|
743 |
var TD = createTD("5","left", "pointer");
|
|
744 |
if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
|
|
745 |
TD.attachEvent("onclick", new Function("keywordEditRow(event, 0, \"" + keyword
|
|
746 |
+ "\",\"" + keywordType + "\",\"" + keywordTh + "\")"));
|
|
747 |
} else {
|
|
748 |
TD.setAttribute("onClick","keywordEditRow(event, 0, \"" + keyword
|
|
749 |
+ "\",\"" + keywordType + "\",\"" + keywordTh + "\")");
|
|
750 |
}
|
|
751 |
|
|
752 |
var text = keyword + " (Type: " + keywordType + ", Thesaurus: " + keywordTh + ")";
|
|
753 |
var label = document.createTextNode(text);
|
|
754 |
TD.appendChild(label);
|
|
755 |
TD.appendChild(createHiddenInput("keyword", keyword));
|
|
756 |
TD.appendChild(createHiddenInput("keywordType", keywordType));
|
|
757 |
TD.appendChild(createHiddenInput("keywordTh", keywordTh));
|
|
758 |
table.appendChild(TD);
|
|
759 |
}
|
|
760 |
} catch(e) {
|
|
761 |
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
|
|
762 |
alert("Error:\n" + msg);
|
|
763 |
return;
|
|
764 |
}
|
|
765 |
}
|
|
766 |
}
|
|
767 |
}
|
|
768 |
|
|
769 |
function createKeywordThesaurusRow(name) {
|
|
770 |
var keyRowTemplate = document.getElementById("keyThRow");
|
|
771 |
var newField = keyRowTemplate.cloneNode(true);
|
|
772 |
var nodes = newField.getElementsByTagName("input");
|
|
773 |
nodes.item(0).setAttribute("name", name);
|
|
774 |
nodes.item(1).setAttribute("name", name);
|
|
775 |
return newField;
|
|
776 |
}
|
|
777 |
|
|
778 |
function createKeyThSelect(name, value) {
|
|
779 |
var newField = document.createElement("select");
|
|
780 |
newField.setAttribute("name", name);
|
|
781 |
var option1 = document.createElement("option");
|
|
782 |
var text1 = document.createTextNode("None");
|
|
783 |
option1.appendChild(text1);
|
|
784 |
newField.appendChild(option1);
|
|
785 |
var option2 = document.createElement("option");
|
|
786 |
var text2 = document.createTextNode("GCMD");
|
|
787 |
option2.appendChild(text2);
|
|
788 |
newField.appendChild(option2);
|
|
789 |
|
|
790 |
if (value == "None") {
|
|
791 |
newField.selectedIndex = 0;
|
|
792 |
} else if (value == "GCMD") {
|
|
793 |
newField.selectedIndex = 1;
|
|
794 |
}
|
|
795 |
return newField;
|
|
796 |
}
|
|
797 |
|
|
798 |
function createKeyTypeSelect(name, value) {
|
|
799 |
var newField = document.createElement("select");
|
|
800 |
newField.setAttribute("name", name);
|
|
801 |
var option1 = document.createElement("option");
|
|
802 |
var text1 = document.createTextNode("None");
|
|
803 |
option1.appendChild(text1);
|
|
804 |
newField.appendChild(option1);
|
|
805 |
var option2 = document.createElement("option");
|
|
806 |
var text2 = document.createTextNode("Theme");
|
|
807 |
option2.appendChild(text2);
|
|
808 |
newField.appendChild(option2);
|
|
809 |
var option3 = document.createElement("option");
|
|
810 |
var text3 = document.createTextNode("Place");
|
|
811 |
option3.appendChild(text3);
|
|
812 |
newField.appendChild(option3)
|
|
813 |
var option4 = document.createElement("option");
|
|
814 |
var text4 = document.createTextNode("Stratum");
|
|
815 |
option4.appendChild(text4);
|
|
816 |
newField.appendChild(option4);
|
|
817 |
var option5 = document.createElement("option");
|
|
818 |
var text5 = document.createTextNode("Temporal");
|
|
819 |
option5.appendChild(text5);
|
|
820 |
newField.appendChild(option5);
|
|
821 |
var option6 = document.createElement("option");
|
|
822 |
var text6 = document.createTextNode("Taxonomic");
|
|
823 |
option6.appendChild(text6);
|
|
824 |
newField.appendChild(option6);
|
|
825 |
if (value == "None") {
|
|
826 |
newField.selectedIndex = 0;
|
|
827 |
} else if (value == "Theme") {
|
|
828 |
newField.selectedIndex = 1;
|
|
829 |
} else if (value == "Place") {
|
|
830 |
newField.selectedIndex = 2;
|
|
831 |
} else if (value == "Stratum") {
|
|
832 |
newField.selectedIndex = 3;
|
|
833 |
}else if (value == "Temporal") {
|
|
834 |
newField.selectedIndex = 4;
|
|
835 |
} else if (value == "Taxonomic") {
|
|
836 |
newField.selectedIndex = 5;
|
|
837 |
}
|
|
838 |
return newField;
|
|
839 |
}
|
|
840 |
|
|
841 |
var basicInfoBit = 1;
|
|
842 |
var submitterBit = 1;
|
|
843 |
var dsoBit = 1;
|
|
844 |
var apBit = 1;
|
|
845 |
var abstractBit = 1;
|
|
846 |
var keywordBit = 1;
|
|
847 |
var temporalBit = 1;
|
|
848 |
var spatialBit = 1;
|
|
849 |
var taxonomicBit = 1;
|
|
850 |
var methodBit = 1;
|
|
851 |
var dscBit = 1;
|
|
852 |
var distBit = 1;
|
|
853 |
var uploadBit = 1;
|
|
854 |
|
|
855 |
function swap(evt, _node, nodeBit) {
|
|
856 |
evt = (evt) ? evt : ((window.event) ? window.event : null);
|
|
857 |
if (evt) {
|
|
858 |
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
|
|
859 |
|
|
860 |
// hack so that this works on safari...
|
|
861 |
if (elem.nodeName != 'A') {
|
|
862 |
elem = elem.parentNode;
|
|
863 |
}
|
|
864 |
elem.removeChild(elem.firstChild);
|
|
865 |
var node = document.getElementById(_node);
|
|
866 |
if (nodeBit) {
|
|
867 |
elem.appendChild(document.createTextNode("Show"));
|
|
868 |
node.className="hide";
|
|
869 |
return 0;
|
|
870 |
} else {
|
|
871 |
elem.appendChild(document.createTextNode("Hide"));
|
|
872 |
node.className="tables";
|
|
873 |
return 1;
|
|
874 |
}
|
|
875 |
}
|
|
876 |
}
|
|
877 |
|
|
878 |
function handleOther(enable, node) {
|
|
879 |
var textBox = document.getElementById(node);
|
|
880 |
if (enable) {
|
|
881 |
textBox.removeAttribute("disabled");
|
|
882 |
} else {
|
|
883 |
textBox.value="";
|
|
884 |
textBox.disabled = "true";
|
|
885 |
}
|
|
886 |
}
|
|
887 |
|
|
888 |
function copyContact() {
|
|
889 |
var checkBox = document.getElementById("copyCheckBox");
|
|
890 |
if (checkBox.checked == true)
|
|
891 |
{
|
|
892 |
var cnf = document.getElementById("contactNameFirst");
|
|
893 |
var onf = document.getElementById("origNameFirst");
|
|
894 |
cnf.value = onf.value;
|
|
895 |
cnf.disabled = "true";
|
|
896 |
|
|
897 |
var cnl = document.getElementById("contactNameLast");
|
|
898 |
var onl = document.getElementById("origNameLast");
|
|
899 |
cnl.value = onl.value;
|
|
900 |
cnl.disabled = "true";
|
|
901 |
|
|
902 |
var cno = document.getElementById("contactNameOrg");
|
|
903 |
var ono = document.getElementById("origNameOrg");
|
|
904 |
cno.value = ono.value;
|
|
905 |
cno.disabled = "true";
|
|
906 |
|
|
907 |
var ce = document.getElementById("contactEmail");
|
|
908 |
var oe = document.getElementById("origEmail");
|
|
909 |
ce.value = oe.value;
|
|
910 |
ce.disabled = "true";
|
|
911 |
|
|
912 |
var cp = document.getElementById("contactPhone");
|
|
913 |
var op = document.getElementById("origPhone");
|
|
914 |
cp.value = op.value;
|
|
915 |
cp.disabled = "true";
|
|
916 |
|
|
917 |
var cf = document.getElementById("contactFAX");
|
|
918 |
var of = document.getElementById("origFAX");
|
|
919 |
cf.value = of.value;
|
|
920 |
cf.disabled = "true";
|
|
921 |
|
|
922 |
var cd = document.getElementById("contactDelivery");
|
|
923 |
var od = document.getElementById("origDelivery");
|
|
924 |
cd.value = od.value;
|
|
925 |
cd.disabled = "true";
|
|
926 |
|
|
927 |
var cc = document.getElementById("contactCity");
|
|
928 |
var oc = document.getElementById("origCity");
|
|
929 |
cc.value = oc.value;
|
|
930 |
cc.disabled = "true";
|
|
931 |
|
|
932 |
var cs = document.getElementById("contactState");
|
|
933 |
var os = document.getElementById("origState");
|
|
934 |
cs.options[os.selectedIndex].selected = true;
|
|
935 |
cs.disabled = "true";
|
|
936 |
|
|
937 |
var cso = document.getElementById("contactStateOther");
|
|
938 |
var oso = document.getElementById("origStateOther");
|
|
939 |
cso.value = oso.value;
|
|
940 |
cso.disabled = "true";
|
|
941 |
|
|
942 |
var cz = document.getElementById("contactZip");
|
|
943 |
var oz = document.getElementById("origZip");
|
|
944 |
cz.value = oz.value;
|
|
945 |
cz.disabled = "true";
|
|
946 |
|
|
947 |
var cC = document.getElementById("contactCountry");
|
|
948 |
var oC = document.getElementById("origCountry");
|
|
949 |
cC.value = oC.value;
|
|
950 |
cC.disabled = "true";
|
|
951 |
} else {
|
|
952 |
var cnf = document.getElementById("contactNameFirst");
|
|
953 |
cnf.value = "";
|
|
954 |
cnf.removeAttribute("disabled");
|
|
955 |
|
|
956 |
var cnl = document.getElementById("contactNameLast");
|
|
957 |
cnl.value = "";
|
|
958 |
cnl.removeAttribute("disabled");
|
|
959 |
|
|
960 |
var cno = document.getElementById("contactNameOrg");
|
|
961 |
cno.value = "";
|
|
962 |
cno.removeAttribute("disabled");
|
|
963 |
|
|
964 |
var ce = document.getElementById("contactEmail");
|
|
965 |
ce.value = "";
|
|
966 |
ce.removeAttribute("disabled");
|
|
967 |
|
|
968 |
var cp = document.getElementById("contactPhone");
|
|
969 |
cp.value = "";
|
|
970 |
cp.removeAttribute("disabled");
|
|
971 |
|
|
972 |
var cf = document.getElementById("contactFAX");
|
|
973 |
cf.value = "";
|
|
974 |
cf.removeAttribute("disabled");
|
|
975 |
|
|
976 |
var cd = document.getElementById("contactDelivery");
|
|
977 |
cd.value = "";
|
|
978 |
cd.removeAttribute("disabled");
|
|
979 |
|
|
980 |
var cc = document.getElementById("contactCity");
|
|
981 |
cc.value = "";
|
|
982 |
cc.removeAttribute("disabled");
|
|
983 |
|
|
984 |
var cs = document.getElementById("contactState");
|
|
985 |
cs.options[0].selected = true;
|
|
986 |
cs.removeAttribute("disabled");
|
|
987 |
|
|
988 |
var cso = document.getElementById("contactStateOther");
|
|
989 |
cso.value = "";
|
|
990 |
cso.removeAttribute("disabled");
|
|
991 |
|
|
992 |
var cz = document.getElementById("contactZip");
|
|
993 |
cz.value = "";
|
|
994 |
cz.removeAttribute("disabled");
|
|
995 |
|
|
996 |
var cC = document.getElementById("contactCountry");
|
|
997 |
cC.value = "";
|
|
998 |
cC.removeAttribute("disabled");
|
|
999 |
}
|
|
1000 |
}
|
|
1001 |
|
|
1002 |
// include source for Multiple file uploader:
|
|
1003 |
// http://the-stickman.com/web-development/javascript/
|
|
1004 |
|
|
1005 |
function MultiSelector(list_target, max) {
|
|
1006 |
|
|
1007 |
this.list_target = list_target;
|
|
1008 |
this.count = 0;
|
|
1009 |
this.id = 0;
|
|
1010 |
var ucount = document.getElementById("upCount");
|
|
1011 |
var fcount = document.getElementById("fileCount");
|
|
1012 |
if (fcount.value > 0) {
|
|
1013 |
this.id = fcount.value;
|
|
1014 |
} else {
|
|
1015 |
// upCount contains pre-existing uploads, check this for editing existing packages
|
|
1016 |
if (ucount != null && ucount.value > 0) {
|
|
1017 |
this.id = ucount.value;
|
|
1018 |
}
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
if (max) {
|
|
1022 |
this.max = max;
|
|
1023 |
} else {
|
|
1024 |
this.max = -1;
|
|
1025 |
};
|
|
1026 |
|
|
1027 |
/**
|
|
1028 |
* Add a new file input element
|
|
1029 |
*/
|
|
1030 |
this.addElement = function( element ) {
|
|
1031 |
|
|
1032 |
// Make sure it's a file input element
|
|
1033 |
if (element.tagName == 'INPUT' && element.type == 'file' ) {
|
|
1034 |
// Element name -- what number am I?
|
|
1035 |
element.name = 'file_' + this.id++;
|
|
1036 |
|
|
1037 |
// Add reference to this object
|
|
1038 |
element.multi_selector = this;
|
|
1039 |
|
|
1040 |
// What to do when a file is selected
|
|
1041 |
element.onchange = function() {
|
|
1042 |
// Increment file counter
|
|
1043 |
var fileCount = incrementCount("fileCount");
|
|
1044 |
// If pre-existing uploads exist, make sure the fileCount is synced
|
|
1045 |
if (ucount != null && ucount.value > 0) {
|
|
1046 |
fileCount += ucount.value;
|
|
1047 |
setCount("fileCount", fileCount);
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
// Clean up file text
|
|
1051 |
var comment_element = document.getElementById( 'file_comment' );
|
|
1052 |
if (comment_element) {
|
|
1053 |
comment_element.parentNode.removeChild(comment_element);
|
|
1054 |
}
|
|
1055 |
|
|
1056 |
// New file input
|
|
1057 |
var new_element = document.createElement( 'input' );
|
|
1058 |
new_element.type = 'file';
|
|
1059 |
|
|
1060 |
// Add new element
|
|
1061 |
this.parentNode.insertBefore( new_element, this );
|
|
1062 |
|
|
1063 |
// Apply 'update' to element
|
|
1064 |
this.multi_selector.addElement( new_element );
|
|
1065 |
|
|
1066 |
// Update list
|
|
1067 |
this.multi_selector.addListRow( this );
|
|
1068 |
|
|
1069 |
// Hide this: we can't use display:none because Safari doesn't like it
|
|
1070 |
this.style.position = 'absolute';
|
|
1071 |
this.style.left = '-1000px';
|
|
1072 |
};
|
|
1073 |
|
|
1074 |
// If we've reached maximum number, disable input element
|
|
1075 |
if (this.max != -1 && this.count >= this.max ) {
|
|
1076 |
element.disabled = true;
|
|
1077 |
};
|
|
1078 |
|
|
1079 |
// File element counter
|
|
1080 |
this.count++;
|
|
1081 |
|
|
1082 |
// Most recent element
|
|
1083 |
this.current_element = element;
|
|
1084 |
|
|
1085 |
} else {
|
|
1086 |
// This can only be applied to file input elements!
|
|
1087 |
alert( 'Error: not a file input element' );
|
|
1088 |
};
|
|
1089 |
};
|
|
1090 |
|
|
1091 |
/**
|
|
1092 |
* Add a new row to the list of files
|
|
1093 |
*/
|
|
1094 |
this.addListRow = function( element ) {
|
|
1095 |
// Row div
|
|
1096 |
var new_row = document.createElement( 'div' );
|
|
1097 |
|
|
1098 |
// Delete button
|
|
1099 |
var new_row_button = document.createElement( 'input' );
|
|
1100 |
new_row_button.type = 'button';
|
|
1101 |
new_row_button.value = 'Delete';
|
|
1102 |
|
|
1103 |
// Permissions check boxes
|
|
1104 |
var radio_value_a = 'public';
|
|
1105 |
var radio_value_b = 'private';
|
|
1106 |
var new_radio_a = document.createElement('input');
|
|
1107 |
var new_radio_b = document.createElement('input');
|
|
1108 |
new_radio_a.type = new_radio_b.type = 'radio';
|
|
1109 |
// get the file upload name, use the number to keep track of the file we're setting permissions on
|
|
1110 |
new_radio_a.name = new_radio_b.name = 'uploadperm_' + element.name.split("_")[1];
|
|
1111 |
new_radio_a.value = radio_value_a;
|
|
1112 |
new_radio_b.value = radio_value_b;
|
|
1113 |
new_radio_a.checked = false;
|
|
1114 |
new_radio_b.checked = true; // when adding new files, default is private
|
|
1115 |
|
|
1116 |
// References
|
|
1117 |
new_row.element = element;
|
|
1118 |
|
|
1119 |
// Delete function
|
|
1120 |
new_row_button.onclick= function() {
|
|
1121 |
// Remove element from form
|
|
1122 |
this.parentNode.element.parentNode.removeChild( this.parentNode.element );
|
|
1123 |
|
|
1124 |
// Remove this row from the list
|
|
1125 |
this.parentNode.parentNode.removeChild( this.parentNode );
|
|
1126 |
// Decrement counter
|
|
1127 |
this.parentNode.element.multi_selector.count--;
|
|
1128 |
|
|
1129 |
// Re-enable input element (if it's disabled)
|
|
1130 |
this.parentNode.element.multi_selector.current_element.disabled = false;
|
|
1131 |
|
|
1132 |
// Appease Safari
|
|
1133 |
// without it Safari wants to reload the browser window
|
|
1134 |
// which nixes your already queued uploads
|
|
1135 |
return false;
|
|
1136 |
};
|
|
1137 |
|
|
1138 |
// filename may include path, show only file name itself
|
|
1139 |
var name_pattern = element.value.replace(/.*[\/\\](.*)/, "$1");
|
|
1140 |
|
|
1141 |
// Set row value
|
|
1142 |
new_row.appendChild( document.createTextNode(name_pattern + " ") );
|
|
1143 |
|
|
1144 |
// Add in radio buttons and their text
|
|
1145 |
new_row.appendChild( new_radio_a );
|
|
1146 |
new_row.appendChild( document.createTextNode(capitalize(radio_value_a) + " ") );
|
|
1147 |
new_row.appendChild( new_radio_b );
|
|
1148 |
new_row.appendChild( document.createTextNode(capitalize(radio_value_b) + " ") );
|
|
1149 |
|
|
1150 |
// Add button
|
|
1151 |
new_row.appendChild( new_row_button );
|
|
1152 |
|
|
1153 |
// Add it to the list
|
|
1154 |
this.list_target.appendChild( new_row );
|
|
1155 |
};
|
|
1156 |
|
|
1157 |
};
|
|
1158 |
|
|
1159 |
// Append files to be deleted to an HTML array
|
|
1160 |
function deleteFile(evt, file) {
|
|
1161 |
evt = (evt) ? evt : ((window.event) ? window.event : null);
|
|
1162 |
if (evt) {
|
|
1163 |
// equalize W3C/IE models to get event target reference
|
|
1164 |
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
|
|
1165 |
var element = document.getElementById("file_element");
|
|
1166 |
if (elem) {
|
|
1167 |
try {
|
|
1168 |
// Add a new hidden form element to delete exisiting files
|
|
1169 |
var delete_existing = document.createElement( 'input' );
|
|
1170 |
delete_existing.type = "hidden";
|
|
1171 |
delete_existing.name = "deletefile"; // HTML array
|
|
1172 |
delete_existing.value = file.name;
|
|
1173 |
element.parentNode.appendChild( delete_existing );
|
|
1174 |
|
|
1175 |
// Remove this row from the list
|
|
1176 |
elem.parentNode.parentNode.removeChild( elem.parentNode );
|
|
1177 |
} catch(e) {
|
|
1178 |
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
|
|
1179 |
alert("Error:\n" + msg);
|
|
1180 |
return;
|
|
1181 |
}
|
|
1182 |
}
|
|
1183 |
}
|
|
1184 |
}
|
|
1185 |
|
|
1186 |
function capitalize(word) {
|
|
1187 |
return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase();
|
|
1188 |
}
|
0 |
1189 |
|
Initial copy of original Perl templates - before making any changes. https://projects.ecoinformatics.org/ecoinfo/issues/5951