Show SFX ISBN resources in record details page
authorDan Scott <dan@coffeecode.net>
Thu, 23 Jun 2011 15:57:19 +0000 (11:57 -0400)
committerDan Scott <dan@coffeecode.net>
Thu, 23 Jun 2011 15:57:19 +0000 (11:57 -0400)
A pretty straightforward rip-off of the current ISSN processing code

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/web/opac/skin/uwin/xml/rdetail/rdetail_summary.xml

index 0f21578..a2faf13 100644 (file)
                                <td type='opac/slot-data' query='datafield[tag=020]' class='rdetail_item'>
                                    <script type='opac/slot-format'><![CDATA[
                                        dojo.query('#tag020').removeClass('hide_me');
-                                       return '<span>' + BT.textContent(item) + '</span><br/>';
+                                       
+                                       /* Check for subfield 9 = SFX */
+                                       var isbn_raw = dojo.trim(BT.textContent(item));
+                                       var found_isbn_sfx = false;
+                    dojo.query('subfield[code="9"]', item).forEach(function(item) {
+                        if (dojo.trim(BT.textContent(item)) == 'SFX') {
+                            found_isbn_sfx = true;
+                        }
+                    });
+                    if (!found_isbn_sfx) {
+                        return '<span>' + isbn_raw + '</span><br/>';
+                    }
+
+                    var isbn = isbn_raw.replace(/^\s|.*?(\d\S*).*?$/, "$1");
+                    isbn = isbn.replace(/-/g, "");
+
+                                       var ses = new OpenSRF.ClientSession('open-ils.resolver');       
+                                       var req = ses.request('open-ils.resolver.resolve_holdings.raw', 'isbn', isbn, 'http://sfx.scholarsportal.info/windsor');        
+                                       req.oncomplete = function(r) {
+                                               var msg;
+                                               dojo.forEach(r.recv().content(), function(entry) {
+                                                       var resolverInfo = entry.public_name + "_" + entry.target_coverage;
+                                                       /* uwin has a lot of duplicates for some reason */
+                                                       if (url_list.indexOf(resolverInfo) == -1) {
+                                                               if (first_isbn) {
+                                                                       dojo.query('#rdetail_sfx *').orphan();
+                                                                       first_isbn = false;
+                                                               }
+
+                                                               dojo.place('<div style="width: 100%">'
+                                                                       + ' <a class="search_link" href="' + entry.target_url
+                                                                       + '">' + entry.public_name + '</a> - '
+                                                                       + entry.target_coverage 
+                                                                       + (entry.target_embargo ? (' / ' + entry.target_embargo) : '') 
+                                                                       + '</div>', 'rdetail_sfx');
+                                                               dojo.query('#rdetail_sfx_row').removeClass('hide_me');
+                                                               url_list += resolverInfo;
+                                                       }
+                                               });
+                                       }
+                                       req.send();
+
+                                       return '<span>' + isbn + '</span><br/>';
+
                                    ]]></script>
                                </td>
 
 
         /* Only clear the resources box once */
         var first_issn = true;
+        var first_isbn = true;
         var url_list = "";
 
         function subjectMe(tag, item) {