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 rresultCachedSearch() {
32 cookieManager.remove(COOKIE_SRIDS);
36 var data = JSON2js(cookieManager.read(COOKIE_SRIDS));
38 if( data && data.ids[getOffset()] != null &&
39 data.ids[resultFinalPageIndex()] != null ) {
40 _rresultHandleIds( data.ids, data.count );
47 function rresultCollectIds() {
50 if(rresultCachedSearch()) return;
55 ids = JSON2js(cookieManager.read(COOKIE_RIDS));
56 _rresultHandleIds( ids, ids.length );
64 rresultDoRecordSearch();
68 rresultDoRecordMultiSearch();
76 rresultCollectMARCIds();
80 rresultCollectISBNIds();
84 rresultCollectTCNIds();
88 rresultCollectISSNIds();
96 var form = rresultGetForm();
97 var args = { format : form, org : getLocation(), depth : rresultGetDepth() };
98 var req = new Request(FETCH_RIDS, getMrid(), args);
99 req.callback( rresultHandleRIds );
102 if( rresultGetDepth() != findOrgDepth(globalOrgTree) ) {
103 unHideMe($('rresult_show_all'));
104 var link = $('rresult_show_all_link');
105 link.appendChild( text(
106 findOrgType(globalOrgTree.ou_type()).opac_label()));
109 if( rresultGetDepth() != getDepth() ) { /* inside a limited display */
110 var link = $('rresult_show_here_link');
111 link.appendChild( text(
112 findOrgType(findOrgUnit(getLocation()).ou_type()).opac_label()));
113 unHideMe($('rresult_show_here'));
119 function rresultExpandSearch() {
121 args[PARAM_RDEPTH] = findOrgDepth(globalOrgTree);
122 goTo(buildOPACLink(args));
125 function rresultContractSearch() {
128 args[PARAM_OFFSET] = 0;
129 goTo(buildOPACLink(args));
133 function rresultGetDepth() {
134 if( getRdepth() != null) return getRdepth();
139 function rresultGetForm() {
142 if(getTform()) /* did the user select a format from the icon list (temporary) */
143 form = (getTform() == 'all') ? null : getTform();
144 else /* did the use select a format from simple search dropdown */
145 form = (getForm() == 'all') ? null : getForm();
147 if(!form) { /* did the user select a format from the advanced search */
148 form = getItemType();
149 var f = getItemForm();
152 form = form.replace(/,/,'');
153 if(f) form += '-' + f;
155 if(f) form = '-' + f;
163 function rresultCollectMARCIds() {
166 args.searches = JSON2js(getSearches());
168 args.org_unit = globalOrgTree.id();
171 var req = new Request(FETCH_ADV_MARC_MRIDS, args);
172 req.callback(rresultHandleRIds);
173 req.request.noretry = true;
178 function rresultCollectISBNIds() {
179 var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
182 var blob = r.getResultObject();
183 _rresultHandleIds(blob.ids, blob.count);
189 function rresultCollectTCNIds() {
190 var req = new Request(FETCH_ADV_TCN_RIDS, getAdvTerm() );
193 var blob = r.getResultObject();
194 _rresultHandleIds(blob.ids, blob.count);
200 function rresultCollectISSNIds() {
201 var req = new Request(FETCH_ADV_ISSN_RIDS, getAdvTerm() );
204 var blob = r.getResultObject();
205 _rresultHandleIds(blob.ids, blob.count);
211 function rresultHandleList() {
212 var ids = new CGI().param(PARAM_RLIST);
213 if(ids) _rresultHandleIds(ids, ids.length);
216 var rresultTries = 0;
217 function rresultHandleRIds(r) {
218 var res = r.getResultObject();
220 if( res.count == 0 && rresultTries == 0 && ! r.noretry) {
223 var form = rresultGetForm();
224 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
225 var req = new Request(FETCH_RIDS, getMrid(), args );
226 req.callback( rresultHandleRIds );
228 unHideMe($('no_formats'));
229 hideMe($('rresult_show_all'));
233 _rresultHandleIds(res.ids, res.count);
237 function _rresultHandleIds(ids, count) {
238 cookieManager.write(COOKIE_SRIDS, js2JSON({ids:ids,count:count}), '+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 );