Revision 4387
Added by ben leinfelder almost 16 years ago
search.js | ||
---|---|---|
3 | 3 |
* @param form containing the neceassary input items |
4 | 4 |
* @return true/false for form submission |
5 | 5 |
*****************************************************************************/ |
6 |
function multipleAssessmentSearch(submitFormObj) { |
|
6 |
function multipleAssessmentSearch(submitFormObj, fieldFormObj) {
|
|
7 | 7 |
|
8 | 8 |
//alert("submitFormObj=" + submitFormObj); |
9 | 9 |
//harvest the metadata fields we want to include |
10 | 10 |
var metadataObjs = new Array(); |
11 |
/* |
|
12 | 11 |
var index = 0; |
13 |
for (var i=0; i < submitFormObj.length; i++) { |
|
14 |
var formElement = submitFormObj.elements[i]; |
|
15 |
if (formElement.type == "checkbox" && formElement.checked) { |
|
16 |
//ignore certain other checkboxes, kind of a hack |
|
17 |
if (formElement.name == "includeQuestions") { |
|
18 |
continue; |
|
19 |
} |
|
20 |
var metadataObj = new Object(); |
|
21 |
metadataObj.name = formElement.name; |
|
22 |
metadataObj.value = formElement.value; |
|
23 |
metadataObjs[index] = metadataObj; |
|
24 |
index++; |
|
25 |
} |
|
12 |
for (var i=0; i < fieldFormObj.length; i++) { |
|
13 |
var formElement = fieldFormObj.elements[i]; |
|
14 |
var metadataObj = new Object(); |
|
15 |
metadataObj.name = formElement.name; |
|
16 |
metadataObj.value = formElement.value; |
|
17 |
metadataObjs[index] = metadataObj; |
|
18 |
index++; |
|
26 | 19 |
} |
27 |
*/ |
|
28 | 20 |
|
29 | 21 |
//TODO option for all questions vs. just one |
30 | 22 |
var questionId = submitFormObj.questionId.value; |
... | ... | |
134 | 126 |
} |
135 | 127 |
|
136 | 128 |
/**************************************************************************** |
129 |
* Save fields for the attribute maping |
|
130 |
* @param formId containing the neceassary input items |
|
131 |
* @return true/false for form submission |
|
132 |
*****************************************************************************/ |
|
133 |
function saveFields(formId, metacatURL) { |
|
134 |
|
|
135 |
var submitFormObj = document.getElementById(formId); |
|
136 |
|
|
137 |
//send the request to clear |
|
138 |
var myRequest = new Ajax.Request( |
|
139 |
metacatURL, |
|
140 |
{ method: 'post', |
|
141 |
parameters: { |
|
142 |
action: 'editcart', |
|
143 |
operation: 'clearfields'}, |
|
144 |
evalScripts: true, |
|
145 |
//onSuccess: function(transport) {alert('success: ' + transport.status);}, |
|
146 |
onFailure: function(transport) {alert('failure clearing fields');} |
|
147 |
}); |
|
148 |
|
|
149 |
//go through the check boxes and set the ones we want |
|
150 |
var count = 0; |
|
151 |
for (var i=0; i < submitFormObj.length; i++) { |
|
152 |
var formElement = submitFormObj.elements[i]; |
|
153 |
if (formElement.type == "checkbox" && formElement.checked) { |
|
154 |
//ignore certain other checkboxes, kind of a hack |
|
155 |
if (formElement.name == "includeQuestions") { |
|
156 |
continue; |
|
157 |
} |
|
158 |
|
|
159 |
//send the request |
|
160 |
var myRequest = new Ajax.Request( |
|
161 |
metacatURL, |
|
162 |
{ method: 'post', |
|
163 |
parameters: { |
|
164 |
action: 'editcart', |
|
165 |
operation: 'addfield', |
|
166 |
field: formElement.name, |
|
167 |
path: formElement.value}, |
|
168 |
evalScripts: true, |
|
169 |
//onSuccess: function(transport) {alert('Selections saved: ' + operation); window.document.getElementById("iframeheaderclass").src=window.document.getElementById("iframeheaderclass").src;}, |
|
170 |
onFailure: function(transport) {alert('failure saving field: ' + formElement.name);} |
|
171 |
}); |
|
172 |
count++; |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
window.document.getElementById("iframeheaderclass").src = window.document.getElementById("iframeheaderclass").src; |
|
177 |
|
|
178 |
alert(count + ' Field selections saved.'); |
|
179 |
|
|
180 |
return true; |
|
181 |
|
|
182 |
} |
|
183 |
|
|
184 |
/**************************************************************************** |
|
137 | 185 |
* Query Generation function |
138 | 186 |
* @param docObjs is an Array of Objects with "docid" (String) and "questionIds" (Array) properties |
139 | 187 |
* @param metadataObjs is an Array of Objects with "name" and "value" properties (both String) |
Also available in: Unified diff
can now select and save metadata fields from a document and use them when merging across documents in the "cart"