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();
62 var form = rresultGetForm();
63 var args = { format : form, org : getLocation(), depth : rresultGetDepth() };
64 var req = new Request(FETCH_RIDS, getMrid(), args);
65 req.callback( rresultHandleRIds );
68 if( rresultGetDepth() != findOrgDepth(globalOrgTree) ) {
69 unHideMe($('rresult_show_all'));
70 var link = $('rresult_show_all_link');
71 link.appendChild( text(
72 findOrgType(globalOrgTree.ou_type()).opac_label()));
75 if( rresultGetDepth() != getDepth() ) { /* inside a limited display */
76 var link = $('rresult_show_here_link');
77 link.appendChild( text(
78 findOrgType(findOrgUnit(getLocation()).ou_type()).opac_label()));
79 unHideMe($('rresult_show_here'));
85 function rresultExpandSearch() {
87 args[PARAM_RDEPTH] = findOrgDepth(globalOrgTree);
88 goTo(buildOPACLink(args));
91 function rresultContractSearch() {
94 args[PARAM_OFFSET] = 0;
95 goTo(buildOPACLink(args));
99 function rresultGetDepth() {
100 if( getRdepth() != null) return getRdepth();
105 function rresultGetForm() {
108 if(getTform()) /* did the user select a format from the icon list (temporary) */
109 form = (getTform() == 'all') ? null : getTform();
110 else /* did the use select a format from simple search dropdown */
111 form = (getForm() == 'all') ? null : getForm();
113 if(!form) { /* did the user select a format from the advanced search */
114 form = getItemType();
116 form = form.replace(/,/,'');
117 var f = getItemForm();
118 if(f) form += '-' + f;
126 function rresultCollectMARCIds() {
129 args.searches = JSON2js(getSearches());
131 args.org_unit = globalOrgTree.id();
134 var req = new Request(FETCH_ADV_MARC_MRIDS, args);
135 req.callback(rresultHandleRIds);
139 function rresultHandleList() {
140 var ids = new CGI().param(PARAM_RLIST);
141 if(ids) _rresultHandleIds(ids, ids.length);
144 var rresultTries = 0;
145 function rresultHandleRIds(r) {
146 var res = r.getResultObject();
148 if( res.count == 0 ) {
150 if( rresultTries == 0 ) {
152 var form = rresultGetForm();
153 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
154 var req = new Request(FETCH_RIDS, getMrid(), args );
155 req.callback( rresultHandleRIds );
157 unHideMe($('no_formats'));
158 hideMe($('rresult_show_all'));
163 _rresultHandleIds(res.ids, res.count);
167 function _rresultHandleIds(ids, count) {
168 HITCOUNT = parseInt(count);
169 runEvt('result', 'hitCountReceived');
170 runEvt('result', 'idsReceived', ids);
173 function rresultCollectRecords(ids) {
174 runEvt("result", "preCollectRecords");
176 for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
177 if(ids[i] == null) break;
178 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
179 req.callback(rresultHandleMods);
180 req.request.userdata = x++;
185 function rresultHandleMods(r) {
186 var rec = r.getResultObject();
187 runEvt('result', 'recordReceived', rec, r.userdata, false);
188 resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
189 if(resultPageIsDone()) {
190 runEvt('result', 'allRecordsReceived', recordsCache);
191 unHideMe($('copyright_block'));
196 function rresultLaunchDrawn(id, node) {
197 runEvt("rresult", "recordDrawn", id, node);
201 function rresultDoRecordSearch() {
202 resultCollectSearchIds(true, SEARCH_RS, rresultFilterSearchResults ); }
203 function rresultDoRecordMultiSearch() {
204 resultCollectSearchIds(false, SEARCH_RS, rresultFilterSearchResults ); }
207 function _rresultCollectSearchIds( type ) {
209 var sort = (getSort() == SORT_TYPE_REL) ? null : getSort();
210 var sortdir = (sort) ? ((getSortDir()) ? getSortDir() : SORT_DIR_ASC) : null;
212 var form = parseForm(getForm());
213 var item_type = form.item_type;
214 var item_form = form.item_form;
220 args.searches[getRtype()] = {};
221 args.searches[getRtype()].term = getTerm();
223 args.searches = JSON2js(getAdvTerm());
226 args.org_unit = getLocation();
227 args.depth = getDepth();
228 args.limit = rresultLimit;
229 args.offset = getOffset();
231 if(sort) args.sort = sort;
232 if(sortdir) args.sort_dir = sortdir;
233 if(item_type) args.item_type = item_type;
234 if(item_form) args.item_form = item_form;
236 var req = new Request(SEARCH_RS, args);
237 req.callback(rresultFilterSearchResults);
243 function rresultFilterSearchResults(r) {
244 var result = r.getResultObject();
246 for( var i = 0; i != result.ids.length; i++ )
247 ids.push(result.ids[i][0]);
248 _rresultHandleIds( ids, result.count );