From: Dan Scott Date: Fri, 24 Jun 2011 13:59:07 +0000 (-0400) Subject: Improve handling of OpenLibrary content in various browsers X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=92f4c09df4007be468e2120c646237d9fa0b6608;p=working%2FEvergreen.git Improve handling of OpenLibrary content in various browsers Firefox and Internet Explorer would display multiple links in a most disturbing fashion; the event model seems to be different than on Chrome, as the same link was being appended to a record that had an OL link for each record in the result list. Also, teach the search results to proxy OL "Borrow" links. Signed-off-by: Dan Scott Signed-off-by: Dan Scott --- diff --git a/Open-ILS/web/opac/skin/default/js/result_common.js b/Open-ILS/web/opac/skin/default/js/result_common.js index 6a5d8c3024..37eb544868 100644 --- a/Open-ILS/web/opac/skin/default/js/result_common.js +++ b/Open-ILS/web/opac/skin/default/js/result_common.js @@ -8,6 +8,13 @@ var lowHitCount = 4; var isbnList = new Array(); var googleBooksLink = true; var OpenLibraryLinks = true; +var fetchedOpenLibraryLinks = false; + +/* If you use EZProxy or similar to enable remote access to protected content, + * set your proxy prefix accordingly; for example: + * var localProxyPrefix = 'http://proxy.example.com/login?url=' + */ +var localProxyPrefix = ''; var resultFetchAllRecords = false; var resultCompiledSearch = null; @@ -684,7 +691,9 @@ function resultBuildFormatIcons( row, rec, is_mr ) { } function fetchOpenLibraryLinks() { - if (isbnList.length > 0 && OpenLibraryLinks) { + if (isbnList.length > 0 && OpenLibraryLinks && !fetchedOpenLibraryLinks) { + + fetchedOpenLibraryLinks = true; /* OpenLibrary supports a number of different identifiers: * ISBN: isbn: * LCCN: lccn: @@ -753,7 +762,8 @@ function renderOpenLibraryLinks(response) { /* Fall back to slightly less palatable options */ else if (ol_ebooks[isbn]['exact_lendable']) { createOpenLibraryLink( - isbn, ol_ebooks[isbn]['exact_lendable'], 'Borrow online' + isbn, localProxyPrefix + ol_ebooks[isbn]['exact_lendable'], + 'Borrow online' ); } @@ -763,7 +773,8 @@ function renderOpenLibraryLinks(response) { ); } else if (ol_ebooks[isbn]['similar_lendable']) { createOpenLibraryLink( - isbn, ol_ebooks[isbn]['similar_lendable'], 'Borrow similar online' + isbn, localProxyPrefix + ol_ebooks[isbn]['similar_lendable'], + 'Borrow similar online' ); } }