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();
115 var f = getItemForm();
118 form = form.replace(/,/,'');
119 if(f) form += '-' + f;
121 if(f) form = '-' + f;
129 function rresultCollectMARCIds() {
132 args.searches = JSON2js(getSearches());
134 args.org_unit = globalOrgTree.id();
137 var req = new Request(FETCH_ADV_MARC_MRIDS, args);
138 req.callback(rresultHandleRIds);
142 function rresultHandleList() {
143 var ids = new CGI().param(PARAM_RLIST);
144 if(ids) _rresultHandleIds(ids, ids.length);
147 var rresultTries = 0;
148 function rresultHandleRIds(r) {
149 var res = r.getResultObject();
151 if( res.count == 0 ) {
153 if( rresultTries == 0 ) {
155 var form = rresultGetForm();
156 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
157 var req = new Request(FETCH_RIDS, getMrid(), args );
158 req.callback( rresultHandleRIds );
160 unHideMe($('no_formats'));
161 hideMe($('rresult_show_all'));
166 _rresultHandleIds(res.ids, res.count);
170 function _rresultHandleIds(ids, count) {
171 HITCOUNT = parseInt(count);
172 runEvt('result', 'hitCountReceived');
173 runEvt('result', 'idsReceived', ids);
176 function rresultCollectRecords(ids) {
177 runEvt("result", "preCollectRecords");
179 for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
180 if(ids[i] == null) break;
181 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
182 req.callback(rresultHandleMods);
183 req.request.userdata = x++;
188 function rresultHandleMods(r) {
189 var rec = r.getResultObject();
190 runEvt('result', 'recordReceived', rec, r.userdata, false);
191 resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
192 if(resultPageIsDone()) {
193 runEvt('result', 'allRecordsReceived', recordsCache);
194 unHideMe($('copyright_block'));
199 function rresultLaunchDrawn(id, node) {
200 runEvt("rresult", "recordDrawn", id, node);
204 function rresultDoRecordSearch() {
205 resultCollectSearchIds(true, SEARCH_RS, rresultFilterSearchResults ); }
206 function rresultDoRecordMultiSearch() {
207 resultCollectSearchIds(false, SEARCH_RS, rresultFilterSearchResults ); }
210 function _rresultCollectSearchIds( type ) {
212 var sort = (getSort() == SORT_TYPE_REL) ? null : getSort();
213 var sortdir = (sort) ? ((getSortDir()) ? getSortDir() : SORT_DIR_ASC) : null;
215 var form = parseForm(getForm());
216 var item_type = form.item_type;
217 var item_form = form.item_form;
223 args.searches[getRtype()] = {};
224 args.searches[getRtype()].term = getTerm();
226 args.searches = JSON2js(getAdvTerm());
229 args.org_unit = getLocation();
230 args.depth = getDepth();
231 args.limit = rresultLimit;
232 args.offset = getOffset();
234 if(sort) args.sort = sort;
235 if(sortdir) args.sort_dir = sortdir;
236 if(item_type) args.item_type = item_type;
237 if(item_form) args.item_form = item_form;
239 var req = new Request(SEARCH_RS, args);
240 req.callback(rresultFilterSearchResults);
246 function rresultFilterSearchResults(r) {
247 var result = r.getResultObject();
249 for( var i = 0; i != result.ids.length; i++ )
250 ids.push(result.ids[i][0]);
251 _rresultHandleIds( ids, result.count );