6 var mresultPreCache = 200;
10 attachEvt("common", "unload", mresultUnload);
11 attachEvt("common", "run", mresultDoSearch);
12 attachEvt("result", "idsReceived", mresultSetRecords);
13 attachEvt("result", "idsReceived", mresultCollectRecords);
15 function mresultUnload() { removeChildren(table); table = null;}
17 hideMe($('copyright_block'));
19 function mresultDoSearch() {
22 TFORM = null; /* clear the rresult tform var so it's not propogated */
24 swapCanvas($('loading_alt'));
25 table = G.ui.result.main_table;
27 var holdTarget = new CGI().param('hold_target');
28 if(holdTarget != null) {
29 mresultHandlePlaceHold(holdTarget);
34 while( table.parentNode.rows.length <= (getDisplayCount() + 1) )
35 table.appendChild(G.ui.result.row_template.cloneNode(true));
37 if( (getSearches() || getAdvTerm()) && !getTerm() ) {
38 if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds();
47 function _mresultCollectIds() {
48 resultCollectSearchIds(true, SEARCH_MRS_QUERY, mresultHandleMRIds );
51 function mresultCollectAdvIds() {
52 resultCollectSearchIds(false, SEARCH_MRS_QUERY, mresultHandleMRIds );
55 function mresultHandleMRIds(r) {
56 var res = r.getResultObject();
57 resultFacetKey = res.facet_key;
58 resultCompiledSearch = res.compiled_search;
59 dojo.require('dojo.cookie');
60 dojo.cookie(COOKIE_SEARCH, js2JSON(res.compiled_search));
61 if(res.count != null) {
62 if( getOffset() == 0 ) HITCOUNT = res.count;
63 runEvt('result', 'hitCountReceived');
65 runEvt('result', 'idsReceived', res.ids);
70 function mresultSetRecords(idstruct) {
73 for( var x = o; x < idstruct.length + o; x++ ) {
74 if( idstruct[x-o] != null ) {
75 var r = parseInt(idstruct[x - o][0]);
76 var ra = parseFloat(idstruct[x - o][1]);
77 var or = parseInt(idstruct[x - o][2]);
78 if(!isNull(r) && !isNaN(r)) records[x] = r;
79 if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra;
80 if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or;
84 TOPRANK = ranks[getOffset()];
89 var recsReceivedCalled = false;
90 function mresultCollectRecords() {
91 if(getHitCount() > 0 ) runEvt("result", "preCollectRecords");
93 for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) {
94 if(isNull(records[x])) break;
95 if(isNaN(records[x])) continue;
96 var req = new Request(FETCH_MRMODS, records[x]);
98 req.request.userdata = i++;
100 /* wait at most 10 seconds for the mods rec to come back */
101 /* this needs more testing */
102 req.request.timeout(10);
103 req.request.abortCallback(
106 if(resultPageIsDone() && !recsReceivedCalled) {
107 recsReceivedCalled = true;
108 runEvt('result', 'allRecordsReceived', recordsCache);
109 unHideMe($('copyright_block'));
114 req.callback(mresultHandleMods);
119 function mresultHandleMods(r) {
120 var rec = r.getResultObject();
121 var pagePosition = r.userdata;
122 runEvt('result', 'recordReceived', rec, pagePosition, true);
123 if(rec) resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS);
124 if(resultPageIsDone()) {
125 runEvt('result', 'allRecordsReceived', recordsCache);
126 unHideMe($('copyright_block')); /* *** */
131 function mresultHandlePlaceHold(target) {
133 location.href = location.href.replace(/&hold_target=\d+/, '');
135 attachEvt("common", "holdUpdated", reload);
136 attachEvt("common", "holdUpdateCanceled", reload);
137 attachEvt("common", "loginCanceled", reload);
138 holdsDrawEditor({record:target, type: 'M'});