Move Google Book Preview calls in item details page to after page load
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Sep 2009 17:56:22 +0000 (17:56 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Sep 2009 17:56:22 +0000 (17:56 +0000)
Speeds things up a bit and cleans up some custom DHTML with cleaner Dojo implementation

git-svn-id: svn://svn.open-ils.org/ILS/trunk@14226 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/skin/craftsman/xml/page_rdetail.xml
Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/xml/common/js_common.xml

index b07c283..f9731fb 100644 (file)
@@ -6,8 +6,6 @@
        <script language='javascript' type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/holds.js'></script>
        <script language='javascript' type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/cn_browse.js'></script>
        <script language='javascript' type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/container.js'></script>
-       <script src='http://www.google.com/jsapi' type='text/javascript' language='javascript'></script>
-       <script type='text/javascript' src='http://books.google.com/books/api.js?key=notsupplied&amp;v=0&amp;callback=google.loader.callbacks.books'></script>
 
        <script language='javascript' type='text/javascript'>
                config.ids.rdetail = {};
index 66df723..2850235 100644 (file)
@@ -968,39 +968,24 @@ function _rdetailSortStatuses(a, b) {
 }
 
 /**
- * Check for a Google Book preview 
+ * Check for a Google Book preview after the main page loads
  */
 function rdetailCheckForGBPreview() {
        if (!rdetailGoogleBookPreview) return;
-       searchForGBPreview( cleanISBN(record.isbn()) );
+        dojo.addOnLoad(function() {
+               searchForGBPreview( cleanISBN(record.isbn()) );
+       });
 }
 
 /**
  *
- * @param {DOM object} query The form element containing the
- *                     input parameters "isbns"
+ * @param {DOM object} isbn The form element containing the input parameters "isbns"
  */
 function searchForGBPreview( isbn ) {
-
-       // Delete any previous Google Booksearch JSON queries.
-       var GBPJsonScript = document.getElementById("GBPJsonScript");
-       if (GBPJsonScript) {
-               GBPJsonScript.parentNode.removeChild(GBPJsonScript);
-       }
-
-       // Add a script element with the src as the user's Google Booksearch query. 
-       // JSON output is specified by including the alt=json-in-script argument
-       // and the callback function is also specified as a URI argument.
-       var GBPScriptElement = document.createElement("script");
-
-       GBPScriptElement.setAttribute("id", "GBPJsonScript");
-       GBPScriptElement.setAttribute("src",
-                       "http://books.google.com/books?bibkeys=" + 
-                       isbn + "&jscmd=viewapi&callback=GBPreviewCallback");
-       GBPScriptElement.setAttribute("type", "text/javascript");
-
-       // make the request to Google booksearch
-       document.documentElement.firstChild.appendChild(GBPScriptElement);
+       dojo.require("dojo.io.script");
+       dojo.io.script.get({"url": "https://www.google.com/jsapi"});
+       dojo.io.script.get({"url": "http://books.google.com/books/api.js", "content": {"key": "notsupplied", "callback": "google.loader.callbacks.books"}});
+       dojo.io.script.get({"url": "http://books.google.com/books", "content": { "bibkeys": isbn, "jscmd": "viewapi", "callback": "GBPreviewCallback"}});
 }
 
 /**
@@ -1009,7 +994,7 @@ function searchForGBPreview( isbn ) {
  *
  * XXX I18N of text needed
  *
- * @param {JSON} booksInfo is the JSON object pulled from the Google books service.
+ * @param {JSON} GBPBookInfo is the JSON object pulled from the Google books service.
  */
 function GBPreviewCallback(GBPBookInfo) {
        var GBPreviewDiv = document.getElementById("rdetail_preview_div");
index 542faa1..884a423 100644 (file)
@@ -16,7 +16,6 @@
        <script language='javascript' src='<!--#echo var="OILS_JS_BASE"-->/RemoteRequest.js' type='text/javascript'></script>
        <script language='javascript' src='<!--#echo var="OILS_JS_BASE"-->/init.js' type='text/javascript'></script>
        <script language='javascript' src='<!--#echo var="OILS_JS_BASE"-->/added_content.js' type='text/javascript'></script>
-       <script src='https://www.google.com/jsapi' type='text/javascript' language='javascript'></script>
 
        <!-- Some global js -->
        <script language='javascript' type='text/javascript'>