From 691e6cfbc8c95442f7d2e1b528f82e7e67c07bb7 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 14 Mar 2008 13:00:32 +0000 Subject: [PATCH] adding google books view to result pages git-svn-id: svn://svn.open-ils.org/ILS/trunk@9008 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/opac.dtd | 1 + .../web/opac/skin/default/js/result_common.js | 46 ++++++++++++++++++- .../skin/default/xml/result/result_table.xml | 10 +++- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/opac.dtd b/Open-ILS/web/opac/locale/en-US/opac.dtd index f7c564a361..766bd45403 100644 --- a/Open-ILS/web/opac/locale/en-US/opac.dtd +++ b/Open-ILS/web/opac/locale/en-US/opac.dtd @@ -554,6 +554,7 @@ We recommend that you remove this title from any bookbags it may have been added + 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 318cba5aa1..3810402ee2 100644 --- a/Open-ILS/web/opac/skin/default/js/result_common.js +++ b/Open-ILS/web/opac/skin/default/js/result_common.js @@ -2,6 +2,8 @@ var recordsHandled = 0; var recordsCache = []; var lowHitCount = 4; +var isbnList = ''; +var googleBooks = false; var resultFetchAllRecords = false; var resultCompiledSearch = null; @@ -394,6 +396,21 @@ function buildunAPISpan (span, type, id) { ); } +function unhideGoogleBooks (data) { + for ( var i in data ) { + if (data[i].preview == 'noview') continue; + + var gbspan = $n('googleBooks-' + i); + var gba = $n("googleBooks-link",gbspan) + + gba..setAttribute( + 'href', + data[i].info_url + ); + removeCSSClass( gbspan, 'hide_me' ); + } +} + /* display the record info in the record display table 'pos' is the zero based position the record should have in the display table */ function resultDisplayRecord(rec, pos, is_mr) { @@ -403,8 +420,21 @@ function resultDisplayRecord(rec, pos, is_mr) { recordsCache.push(rec); var r = table.rows[pos + 1]; + var currentISBN = cleanISBN(rec.isbn()); + + if (googleBooks) { + var gbspan = $n(r, "googleBooks"); + if (currentISBN) { + gbspan.setAttribute( + 'name', + gbspan.getAttribute('name') + '-' + currentISBN + ); + + if (isbnList) isbnList += ', '; + isbnList += currentISBN; + } + } - try { var rank = parseFloat(ranks[pos + getOffset()]); rank = parseInt( rank * 100 ); @@ -414,7 +444,7 @@ function resultDisplayRecord(rec, pos, is_mr) { } catch(e){ } var pic = $n(r, config.names.result.item_jacket); - pic.setAttribute("src", buildISBNSrc(cleanISBN(rec.isbn()))); + pic.setAttribute("src", buildISBNSrc(currentISBN)); var title_link = $n(r, config.names.result.item_title); var author_link = $n(r, config.names.result.item_author); @@ -550,6 +580,18 @@ function resultBuildFormatIcons( row, rec, is_mr ) { function resultPageIsDone(pos) { + + if (isbnList && googleBooks) { + var scriptElement = document.createElement("script"); + scriptElement.setAttribute("id", "jsonScript"); + scriptElement.setAttribute("src", + "http://books.google.com/books?bibkeys=" + + escape(isbnList) + "&jscmd=viewapi&callback=unhideGoogleBooks"); + scriptElement.setAttribute("type", "text/javascript"); + // make the request to Google Book Search + document.documentElement.firstChild.appendChild(scriptElement); + } + return (recordsHandled == getDisplayCount() || recordsHandled + getOffset() == getHitCount()); } diff --git a/Open-ILS/web/opac/skin/default/xml/result/result_table.xml b/Open-ILS/web/opac/skin/default/xml/result/result_table.xml index cd1137bcd0..ad90031c18 100644 --- a/Open-ILS/web/opac/skin/default/xml/result/result_table.xml +++ b/Open-ILS/web/opac/skin/default/xml/result/result_table.xml @@ -120,15 +120,21 @@ - &opac.holds.placeHold; - + + + + &result.googleBooks.browse; + + + -- 2.43.2