]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/common/js/added_content.js
LP2045292 Color contrast for AngularJS patron bills
[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         var protocol = (OILS_OPAC_STATIC_PROTOCOL) ? OILS_OPAC_STATIC_PROTOCOL + ':' : location.protocol;
9     if(OILS_OPAC_IMAGES_HOST)
10         return protocol + '//' + OILS_OPAC_IMAGES_HOST + size + '/' + isbn;
11         return '../../../../extras/ac/jacket/'+size+'/'+isbn;
12 }      
13
14 /**
15 * This function should return a URL which points to the book cover image based on record ID.
16 */
17
18 function buildJacketSrc(rec_id, size) {
19 size = (size) ? size : 'small';
20         var protocol = (OILS_OPAC_STATIC_PROTOCOL) ? OILS_OPAC_STATIC_PROTOCOL + ':' : location.protocol;
21         if(OILS_OPAC_IMAGES_HOST)
22                 return protocol + '//' + OILS_OPAC_IMAGES_HOST + size + '/r/' + rec_id;
23         return '../../../../extras/ac/jacket/'+size+'/r/'+rec_id;
24 }
25
26 function acMakeURL(type, key) {
27         return '../../../../extras/ac/' + type + '/html/' + key;
28 }
29
30
31 function acCollectData( key, callback ) {
32         var context = { key : key, callback: callback, data : {} };
33         acCollectItem(context, 'summary');
34         acCollectItem(context, 'reviews');
35         acCollectItem(context, 'toc');
36         acCollectItem(context, 'excerpt');
37         acCollectItem(context, 'anotes');
38 }
39
40 function acCheckDone(context) {
41         if(     context.data.reviews && context.data.reviews.done &&
42                         context.data.toc                && context.data.toc.done &&
43                         context.data.excerpt && context.data.excerpt.done &&
44                         context.data.anotes     && context.data.anotes.done ) {
45
46                 if(context.callback) context.callback(context.data);
47         }
48 }
49
50 function acCollectItem(context, type) {
51         var req = buildXMLRequest();
52         req.open('GET', acMakeURL(type, context.key), true);
53         req.onreadystatechange = function() {
54                 if( req.readyState == 4 ) {
55                         context.data[type] = { done : true }
56
57                         if(IE) {
58
59                                 /* Someone please explain why IE treats status 404 as status 200?? 
60                                         On second thought, don't bother.
61                                 */
62                                 if( ! req.responseText.match(
63                                         /The requested URL.*was not found on this server/) )
64                                         context.data[type].html = req.responseText;
65
66                         } else {
67                                 if( req.status != 404 ) 
68                                         context.data[type].html = req.responseText;
69                         }
70                         acCheckDone(context);
71                 }
72         }
73         req.send(null);
74 }
75
76