1 var records = new Array();
4 var rresultLimit = 200;
6 function rresultUnload() { removeChildren(table); table = null;}
8 attachEvt("common", "unload", rresultUnload);
9 attachEvt("common", "run", rresultDoSearch);
10 attachEvt("result", "idsReceived", rresultCollectRecords);
11 attachEvt("result", "recordDrawn", rresultLaunchDrawn);
13 hideMe($('copyright_block'));
15 function rresultDoSearch() {
17 swapCanvas($('loading_alt'));
19 table = G.ui.result.main_table;
20 hideMe(G.ui.result.row_template);
21 while( table.parentNode.rows.length <= (getDisplayCount() +1) )
22 hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true)));
26 function rresultCachedSearch() {
29 cookieManager.remove(COOKIE_SRIDS);
33 var data = JSON2js(cookieManager.read(COOKIE_SRIDS));
34 //alert('cached count = ' + data.count);
36 if( data && data.ids[getOffset()] != null &&
37 data.ids[resultFinalPageIndex()] != null ) {
38 _rresultHandleIds( data.ids, data.count );
45 function rresultCollectIds() {
48 if(rresultCachedSearch()) return;
53 ids = JSON2js(cookieManager.read(COOKIE_RIDS));
54 _rresultHandleIds( ids, ids.length );
62 rresultDoRecordSearch();
66 rresultDoRecordMultiSearch();
74 rresultCollectMARCIds();
78 rresultCollectISBNIds();
82 rresultCollectTCNIds();
86 rresultCollectISSNIds();
94 var form = rresultGetForm();
95 var args = { format : form, org : getLocation(), depth : rresultGetDepth() };
96 var req = new Request(FETCH_RIDS, getMrid(), args);
97 req.callback( rresultHandleRIds );
100 if( rresultGetDepth() != findOrgDepth(globalOrgTree) ) {
101 unHideMe($('rresult_show_all'));
102 var link = $('rresult_show_all_link');
103 link.appendChild( text(
104 findOrgType(globalOrgTree.ou_type()).opac_label()));
107 if( rresultGetDepth() != getDepth() ) { /* inside a limited display */
108 var link = $('rresult_show_here_link');
109 link.appendChild( text(
110 findOrgType(findOrgUnit(getLocation()).ou_type()).opac_label()));
111 unHideMe($('rresult_show_here'));
117 function rresultExpandSearch() {
119 args[PARAM_RDEPTH] = findOrgDepth(globalOrgTree);
120 goTo(buildOPACLink(args));
123 function rresultContractSearch() {
126 args[PARAM_OFFSET] = 0;
127 goTo(buildOPACLink(args));
131 function rresultGetDepth() {
132 if( getRdepth() != null) return getRdepth();
137 function rresultGetForm() {
140 if(getTform()) /* did the user select a format from the icon list (temporary) */
141 form = (getTform() == 'all') ? null : getTform();
142 else /* did the use select a format from simple search dropdown */
143 form = (getForm() == 'all') ? null : getForm();
145 if(!form) { /* did the user select a format from the advanced search */
146 form = getItemType();
147 var f = getItemForm();
150 form = form.replace(/,/,'');
151 if(f) form += '-' + f;
153 if(f) form = '-' + f;
161 function rresultCollectMARCIds() {
164 args.searches = JSON2js(getSearches());
166 args.org_unit = globalOrgTree.id();
169 var req = new Request(FETCH_ADV_MARC_MRIDS, args);
170 req.callback(rresultHandleRIds);
171 req.request.noretry = true;
176 function rresultCollectISBNIds() {
177 var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
180 var blob = r.getResultObject();
181 _rresultHandleIds(blob.ids, blob.count);
187 function rresultCollectTCNIds() {
188 var req = new Request(FETCH_ADV_TCN_RIDS, getAdvTerm() );
191 var blob = r.getResultObject();
192 _rresultHandleIds(blob.ids, blob.count);
198 function rresultCollectISSNIds() {
199 var req = new Request(FETCH_ADV_ISSN_RIDS, getAdvTerm() );
202 var blob = r.getResultObject();
203 _rresultHandleIds(blob.ids, blob.count);
209 function rresultHandleList() {
210 var ids = new CGI().param(PARAM_RLIST);
211 if(ids) _rresultHandleIds(ids, ids.length);
214 var rresultTries = 0;
215 function rresultHandleRIds(r) {
216 var res = r.getResultObject();
218 if( res.count == 0 && rresultTries == 0 && ! r.noretry) {
221 var form = rresultGetForm();
222 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
223 var req = new Request(FETCH_RIDS, getMrid(), args );
224 req.callback( rresultHandleRIds );
226 unHideMe($('no_formats'));
227 hideMe($('rresult_show_all'));
231 _rresultHandleIds(res.ids, res.count);
235 function _rresultHandleIds(ids, count) {
236 var json = js2JSON({ids:ids,count:count});
237 cookieManager.write(COOKIE_SRIDS, json, '+1d');
239 HITCOUNT = parseInt(count);
240 runEvt('result', 'hitCountReceived');
241 runEvt('result', 'idsReceived', ids);
244 function rresultCollectRecords(ids) {
245 runEvt("result", "preCollectRecords");
247 for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
248 if(ids[i] == null) break;
249 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
250 req.callback(rresultHandleMods);
251 req.request.userdata = x++;
256 function rresultHandleMods(r) {
257 var rec = r.getResultObject();
258 runEvt('result', 'recordReceived', rec, r.userdata, false);
259 resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
260 if(resultPageIsDone()) {
261 runEvt('result', 'allRecordsReceived', recordsCache);
262 unHideMe($('copyright_block'));
266 function rresultLaunchDrawn(id, node) {
267 runEvt("rresult", "recordDrawn", id, node);
271 function rresultDoRecordSearch() {
272 resultCollectSearchIds(true, SEARCH_RS, rresultFilterSearchResults ); }
273 function rresultDoRecordMultiSearch() {
274 resultCollectSearchIds(false, SEARCH_RS, rresultFilterSearchResults ); }
277 function rresultFilterSearchResults(r) {
278 var result = r.getResultObject();
280 for( var i = 0; i != result.ids.length; i++ )
281 ids.push(result.ids[i][0]);
282 _rresultHandleIds( ids, result.count );