Project

General

Profile

« Previous | Next » 

Revision 3473

Added by walbridge about 17 years ago

Cleaned up regexes used in register-dataset.cgi to support arbitrary numbers of elements for keywords. Cleaned up regexes for state selection, to omit default values. Added debug as a GET parameter, so a page can be debugged by appending `&debug=1'. Committed latest changes to file processing, to allow files to be deleted after returning to the entry page from confirmation or processing errors. Seperated out entryForm.js from entryForm.tmpl to simplify debugging.

View differences:

lib/style/common/templates/entryForm.js
1
function addParagraph() {
2
    var newParaWidget = document.createElement("textarea");
3
    newParaWidget.setAttribute("rows", "6");
4
    newParaWidget.className="longwidth";
5
    newParaWidget.setAttribute("name", "methodPara");
6

  
7
    var TR = document.createElement("tr");
8
    TR.className='sectbody';
9
    var TD = createTD("5","left");
10
    var emptyTD = createTD("","right");
11
    TD.appendChild(newParaWidget);
12
    TR.appendChild(emptyTD);
13
    TR.appendChild(TD);
14
    var addParaButton = document.getElementById("addparabutton1");
15
    var parent = addParaButton.parentNode;
16
    parent.insertBefore(TR, addParaButton);
17
}
18

  
19
function addMethod() {
20
    var index = incrementCount('methodCount');
21
    var methodButton = document.getElementById("addmethodbutton");
22
    var parent = methodButton.parentNode;
23
    
24
    parent.insertBefore(createHRRow(), methodButton);
25
    parent.insertBefore(addMethodTitle(), methodButton);
26
    parent.insertBefore(addMethodDescription(index), methodButton);
27
    parent.insertBefore(addMethodButton(index), methodButton);
28
}
29

  
30
function  addMethodButton(index) {
31
    var TR = document.createElement("tr");
32
    var buttonId = 'addparabutton' + index;
33
    TR.className='sectbody';
34
    TR.setAttribute("id", buttonId);
35
    var labelTD = createTD("","right");
36
    var TD = createTD("5","left");
37
    var button = document.createElement("input");
38
    button.setAttribute("type", "button"); 
39
    button.setAttribute("value", "Add Paragraph to Method Description"); 
40
    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
41
        button.attachEvent("onclick", new Function("addParagraph("+ index + ", '" + buttonId + "')"));
42
    } else {
43
        button.setAttribute("onclick", "addParagraph("+ index +", '" + buttonId + "')"); 
44
    }
45
    TD.appendChild(button);
46
    TR.appendChild(labelTD);
47
    TR.appendChild(TD);
48
    return TR;
49
}
50

  
51
function  addMethodTitle() {
52
    var TR = document.createElement("tr");
53
    TR.className='sectbody';
54
    var labelTD = createTD("","right");
55
    labelTD.appendChild(document.createTextNode("Method Title"));
56
    var TD = createTD("5","left");
57
    var textField = document.createElement("input");
58
    textField.setAttribute("type", "text"); 
59
    textField.setAttribute("name", "methodTitle"); 
60
    textField.className="longwidth";
61
    TD.appendChild(textField);
62
    TR.appendChild(labelTD);
63
    TR.appendChild(TD);
64
    return TR;
65
}
66

  
67
function  addMethodDescription(index) {
68
    var TR = document.createElement("tr");
69
    TR.className='sectbody';
70
    var labelTD = createTD("","right");
71
    labelTD.setAttribute("vAlign","top");
72
    labelTD.appendChild(document.createTextNode("Method Description"));
73
    var TD = createTD("5","left");
74
    var textArea = document.createElement("textarea");
75
    textArea.setAttribute("name", "methodPara"+index);
76
    textArea.setAttribute("rows", 6); 
77
    textArea.className="longwidth";
78
    TD.appendChild(textArea);
79
    TR.appendChild(labelTD);
80
    TR.appendChild(TD);
81
    return TR;
82
}
83

  
84
function createTextField(name, size, value) {
85
    var newField = document.createElement("input");
86
    newField.setAttribute("type", "text"); 
87
    newField.setAttribute("name", name); 
88
    newField.setAttribute("size", size); 
89
    newField.value = value; 
90
    return newField;
91
}
92

  
93
function createTextRow(count, varName, labelText, value) {
94
    var textField = createTextField(varName + count, "30", value);
95
    var row = createRow(count, textField, labelText);
96
    return row;
97
}
98

  
99
function createRow(count, elem, labelText) {
100
    var textTD = createTD("5");
101
    textTD.appendChild(elem);
102

  
103
    var labelTD = createTD("","right");
104

  
105
    var labelSpan = document.createElement("span");
106
    labelSpan.className = 'label';
107

  
108
    var label = document.createTextNode(labelText);
109
    labelSpan.appendChild(label);
110
    labelTD.appendChild(labelSpan);
111

  
112
    var TR = document.createElement("tr");
113
    TR.className='sectbody';
114
    TR.appendChild(labelTD);
115
    TR.appendChild(textTD);
116

  
117
    return TR;
118
}
119

  
120
function createHRRow() {
121
    var hrCell = createTD("6");
122
    var hr = document.createElement("hr");
123
    hr.setAttribute("width", "85%");
124
    hrCell.appendChild(hr);
125

  
126
    var hrTR = document.createElement("tr");
127
    hrTR.className = 'sectbody';
128
    hrTR.appendChild(hrCell);
129

  
130
    return hrTR;
131
}
132

  
133
function createHiddenInput(name, value) {
134
    var elem = document.createElement("input");
135
    elem.setAttribute("type", "hidden");
136
    elem.setAttribute("name", name);
137
    elem.setAttribute("value", value);
138
    return elem
139
}
140

  
141
function sortInputTags() {
142
    sortTagWithAttributeName("aoFirstName", "addAssociatedParty");
143
    sortTagWithAttributeName("aoLastName", "addAssociatedParty");
144
    sortTagWithAttributeName("aoRole", "addAssociatedParty", "select");
145
    
146
    sortTagWithAttributeName("taxonName", "addTaxon");
147
    sortTagWithAttributeName("taxonRank", "addTaxon");
148
    
149
    sortTagWithAttributeName("keyword", "addKeyword");
150
    sortTagWithAttributeName("keywordType", "addKeyword");
151
    sortTagWithAttributeName("keywordTh", "addKeyword");
152
}
153

  
154

  
155
function sortTagWithAttributeName(tag, afterTag, parentTag) {
156
    var elem = document.getElementById(afterTag);
157
   
158
    elem = elem.nextSibling.nextSibling;
159
    while (elem.nodeName == "TR") {
160
    var nodes = elem.getElementsByTagName("input");
161
        for(var i = 0; i < nodes.length; i++) {
162
            var node = nodes.item(i); 
163
            if (node.getAttribute("name")==tag) {
164
                    var parent = node.parentNode;
165
                    var clone = node.cloneNode(true);
166
                    parent.removeChild(node);
167
                    parent.appendChild(clone);
168
            }
169
        }
170
        if (parentTag != null) {
171
            var nodes = elem.getElementsByTagName(parentTag);
172
            for(var i = 0; i < nodes.length; i++) {
173
                var node = nodes.item(i); 
174
                if (node.getAttribute("name")==tag) {
175
                        var parent = node.parentNode;
176
                        var clone = node.cloneNode(true);
177
                        clone.value = node.value;
178
                        parent.removeChild(node);
179
                        parent.appendChild(clone);
180
                }
181
            }
182
        }
183
        elem = elem.nextSibling;
184
    }
185
}
186

  
187
function incrementCount(_count) {
188
    var countField = document.getElementById(_count);
189
    var count = countField.getAttribute("value");
190
    count++;
191
    countField.setAttribute("value", count);
192
    return count;
193
}
194

  
195
function decrementCount(_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 createImageLink(imgSrc, imgAlt, imgOnClick, cursor) {
204
    var link = document.createElement("a");
205
    var img = document.createElement("img");
206
    img.setAttribute("src", imgSrc);
207
    img.setAttribute("alt", imgAlt);
208
    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
209
        link.style.setAttribute("cursor", cursor);
210
        img.attachEvent("onclick", new Function(imgOnClick));
211
    } else {
212
        link.setAttribute("style", "cursor:"+cursor);
213
        img.setAttribute("onClick", imgOnClick);
214
    }
215
    img.setAttribute("border", "0");
216
    link.appendChild(img);        
217
    return link;
218
}
219

  
220

  
221
function createTD(colSpan, align, cursor) {
222
    var td = document.createElement("td");
223
    if (colSpan != "")
224
        td.setAttribute("colSpan", colSpan);
225
    td.setAttribute("align", align);
226
    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
227
        td.style.setAttribute("cursor", cursor);
228
    } else {
229
        td.setAttribute("style", "cursor:"+cursor);
230
    }
231
    return td;
232
}
233

  
234

  
235
function cleanTextNodes(startTagId, endTagId) {
236
    var startTag = document.getElementById(startTagId);
237

  
238
    var bro = startTag.nextSibling;       
239

  
240
    while(bro) {
241
        if (bro.nodeName == "#text") {
242
            var temp = bro.nextSibling;
243
            bro.parentNode.removeChild(bro);
244
            bro = temp;
245
        } else {
246
            var id = bro.getAttribute("id");
247
            if (id == endTagId) {
248
              return;
249
            }
250
            bro = bro.nextSibling;
251
        }
252
    }
253

  
254
}
255

  
256
function delRow(evt) {
257
    evt = (evt) ? evt : ((window.event) ? window.event : null);
258
    if (evt) {
259
        // equalize W3C/IE models to get event target reference
260
        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
261
        if (elem) {
262
            try {
263
                var table = elem.parentNode.parentNode.parentNode.parentNode;
264
                var row = elem.parentNode.parentNode.parentNode;
265

  
266
                table.removeChild(row);
267
            }
268
            catch(e) {
269
                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
270
                alert("Error:\n" + msg);
271
                return;
272
            }
273
        }
274
    }
275
}
276

  
277
function moveUpRow(evt) {
278
    evt = (evt) ? evt : ((window.event) ? window.event : null);
279
    if (evt) {
280
        // equalize W3C/IE models to get event target reference
281
        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
282
        if (elem) {
283
            try {
284
                var table = elem.parentNode.parentNode.parentNode.parentNode;
285
                var row = elem.parentNode.parentNode.parentNode;
286
                
287
                var bro = row.previousSibling;
288
                if (bro != null && bro.previousSibling.nodeName =="TR") {
289
                    clone = row.cloneNode(true);
290
                    table.insertBefore(clone, bro);
291
                    table.removeChild(row);
292
                }
293
            }
294
            catch(e) {
295
                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
296
                alert("Error:\n" + msg);
297
                return;
298
            }
299
        }
300
    }
301
}
302

  
303
function moveDownRow(evt, lastTR) {
304
    evt = (evt) ? evt : ((window.event) ? window.event : null);
305
    if (evt) {
306
        // equalize W3C/IE models to get event target reference
307
        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
308
        if (elem) {
309
            try {
310
                var table = elem.parentNode.parentNode.parentNode.parentNode;
311
                var row = elem.parentNode.parentNode.parentNode;
312
                
313
                var _test = row.nextSibling;
314
                if (_test.getAttribute("id") == lastTR) {
315
                    return;
316
                }
317
                var bro = row.nextSibling.nextSibling;
318
                if (bro != null && bro.nodeName =="TR") {
319
                    clone = row.cloneNode(true);
320
                    table.insertBefore(clone, bro);
321
                    table.removeChild(row);
322
                }
323
            }
324
            catch(e) {
325
                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
326
                alert("Error:\n" + msg);
327
                return;
328
            }
329
        }
330
    }
331
}
332

  
333
function addAssociatedParty() {
334
    var AOLN   = document.getElementById("AONameLast");
335
    var AOFN   = document.getElementById("AONameFirst");
336
    var AORole = document.getElementById("AORole");
337

  
338
    if (AOLN.value != "") {
339
        var aoCount = incrementCount("aoCount");
340
        
341
        try {
342
            var aoRow = createAORow(aoCount, AOLN.value, AOFN.value, AORole.options[AORole.selectedIndex].text);
343
        } catch(e) {
344
            var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
345
            alert("Error:\n" + msg);
346
            return;
347
        }
348

  
349
        var aoRowMarker = document.getElementById("addaorow");
350
        var parent = aoRowMarker.parentNode;
351
        
352
        var aoHR = document.getElementById("aoHRRow");
353
        if (aoHR == null) {
354
            var aoHRRow = createHRRow();
355
            aoHRRow.setAttribute("id", "aoHRRow");
356
            parent.insertBefore(aoHRRow, aoRowMarker);
357
        }
358
        
359
        parent.insertBefore(aoRow, aoRowMarker);
360
    
361
        AOFN.value = "";
362
        AOLN.value = "";
363
        AORole.selectedIndex = 0;
364
    } else {
365
        alert("Enter the last name of the associated party");
366
    }
367
}
368

  
369
function createAORow(aoCount, AOLN, AOFN, AORole){    
370
    var TR = document.createElement("tr");
371
    TR.className='sectbody';
372
    var labelTD = createTD("5","left", "pointer");
373
    
374
    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
375
        labelTD.attachEvent("onclick", new Function("aoEditRow(event, 0, \"" + AOFN  + "\",\""
376
                         + AOLN  + "\",\"" + AORole + "\")"));
377
    } else {
378
        labelTD.setAttribute("onClick","aoEditRow(event, 0, \"" + AOFN  + "\",\""
379
                         + AOLN  + "\",\"" + AORole + "\")");
380
    }
381

  
382
    var text   = AOFN + " " + AOLN + " (Role: " + AORole + ")";
383
    var label = document.createTextNode(text);
384

  
385
    labelTD.appendChild(label);
386
    labelTD.appendChild(createHiddenInput("aoFirstName", AOFN));
387
    labelTD.appendChild(createHiddenInput("aoLastName", AOLN));
388
    labelTD.appendChild(createHiddenInput("aoRole", AORole));
389
    
390
    var imgTD = createTD("","right");
391
    
392
    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/previous.gif",
393
                                      "Move Up","moveUpRow(event)","pointer"));
394
    imgTD.appendChild(document.createTextNode(" "));
395
    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/next.gif",
396
                                      "Move Down", "moveDownRow(event, \"addaorow\")",
397
                                      "pointer"));
398
    imgTD.appendChild(document.createTextNode(" "));
399
    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/delete.gif",
400
                                      "Delete", "delRow(event)",
401
                                      "pointer"));
402

  
403
    TR.appendChild(imgTD);
404
    TR.appendChild(labelTD);
405
    
406
    return TR;
407
}
408

  
409
function aoEditRow(evt, num,  AOFN ,  AOLN ,  AORole) {
410
    evt = (evt) ? evt : ((window.event) ? window.event : null);
411
    if (evt) {
412
        // equalize W3C/IE models to get event target reference
413
        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
414
        if (elem && elem.nodeName == "TD") {
415
            try {
416
                var table = elem.parentNode;
417
                if (num == 0) {
418
                    table.removeChild(elem);
419
                    var TD = createTD("5","left", "pointer");
420
                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
421
                        TD.attachEvent("onclick", new Function("aoEditRow(event, 1, \"" + AOFN  + "\",\""
422
                                                    + AOLN  + "\",\"" + AORole + "\")"));
423
                    } else {
424
                        TD.setAttribute("onClick","aoEditRow(event, 1, \"" + AOFN  + "\",\""
425
                                             + AOLN  + "\",\"" + AORole + "\")");
426
                    }                   
427
                    TD.appendChild(createTextField("aoFirstName", 15, AOFN));
428
                    TD.appendChild(document.createTextNode(" "));
429
                    TD.appendChild(createTextField("aoLastName", 15, AOLN));
430
                    TD.appendChild(document.createTextNode(" Role: "));
431
                    TD.appendChild(createAORoleTypeSelect("aoRole", AORole));
432
                    table.appendChild(TD);
433
                } else {
434
                    var child = elem.childNodes;
435
                    AOFN = child.item(0).value;
436
                    AOLN = child.item(2).value;
437
                    var _AORole = child.item(4);
438
                    AORole = _AORole.options[_AORole.selectedIndex].text;
439
                    table.removeChild(elem);
440

  
441
                    var TD = createTD("5","left", "pointer");
442
                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
443
                        TD.attachEvent("onclick", new Function("aoEditRow(event, 0, \"" + AOFN  + "\",\""
444
                                                    + AOLN  + "\",\"" + AORole + "\")"));
445
                    } else {
446
                        TD.setAttribute("onClick","aoEditRow(event, 0, \"" + AOFN  + "\",\""
447
                                             + AOLN  + "\",\"" + AORole + "\")");
448
                    }
449
                    var text   = AOFN + " " + AOLN + " (Role: " + AORole + ")";
450
                    var label = document.createTextNode(text);
451
                    TD.appendChild(label);
452
                    TD.appendChild(createHiddenInput("aoFirstName", AOFN));
453
                    TD.appendChild(createHiddenInput("aoLastName", AOLN));
454
                    TD.appendChild(createHiddenInput("aoRole", AORole));
455
                    table.appendChild(TD);
456
                }
457
            } catch(e) {
458
                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
459
                alert("Error:\n" + msg);
460
                return;
461
            }
462
        }
463
    }
464
}
465

  
466
function createAORoleTypeSelect(name, value) {
467
    var newField = document.createElement("select");
468
    newField.setAttribute("name", name);
469
    var option1 = document.createElement("option");
470
    var text1 = document.createTextNode("Co-owner");
471
    option1.appendChild(text1);
472
    newField.appendChild(option1);
473
    var option2 = document.createElement("option");
474
    var text2 = document.createTextNode("Custodian/Steward");
475
    option2.appendChild(text2);
476
    newField.appendChild(option2);
477
    var option3 = document.createElement("option");
478
    var text3 = document.createTextNode("Metadata Provider");
479
    option3.appendChild(text3);
480
    newField.appendChild(option3)
481
    var option4 = document.createElement("option");
482
    var text4 = document.createTextNode("User");
483
    option4.appendChild(text4);
484
    newField.appendChild(option4);
485
        
486
    if (value == "Co-owner") {
487
        newField.selectedIndex = 0;
488
    } else if (value == "Custodian/Steward") {
489
        newField.selectedIndex = 1;
490
    } else if (value == "Metadata Provider") {
491
        newField.selectedIndex = 2;
492
    } else if (value == "User") {
493
        newField.selectedIndex = 3;
494
    }
495

  
496
    return newField;
497
}
498

  
499
function addTaxon() {   
500
    var taxonRank   = document.getElementById("taxonRank");
501
    var taxonName   = document.getElementById("taxonName");
502

  
503
    if (taxonRank.value !="" && taxonName.value != "") {
504
        var taxonCount = incrementCount("taxaCount");
505
        var row = createTaxonRow(taxonCount, taxonRank.value, taxonName.value);
506
        var taxonRowMarker = document.getElementById("addtaxarow");
507
        var parent = taxonRowMarker.parentNode;
508
        
509
        var taxonHR = document.getElementById("taxonHRRow");
510
        if (taxonHR == null) {
511
            var taxonHRRow = createHRRow();
512
            taxonHRRow.setAttribute("id", "taxonHRRow");
513
            parent.insertBefore(taxonHRRow, taxonRowMarker);
514
        }
515
        
516
        parent.insertBefore(row, taxonRowMarker);
517

  
518
        taxonRank.value = "";
519
        taxonName.value = "";
520
    } else {
521
        alert("Enter complete taxonomic information");
522
    }
523
}
524

  
525
function createTaxonRow(taxonCount, taxonRank, taxonName){    
526
    var TR = document.createElement("tr");
527
    TR.className='sectbody';
528

  
529
    var labelTD = createTD("5","left", "pointer");
530
    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
531
        labelTD.attachEvent("onclick",new Function("taxonEditRow(event, 0, \"" + taxonName
532
                         + "\",\"" + taxonRank  + "\")"));
533
    } else {
534
        labelTD.setAttribute("onClick","taxonEditRow(event, 0, \"" + taxonName
535
                         + "\",\"" + taxonRank  + "\")");
536
    }
537

  
538
    var text = "Rank: " + taxonRank + ", Name: " + taxonName;
539
    var label = document.createTextNode(text);
540

  
541
    labelTD.appendChild(label);
542
    labelTD.appendChild(createHiddenInput("taxonName", taxonName));
543
    labelTD.appendChild(createHiddenInput("taxonRank", taxonRank));
544
    
545
    var imgTD = createTD("","right");
546
    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/previous.gif",
547
                                      "Move Up", "moveUpRow(event)",
548
                                      "pointer"));
549
    imgTD.appendChild(document.createTextNode(" "));
550
    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/next.gif",
551
                                      "Move Down", "moveDownRow(event, 'addtaxarow')",
552
                                      "pointer"));
553
    imgTD.appendChild(document.createTextNode(" "));
554
    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/delete.gif",
555
                                      "Delete", "delRow(event)",
556
                                      "pointer"));
557

  
558
    TR.appendChild(imgTD);
559
    TR.appendChild(labelTD);
560
    
561
    return TR;
562
}
563

  
564
function taxonEditRow(evt, num,  taxonName ,  taxonRank) {
565
    evt = (evt) ? evt : ((window.event) ? window.event : null);
566
    if (evt) {
567
        // equalize W3C/IE models to get event target reference
568
        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
569
        if (elem && elem.nodeName == "TD") {
570
            try {
571
                var table = elem.parentNode;
572
                if (num == 0) {
573
                    table.removeChild(elem);
574
                    var TD = createTD("5","left", "pointer");
575
                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
576
                        TD.attachEvent("onclick",new Function("taxonEditRow(event, 1, \"" + taxonName
577
                                       + "\",\"" + taxonRank  + "\")"));
578
                    } else {
579
                        TD.setAttribute("onClick","taxonEditRow(event, 1, \"" + taxonName
580
                                        + "\",\"" + taxonRank  + "\")");
581
                    }
582
          
583
                    TD.appendChild(document.createTextNode("Rank: "));
584
                    TD.appendChild(createTextField("taxonName", 15, taxonName));
585
                    TD.appendChild(document.createTextNode(" Name: "));
586
                    TD.appendChild(createTextField("taxonRank", 15, taxonRank));
587
                    table.appendChild(TD);
588
                } else {
589
                    var child = elem.childNodes;
590
                    taxonName = child.item(1).value;
591
                    taxonRank = child.item(3).value;
592
                    table.removeChild(elem);
593

  
594
                    var TD = createTD("5","left", "pointer");
595
                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
596
                        TD.attachEvent("onclick",new Function("taxonEditRow(event, 0, \"" + taxonName
597
                                       + "\",\"" + taxonRank  + "\")"));
598
                    } else {
599
                        TD.setAttribute("onClick","taxonEditRow(event, 0, \"" + taxonName
600
                                        + "\",\"" + taxonRank  + "\")");
601
                    }                        
602
                    var text = "Rank: " + taxonName + ", Name: " + taxonRank;
603
                    var label = document.createTextNode(text);
604
                    TD.appendChild(label);
605
                    TD.appendChild(createHiddenInput("taxonName", taxonName));
606
                    TD.appendChild(createHiddenInput("taxonRank", taxonRank));
607
                    table.appendChild(TD);
608
                }
609
            } catch(e) {
610
                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
611
                alert("Error:\n" + msg);
612
                return;
613
            }
614
        }
615
    }
616
}
617

  
618
function addKeyword() {
619
    var keyword   = document.getElementById("keyword");
620
    var keywordType   = document.getElementById("keywordType");
621
    var keywordTh = document.getElementById("keywordTh");
622

  
623
    if (keyword.value !="") {
624
        var keyCount = incrementCount("keyCount");
625
        var keyRow = createKeywordRow(keyCount, keyword.value, 
626
                                      keywordType.options[keywordType.selectedIndex].text, 
627
                                      keywordTh.options[keywordTh.selectedIndex].text);
628
        var keyRowMarker = document.getElementById("addkeyrow");
629
        var parent = keyRowMarker.parentNode;
630
        
631
        var keyHR = document.getElementById("keywordHRRow");
632
        if (keyHR == null) {
633
            var keyHRRow = createHRRow();
634
            keyHRRow.setAttribute("id", "keywordHRRow");
635
            parent.insertBefore(keyHRRow, keyRowMarker);
636
        }
637
        
638
        parent.insertBefore(keyRow, keyRowMarker);
639
    
640
        keyword.value = "";
641
        keywordType.selectedIndex = 0;
642
        keywordTh.selectedIndex = 0;
643
    } else {
644
        alert("Enter keyword");
645
    }
646
}
647

  
648
function createKeywordRow(keyCount, keyword, keywordType, keywordTh){    
649
    var TR = document.createElement("tr");
650
    TR.className='sectbody';
651

  
652
    var labelTD = createTD("5","left", "pointer");
653
    
654
    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
655
        labelTD.attachEvent("onclick", new Function("keywordEditRow(event, 0, \"" + keyword
656
            + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")"));
657
    } else {
658
        labelTD.setAttribute("onClick","keywordEditRow(event, 0, \"" + keyword
659
            + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")");
660
    }
661
              
662
    var text   = keyword + " (Type: " + keywordType + ", Thesaurus: " + keywordTh + ")";
663
    var label = document.createTextNode(text);
664

  
665
    labelTD.appendChild(label);
666
    labelTD.appendChild(createHiddenInput("keyword", keyword));
667
    labelTD.appendChild(createHiddenInput("keywordType", keywordType));
668
    labelTD.appendChild(createHiddenInput("keywordTh", keywordTh));
669
    
670
    var imgTD = createTD("","right");
671
    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/previous.gif",
672
                                      "Move Up", "moveUpRow(event)",
673
                                      "pointer"));
674
    imgTD.appendChild(document.createTextNode(" "));
675
    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/next.gif",
676
                                      "Move Down", "moveDownRow(event, 'addkeyrow')",
677
                                      "pointer"));
678
    imgTD.appendChild(document.createTextNode(" "));
679
    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/delete.gif",
680
                                      "Delete", "delRow(event)",
681
                                      "pointer"));
682

  
683
    TR.appendChild(imgTD);
684
    TR.appendChild(labelTD);
685
    
686
    return TR;
687
}
688

  
689
function keywordEditRow(evt, num,  keyword,  keywordType, keywordTh) {
690
    evt = (evt) ? evt : ((window.event) ? window.event : null);
691
    if (evt) {
692
        // equalize W3C/IE models to get event target reference
693
        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
694
        if (elem && elem.nodeName == "TD") {
695
            try {
696
                var table = elem.parentNode;
697
                if (num == 0) {
698
                    table.removeChild(elem);
699
                    var TD = createTD("5","left", "pointer");
700
                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
701
                        TD.attachEvent("onclick", new Function("keywordEditRow(event, 1, \"" + keyword
702
                        + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")"));
703
                    } else {
704
                        TD.setAttribute("onClick","keywordEditRow(event, 1, \"" + keyword
705
                        + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")");
706
                    }
707
                
708
                    TD.appendChild(createTextField("keyword", 15, keyword));
709
                    TD.appendChild(document.createTextNode(" Type: "));
710
                    TD.appendChild(createKeyTypeSelect("keywordType", keywordType));
711
                    TD.appendChild(document.createTextNode(" Thesaurus: "));
712
                    TD.appendChild(createKeyThSelect("keywordTh", keywordTh));
713
                    table.appendChild(TD);
714
                } else {
715
                    var child = elem.childNodes;
716
                    keyword = child.item(0).value;
717
                    var _keywordType = child.item(2);
718
                    keywordType = _keywordType.options[_keywordType.selectedIndex].text;
719
                    var _keywordTh = child.item(4);
720
                    keywordTh = _keywordTh.options[_keywordTh.selectedIndex].text;
721
                    table.removeChild(elem);
722

  
723
                    var TD = createTD("5","left", "pointer");
724
                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
725
                        TD.attachEvent("onclick", new Function("keywordEditRow(event, 0, \"" + keyword
726
                        + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")"));
727
                    } else {
728
                        TD.setAttribute("onClick","keywordEditRow(event, 0, \"" + keyword
729
                        + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")");
730
                    }
731
                
732
                    var text   = keyword + " (Type: " + keywordType + ", Thesaurus: " + keywordTh + ")";
733
                    var label = document.createTextNode(text);
734
                    TD.appendChild(label);
735
                    TD.appendChild(createHiddenInput("keyword", keyword));
736
                    TD.appendChild(createHiddenInput("keywordType", keywordType));
737
                    TD.appendChild(createHiddenInput("keywordTh", keywordTh));
738
                    table.appendChild(TD);
739
                }
740
            } catch(e) {
741
                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
742
                alert("Error:\n" + msg);
743
                return;
744
            }
745
        }
746
    }
747
}
748

  
749
function createKeywordThesaurusRow(name) {        
750
    var keyRowTemplate = document.getElementById("keyThRow");
751
    var newField =  keyRowTemplate.cloneNode(true);
752
    var nodes = newField.getElementsByTagName("input");
753
    nodes.item(0).setAttribute("name", name);
754
    nodes.item(1).setAttribute("name", name);
755
    return newField;
756
}
757

  
758
function createKeyThSelect(name, value) {
759
    var newField = document.createElement("select");
760
    newField.setAttribute("name", name);
761
    var option1 = document.createElement("option");
762
    var text1 = document.createTextNode("None");
763
    option1.appendChild(text1);
764
    newField.appendChild(option1);
765
    var option2 = document.createElement("option");
766
    var text2 = document.createTextNode("GCMD");
767
    option2.appendChild(text2);
768
    newField.appendChild(option2);
769

  
770
    if (value == "None") {
771
        newField.selectedIndex = 0;
772
    } else if (value == "GCMD") {
773
        newField.selectedIndex = 1;
774
    }
775
    return newField;
776
}
777

  
778
function createKeyTypeSelect(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("Theme");
787
    option2.appendChild(text2);
788
    newField.appendChild(option2);
789
    var option3 = document.createElement("option");
790
    var text3 = document.createTextNode("Place");
791
    option3.appendChild(text3);
792
    newField.appendChild(option3)
793
    var option4 = document.createElement("option");
794
    var text4 = document.createTextNode("Stratum");
795
    option4.appendChild(text4);
796
    newField.appendChild(option4);
797
    var option5 = document.createElement("option");
798
    var text5 = document.createTextNode("Temporal");
799
    option5.appendChild(text5);
800
    newField.appendChild(option5);
801
    var option6 = document.createElement("option");
802
    var text6 = document.createTextNode("Taxonomic");
803
    option6.appendChild(text6);
804
    newField.appendChild(option6);        
805
    if (value == "None") {
806
        newField.selectedIndex = 0;
807
    } else if (value == "Theme") {
808
        newField.selectedIndex = 1;
809
    } else if (value == "Place") {
810
        newField.selectedIndex = 2;
811
    } else if (value == "Stratum") {
812
        newField.selectedIndex = 3;
813
    }else if (value == "Temporal") {
814
        newField.selectedIndex = 4;
815
    } else if (value == "Taxonomic") {
816
        newField.selectedIndex = 5;
817
    }
818
    return newField;
819
}
820

  
821
var basicInfoBit = 1;
822
var submitterBit = 1;
823
var dsoBit = 1;
824
var apBit = 1;
825
var abstractBit = 1;
826
var keywordBit = 1;
827
var temporalBit = 1;
828
var spatialBit = 1;
829
var taxonomicBit = 1;
830
var methodBit = 1;
831
var dscBit = 1;
832
var distBit = 1;
833
var uploadBit = 1;
834

  
835
function swap(evt, _node, nodeBit) {
836
    evt = (evt) ? evt : ((window.event) ? window.event : null);
837
    if (evt) {
838
        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
839
        
840
        // hack so that this works on safari...
841
        if (elem.nodeName != 'A') {
842
            elem = elem.parentNode;
843
        }
844
        elem.removeChild(elem.firstChild);
845
        var node = document.getElementById(_node);
846
        if (nodeBit) {
847
            elem.appendChild(document.createTextNode("Show"));
848
            node.className="hide";
849
            return 0;
850
        } else {
851
            elem.appendChild(document.createTextNode("Hide"));
852
            node.className="tables";
853
            return 1;
854
        }
855
    }        
856
}
857

  
858
function handleOther(enable, node) {
859
    var textBox = document.getElementById(node);
860
    if (enable) {
861
        textBox.removeAttribute("disabled");   
862
    } else {
863
        textBox.value="";
864
        textBox.disabled = "true";   
865
    }
866
}
867

  
868
function copyContact() {
869
    var checkBox = document.getElementById("copyCheckBox");
870
    if (checkBox.checked == true)
871
    {
872
        var cnf = document.getElementById("contactNameFirst");
873
        var onf = document.getElementById("origNameFirst");
874
        cnf.value = onf.value;
875
        cnf.disabled = "true";
876

  
877
        var cnl = document.getElementById("contactNameLast");
878
        var onl = document.getElementById("origNameLast");
879
        cnl.value = onl.value;
880
        cnl.disabled = "true";
881

  
882
        var cno = document.getElementById("contactNameOrg");
883
        var ono = document.getElementById("origNameOrg");
884
        cno.value = ono.value;
885
        cno.disabled = "true";
886

  
887
        var ce = document.getElementById("contactEmail");
888
        var oe = document.getElementById("origEmail");
889
        ce.value = oe.value;
890
        ce.disabled = "true";
891

  
892
        var cp = document.getElementById("contactPhone");
893
        var op = document.getElementById("origPhone");
894
        cp.value = op.value;
895
        cp.disabled = "true";
896

  
897
        var cf = document.getElementById("contactFAX");
898
        var of = document.getElementById("origFAX");
899
        cf.value = of.value;
900
        cf.disabled = "true";
901

  
902
        var cd = document.getElementById("contactDelivery");
903
        var od = document.getElementById("origDelivery");
904
        cd.value = od.value;
905
        cd.disabled = "true";
906

  
907
        var cc = document.getElementById("contactCity");
908
        var oc = document.getElementById("origCity");
909
        cc.value = oc.value;
910
        cc.disabled = "true";
911

  
912
        var cs = document.getElementById("contactState");
913
        var os = document.getElementById("origState");
914
        cs.options[os.selectedIndex].selected = true;
915
        cs.disabled = "true";           
916

  
917
        var cso = document.getElementById("contactStateOther");
918
        var oso = document.getElementById("origStateOther");
919
        cso.value = oso.value;
920
        cso.disabled = "true";
921

  
922
        var cz = document.getElementById("contactZip");
923
        var oz = document.getElementById("origZip");
924
        cz.value = oz.value;
925
        cz.disabled = "true";
926

  
927
        var cC = document.getElementById("contactCountry");
928
        var oC = document.getElementById("origCountry");
929
        cC.value = oC.value;
930
        cC.disabled = "true";
931
    } else {
932
        var cnf = document.getElementById("contactNameFirst");
933
        cnf.value = "";
934
        cnf.removeAttribute("disabled");
935

  
936
        var cnl = document.getElementById("contactNameLast");
937
        cnl.value = "";
938
        cnl.removeAttribute("disabled");
939

  
940
        var cno = document.getElementById("contactNameOrg");
941
        cno.value = "";
942
        cno.removeAttribute("disabled");
943

  
944
        var ce = document.getElementById("contactEmail");
945
        ce.value = "";
946
        ce.removeAttribute("disabled");
947

  
948
        var cp = document.getElementById("contactPhone");
949
        cp.value = "";
950
        cp.removeAttribute("disabled");
951

  
952
        var cf = document.getElementById("contactFAX");
953
        cf.value = "";
954
        cf.removeAttribute("disabled");
955

  
956
        var cd = document.getElementById("contactDelivery");
957
        cd.value = "";
958
        cd.removeAttribute("disabled");
959

  
960
        var cc = document.getElementById("contactCity");
961
        cc.value = "";
962
        cc.removeAttribute("disabled");
963

  
964
        var cs = document.getElementById("contactState");
965
              cs.options[0].selected = true;
966
        cs.removeAttribute("disabled");
967

  
968
        var cso = document.getElementById("contactStateOther");
969
        cso.value = "";
970
        cso.removeAttribute("disabled");
971

  
972
        var cz = document.getElementById("contactZip");
973
        cz.value = "";
974
        cz.removeAttribute("disabled");
975

  
976
        var cC = document.getElementById("contactCountry");
977
        cC.value = "";
978
        cC.removeAttribute("disabled");
979
    }
980
}
981

  
982
// include source for Multiple file uploader:
983
// http://the-stickman.com/web-development/javascript/
984

  
985
function MultiSelector(list_target, max) {
986

  
987
    this.list_target = list_target;
988
    this.count = 0;
989
    this.id = 0;
990
    var fcount =  document.getElementById("fileCount");
991
    if (fcount.value > 0) {
992
        this.id = fcount.value;
993
    }
994

  
995
    if (max) {
996
        this.max = max;
997
    } else {
998
      this.max = -1;
999
    };
1000

  
1001
    /**
1002
     * Add a new file input element
1003
     */
1004
    this.addElement = function( element ) {
1005

  
1006
        // Make sure it's a file input element
1007
        if (element.tagName == 'INPUT' && element.type == 'file' ) {
1008
            // Element name -- what number am I?
1009
            element.name = 'file_' + this.id++;
1010

  
1011
            // Add reference to this object
1012
            element.multi_selector = this;
1013

  
1014
            // What to do when a file is selected
1015
            element.onchange = function() {
1016
            // Increment file counter
1017
            var fileCount = incrementCount("fileCount");
1018
                // Clean up file text
1019
                var comment_element = document.getElementById( 'file_comment' );
1020
                if (comment_element) {
1021
                    comment_element.parentNode.removeChild(comment_element);
1022
                }
1023

  
1024
                // New file input
1025
                var new_element = document.createElement( 'input' );
1026
                new_element.type = 'file';
1027

  
1028
                // Add new element
1029
                this.parentNode.insertBefore( new_element, this );
1030

  
1031
                // Apply 'update' to element
1032
                this.multi_selector.addElement( new_element );
1033

  
1034
                // Update list
1035
                this.multi_selector.addListRow( this );
1036

  
1037
                // Hide this: we can't use display:none because Safari doesn't like it
1038
                this.style.position = 'absolute';
1039
                this.style.left = '-1000px';
1040
            };
1041

  
1042
            // If we've reached maximum number, disable input element
1043
            if (this.max != -1 && this.count >= this.max ) {
1044
                element.disabled = true;
1045
            };
1046
            
1047
            // File element counter
1048
            this.count++;
1049

  
1050
            // Most recent element
1051
            this.current_element = element;
1052

  
1053
        } else {
1054
            // This can only be applied to file input elements!
1055
            alert( 'Error: not a file input element' );
1056
        };
1057
    };
1058

  
1059
    /**
1060
     * Add a new row to the list of files
1061
     */
1062
    this.addListRow = function( element ) {
1063
        // Row div
1064
        var new_row = document.createElement( 'div' );
1065

  
1066
        // Delete button
1067
        var new_row_button = document.createElement( 'input' );
1068
        new_row_button.type = 'button';
1069
        new_row_button.value = 'Delete';
1070

  
1071
        // References
1072
        new_row.element = element;
1073

  
1074
        // Delete function
1075
        new_row_button.onclick= function() {
1076
            // Remove element from form
1077
            this.parentNode.element.parentNode.removeChild( this.parentNode.element );
1078

  
1079
            // Remove this row from the list
1080
            this.parentNode.parentNode.removeChild( this.parentNode );
1081
            // Decrement counter
1082
            this.parentNode.element.multi_selector.count--;
1083

  
1084
            // Re-enable input element (if it's disabled)
1085
            this.parentNode.element.multi_selector.current_element.disabled = false;
1086

  
1087
            // Appease Safari
1088
            //    without it Safari wants to reload the browser window
1089
            //    which nixes your already queued uploads
1090
            return false;
1091
        };
1092

  
1093
        // Set row value
1094
        new_row.innerHTML = element.value + " ";
1095
  
1096
        // Add button
1097
        new_row.appendChild( new_row_button );
1098

  
1099
        // Add it to the list
1100
        this.list_target.appendChild( new_row );
1101
    };
1102

  
1103
};
1104

  
1105
function deleteFile(evt, file) {
1106
    evt = (evt) ? evt : ((window.event) ? window.event : null);
1107
    if (evt) {
1108
        // equalize W3C/IE models to get event target reference
1109
        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
1110
        var element = document.getElementById("file_element");
1111
        if (elem) {
1112
            try {
1113
                // Add a new hidden form element to delete exisiting files
1114
                var delete_existing = document.createElement( 'input' );
1115
                delete_existing.type = "hidden";
1116
                delete_existing.name = "deletefile"; // HTML array
1117
                delete_existing.value = file.name;
1118
                element.parentNode.appendChild( delete_existing );
1119

  
1120
                // Remove this row from the list
1121
                elem.parentNode.parentNode.removeChild( elem.parentNode );
1122
            } catch(e) {
1123
                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
1124
                alert("Error:\n" + msg);
1125
                return;
1126
            }
1127
        }
1128
    }
1129
}
0 1130

  
lib/style/common/templates/entryForm.tmpl
1 1
[% INCLUDE "genericHeader.tmpl" %]
2 2

  
3
  <script language="JavaScript" type="text/javascript">
4

  
5
    function addParagraph() {
6
        var newParaWidget=document.createElement("textarea");
7
        newParaWidget.setAttribute("rows", "6");
8
        newParaWidget.className="longwidth";
9
        newParaWidget.setAttribute("name", "methodPara");
10

  
11
        var TR = document.createElement("tr");
12
        TR.className='sectbody';
13
        var TD = createTD("5","left");
14
        var emptyTD = createTD("","right");
15
        TD.appendChild(newParaWidget);
16
        TR.appendChild(emptyTD);
17
        TR.appendChild(TD);
18
        var addParaButton = document.getElementById("addparabutton1");
19
        var parent = addParaButton.parentNode;
20
        parent.insertBefore(TR, addParaButton);
21
    }
22

  
23
    function addMethod(){
24
        var index = incrementCount('methodCount');
25
        var methodButton = document.getElementById("addmethodbutton");
26
        var parent = methodButton.parentNode;
27
        
28
        parent.insertBefore(createHRRow(), methodButton);
29
        parent.insertBefore(addMethodTitle(), methodButton);
30
        parent.insertBefore(addMethodDescription(index), methodButton);
31
        parent.insertBefore(addMethodButton(index), methodButton);
32
    }
33

  
34
    function  addMethodButton(index){
35
        var TR = document.createElement("tr");
36
        var buttonId = 'addparabutton' + index;
37
        TR.className='sectbody';
38
        TR.setAttribute("id", buttonId);
39
        var labelTD = createTD("","right");
40
        var TD = createTD("5","left");
41
        var button=document.createElement("input");
42
        button.setAttribute("type", "button"); 
43
        button.setAttribute("value", "Add Paragraph to Method Description"); 
44
        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
45
            button.attachEvent("onclick", new Function("addParagraph("+ index + ", '" + buttonId + "')"));
46
        } else {
47
            button.setAttribute("onclick", "addParagraph("+ index +", '" + buttonId + "')"); 
48
        }
49
        TD.appendChild(button);
50
        TR.appendChild(labelTD);
51
        TR.appendChild(TD);
52
        return TR;
53
    }
54
    
55
    function  addMethodTitle(){
56
        var TR = document.createElement("tr");
57
        TR.className='sectbody';
58
        var labelTD = createTD("","right");
59
        labelTD.appendChild(document.createTextNode("Method Title"));
60
        var TD = createTD("5","left");
61
        var textField=document.createElement("input");
62
        textField.setAttribute("type", "text"); 
63
        textField.setAttribute("name", "methodTitle"); 
64
        textField.className="longwidth";
65
        TD.appendChild(textField);
66
        TR.appendChild(labelTD);
67
        TR.appendChild(TD);
68
        return TR;
69
    }
70

  
71
    function  addMethodDescription(index){
72
        var TR = document.createElement("tr");
73
        TR.className='sectbody';
74
        var labelTD = createTD("","right");
75
        labelTD.setAttribute("vAlign","top");
76
        labelTD.appendChild(document.createTextNode("Method Description"));
77
        var TD = createTD("5","left");
78
        var textArea=document.createElement("textarea");
79
        textArea.setAttribute("name", "methodPara"+index);
80
        textArea.setAttribute("rows", 6); 
81
        textArea.className="longwidth";
82
        TD.appendChild(textArea);
83
        TR.appendChild(labelTD);
84
        TR.appendChild(TD);
85
        return TR;
86
    }
87
    
88
    function createTextField(name, size, value) {
89
        var newField=document.createElement("input");
90
        newField.setAttribute("type", "text"); 
91
        newField.setAttribute("name", name); 
92
        newField.setAttribute("size", size); 
93
        newField.value = value; 
94
        return newField;
95
    }
96

  
97
    function createTextRow(count, varName, labelText, value) {
98
        var textField=createTextField(varName + count, "30", value);
99
	var row = createRow(count, textField, labelText);
100
	return row;
101
    }
102

  
103
    function createRow(count, elem, labelText){
104
        var textTD = createTD("5");
105
        textTD.appendChild(elem);
106

  
107
        var labelTD = createTD("","right");
108

  
109
        var labelSpan = document.createElement("span");
110
        labelSpan.className = 'label';
111

  
112
        var label = document.createTextNode(labelText);
113
        labelSpan.appendChild(label);
114
        labelTD.appendChild(labelSpan);
115

  
116
        var TR = document.createElement("tr");
117
        TR.className='sectbody';
118
        TR.appendChild(labelTD);
119
        TR.appendChild(textTD);
120

  
121
       return TR;
122
    }
123

  
124
    function createHRRow() {
125
        var hrCell = createTD("6");
126
	var hr = document.createElement("hr");
127
	hr.setAttribute("width", "85%");
128
        hrCell.appendChild(hr);
129

  
130
        var hrTR = document.createElement("tr");
131
        hrTR.className = 'sectbody';
132
        hrTR.appendChild(hrCell);
133

  
134
        return hrTR;
135
    }
136

  
137
    function createHiddenInput(name, value){
138
        var elem = document.createElement("input");
139
        elem.setAttribute("type", "hidden");
140
        elem.setAttribute("name", name);
141
        elem.setAttribute("value", value);
142
        return elem
143
    }
144

  
145
    function sortInputTags(){
146
        sortTagWithAttributeName("aoFirstName", "addAssociatedParty");
147
        sortTagWithAttributeName("aoLastName", "addAssociatedParty");
148
        sortTagWithAttributeName("aoRole", "addAssociatedParty", "select");
149
        
150
        sortTagWithAttributeName("taxonName", "addTaxon");
151
        sortTagWithAttributeName("taxonRank", "addTaxon");
152
        
153
        sortTagWithAttributeName("keyword", "addKeyword");
154
        sortTagWithAttributeName("keywordType", "addKeyword");
155
        sortTagWithAttributeName("keywordTh", "addKeyword");
156

  
157
    }
158
    
159

  
160
    function sortTagWithAttributeName(tag, afterTag, parentTag){
161
       var elem = document.getElementById(afterTag);
162
       
163
       elem=elem.nextSibling.nextSibling;
164
        while(elem.nodeName == "TR"){
165
            var nodes = elem.getElementsByTagName("input");
166
            for(var i=0; i < nodes.length; i++){
167
                var node = nodes.item(i); 
168
                if(node.getAttribute("name")==tag){
169
                        var parent = node.parentNode;
170
                        var clone = node.cloneNode(true);
171
                        parent.removeChild(node);
172
                        parent.appendChild(clone);
173
                }
174
            }
175
            if(parentTag != null){
176
            var nodes = elem.getElementsByTagName(parentTag);
177
            for(var i=0; i < nodes.length; i++){
178
                var node = nodes.item(i); 
179
                if(node.getAttribute("name")==tag){
180
                        var parent = node.parentNode;
181
                        var clone = node.cloneNode(true);
182
                        clone.value = node.value;
183
                        parent.removeChild(node);
184
                        parent.appendChild(clone);
185
                }
186
            }
187
            }
188
            elem=elem.nextSibling;
189
        }
190
    }
191
    
192
    function incrementCount(_count){
193
        var countField = document.getElementById(_count);
194
        var count = countField.getAttribute("value");
195
        count++;
196
        countField.setAttribute("value", count);
197
        return count;
198
    }
199
    
200
    function decrementCount(_count){
201
        var countField = document.getElementById(_count);
202
        var count = countField.getAttribute("value");
203
        count--;
204
        countField.setAttribute("value", count);
205
        return count;
206
    }
207
    
208
    function createImageLink(imgSrc, imgAlt, imgOnClick, cursor){
209
        var link = document.createElement("a");
210
        var img = document.createElement("img");
211
        img.setAttribute("src", imgSrc);
212
        img.setAttribute("alt", imgAlt);
213
        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
214
            link.style.setAttribute("cursor", cursor);
215
            img.attachEvent("onclick", new Function(imgOnClick));
216
        } else {
217
            link.setAttribute("style", "cursor:"+cursor);
218
            img.setAttribute("onClick", imgOnClick);
219
        }
220
        img.setAttribute("border", "0");
221
        link.appendChild(img);        
222
        return link;
223
    }
224
    
225
    
226
    function createTD(colSpan, align, cursor){
227
        var td = document.createElement("td");
228
        if(colSpan != "")
229
            td.setAttribute("colSpan", colSpan);
230
        td.setAttribute("align", align);
231
        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
232
            td.style.setAttribute("cursor", cursor);
233
        } else {
234
            td.setAttribute("style", "cursor:"+cursor);
235
        }
236
        return td;
237
    }
238
  
239
  
240
    function cleanTextNodes(startTagId, endTagId){
241
        var startTag = document.getElementById(startTagId);
242

  
243
        var bro = startTag.nextSibling;       
244

  
245
        while(bro){
246
            if(bro.nodeName == "#text"){
247
                var temp = bro.nextSibling;
248
                bro.parentNode.removeChild(bro);
249
                bro = temp;
250
            } else {
251
                var id = bro.getAttribute("id");
252
                if(id == endTagId){
253
                  return;
254
                }
255
                bro = bro.nextSibling;
256
            }
257
        }
258

  
259
    }
260
  
261
    function delRow(evt){
262
         evt = (evt) ? evt : ((window.event) ? window.event : null);
263
         if (evt) {
264
           // equalize W3C/IE models to get event target reference
265
           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
266
           if (elem) {
267
               try {
268
                    var table = elem.parentNode.parentNode.parentNode.parentNode;
269
                    var row = elem.parentNode.parentNode.parentNode;
270

  
271
                    table.removeChild(row);
272
                 }
273
               catch(e) {
274
                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
275
                   alert("Error:\n" + msg);
276
                   return;
277
               }
278
           }
279
         }
280
    }
281

  
282
    function moveUpRow(evt){
283
         evt = (evt) ? evt : ((window.event) ? window.event : null);
284
         if (evt) {
285
           // equalize W3C/IE models to get event target reference
286
           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
287
           if (elem) {
288
               try {
289
                    var table = elem.parentNode.parentNode.parentNode.parentNode;
290
                    var row = elem.parentNode.parentNode.parentNode;
291
                    
292
                    var bro = row.previousSibling;
293
                    if(bro != null && bro.previousSibling.nodeName =="TR"){
294
                        clone = row.cloneNode(true);
295
                        table.insertBefore(clone, bro);
296
                        table.removeChild(row);
297
                    }
298
                 }
299
               catch(e) {
300
                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
301
                   alert("Error:\n" + msg);
302
                   return;
303
               }
304
           }
305
         }
306
    }
307

  
308
    function moveDownRow(evt, lastTR){
309
         evt = (evt) ? evt : ((window.event) ? window.event : null);
310
         if (evt) {
311
           // equalize W3C/IE models to get event target reference
312
           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
313
           if (elem) {
314
               try {
315
                    var table = elem.parentNode.parentNode.parentNode.parentNode;
316
                    var row = elem.parentNode.parentNode.parentNode;
317
                    
318
                    var _test = row.nextSibling;
319
                    if(_test.getAttribute("id") == lastTR){
320
                            return;
321
                    }
322
                    var bro = row.nextSibling.nextSibling;
323
                    if(bro != null && bro.nodeName =="TR"){
324
                        clone = row.cloneNode(true);
325
                        table.insertBefore(clone, bro);
326
                        table.removeChild(row);
327
                    }
328
                 }
329
               catch(e) {
330
                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
331
                   alert("Error:\n" + msg);
332
                   return;
333
               }
334
           }
335
         }
336
    }
337
  
338
    function addAssociatedParty() {
339
    	var AOLN   = document.getElementById("AONameLast");
340
	var AOFN   = document.getElementById("AONameFirst");
341
	var AORole = document.getElementById("AORole");
342

  
343
        if(AOLN.value != ""){
344
            
345
            var aoCount = incrementCount("aoCount");
346
            
347
        try{
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff