[open-ils-commits] r14226 - in trunk/Open-ILS/web/opac/skin: craftsman/xml default/js default/xml/common (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Sep 30 13:56:26 EDT 2009


Author: dbs
Date: 2009-09-30 13:56:22 -0400 (Wed, 30 Sep 2009)
New Revision: 14226

Modified:
   trunk/Open-ILS/web/opac/skin/craftsman/xml/page_rdetail.xml
   trunk/Open-ILS/web/opac/skin/default/js/rdetail.js
   trunk/Open-ILS/web/opac/skin/default/xml/common/js_common.xml
Log:
Move Google Book Preview calls in item details page to after page load

Speeds things up a bit and cleans up some custom DHTML with cleaner Dojo implementation


Modified: trunk/Open-ILS/web/opac/skin/craftsman/xml/page_rdetail.xml
===================================================================
--- trunk/Open-ILS/web/opac/skin/craftsman/xml/page_rdetail.xml	2009-09-30 17:30:14 UTC (rev 14225)
+++ trunk/Open-ILS/web/opac/skin/craftsman/xml/page_rdetail.xml	2009-09-30 17:56:22 UTC (rev 14226)
@@ -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 = {};

Modified: trunk/Open-ILS/web/opac/skin/default/js/rdetail.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/rdetail.js	2009-09-30 17:30:14 UTC (rev 14225)
+++ trunk/Open-ILS/web/opac/skin/default/js/rdetail.js	2009-09-30 17:56:22 UTC (rev 14226)
@@ -968,39 +968,24 @@
 }
 
 /**
- * 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 @@
  *
  * 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");

Modified: trunk/Open-ILS/web/opac/skin/default/xml/common/js_common.xml
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/xml/common/js_common.xml	2009-09-30 17:30:14 UTC (rev 14225)
+++ trunk/Open-ILS/web/opac/skin/default/xml/common/js_common.xml	2009-09-30 17:56:22 UTC (rev 14226)
@@ -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'>



More information about the open-ils-commits mailing list