78a3d6967867f4091a2e63334eaac98248be7b3f
[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 attachEvt("common", "unload", rresultUnload);
8 attachEvt("common", "run", rresultDoSearch);
9 attachEvt("result", "idsReceived", rresultCollectRecords); 
10 attachEvt("result", "recordDrawn", rresultLaunchDrawn); 
11
12 function rresultDoSearch() {
13         table = G.ui.result.main_table;
14         hideMe(G.ui.result.row_template);
15         while( table.parentNode.rows.length < getDisplayCount() ) 
16                 hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true)));
17         rresultCollectIds();
18 }
19
20 function rresultCollectIds() {
21         var form = (getForm() == "all") ? null : getForm();
22         var req = new Request(FETCH_RIDS, getMrid(), form );
23         req.callback( rresultHandleRIds );
24         req.send();
25 }
26
27 function rresultHandleRIds(r) {
28         var res = r.getResultObject();
29         HITCOUNT = parseInt(res.count);
30         runEvt('result', 'hitCountReceived');
31         runEvt('result', 'idsReceived', res.ids);
32 }
33
34 function rresultCollectRecords(ids) {
35         runEvt("result", "preCollectRecords");
36         var x = 0;
37         for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) {
38                 if(ids[i] == null) break;
39                 var req = new Request(FETCH_RMODS, parseInt(ids[i]));
40                 req.callback(rresultHandleMods);
41                 req.request.userdata = x++;
42                 req.send();
43         }
44 }
45
46 function rresultHandleMods(r) {
47         var rec = r.getResultObject();
48         runEvt('result', 'recordReceived', rec, r.userdata, false);
49         resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS);
50 }
51
52
53 function rresultLaunchDrawn(id, node) {
54         runEvt("rresult", "recordDrawn", id, node);
55 }