OL TOC cleanup
authorMichael Ang <mang@archive.org>
Tue, 5 Oct 2010 23:57:52 +0000 (23:57 +0000)
committerMichael Ang <mang@archive.org>
Tue, 5 Oct 2010 23:57:52 +0000 (23:57 +0000)
BookReader/BookReader.js
BookReaderIA/datanode/BookReaderJSIA.php

index e4fbf51..fb6231d 100644 (file)
@@ -265,17 +265,16 @@ BookReader.prototype.init = function() {
     this.updateFromParams(params);
     
     // Start AJAX request for OL data
-    this.getOpenLibraryJSON(this.gotOpenLibraryRecord);
-    
+    if (this.getOpenLibraryRecord) {
+        this.getOpenLibraryRecord(this.gotOpenLibraryRecord);
+    }
 }
 
-// XXXmang
-BookReader.prototype.gotOpenLibraryRecord = function(olObject) {
-    // console.log(olObject);
+BookReader.prototype.gotOpenLibraryRecord = function(self, olObject) {
+    // $$$ could refactor this so that 'this' is available
     if (olObject) {
         if (olObject['table_of_contents']) {
-            console.log('xxx updating table of contents');
-            br.updateTOC(olObject['table_of_contents']); // XXX
+            self.updateTOC(olObject['table_of_contents']);
         }
     }
 }
index 8b48238..5418573 100644 (file)
@@ -328,8 +328,8 @@ br.getEmbedCode = function() {
     return "<iframe src='" + this.getEmbedURL() + "' width='480px' height='430px'></iframe>";
 }
 
-// getOpenLibraryJSON
-br.getOpenLibraryJSON = function(callback) {
+// getOpenLibraryRecord
+br.getOpenLibraryRecord = function(callback) {
     // Try looking up by ocaid first, then by source_record
     
     var jsonURL = 'http://openlibrary.org/query.json?type=/type/edition&*=&ocaid=' + br.bookId;
@@ -337,16 +337,15 @@ br.getOpenLibraryJSON = function(callback) {
         url: jsonURL,
         success: function(data) {
             if (data && data.length > 0) {
-                callback(data[0]);
+                callback(br, data[0]);
             } else {
                 // try sourceid
-                console.log('XXXmang couldnt find via ocaid');
                 jsonURL = 'http://openlibrary.org/query.json?type=/type/edition&*=&source_records=ia:' + br.bookId;
                 $.ajax({
                     url: jsonURL,
                     success: function(data) {
                         if (data && data.length > 0) {
-                            callback(data[0]);
+                            callback(br, data[0]);
                         }
                     },
                     dataType: 'jsonp'