removed the older Cookie.js code.
[Evergreen.git] / Open-ILS / web / opac / extras / bbags.js
1
2 /* XXX allow to pass in a 'local' var so the links back into the opac can be localized */
3 /* maybe also a 'skin' var */
4
5 function bbInit() {
6         var cgi = new CGI();
7         var bb  = cgi.param('bb');
8         if(!bb) { unHideMe($('not_found')); return; }
9         var req = new Request(FLESH_PUBLIC_CONTAINER, 'biblio', bb);
10         req.callback( bbShow );
11         req.send();
12 }
13
14
15 var template;
16 function bbShow(r) {
17
18         var bb = r.getResultObject();
19         if(!bb || !bb.pub()) { unHideMe($('not_found')); return; }
20         $('bb_name').appendChild(text(bb.name()));
21
22         var tbody = $('tbody');
23         if(!template) template = tbody.removeChild($('row_template'));
24
25         for( var i in bb.items() ) 
26                 tbody.appendChild(bbShowItem( template, bb.items()[i] ));
27 }
28
29 function bbShowItem( template, item ) {
30         var row = template.cloneNode(true);
31
32         var req = new Request( FETCH_RMODS, item.target_biblio_record_entry() );
33         req.request.tlink = $n(row, 'title');
34         req.request.alink = $n(row, 'author');
35         req.request.blink = $n(row, 'by');
36
37         req.callback( function(r) { 
38                 var rec = r.getResultObject();
39                 buildTitleDetailLink(rec, r.tlink); 
40                 r.tlink.setAttribute('href', '/opac/en-US/skin/default/xml/rdetail.xml?r='+rec.doc_id());
41                 r.alink.appendChild(text(rec.author()));
42                 unHideMe(r.blink);
43         });
44
45         req.send();
46         return row;
47 }