]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/common/js/added_content.js
added params for filtering pubdate before/after/between/during. added functional...
[Evergreen.git] / Open-ILS / web / opac / common / js / added_content.js
1 /**
2 * This function should return a URL which points to the book cover image based on ISBN.
3 */
4
5
6 function buildISBNSrc(isbn, size) {
7         size = (size) ? size : 'small';
8     if(OILS_OPAC_IMAGES_HOST)
9         return location.protocol + '//' + OILS_OPAC_IMAGES_HOST + size + '/' + isbn;
10         return '../../../../extras/ac/jacket/'+size+'/'+isbn;
11 }      
12
13
14 function acMakeURL(type, key) {
15         return '../../../../extras/ac/' + type + '/html/' + key;
16 }
17
18
19 function acCollectData( key, callback ) {
20         var context = { key : key, callback: callback, data : {} };
21         acCollectItem(context, 'reviews');
22         acCollectItem(context, 'toc');
23         acCollectItem(context, 'excerpt');
24         acCollectItem(context, 'anotes');
25 }
26
27 function acCheckDone(context) {
28         if(     context.data.reviews && context.data.reviews.done &&
29                         context.data.toc                && context.data.toc.done &&
30                         context.data.excerpt && context.data.excerpt.done &&
31                         context.data.anotes     && context.data.anotes.done ) {
32
33                 if(context.callback) context.callback(context.data);
34         }
35 }
36
37 function acCollectItem(context, type) {
38         var req = buildXMLRequest();
39         req.open('GET', acMakeURL(type, context.key), true);
40         req.onreadystatechange = function() {
41                 if( req.readyState == 4 ) {
42                         context.data[type] = { done : true }
43
44                         if(IE) {
45
46                                 /* Someone please explain why IE treats status 404 as status 200?? 
47                                         On second thought, don't bother.
48                                 */
49                                 if( ! req.responseText.match(
50                                         /The requested URL.*was not found on this server/) )
51                                         context.data[type].html = req.responseText;
52
53                         } else {
54                                 if( req.status != 404 ) 
55                                         context.data[type].html = req.responseText;
56                         }
57                         acCheckDone(context);
58                 }
59         }
60         req.send(null);
61 }
62
63