Stab at implementing marked SFX ISBN lookups
authorDan Scott <dan@coffeecode.net>
Thu, 23 Jun 2011 13:02:09 +0000 (09:02 -0400)
committerDan Scott <dan@coffeecode.net>
Thu, 23 Jun 2011 13:02:09 +0000 (09:02 -0400)
Goal is to only fire an ISBN lookup where the 020 $9 subfield = "SFX";
if we don't find one of those, fall back to normal display methods
(located URIs via 856 or NOTHING).

This is just a quick test of the search result page for uwin skin.

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

index b400b2b..b8c20d9 100644 (file)
                                         this_title_id = dojo.trim(BT.textContent(item));
                                     });
 
+                                    dojo.query('datafield[tag="020"]', item).forEach(function(item) {
+                                        var sfx_mark = false;
+                                        dojo.query('subfield[code="9"]', item).forEach(function(item) {
+                                            sfx_mark = true;
+                                        });
+                                        if (!sfx_mark) {
+                                            return;
+                                        }
+
+                                        var isbn = '';
+                                        isbn = BT.textContent(item) + '';
+                                        isbn = isbn.replace(/^\s|.*?(\d\S*).*?$/, "$1");
+                                        isbn = isbn.replace(/-/g, "");
+                                        if (isbn.length > 0) {
+                                            try {
+                                                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 resolverInfo = "";
+                                                    dojo.forEach(r.recv().content(), function(entry) {
+                                                        resolverInfo = entry.public_name + "_" + entry.target_coverage;
+                                                        if (title_list.indexOf(this_title_id) == -1) {
+                                                            url_list = "";
+                                                        }
+                                                        if (url_list.indexOf(resolverInfo) == -1) {
+                                                            var resolverNode = null;
+                                                            dojo.query('.recid').forEach(function(recinfo) {
+                                                                if (parseFloat(dojo.trim(BT.textContent(recinfo))) == parseFloat(this_title_id)) {
+                                                                    resolverNode = recinfo;
+                                                                }
+                                                            });
+                                                            url_list += resolverInfo;
+                                                            var output = null;
+                                                            if (resolverNode != null) {
+                                                                var parent = resolverNode.parentNode;
+                                                                if (parent) {
+                                                                    parent = parent.parentNode;
+                                                                }
+                                                                if (parent) {
+                                                                    dojo.removeClass(parent,'hide_me');
+                                                                }
+                                                                output = dojo.create('div',{"style":"background-color:#EEFFEE;"},resolverNode,"last");
+                                                                dojo.addClass(output,"result_table_sfx_cell");
+                                                                title_list += this_title_id;
+                                                                var link = dojo.create('a',  {"style": "margin-left: 1em;", "class":"search_link", "href":  entry.target_url});
+                                                                var link_text = dojo.doc.createTextNode( entry.public_name);
+                                                                link.appendChild(link_text);
+                                                                output.appendChild(link);
+                                                                var coverage_text = dojo.doc.createTextNode(' - ' + entry.target_coverage
+                                                                        + (entry.target_embargo ? (' / ' + entry.target_embargo) : ''));
+                                                                output.appendChild(coverage_text);
+                                                                resolved[this_title_id] = true;
+                                                            }
+                                                        }
+                                                    });
+                                                };
+                                                req.send();
+                                            } catch (err) { alert(err.message);}
+                                        }
+                                    });
                                     dojo.query('datafield[tag="022"] subfield', item).forEach(function(item) {
                                         var issn = '';
                                         issn = BT.textContent(item) + '';
                                             } catch (err) { alert(err.message);}
                                         }
                                     });
+
                                 ]]></span>
                                 </span>
 
                                 <span type='opac/slot-data+marcxml-uris' query='record'>
                                     <span class='hide_me' type='opac/slot-format'><![CDATA[
                                         var found_issn = false;
+                                        var found_isbn = false;
                                         dojo.query('datafield[tag="022"]', item).forEach(function(issn) {
                                             found_issn = true;
                                         });
-                                        if (found_issn) { return; }
+                                        dojo.query('datafield[tag="020"] subfield[code="9"]', item).forEach(function(isbn) {
+                                            found_isbn = true;
+                                        });
+                                        if (found_issn or found_isbn) { return; }
 
                                         var this_title_id;