Project

General

Profile

« Previous | Next » 

Revision 3551

add CSV download as an option for retrieving datasets.
NOTE: depends on opencsv jar in the /first project...

View differences:

first-assessment-resultset.xsl
57 57
        </script>
58 58
        <script type="text/javascript" language="Javascript">
59 59
			<![CDATA[
60
			getResponseData = function(docid, divId) {
60
			//reusable function to get the URL since I know this could change....
61
			getResponseDataURL = function() {
61 62
				var styleURL = "/knb/style/skins/first";
62 63
				styleURL += "/assessmentQuery.jsp";
64
				return styleURL;
65
			}	
66
			getResponseData = function(docid, divId) {
67
				var styleURL = getResponseDataURL();
63 68
																				
64 69
				//alert("calling ajax: " + styleURL);
65 70
				//alert("docid: " + docid);
......
79 84
				//alert("done calling response ajax");
80 85
			}
81 86
			getMergedResponseData = function(formId,divId) {
82
				var styleURL = "/knb/style/skins/first";
83
				styleURL += "/assessmentQuery.jsp";
87
				if (!areItemsSelected('docids')) {
88
					alert("Please select at least one dataset to view");
89
					return false;
90
				}
91
				var styleURL = getResponseDataURL();
84 92
																				
85 93
				//alert("calling ajax: " + styleURL);
86 94
				//alert("docid: " + docid);
......
99 107
				Element.show(divId);					
100 108
				//alert("done calling response ajax");
101 109
			}
110
			downloadMergedResponseData = function(formId) {
111
			
112
				if (!areItemsSelected('docids')) {
113
					alert("Please select at least one dataset to download");
114
					return false;
115
				}
116
				
117
				var styleURL = getResponseDataURL();
118
				
119
				var submitFormObj = document.getElementById(formId);
120
				submitFormObj.qformat.value = 'csv';
121
				submitFormObj.action = styleURL;
122
																				
123
				//alert("downloading response data from: " + submitFormObj.action);
124
				//alert("format=" + submitFormObj.qformat.value);
125
				
126
				submitFormObj.submit();
127
			}
128
			areItemsSelected = function(checkBoxName) {
129
				var checkBoxes = document.getElementsByName(checkBoxName);
130
				
131
				for (var i=0; i< checkBoxes.length; i++) {
132
					if (checkBoxes[i].checked == true) {
133
						return true;
134
					}	
135
				}
136
				//alert("please select a checkbox: " + checkBoxName);
137
				return false;
138
				
139
			}
102 140
			hideDiv = function(divId) {
103 141
				Element.hide(divId);
104 142
			}
......
130 168
					<xsl:text>None</xsl:text>
131 169
				</a>
132 170
				<br/>
133
				Actions:
171
				View:
134 172
				<a>
135
					<xsl:attribute name="href">javascript:getMergedResponseData('assessmentForm','mergedResponseData')</xsl:attribute>
136
					<xsl:text>Merge Selected</xsl:text>
173
					<xsl:attribute name="href">#</xsl:attribute>
174
					<xsl:attribute name="onClick">javascript:getMergedResponseData('assessmentForm','mergedResponseData')</xsl:attribute>
175
					<xsl:text>Selected</xsl:text>
137 176
				</a>
138 177
				/
139 178
				<a>
......
141 180
					<xsl:text>Hide</xsl:text>
142 181
				</a>
143 182
				<br/>
183
				Download Selected as:
184
				<a>
185
					<xsl:attribute name="href">#</xsl:attribute>
186
					<xsl:attribute name="onClick">javascript:downloadMergedResponseData('assessmentForm')</xsl:attribute>
187
					<xsl:text>Datafile (.csv)</xsl:text>
188
				</a>
189
				/
190
				<a>
191
					<xsl:attribute name="href">#doNothing</xsl:attribute>
192
					<xsl:text>Metadata Package (.zip)</xsl:text>
193
				</a>
194
				<br/>
144 195
				<div id="mergedResponseData"/>
145 196
				<br/>
146 197
				

Also available in: Unified diff