From: Michael Ang Date: Tue, 5 Oct 2010 23:57:52 +0000 (+0000) Subject: OL TOC cleanup X-Git-Url: http://git.rot13.org/?p=bookreader.git;a=commitdiff_plain;h=e4e84956241e29ae24513cc6cf212aa21c3dd9d6 OL TOC cleanup --- diff --git a/BookReader/BookReader.js b/BookReader/BookReader.js index e4fbf51..fb6231d 100644 --- a/BookReader/BookReader.js +++ b/BookReader/BookReader.js @@ -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']); } } } diff --git a/BookReaderIA/datanode/BookReaderJSIA.php b/BookReaderIA/datanode/BookReaderJSIA.php index 8b48238..5418573 100644 --- a/BookReaderIA/datanode/BookReaderJSIA.php +++ b/BookReaderIA/datanode/BookReaderJSIA.php @@ -328,8 +328,8 @@ br.getEmbedCode = function() { return ""; } -// 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'