Add catalogue SFX resolution
authorDan Scott <dan@coffeecode.net>
Mon, 30 May 2011 16:34:47 +0000 (12:34 -0400)
committerDan Scott <dan@coffeecode.net>
Mon, 30 May 2011 16:34:47 +0000 (12:34 -0400)
For automatic munging in generated skins, provide a local
SFX_TARGET that defines the base URL for the SFX resolver.

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

index e8a186e..8523487 100644 (file)
                                <td class='rdetail_item' id='rdetail_isbn'> </td>
                        </tr>
 
+                       <tr class='hide_me' id='tag022'>
+                               <td nowrap='nowrap' class='rdetail_desc' id='issn_title'>&common.issn;</td>
+                               <td type='opac/slot-data' query='datafield[tag=022]' class='rdetail_item' id='rdetail_issn'>
+                                       <script type='opac/slot-format'><![CDATA[
+                                       dojo.query('#tag022').removeClass('hide_me');
+                                       var issn_raw = dojo.trim(BT.textContent(item));
+
+                                       /*
+                                               textContent returns multiple subfields concatenated with linefeeds,
+                                               so our regex needs to match against linefeeds. "." does not match
+                                               linefeeds, so get \s into the mix
+                                       */
+                                       var issn = issn_raw.replace(/^(\s|.)*?(\d{4}).(\d{3,4}[xX]?)(\s|.)*/, "$2-$3");
+
+                                       var SFX_TARGET = null;
+                                       /* short-circuit if this is not set */
+                                       if (!SFX_TARGET) {
+                                               return '<span>' + issn + '</span><br/>';
+                                       }
+
+                                       var ses = new OpenSRF.ClientSession('open-ils.resolver');       
+                                       var req = ses.request('open-ils.resolver.resolve_holdings.raw', 'issn', issn);  
+                                       req.oncomplete = function(r) {
+                                               var msg;
+                                               dojo.forEach(r.recv().content(), function(entry) {
+                                                       if (first_issn) {
+                                                               dojo.query('#rdetail_online *').orphan();
+                                                               first_issn = 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_online');
+                                                       dojo.query('#rdetail_online_row').removeClass('hide_me');
+                                               });
+                                       }
+                                       req.send();
+
+                                       return '<span>' + issn + '</span><br/>';
+                                       ]]></script>
+                               </td>
+
+                       </tr>
+
                        <tr>
                                <td nowrap='nowrap' class='rdetail_desc'>&common.edition;</td>          
                                <td class='rdetail_item' id='rdetail_edition'> </td>