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']);
}
}
}
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;
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'