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 if(getOffset() == 0) swapCanvas($('loading_alt'));
22 table = G.ui.result.main_table;
23 hideMe(G.ui.result.row_template);
24 while( table.parentNode.rows.length <= (getDisplayCount() +1) )
25 hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true)));
29 function rresultCollectIds() {
34 ids = JSON2js(cookieManager.read(COOKIE_RIDS));
35 _rresultHandleIds( ids, ids.length );
43 rresultDoRecordSearch();
47 rresultDoRecordMultiSearch();
55 rresultCollectMARCIds();
59 rresultCollectISBNIds();
63 rresultCollectTCNIds();
67 rresultCollectISSNIds();
75 var form = rresultGetForm();
76 var args = { format : form, org : getLocation(), depth : rresultGetDepth() };
77 var req = new Request(FETCH_RIDS, getMrid(), args);
78 req.callback( rresultHandleRIds );
81 if( rresultGetDepth() != findOrgDepth(globalOrgTree) ) {
82 unHideMe($('rresult_show_all'));
83 var link = $('rresult_show_all_link');
84 link.appendChild( text(
85 findOrgType(globalOrgTree.ou_type()).opac_label()));
88 if( rresultGetDepth() != getDepth() ) { /* inside a limited display */
89 var link = $('rresult_show_here_link');
90 link.appendChild( text(
91 findOrgType(findOrgUnit(getLocation()).ou_type()).opac_label()));
92 unHideMe($('rresult_show_here'));
98 function rresultExpandSearch() {
100 args[PARAM_RDEPTH] = findOrgDepth(globalOrgTree);
101 goTo(buildOPACLink(args));
104 function rresultContractSearch() {
107 args[PARAM_OFFSET] = 0;
108 goTo(buildOPACLink(args));
112 function rresultGetDepth() {
113 if( getRdepth() != null) return getRdepth();
118 function rresultGetForm() {
121 if(getTform()) /* did the user select a format from the icon list (temporary) */
122 form = (getTform() == 'all') ? null : getTform();
123 else /* did the use select a format from simple search dropdown */
124 form = (getForm() == 'all') ? null : getForm();
126 if(!form) { /* did the user select a format from the advanced search */
127 form = getItemType();
128 var f = getItemForm();
131 form = form.replace(/,/,'');
132 if(f) form += '-' + f;
134 if(f) form = '-' + f;
142 function rresultCollectMARCIds() {
145 args.searches = JSON2js(getSearches());
147 args.org_unit = globalOrgTree.id();
150 var req = new Request(FETCH_ADV_MARC_MRIDS, args);
151 req.callback(rresultHandleRIds);
152 req.request.noretry = true;
157 function rresultCollectISBNIds() {
158 var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
161 var blob = r.getResultObject();
162 _rresultHandleIds(blob.ids, blob.count);
168 function rresultCollectTCNIds() {
169 var req = new Request(FETCH_ADV_TCN_RIDS, getAdvTerm() );
172 var blob = r.getResultObject();
173 _rresultHandleIds(blob.ids, blob.count);
179 function rresultCollectISSNIds() {
180 var req = new Request(FETCH_ADV_ISSN_RIDS, getAdvTerm() );
183 var blob = r.getResultObject();
184 _rresultHandleIds(blob.ids, blob.count);
190 function rresultHandleList() {
191 var ids = new CGI().param(PARAM_RLIST);
192 if(ids) _rresultHandleIds(ids, ids.length);
195 var rresultTries = 0;
196 function rresultHandleRIds(r) {
197 var res = r.getResultObject();
199 if( res.count == 0 && rresultTries == 0 && ! r.noretry) {
202 var form = rresultGetForm();
203 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
204 var req = new Request(FETCH_RIDS, getMrid(), args );
205 req.callback( rresultHandleRIds );
207 unHideMe($('no_formats'));
208 hideMe($('rresult_show_all'));
212 _rresultHandleIds(res.ids, res.count);
216 function _rresultHandleIds(ids, count) {
217 HITCOUNT = parseInt(count);
218 runEvt('result', 'hitCountReceived');
219 runEvt('result', 'idsReceived', ids);
222 function rresultCollectRecords(ids) {
223 runEvt("result", "preCollectRecords");
225 for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
226 if(ids[i] == null) break;
227 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
228 req.callback(rresultHandleMods);
229 req.request.userdata = x++;
234 function rresultHandleMods(r) {
235 var rec = r.getResultObject();
236 runEvt('result', 'recordReceived', rec, r.userdata, false);
237 resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
238 if(resultPageIsDone()) {
239 runEvt('result', 'allRecordsReceived', recordsCache);
240 unHideMe($('copyright_block'));
245 function rresultLaunchDrawn(id, node) {
246 runEvt("rresult", "recordDrawn", id, node);
250 function rresultDoRecordSearch() {
251 resultCollectSearchIds(true, SEARCH_RS, rresultFilterSearchResults ); }
252 function rresultDoRecordMultiSearch() {
253 resultCollectSearchIds(false, SEARCH_RS, rresultFilterSearchResults ); }
256 function _rresultCollectSearchIds( type ) {
258 var sort = (getSort() == SORT_TYPE_REL) ? null : getSort();
259 var sortdir = (sort) ? ((getSortDir()) ? getSortDir() : SORT_DIR_ASC) : null;
261 var form = parseForm(getForm());
262 var item_type = form.item_type;
263 var item_form = form.item_form;
269 args.searches[getRtype()] = {};
270 args.searches[getRtype()].term = getTerm();
272 args.searches = JSON2js(getAdvTerm());
275 args.org_unit = getLocation();
276 args.depth = getDepth();
277 args.limit = rresultLimit;
278 args.offset = getOffset();
280 if(sort) args.sort = sort;
281 if(sortdir) args.sort_dir = sortdir;
282 if(item_type) args.item_type = item_type;
283 if(item_form) args.item_form = item_form;
285 var req = new Request(SEARCH_RS, args);
286 req.callback(rresultFilterSearchResults);
292 function rresultFilterSearchResults(r) {
293 var result = r.getResultObject();
295 for( var i = 0; i != result.ids.length; i++ )
296 ids.push(result.ids[i][0]);
297 _rresultHandleIds( ids, result.count );