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() {
86 var link = buildOPACLink();
87 link += "&tmpdepth=" + findOrgDepth(globalOrgTree);
92 function rresultGetDepth() {
94 if(cgi.param('tmpdepth'))
95 return cgi.param('tmpdepth');
100 function rresultGetForm() {
103 if(getTform()) /* did the user select a format from the icon list (temporary) */
104 form = (getTform() == 'all') ? null : getTform();
105 else /* did the use select a format from simple search dropdown */
106 form = (getForm() == 'all') ? null : getForm();
108 if(!form) { /* did the user select a format from the advanced search */
109 form = getItemType();
111 form = form.replace(/,/,'');
112 var f = getItemForm();
113 if(f) form += '-' + f;
121 function rresultCollectMARCIds() {
124 args.searches = JSON2js(getSearches());
126 args.org_unit = globalOrgTree.id();
129 var req = new Request(FETCH_ADV_MARC_MRIDS, args);
130 req.callback(rresultHandleRIds);
134 function rresultHandleList() {
135 var ids = new CGI().param(PARAM_RLIST);
136 if(ids) _rresultHandleIds(ids, ids.length);
139 var rresultTries = 0;
140 function rresultHandleRIds(r) {
141 var res = r.getResultObject();
143 if( res.count == 0 ) {
145 if( rresultTries == 0 ) {
147 var form = rresultGetForm();
148 var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) };
149 var req = new Request(FETCH_RIDS, getMrid(), args );
150 req.callback( rresultHandleRIds );
152 unHideMe($('no_formats'));
153 hideMe($('rresult_show_all'));
158 _rresultHandleIds(res.ids, res.count);
162 function _rresultHandleIds(ids, count) {
163 HITCOUNT = parseInt(count);
164 runEvt('result', 'hitCountReceived');
165 runEvt('result', 'idsReceived', ids);
168 function rresultCollectRecords(ids) {
169 runEvt("result", "preCollectRecords");
171 for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
172 if(ids[i] == null) break;
173 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
174 req.callback(rresultHandleMods);
175 req.request.userdata = x++;
180 function rresultHandleMods(r) {
181 var rec = r.getResultObject();
182 runEvt('result', 'recordReceived', rec, r.userdata, false);
183 resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
184 if(resultPageIsDone()) {
185 runEvt('result', 'allRecordsReceived', recordsCache);
186 unHideMe($('copyright_block'));
191 function rresultLaunchDrawn(id, node) {
192 runEvt("rresult", "recordDrawn", id, node);
196 function rresultDoRecordSearch() {
197 resultCollectSearchIds(true, SEARCH_RS, rresultFilterSearchResults ); }
198 function rresultDoRecordMultiSearch() {
199 resultCollectSearchIds(false, SEARCH_RS, rresultFilterSearchResults ); }
202 function _rresultCollectSearchIds( type ) {
204 var sort = (getSort() == SORT_TYPE_REL) ? null : getSort();
205 var sortdir = (sort) ? ((getSortDir()) ? getSortDir() : SORT_DIR_ASC) : null;
207 var form = parseForm(getForm());
208 var item_type = form.item_type;
209 var item_form = form.item_form;
215 args.searches[getRtype()] = {};
216 args.searches[getRtype()].term = getTerm();
218 args.searches = JSON2js(getAdvTerm());
221 args.org_unit = getLocation();
222 args.depth = getDepth();
223 args.limit = rresultLimit;
224 args.offset = getOffset();
226 if(sort) args.sort = sort;
227 if(sortdir) args.sort_dir = sortdir;
228 if(item_type) args.item_type = item_type;
229 if(item_form) args.item_form = item_form;
231 var req = new Request(SEARCH_RS, args);
232 req.callback(rresultFilterSearchResults);
238 function rresultFilterSearchResults(r) {
239 var result = r.getResultObject();
241 for( var i = 0; i != result.ids.length; i++ )
242 ids.push(result.ids[i][0]);
243 _rresultHandleIds( ids, result.count );