194 |
return true; |
return true; |
195 |
} |
} |
196 |
|
|
197 |
|
/* helper function for [% search($display, $search, $delimiter) %] */ |
198 |
|
|
199 |
|
function search_via_link(attr, val, template) { |
200 |
|
|
201 |
|
if (! template) template = $('template_name').value; |
202 |
|
Logger.info('search called from link for '+attr+'='+val+' in '+template); |
203 |
|
|
204 |
|
new WebPAC.Updater( 'results', |
205 |
|
'/search/results?'+attr+'='+val+'&_template='+template, { |
206 |
|
asynchronous: 1, |
207 |
|
onLoading: function(request) { |
208 |
|
show_searching(); |
209 |
|
}, |
210 |
|
onLoaded: function(request) { |
211 |
|
save_search(attr, val); |
212 |
|
hide_searching(); |
213 |
|
} |
214 |
|
} |
215 |
|
); |
216 |
|
|
217 |
|
return false; |
218 |
|
} |
219 |
|
|
220 |
|
;/* save search and add element for it in search form */ |
221 |
|
|
222 |
|
function save_search( attr, val ) { |
223 |
|
Logger.info('save_search '+attr+','+val+')'); |
224 |
|
|
225 |
|
var t=$('search_table'); |
226 |
|
if (! t) { |
227 |
|
Logger.error("can't find search_table"); |
228 |
|
return; |
229 |
|
} |
230 |
|
Logger.debug('reset results_form'); |
231 |
|
Form.reset('results_form'); |
232 |
|
|
233 |
|
var row_nr = t.rows.length; |
234 |
|
Logger.debug('adding row '+row_nr); |
235 |
|
var tr = t.insertRow( t.rows.length ); |
236 |
|
|
237 |
|
var td = tr.insertCell(0); |
238 |
|
td.setAttribute('align', 'right'); |
239 |
|
td.appendChild( |
240 |
|
document.createTextNode(attr) |
241 |
|
); |
242 |
|
|
243 |
|
td = tr.insertCell(1); |
244 |
|
td.setAttribute('align', 'left'); |
245 |
|
|
246 |
|
var el = document.createElement('input'); |
247 |
|
el.setAttribute('type', 'text'); |
248 |
|
el.setAttribute('disabled', 'true'); |
249 |
|
el.setAttribute('name', attr); |
250 |
|
el.setAttribute('id', '_attr_'+attr+'_id'); |
251 |
|
el.setAttribute('size', val.length < 60 ? val.length : 60); |
252 |
|
el.setAttribute('value', val ); |
253 |
|
td.appendChild(el); |
254 |
|
|
255 |
|
var el = document.createElement('input'); |
256 |
|
el.setAttribute('type', 'button'); |
257 |
|
el.setAttribute('value', '-'); |
258 |
|
el.onclick = function () { |
259 |
|
Logger.info('remove:' + attr + ' row:'+row_nr); |
260 |
|
t.deleteRow( row_nr ); |
261 |
|
submit_results_form(); |
262 |
|
return false; |
263 |
|
} |
264 |
|
td.appendChild(el); |
265 |
|
|
266 |
|
return true; |
267 |
|
}; |