Improve handling of OpenLibrary content in various browsers user/dbs/openlibrary-read-api-2_1
authorDan Scott <dan@coffeecode.net>
Fri, 24 Jun 2011 13:59:07 +0000 (09:59 -0400)
committerDan Scott <dan@coffeecode.net>
Fri, 24 Jun 2011 14:03:53 +0000 (10:03 -0400)
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 <dscott@laurentian.ca>
Signed-off-by: Dan Scott <dan@coffeecode.net>
Open-ILS/web/opac/skin/default/js/result_common.js

index 6a5d8c3..37eb544 100644 (file)
@@ -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:<isbn>
          * LCCN: 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'
             );
         }
     }