adding
[Evergreen.git] / Open-ILS / web / opac / skin / default / js / rresult.js
1 var records = new Array();
2 var table;
3 var rowtemplate;
4
5 function rresultUnload() { removeChildren(table); table = null;}
6
7 G.evt.common.unload.push(rresultUnload);
8 G.evt.rresult.run.push(rresultDoSearch);
9 G.evt.rresult.idsReceived.push(rresultCollectRecords); 
10
11 function rresultDoSearch() {
12         table = G.ui.result.main_table;
13         hideMe(G.ui.result.row_template);
14         while( table.parentNode.rows.length < getDisplayCount() ) 
15                 hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true)));
16         rresultCollectIds();
17 }
18
19 function rresultCollectIds() {
20         var form = (getForm() == "all") ? null : getForm();
21         var req = new Request(FETCH_RIDS, getMrid(), form );
22         req.callback( rresultHandleRIds );
23         req.send();
24 }
25
26 function rresultHandleRIds(r) {
27         var res = r.getResultObject();
28         HITCOUNT = parseInt(res.count);
29         runEvt('result', 'hitCountReceived');
30         runEvt('rresult', 'idsReceived', res.ids);
31 }
32
33 function rresultCollectRecords(ids) {
34         var x = 0;
35         for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
36                 if(ids[i] == null) break;
37                 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
38                 req.callback(rresultHandleMods);
39                 req.request.userdata = x++;
40                 req.send();
41         }
42 }
43
44 function rresultHandleMods(r) {
45         var rec = r.getResultObject();
46         runEvt('result', 'recordReceived', rec, r.userdata, false);
47         resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
48 }
49