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 rtype = getRtype();
35 if (rtype && rtype.indexOf('|') > -1)
36 rtype = rtype.substring(0,rtype.indexOf('|'));
41 ids = JSON2js(cookieManager.read(COOKIE_RIDS));
42 _rresultHandleIds( ids, ids.length );
50 rresultDoRecordSearch();
54 rresultDoRecordMultiSearch();
62 rresultCollectMARCIds();
66 rresultCollectISBNIds();
70 rresultCollectTCNIds();
74 rresultCollectISSNIds();
82 var form = rresultGetForm();
83 var args = { format : form, org : getLocation(), depth : rresultGetDepth() };
85 var lasso = getLasso();
86 if (lasso) args.org = -lasso;
88 var req = new Request(FETCH_RIDS, getMrid(), args);
89 req.callback( rresultHandleRIds );
92 if( rresultGetDepth() != findOrgDepth(globalOrgTree) ) {
93 var link = $('rresult_show_all_link');
95 unHideMe($('rresult_show_all'));
96 link.appendChild( text(
97 findOrgType(globalOrgTree.ou_type()).opac_label()));
101 if( rresultGetDepth() != getDepth() ) { /* inside a limited display */
102 var link = $('rresult_show_here_link');
104 link.appendChild( text(
105 findOrgType(findOrgUnit(getLocation()).ou_type()).opac_label()));
106 unHideMe($('rresult_show_here'));
113 function rresultExpandSearch() {
115 args[PARAM_RDEPTH] = findOrgDepth(globalOrgTree);
116 goTo(buildOPACLink(args));
119 function rresultContractSearch() {
122 args[PARAM_OFFSET] = 0;
123 goTo(buildOPACLink(args));
127 function rresultGetDepth() {
128 if( getRdepth() != null) return getRdepth();
133 function rresultGetForm() {
136 if(getTform()) /* did the user select a format from the icon list (temporary) */
137 form = (getTform() == 'all') ? null : getTform();
138 else /* did the use select a format from simple search dropdown */
139 form = (getForm() == 'all') ? null : getForm();
141 if(!form) { /* did the user select a format from the advanced search */
142 form = getItemType();
143 var f = getItemForm();
146 form = form.replace(/,/,'');
147 if(f) form += '-' + f;
149 if(f) form = '-' + f;
157 function rresultCollectMARCIds() {
160 args.searches = JSON2js(getSearches());
162 args.org_unit = globalOrgTree.id();
165 rresultIsPaged = true;
166 var req = new Request(FETCH_ADV_MARC_MRIDS, args, getDisplayCount(), getOffset());
167 req.callback(rresultHandleRIds);
168 req.request.noretry = true;
173 function rresultCollectISBNIds() {
174 var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
177 var blob = r.getResultObject();
178 _rresultHandleIds(blob.ids, blob.count);
184 function rresultCollectTCNIds() {
185 var req = new Request(FETCH_ADV_TCN_RIDS, getAdvTerm() );
188 var blob = r.getResultObject();
189 _rresultHandleIds(blob.ids, blob.count);
195 function rresultCollectISSNIds() {
196 var req = new Request(FETCH_ADV_ISSN_RIDS, getAdvTerm() );
199 var blob = r.getResultObject();
200 _rresultHandleIds(blob.ids, blob.count);
206 function rresultHandleList() {
207 var ids = new CGI().param(PARAM_RLIST);
209 if(!dojo.isArray(ids)) {
215 if(ids) _rresultHandleIds(ids, count);
218 var rresultTries = 0;
219 function rresultHandleRIds(r) {
220 var res = r.getResultObject();
222 if(!res) res = {count:0,ids:[]};
224 if( res.count == 0 && rresultTries == 0 && ! r.noretry) {
227 var form = rresultGetForm();
228 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
230 var lasso = getLasso();
231 if (lasso) args.org = -lasso;
233 var req = new Request(FETCH_RIDS, getMrid(), args );
234 req.callback( rresultHandleRIds );
236 unHideMe($('no_formats'));
237 hideMe($('rresult_show_all'));
241 _rresultHandleIds(res.ids, res.count);
245 function _rresultHandleIds(ids, count) {
246 //var json = js2JSON({ids:ids,count:count});
248 cookieManager.write(COOKIE_SRIDS, json, '+1d');
251 HITCOUNT = parseInt(count);
252 runEvt('result', 'hitCountReceived');
253 runEvt('result', 'idsReceived', ids, getOffset());
257 function rresultCollectRecords(ids) {
258 runEvt("result", "preCollectRecords");
260 for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
261 if(ids[i] == null) break;
262 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
263 req.callback(rresultHandleMods);
264 req.request.userdata = x++;
271 function rresultCollectRecords(ids, base) {
272 runEvt("result", "preCollectRecords");
276 if( rresultIsPaged ) base = 0;
278 for( var i = base; i!= getDisplayCount() + base; i++ ) {
279 if(ids[i] == null) break;
280 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
281 req.callback(rresultHandleMods);
282 req.request.userdata = x++;
288 function rresultHandleMods(r) {
289 var rec = r.getResultObject();
290 runEvt('result', 'recordReceived', rec, r.userdata, false);
291 resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
292 if(resultPageIsDone()) {
293 runEvt('result', 'allRecordsReceived', recordsCache);
294 unHideMe($('copyright_block'));
298 function rresultLaunchDrawn(id, node) {
299 runEvt("rresult", "recordDrawn", id, node);
303 function rresultDoRecordSearch() {
304 rresultIsPaged = true;
305 resultCollectSearchIds(true, SEARCH_RS_QUERY, rresultFilterSearchResults );
308 function rresultDoRecordMultiSearch() {
309 rresultIsPaged = true;
310 resultCollectSearchIds(false, SEARCH_RS_QUERY, rresultFilterSearchResults );
314 function rresultFilterSearchResults(r) {
315 var result = r.getResultObject();
317 if( result.count > 0 ) {
318 for( var i = 0; i != result.ids.length; i++ )
319 ids.push(result.ids[i][0]);
322 resultFacetKey = result.facet_key;
323 resultCompiledSearch = result.compiled_search;
324 cookieManager.write(COOKIE_SEARCH, js2JSON(result.compiled_search), -1);
325 _rresultHandleIds( ids, result.count );