Revision 3422
Added by walbridge almost 17 years ago
entryForm.tmpl | ||
---|---|---|
847 | 847 |
var methodBit = 1; |
848 | 848 |
var dscBit = 1; |
849 | 849 |
var distBit = 1; |
850 |
var uploadBit = 1; |
|
850 | 851 |
|
851 | 852 |
function swap(evt, _node, nodeBit){ |
852 | 853 |
evt = (evt) ? evt : ((window.event) ? window.event : null); |
... | ... | |
996 | 997 |
} |
997 | 998 |
} |
998 | 999 |
|
1000 |
// include source for Multiple file uploader: |
|
1001 |
// http://the-stickman.com/web-development/javascript/ |
|
1002 |
|
|
1003 |
function MultiSelector( list_target, max ){ |
|
1004 |
|
|
1005 |
this.list_target = list_target; |
|
1006 |
this.count = 0; |
|
1007 |
this.id = 0; |
|
1008 |
var fcount = document.getElementById("fileCount"); |
|
1009 |
if (fcount.value > 0) { |
|
1010 |
this.id = fcount.value; |
|
1011 |
} |
|
1012 |
|
|
1013 |
if( max ){ |
|
1014 |
this.max = max; |
|
1015 |
} else { |
|
1016 |
this.max = -1; |
|
1017 |
}; |
|
1018 |
|
|
1019 |
/** |
|
1020 |
* Add a new file input element |
|
1021 |
*/ |
|
1022 |
this.addElement = function( element ){ |
|
1023 |
|
|
1024 |
// Make sure it's a file input element |
|
1025 |
if( element.tagName == 'INPUT' && element.type == 'file' ){ |
|
1026 |
// Element name -- what number am I? |
|
1027 |
element.name = 'file_' + this.id++; |
|
1028 |
|
|
1029 |
// Add reference to this object |
|
1030 |
element.multi_selector = this; |
|
1031 |
|
|
1032 |
// What to do when a file is selected |
|
1033 |
element.onchange = function(){ |
|
1034 |
// Increment file counter |
|
1035 |
var fileCount = incrementCount("fileCount"); |
|
1036 |
|
|
1037 |
// Clean up file text |
|
1038 |
var comment_element = document.getElementById( 'file_comment' ); |
|
1039 |
if (comment_element){ |
|
1040 |
comment_element.parentNode.removeChild(comment_element); |
|
1041 |
} |
|
1042 |
|
|
1043 |
// New file input |
|
1044 |
var new_element = document.createElement( 'input' ); |
|
1045 |
new_element.type = 'file'; |
|
1046 |
|
|
1047 |
// Add new element |
|
1048 |
this.parentNode.insertBefore( new_element, this ); |
|
1049 |
|
|
1050 |
// Apply 'update' to element |
|
1051 |
this.multi_selector.addElement( new_element ); |
|
1052 |
|
|
1053 |
// Update list |
|
1054 |
this.multi_selector.addListRow( this ); |
|
1055 |
|
|
1056 |
// Hide this: we can't use display:none because Safari doesn't like it |
|
1057 |
this.style.position = 'absolute'; |
|
1058 |
this.style.left = '-1000px'; |
|
1059 |
|
|
1060 |
}; |
|
1061 |
|
|
1062 |
// If we've reached maximum number, disable input element |
|
1063 |
if( this.max != -1 && this.count >= this.max ){ |
|
1064 |
element.disabled = true; |
|
1065 |
}; |
|
1066 |
// File element counter |
|
1067 |
this.count++; |
|
1068 |
|
|
1069 |
// Most recent element |
|
1070 |
this.current_element = element; |
|
1071 |
|
|
1072 |
} else { |
|
1073 |
// This can only be applied to file input elements! |
|
1074 |
alert( 'Error: not a file input element' ); |
|
1075 |
}; |
|
1076 |
|
|
1077 |
}; |
|
1078 |
|
|
1079 |
/** |
|
1080 |
* Add a new row to the list of files |
|
1081 |
*/ |
|
1082 |
this.addListRow = function( element ){ |
|
1083 |
|
|
1084 |
// Row div |
|
1085 |
var new_row = document.createElement( 'div' ); |
|
1086 |
|
|
1087 |
// Delete button |
|
1088 |
var new_row_button = document.createElement( 'input' ); |
|
1089 |
new_row_button.type = 'button'; |
|
1090 |
new_row_button.value = 'Delete'; |
|
1091 |
|
|
1092 |
// References |
|
1093 |
new_row.element = element; |
|
1094 |
|
|
1095 |
// Delete function |
|
1096 |
new_row_button.onclick= function(){ |
|
1097 |
// Remove element from form |
|
1098 |
this.parentNode.element.parentNode.removeChild( this.parentNode.element ); |
|
1099 |
|
|
1100 |
// Remove this row from the list |
|
1101 |
this.parentNode.parentNode.removeChild( this.parentNode ); |
|
1102 |
// Decrement counter |
|
1103 |
this.parentNode.element.multi_selector.count--; |
|
1104 |
|
|
1105 |
// Re-enable input element (if it's disabled) |
|
1106 |
this.parentNode.element.multi_selector.current_element.disabled = false; |
|
1107 |
|
|
1108 |
// Appease Safari |
|
1109 |
// without it Safari wants to reload the browser window |
|
1110 |
// which nixes your already queued uploads |
|
1111 |
return false; |
|
1112 |
}; |
|
1113 |
|
|
1114 |
// Set row value |
|
1115 |
new_row.innerHTML = element.value + " "; |
|
1116 |
|
|
1117 |
// Add button |
|
1118 |
new_row.appendChild( new_row_button ); |
|
1119 |
|
|
1120 |
// Add it to the list |
|
1121 |
this.list_target.appendChild( new_row ); |
|
1122 |
|
|
1123 |
}; |
|
1124 |
|
|
1125 |
}; |
|
1126 |
|
|
1127 |
function deleteFile(evt, file) { |
|
1128 |
evt = (evt) ? evt : ((window.event) ? window.event : null); |
|
1129 |
if (evt) { |
|
1130 |
// equalize W3C/IE models to get event target reference |
|
1131 |
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); |
|
1132 |
var element = document.getElementById("file_element"); |
|
1133 |
if (elem) { |
|
1134 |
try { |
|
1135 |
// Add a new hidden form element to delete exisiting files |
|
1136 |
// FIXME: this needs to find the matching file element, so if our node |
|
1137 |
// has 'test.txt' as the filename, find the input hidden value="test.txt" |
|
1138 |
//element.parentNode.removeChild( element ); |
|
1139 |
|
|
1140 |
var delete_input = document.createElement( 'input' ); |
|
1141 |
delete_input.type = 'hidden'; |
|
1142 |
delete_input.value = file; |
|
1143 |
elem.appendChild( delete_input ); |
|
1144 |
|
|
1145 |
// Remove this row from the list |
|
1146 |
elem.parentNode.parentNode.removeChild( elem.parentNode ); |
|
1147 |
|
|
1148 |
// Decrement counter |
|
1149 |
elem.parentNode.element.multi_selector.count--; |
|
1150 |
|
|
1151 |
// Re-enable input element (if it's disabled) |
|
1152 |
elem.parentNode.element.multi_selector.current_element.disabled = false; |
|
1153 |
} |
|
1154 |
catch(e) { |
|
1155 |
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error"); |
|
1156 |
alert("Error:\n" + msg); |
|
1157 |
return; |
|
1158 |
} |
|
1159 |
} |
|
1160 |
} |
|
1161 |
} |
|
1162 |
|
|
999 | 1163 |
</script> |
1000 | 1164 |
|
1001 | 1165 |
[% IF form != 're_entry' %] |
... | ... | |
1065 | 1229 |
</table> |
1066 | 1230 |
|
1067 | 1231 |
|
1068 |
<form action="@cgi-prefix@/register-dataset.cgi" method="post"> |
|
1232 |
<form action="@cgi-prefix@/register-dataset.cgi" enctype="multipart/form-data" method="post">
|
|
1069 | 1233 |
<input type="hidden" name="cfg" value="[% cfg %]"> |
1070 | 1234 |
<input type="hidden" name="docid" value="[% docid %]"> |
1071 | 1235 |
<input type="hidden" name="stage" value="insert"> |
... | ... | |
1079 | 1243 |
<input type="hidden" name="hasSpatial" value="[% hasSpatial %]"> |
1080 | 1244 |
<input type="hidden" name="hasTaxonomic" value="[% hasTaxonomic %]"> |
1081 | 1245 |
<input type="hidden" name="hasMethod" value="[% hasMethod %]"> |
1246 |
<input type="hidden" name="hasUpload" value="[% hasUpload %]"> |
|
1082 | 1247 |
<input type="hidden" name="temporalRequired" value="[% temporalRequired %]"> |
1083 | 1248 |
<input type="hidden" name="spatialRequired" value="[% spatialRequired %]"> |
1084 | 1249 |
<input type="hidden" name="contactEmailAddressRequired" value="[% contactEmailAddressRequired %]"> |
... | ... | |
1285 | 1450 |
onClick="addAssociatedParty()"></td></tr> |
1286 | 1451 |
|
1287 | 1452 |
[% numAO = 0 %] |
1288 |
[% IF aoCount > 0 %]
|
|
1453 |
[% IF aoCount %] |
|
1289 | 1454 |
[% numAO = aoCount %] |
1290 | 1455 |
<tr class="sectbody" id="aoHRRow"> |
1291 | 1456 |
<td colSpan="6"> |
... | ... | |
1395 | 1560 |
|
1396 | 1561 |
|
1397 | 1562 |
[% numKey = 0 %] |
1398 |
[% IF keyCount > 0 %]
|
|
1563 |
[% IF keyCount %] |
|
1399 | 1564 |
[% numKey = keyCount %] |
1400 | 1565 |
[% numAO = aoCount %] |
1401 | 1566 |
<tr class="sectbody" id="keywordHRRow"> |
... | ... | |
1773 | 1938 |
</tr> |
1774 | 1939 |
|
1775 | 1940 |
[% numTaxa = 0 %] |
1776 |
[% IF taxaCount > 0 %]
|
|
1941 |
[% IF taxaCount %] |
|
1777 | 1942 |
[% numTaxa = taxaCount %] |
1778 | 1943 |
<tr class="sectbody" id="taxonHRRow"> |
1779 | 1944 |
<td colSpan="6"> |
... | ... | |
1842 | 2007 |
|
1843 | 2008 |
<tr class="sectbody"><td valign="top" class="rightCol"><span class="label">Method Description</span> |
1844 | 2009 |
<td colspan="5" align="left"> |
1845 |
[% IF methodPara.size < 1 %]
|
|
2010 |
[% IF !methodPara %]
|
|
1846 | 2011 |
<textarea rows="6" cols="60" name="methodPara"></textarea> |
1847 | 2012 |
[% END %] |
1848 | 2013 |
[% FOREACH para = methodPara %] |
... | ... | |
2090 | 2255 |
|
2091 | 2256 |
</table> |
2092 | 2257 |
|
2258 |
[% IF hasUpload == 'true' %] |
|
2259 |
|
|
2260 |
<!-- Associated Data --> |
|
2261 |
<table class="tables" cellpadding="5" cellspacing="0"> |
|
2262 |
<tr class="sectheader"><td colspan="5" align="left"> |
|
2263 |
<span class="label">UPLOAD DATA </span><a href="@cgi-prefix@/register-dataset.cgi?cfg=[%cfg%]&stage=guide#XXX" |
|
2264 |
target="guide"><span class="smalltext">(What's this?)</span></a></td> |
|
2265 |
<td class="rightCol"><span><a onClick="distBit=swap(event, 'uploadTable', uploadBit)" style="cursor:pointer">Hide</a></span></td> |
|
2266 |
</tr> |
|
2267 |
</table> |
|
2268 |
<table class="tables" cellpadding="5" cellspacing="0" id="uploadTable"> |
|
2269 |
<tr class="sectbody"> |
|
2270 |
<td class="rightCol"><span class="label">Upload Data File:</span></td> |
|
2271 |
<td colspan="5"> |
|
2272 |
<input type="file" id="file_element" name="file_1" class="longwidth"> |
|
2273 |
|
|
2274 |
[% IF form == 're_entry' && upCount %] |
|
2275 |
[% cnt = 0 %] |
|
2276 |
[% WHILE cnt < upCount %] |
|
2277 |
[% SET fileSum = "upload_${cnt}" %] |
|
2278 |
[% SET fileName = "uploadname_${cnt}" %] |
|
2279 |
[% SET fileType = "uploadtype_${cnt}" %] |
|
2280 |
[% IF fileSum %] |
|
2281 |
<input type="hidden" name="[%fileSum%]" value="[% $fileSum %]"> |
|
2282 |
<input type="hidden" name="[%fileName%]" value="[% $fileName %]"> |
|
2283 |
<input type="hidden" name="[%fileType%]" value="[% $fileType %]"> |
|
2284 |
[% END %] |
|
2285 |
[% cnt = cnt + 1 %] |
|
2286 |
[% END %] |
|
2287 |
<input type="hidden" name="upCount" value="[%upCount%]"> |
|
2288 |
[% END %] |
|
2289 |
|
|
2290 |
<input type="hidden" name="fileCount" value="[%fileCount%]" id="fileCount"></td> |
|
2291 |
</tr> |
|
2292 |
<tr class="sectbody"> |
|
2293 |
<td class="rightCol" valign="top"><span class="label">Attached Files:</span></td> |
|
2294 |
<td colspan="5"> |
|
2295 |
[% IF !upCount %] |
|
2296 |
<div id="file_comment"> |
|
2297 |
(<i>None currently attached</i>) |
|
2298 |
</div> |
|
2299 |
[% END %] |
|
2300 |
<div id="files_list">[% IF form == 're_entry' && upCount %] |
|
2301 |
[% cnt = 0 %] |
|
2302 |
[% WHILE cnt < upCount %] |
|
2303 |
[% SET fileName = "uploadname_${cnt}" %] |
|
2304 |
[% IF fileName %]<div>[% $fileName %] <input type="button" value="Delete" onclick="deleteFile(event, [%fileName%]);"</div>[% END %] |
|
2305 |
[% cnt = cnt + 1 %] |
|
2306 |
[% END %] |
|
2307 |
[% END %]</div></td> |
|
2308 |
</tr> |
|
2309 |
</table> |
|
2310 |
|
|
2311 |
<script language="JavaScript" type="text/JavaScript"> |
|
2312 |
var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 10); |
|
2313 |
multi_selector.addElement( document.getElementById( 'file_element' ) ); |
|
2314 |
</script> |
|
2315 |
[% END %] |
|
2093 | 2316 |
<table class="tables" cellpadding="5" cellspacing="0"> |
2094 | 2317 |
<tr class="sectheader"><td colspan="6" align="left"></td></tr> |
2095 | 2318 |
<tr class="sectheader"><td colspan="6" align="center" class="borderbottom"><input type="SUBMIT" onClick="sortInputTags()" value="Submit Data Set Description" name="SUBMIT"> |
Also available in: Unified diff
Added submission of data files to the registry. New parameter 'hasUpload' can be set on a per-skin basis to enable the uploading of data objects to be associated with a metadata document. NCEAS skin is using this by default, to be changed in the future for other skins.
Refactored XML creation in register-dataset.cgi to use function stubs, to allow us flexibility in document creation.