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 rresultCollectISSNIds();
71 var form = rresultGetForm();
72 var args = { format : form, org : getLocation(), depth : rresultGetDepth() };
73 var req = new Request(FETCH_RIDS, getMrid(), args);
74 req.callback( rresultHandleRIds );
77 if( rresultGetDepth() != findOrgDepth(globalOrgTree) ) {
78 unHideMe($('rresult_show_all'));
79 var link = $('rresult_show_all_link');
80 link.appendChild( text(
81 findOrgType(globalOrgTree.ou_type()).opac_label()));
84 if( rresultGetDepth() != getDepth() ) { /* inside a limited display */
85 var link = $('rresult_show_here_link');
86 link.appendChild( text(
87 findOrgType(findOrgUnit(getLocation()).ou_type()).opac_label()));
88 unHideMe($('rresult_show_here'));
94 function rresultExpandSearch() {
96 args[PARAM_RDEPTH] = findOrgDepth(globalOrgTree);
97 goTo(buildOPACLink(args));
100 function rresultContractSearch() {
103 args[PARAM_OFFSET] = 0;
104 goTo(buildOPACLink(args));
108 function rresultGetDepth() {
109 if( getRdepth() != null) return getRdepth();
114 function rresultGetForm() {
117 if(getTform()) /* did the user select a format from the icon list (temporary) */
118 form = (getTform() == 'all') ? null : getTform();
119 else /* did the use select a format from simple search dropdown */
120 form = (getForm() == 'all') ? null : getForm();
122 if(!form) { /* did the user select a format from the advanced search */
123 form = getItemType();
124 var f = getItemForm();
127 form = form.replace(/,/,'');
128 if(f) form += '-' + f;
130 if(f) form = '-' + f;
138 function rresultCollectMARCIds() {
141 args.searches = JSON2js(getSearches());
143 args.org_unit = globalOrgTree.id();
146 var req = new Request(FETCH_ADV_MARC_MRIDS, args);
147 req.callback(rresultHandleRIds);
152 function rresultCollectISBNIds() {
153 var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
156 var blob = r.getResultObject();
157 _rresultHandleIds(blob.ids, blob.count);
163 function rresultCollectISSNIds() {
164 var req = new Request(FETCH_ADV_ISSN_RIDS, getAdvTerm() );
167 var blob = r.getResultObject();
168 _rresultHandleIds(blob.ids, blob.count);
174 function rresultHandleList() {
175 var ids = new CGI().param(PARAM_RLIST);
176 if(ids) _rresultHandleIds(ids, ids.length);
179 var rresultTries = 0;
180 function rresultHandleRIds(r) {
181 var res = r.getResultObject();
183 if( res.count == 0 ) {
185 if( rresultTries == 0 ) {
187 var form = rresultGetForm();
188 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
189 var req = new Request(FETCH_RIDS, getMrid(), args );
190 req.callback( rresultHandleRIds );
192 unHideMe($('no_formats'));
193 hideMe($('rresult_show_all'));
198 _rresultHandleIds(res.ids, res.count);
202 function _rresultHandleIds(ids, count) {
203 HITCOUNT = parseInt(count);
204 runEvt('result', 'hitCountReceived');
205 runEvt('result', 'idsReceived', ids);
208 function rresultCollectRecords(ids) {
209 runEvt("result", "preCollectRecords");
211 for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
212 if(ids[i] == null) break;
213 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
214 req.callback(rresultHandleMods);
215 req.request.userdata = x++;
220 function rresultHandleMods(r) {
221 var rec = r.getResultObject();
222 runEvt('result', 'recordReceived', rec, r.userdata, false);
223 resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
224 if(resultPageIsDone()) {
225 runEvt('result', 'allRecordsReceived', recordsCache);
226 unHideMe($('copyright_block'));
231 function rresultLaunchDrawn(id, node) {
232 runEvt("rresult", "recordDrawn", id, node);
236 function rresultDoRecordSearch() {
237 resultCollectSearchIds(true, SEARCH_RS, rresultFilterSearchResults ); }
238 function rresultDoRecordMultiSearch() {
239 resultCollectSearchIds(false, SEARCH_RS, rresultFilterSearchResults ); }
242 function _rresultCollectSearchIds( type ) {
244 var sort = (getSort() == SORT_TYPE_REL) ? null : getSort();
245 var sortdir = (sort) ? ((getSortDir()) ? getSortDir() : SORT_DIR_ASC) : null;
247 var form = parseForm(getForm());
248 var item_type = form.item_type;
249 var item_form = form.item_form;
255 args.searches[getRtype()] = {};
256 args.searches[getRtype()].term = getTerm();
258 args.searches = JSON2js(getAdvTerm());
261 args.org_unit = getLocation();
262 args.depth = getDepth();
263 args.limit = rresultLimit;
264 args.offset = getOffset();
266 if(sort) args.sort = sort;
267 if(sortdir) args.sort_dir = sortdir;
268 if(item_type) args.item_type = item_type;
269 if(item_form) args.item_form = item_form;
271 var req = new Request(SEARCH_RS, args);
272 req.callback(rresultFilterSearchResults);
278 function rresultFilterSearchResults(r) {
279 var result = r.getResultObject();
281 for( var i = 0; i != result.ids.length; i++ )
282 ids.push(result.ids[i][0]);
283 _rresultHandleIds( ids, result.count );