From 0321b80d12ef97a51737aca75854025a9d68ba60 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Thu, 23 Jun 2011 09:02:09 -0400 Subject: [PATCH] Stab at implementing marked SFX ISBN lookups 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 --- .../web/opac/skin/uwin/xml/result/result_table.xml | 68 +++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/opac/skin/uwin/xml/result/result_table.xml b/Open-ILS/web/opac/skin/uwin/xml/result/result_table.xml index b400b2b879..b8c20d9a2b 100644 --- a/Open-ILS/web/opac/skin/uwin/xml/result/result_table.xml +++ b/Open-ILS/web/opac/skin/uwin/xml/result/result_table.xml @@ -101,6 +101,67 @@ 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) + ''; @@ -153,6 +214,7 @@ } catch (err) { alert(err.message);} } }); + ]]> @@ -224,10 +286,14 @@