Add "Return this book" under the book's title if it's a borrowed book
authorMichael Ang <mang@archive.org>
Fri, 14 Jan 2011 00:49:25 +0000 (00:49 +0000)
committerMichael Ang <mang@archive.org>
Fri, 14 Jan 2011 00:49:25 +0000 (00:49 +0000)
BookReader/BookReader.js
BookReaderIA/datanode/BookReaderJSIA.php

index 3529a60..db5581d 100644 (file)
@@ -4582,6 +4582,30 @@ BookReader.prototype.gotOpenLibraryRecord = function(self, olObject) {
         $('#BRinfo').remove();
         $('#BRshare').after(self.blankInfoDiv());
         self.buildInfoDiv($('#BRinfo'));
+        
+        // Check for borrowed book
+        if (this.olAuth) {
+            var returnUrl = self.olHost + olObject.key + '/do_return/borrow';
+            var borrowUrl = self.olHost + olObject.key + '/borrow';
+            
+            /*
+            $('<a/>')
+                .attr('href', borrowUrl)
+                .text('Return this book')
+                .click(function(event) {
+                    event.preventDefault();
+                    $('#BRreturnform').trigger('submit');
+                })
+                .appendTo('#BRreturn');
+            */
+            
+            $('#BRreturn').css({ 'line-height': '19px'} );
+            
+            $('<form id="BRreturnform" action="' + returnUrl + '" method="post"><input type="submit" value="Return book" /><input type="hidden" name="action" value="return" /></form>')
+                .appendTo('#BRreturn');
+
+        }
+        
     }
 }
 
index 842aa7f..e2b48ef 100644 (file)
@@ -531,6 +531,8 @@ foreach ($metaData->xpath('//collection') as $collection) {
     }
 }
 
+echo "br.olHost = 'http://openlibrary.org'\n";
+
 if ($useOLAuth) {
     echo "br.olAuth = true;\n";
 } else {
@@ -564,7 +566,7 @@ if (typeof(brConfig) != 'undefined') {
 
 
 function OLAuth() {
-    this.authUrl = 'http://openlibrary.org/ia_auth/' + br.bookId;
+    this.authUrl = br.olHost + '/ia_auth/' + br.bookId;
     this.olConnect = false;
     return this;
 }