]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/common/js/added_content.js
fixed session cookie to work with IE
[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 * Ideally, this should point to some type of added content service.
4 * The example below uses Amazon... *use at own risk*
5 */
6
7 function buildISBNSrc(isbn, size) {
8         //return "http://images.amazon.com/images/P/" + isbn + ".01._SCMZZZZZZZ_.jpg";
9         //return '../../../../jackets/'+isbn;
10         size = (size) ? size : 'small';
11         return '../../../../extras/jacket/'+size+'/'+isbn;
12 }      
13
14
15
16 function acMakeURL(type, key) {
17         return '../../../../extras/ac/' + type + '/html/' + key;
18 }
19
20
21 function acCollectData( key, callback ) {
22         var context = { key : key, callback: callback, data : {} };
23         acCollectItem(context, 'reviews');
24         acCollectItem(context, 'toc');
25         acCollectItem(context, 'excerpt');
26         acCollectItem(context, 'anotes');
27 }
28
29 function acCheckDone(context) {
30         if(     context.data.reviews && context.data.reviews.done &&
31                         context.data.toc                && context.data.toc.done &&
32                         context.data.excerpt && context.data.excerpt.done &&
33                         context.data.anotes     && context.data.anotes.done ) {
34
35                 if(context.callback) context.callback(context.data);
36         }
37 }
38
39 function acCollectItem(context, type) {
40         var req = buildXMLRequest();
41         req.open('GET', acMakeURL(type, context.key), true);
42         req.onreadystatechange = function() {
43                 if( req.readyState == 4 ) {
44                         context.data[type] = { done : true }
45
46                         if(IE) {
47
48                                 /* Someone please explain why IE treats status 404 as status 200?? 
49                                         On second thought, don't bother.
50                                 */
51                                 if( ! req.responseText.match(
52                                         /The requested URL.*was not found on this server/) )
53                                         context.data[type].html = req.responseText;
54
55                         } else {
56                                 if( req.status != 404 ) 
57                                         context.data[type].html = req.responseText;
58                         }
59                         acCheckDone(context);
60                 }
61         }
62         req.send(null);
63 }
64
65