1 var records = new Array();
4 var rresultLimit = 200;
7 var rresultIsPaged = false;
9 function rresultUnload() { removeChildren(table); table = null;}
11 attachEvt("common", "unload", rresultUnload);
12 attachEvt("common", "run", rresultDoSearch);
13 attachEvt("result", "idsReceived", rresultCollectRecords);
14 attachEvt("result", "recordDrawn", rresultLaunchDrawn);
16 hideMe($('copyright_block'));
18 function rresultDoSearch() {
20 swapCanvas($('loading_alt'));
22 table = G.ui.result.main_table;
23 hideMe(G.ui.result.row_template);
24 if( table && table.parentNode ) {
25 while( table.parentNode.rows.length <= (getDisplayCount() +1) )
26 hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true)));
31 function rresultCollectIds() {
34 var holdTarget = new CGI().param('hold_target');
35 if(holdTarget != null) {
36 rresultHandlePlaceHold(holdTarget);
41 var rtype = getRtype();
42 if (rtype && rtype.indexOf('|') > -1)
43 rtype = rtype.substring(0,rtype.indexOf('|'));
48 ids = JSON2js(cookieManager.read(COOKIE_RIDS));
49 _rresultHandleIds( ids, ids.length );
57 rresultDoRecordSearch();
61 rresultDoRecordMultiSearch();
69 rresultCollectMARCIds();
73 rresultCollectISBNIds();
77 rresultCollectTCNIds();
81 rresultCollectISSNIds();
89 var form = rresultGetForm();
90 var args = { format : form, org : getLocation(), depth : rresultGetDepth() };
92 var lasso = getLasso();
93 if (lasso) args.org = -lasso;
95 var req = new Request(FETCH_RIDS, getMrid(), args);
96 req.callback( rresultHandleRIds );
99 if( rresultGetDepth() != findOrgDepth(globalOrgTree) ) {
100 var link = $('rresult_show_all_link');
102 unHideMe($('rresult_show_all'));
103 link.appendChild( text(
104 findOrgType(globalOrgTree.ou_type()).opac_label()));
108 if( rresultGetDepth() != getDepth() ) { /* inside a limited display */
109 var link = $('rresult_show_here_link');
111 link.appendChild( text(
112 findOrgType(findOrgUnit(getLocation()).ou_type()).opac_label()));
113 unHideMe($('rresult_show_here'));
120 function rresultExpandSearch() {
122 args[PARAM_RDEPTH] = findOrgDepth(globalOrgTree);
123 goTo(buildOPACLink(args));
126 function rresultContractSearch() {
129 args[PARAM_OFFSET] = 0;
130 goTo(buildOPACLink(args));
134 function rresultGetDepth() {
135 if( getRdepth() != null) return getRdepth();
140 function rresultGetForm() {
143 if(getTform()) /* did the user select a format from the icon list (temporary) */
144 form = (getTform() == 'all') ? null : getTform();
145 else /* did the use select a format from simple search dropdown */
146 form = (getForm() == 'all') ? null : getForm();
148 if(!form) { /* did the user select a format from the advanced search */
149 form = getItemType();
150 var f = getItemForm();
153 form = form.replace(/,/,'');
154 if(f) form += '-' + f;
156 if(f) form = '-' + f;
164 function rresultCollectMARCIds() {
167 args.searches = JSON2js(getSearches());
169 args.org_unit = globalOrgTree.id();
172 rresultIsPaged = true;
173 var req = new Request(FETCH_ADV_MARC_MRIDS, args, getDisplayCount(), getOffset());
174 req.callback(rresultHandleRIds);
175 req.request.noretry = true;
180 function rresultCollectISBNIds() {
181 var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
184 var blob = r.getResultObject();
185 _rresultHandleIds(blob.ids, blob.count);
191 function rresultCollectTCNIds() {
192 var req = new Request(FETCH_ADV_TCN_RIDS, getAdvTerm() );
195 var blob = r.getResultObject();
196 _rresultHandleIds(blob.ids, blob.count);
202 function rresultCollectISSNIds() {
203 var req = new Request(FETCH_ADV_ISSN_RIDS, getAdvTerm() );
206 var blob = r.getResultObject();
207 _rresultHandleIds(blob.ids, blob.count);
213 function rresultHandleList() {
214 var ids = new CGI().param(PARAM_RLIST);
216 if(!dojo.isArray(ids)) {
222 if(ids) _rresultHandleIds(ids, count);
225 var rresultTries = 0;
226 function rresultHandleRIds(r) {
227 var res = r.getResultObject();
229 if(!res) res = {count:0,ids:[]};
231 if( res.count == 0 && rresultTries == 0 && ! r.noretry) {
234 var form = rresultGetForm();
235 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
237 var lasso = getLasso();
238 if (lasso) args.org = -lasso;
240 var req = new Request(FETCH_RIDS, getMrid(), args );
241 req.callback( rresultHandleRIds );
243 unHideMe($('no_formats'));
244 hideMe($('rresult_show_all'));
248 _rresultHandleIds(res.ids, res.count);
252 function _rresultHandleIds(ids, count) {
253 //var json = js2JSON({ids:ids,count:count});
255 cookieManager.write(COOKIE_SRIDS, json, '+1d');
258 HITCOUNT = parseInt(count);
259 runEvt('result', 'hitCountReceived');
260 runEvt('result', 'idsReceived', ids, getOffset());
264 function rresultCollectRecords(ids) {
265 runEvt("result", "preCollectRecords");
267 for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
268 if(ids[i] == null) break;
269 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
270 req.callback(rresultHandleMods);
271 req.request.userdata = x++;
278 function rresultCollectRecords(ids, base) {
279 runEvt("result", "preCollectRecords");
283 if( rresultIsPaged ) base = 0;
285 for( var i = base; i!= getDisplayCount() + base; i++ ) {
286 if(ids[i] == null) break;
287 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
288 req.callback(rresultHandleMods);
289 req.request.userdata = x++;
295 var recsReceivedCalled = false;
296 function rresultHandleMods(r) {
297 var rec = r.getResultObject();
298 runEvt('result', 'recordReceived', rec, r.userdata, false);
299 resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
300 if(resultPageIsDone() && !recsReceivedCalled) {
301 recsReceivedCalled = true;
302 runEvt('result', 'allRecordsReceived', recordsCache);
303 unHideMe($('copyright_block'));
307 function rresultLaunchDrawn(id, node) {
308 runEvt("rresult", "recordDrawn", id, node);
312 function rresultDoRecordSearch() {
313 rresultIsPaged = true;
314 resultCollectSearchIds(true, SEARCH_RS_QUERY, rresultFilterSearchResults );
317 function rresultDoRecordMultiSearch() {
318 rresultIsPaged = true;
319 resultCollectSearchIds(false, SEARCH_RS_QUERY, rresultFilterSearchResults );
323 function rresultFilterSearchResults(r) {
324 var result = r.getResultObject();
326 if( result.count > 0 ) {
327 for( var i = 0; i != result.ids.length; i++ )
328 ids.push(result.ids[i][0]);
331 resultFacetKey = result.facet_key;
332 resultCompiledSearch = result.compiled_search;
333 cookieManager.write(COOKIE_SEARCH, js2JSON(result.compiled_search), -1);
334 _rresultHandleIds( ids, result.count );
337 function rresultHandlePlaceHold(target) {
339 location.href = location.href.replace(/&hold_target=\d+/, '');
341 attachEvt("common", "holdUpdated", reload);
342 attachEvt("common", "holdUpdateCanceled", reload);
343 attachEvt("common", "loginCanceled", reload);
344 holdsDrawEditor({record:target, type: 'T'});