1 var records = new Array();
4 var rresultLimit = 200;
6 var rresultIsPaged = false;
8 function rresultUnload() { removeChildren(table); table = null;}
10 attachEvt("common", "unload", rresultUnload);
11 attachEvt("common", "run", rresultDoSearch);
12 attachEvt("result", "idsReceived", rresultCollectRecords);
13 attachEvt("result", "recordDrawn", rresultLaunchDrawn);
15 hideMe($('copyright_block'));
17 function rresultDoSearch() {
19 swapCanvas($('loading_alt'));
21 table = G.ui.result.main_table;
22 hideMe(G.ui.result.row_template);
23 if( table && table.parentNode ) {
24 while( table.parentNode.rows.length <= (getDisplayCount() +1) )
25 hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true)));
30 function rresultCollectIds() {
36 ids = JSON2js(cookieManager.read(COOKIE_RIDS));
37 _rresultHandleIds( ids, ids.length );
45 rresultDoRecordSearch();
49 rresultDoRecordMultiSearch();
57 rresultCollectMARCIds();
61 rresultCollectISBNIds();
65 rresultCollectTCNIds();
69 rresultCollectISSNIds();
77 var form = rresultGetForm();
78 var args = { format : form, org : getLocation(), depth : rresultGetDepth() };
79 var req = new Request(FETCH_RIDS, getMrid(), args);
80 req.callback( rresultHandleRIds );
83 if( rresultGetDepth() != findOrgDepth(globalOrgTree) ) {
84 var link = $('rresult_show_all_link');
86 unHideMe($('rresult_show_all'));
87 link.appendChild( text(
88 findOrgType(globalOrgTree.ou_type()).opac_label()));
92 if( rresultGetDepth() != getDepth() ) { /* inside a limited display */
93 var link = $('rresult_show_here_link');
95 link.appendChild( text(
96 findOrgType(findOrgUnit(getLocation()).ou_type()).opac_label()));
97 unHideMe($('rresult_show_here'));
104 function rresultExpandSearch() {
106 args[PARAM_RDEPTH] = findOrgDepth(globalOrgTree);
107 goTo(buildOPACLink(args));
110 function rresultContractSearch() {
113 args[PARAM_OFFSET] = 0;
114 goTo(buildOPACLink(args));
118 function rresultGetDepth() {
119 if( getRdepth() != null) return getRdepth();
124 function rresultGetForm() {
127 if(getTform()) /* did the user select a format from the icon list (temporary) */
128 form = (getTform() == 'all') ? null : getTform();
129 else /* did the use select a format from simple search dropdown */
130 form = (getForm() == 'all') ? null : getForm();
132 if(!form) { /* did the user select a format from the advanced search */
133 form = getItemType();
134 var f = getItemForm();
137 form = form.replace(/,/,'');
138 if(f) form += '-' + f;
140 if(f) form = '-' + f;
148 function rresultCollectMARCIds() {
151 args.searches = JSON2js(getSearches());
153 args.org_unit = globalOrgTree.id();
156 rresultIsPaged = true;
157 var req = new Request(FETCH_ADV_MARC_MRIDS, args, getDisplayCount(), getOffset());
158 req.callback(rresultHandleRIds);
159 req.request.noretry = true;
164 function rresultCollectISBNIds() {
165 var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
168 var blob = r.getResultObject();
169 _rresultHandleIds(blob.ids, blob.count);
175 function rresultCollectTCNIds() {
176 var req = new Request(FETCH_ADV_TCN_RIDS, getAdvTerm() );
179 var blob = r.getResultObject();
180 _rresultHandleIds(blob.ids, blob.count);
186 function rresultCollectISSNIds() {
187 var req = new Request(FETCH_ADV_ISSN_RIDS, getAdvTerm() );
190 var blob = r.getResultObject();
191 _rresultHandleIds(blob.ids, blob.count);
197 function rresultHandleList() {
198 var ids = new CGI().param(PARAM_RLIST);
199 if(ids) _rresultHandleIds(ids, ids.length);
202 var rresultTries = 0;
203 function rresultHandleRIds(r) {
204 var res = r.getResultObject();
206 if(!res) res = {count:0,ids:[]};
208 if( res.count == 0 && rresultTries == 0 && ! r.noretry) {
211 var form = rresultGetForm();
212 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
213 var req = new Request(FETCH_RIDS, getMrid(), args );
214 req.callback( rresultHandleRIds );
216 unHideMe($('no_formats'));
217 hideMe($('rresult_show_all'));
221 _rresultHandleIds(res.ids, res.count);
225 function _rresultHandleIds(ids, count) {
226 //var json = js2JSON({ids:ids,count:count});
228 cookieManager.write(COOKIE_SRIDS, json, '+1d');
231 HITCOUNT = parseInt(count);
232 runEvt('result', 'hitCountReceived');
233 runEvt('result', 'idsReceived', ids);
237 function rresultCollectRecords(ids) {
238 runEvt("result", "preCollectRecords");
240 for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
241 if(ids[i] == null) break;
242 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
243 req.callback(rresultHandleMods);
244 req.request.userdata = x++;
251 function rresultCollectRecords(ids) {
252 runEvt("result", "preCollectRecords");
255 //var base = getOffset();
257 if( rresultIsPaged ) base = 0;
259 for( var i = base; i!= getDisplayCount() + base; i++ ) {
260 if(ids[i] == null) break;
261 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
262 req.callback(rresultHandleMods);
263 req.request.userdata = x++;
269 function rresultHandleMods(r) {
270 var rec = r.getResultObject();
271 runEvt('result', 'recordReceived', rec, r.userdata, false);
272 resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
273 if(resultPageIsDone()) {
274 runEvt('result', 'allRecordsReceived', recordsCache);
275 unHideMe($('copyright_block'));
279 function rresultLaunchDrawn(id, node) {
280 runEvt("rresult", "recordDrawn", id, node);
284 function rresultDoRecordSearch() {
285 rresultIsPaged = true;
286 resultCollectSearchIds(true, SEARCH_RS_QUERY, rresultFilterSearchResults );
289 function rresultDoRecordMultiSearch() {
290 rresultIsPaged = true;
291 resultCollectSearchIds(false, SEARCH_RS_QUERY, rresultFilterSearchResults );
295 function rresultFilterSearchResults(r) {
296 var result = r.getResultObject();
298 if( result.count > 0 ) {
299 for( var i = 0; i != result.ids.length; i++ )
300 ids.push(result.ids[i][0]);
303 resultCompiledSearch = result.compiled_search;
304 cookieManager.write(COOKIE_SEARCH, js2JSON(result.compiled_search), -1);
305 _rresultHandleIds( ids, result.count );