Merge branch 'newui' of https://github.com/rajbot/bookreader into raj-merge
authorMichael Ang <mang@archive.org>
Wed, 10 Nov 2010 20:51:58 +0000 (20:51 +0000)
committerMichael Ang <mang@archive.org>
Wed, 10 Nov 2010 20:51:58 +0000 (20:51 +0000)
1  2 
BookReaderIA/datanode/BookReaderJSIA.php

@@@ -358,52 -358,6 +358,52 @@@ br.getOpenLibraryRecord = function(call
      });
  }
  
 +// getInfoDiv
 +br.getInfoDiv = function() {
 +    // $$$ it might make more sense to have a URL on openlibrary.org that returns this info
 +
 +    var escapedTitle = BookReader.util.escapeHTML(this.bookTitle);
 +    var domainRe = /(\w+\.(com|org))/;
 +    var domain = domainRe.exec(this.bookUrl)[1];
 +    // XXX use different icon for archive.org
 +    var html = [
 +                '<div class="BRfloatCover">',
 +                    '<a href="', this.bookUrl, '"><img src="http://www.archive.org/download/', this.bookId, '/page/cover_t.jpg" alt="', escapedTitle, '" height="140"/></a>',
 +                '</div>',
 +                '<div class="BRfloatMeta">',
 +                    '<div class="BRfloatTitle">',
 +                        '<h2><a href="', this.bookUrl, '" class="title">', escapedTitle, '</a></h2>',
 +                        // $$$ lookup on OL
 +                        // 'by',
 +                        // '<a href="Open Library Author Page">Book Author</a>',
 +                    '</div>',
 +                    '<p>Published ', this.bookPublished,
 +                    //, <a href="Open Library Publisher Page">Publisher name</a>',
 +                    '</p>',
 +                    //'<p>Written in <a href="Open Library Language page">Language</a></p>',
 +                    '<h3>Other Formats</h3>',
 +                    '<ul class="links">',
 +                        '<li><a href="http://www.archive.org/download/', this.bookId, '/', this.subPrefix, '.pdf">PDF</a><span>|</span></li>',
 +                        '<li><a href="http://www.archive.org/download/', this.bookId, '/', this.subPrefix, '_djvu.txt">Plain Text</a><span>|</span></li>',
 +                        '<li><a href="http://www.archive.org/download/', this.bookId, '/', this.subPrefix, '_daisy.zip">DAISY</a><span>|</span></li>',
 +                        '<li><a href="http://www.archive.org/download/', this.bookId, '/', this.subPrefix, '.epub">ePub</a><span>|</span></li>',
 +                        '<li><a href="https://www.amazon.com/gp/digital/fiona/web-to-kindle?clientid=IA&itemid=', this.bookId, '&docid=', this.subPrefix, '">Send to Kindle</a><span>|</span></li>',
 +                        '<li><a href="', this.bookUrl, '">More...</a></li>',
 +                    '</ul>',
 +                    '<p class="moreInfo"><span></span>More information on <a href="'+ this.bookUrl + '">' + domain + '</a>.</p>',
 +                '</div>',
 +            '</div>',
 +            '<div class="BRfloatFoot">',
 +                // XXX add link to bug tracker
 +                '<a href="http://openlibrary.org/contact" class="problem">Report a problem</a>',
 +                '<span>|</span>',
 +                '<a href="http://openlibrary.org/dev/docs/bookreader">About the Bookreader</a>',
 +            '</div>'
 +    ];
 +    
 +    return html.join('\n');
 +}
 +
  br.pageW =  [
              <?
              $i=0;
@@@ -535,6 -489,7 +535,7 @@@ if (typeof(brConfig) != 'undefined') 
  
  function OLAuth() {
      this.authUrl = 'http://openlibrary.org/ia_auth/' + br.bookId;
+     this.olConnect = false;
      return this;
  }
  
@@@ -577,6 -532,7 +578,7 @@@ OLAuth.prototype.initCallback = functio
      
      //user is authenticated
      this.setCookie(obj.token);
+     this.olConnect = true;
      this.startPolling();    
      br.init();
  }
@@@ -587,6 -543,7 +589,7 @@@ OLAuth.prototype.callback = function(ob
          clearInterval(this.poller);
          this.ttsPoller = null;
      } else {
+         this.olConnect = true;
          this.setCookie(obj.token);
      }
  }
@@@ -604,7 -561,15 +607,15 @@@ OLAuth.prototype.setCookie = function(v
  OLAuth.prototype.startPolling = function () {    
      var self = this;
      this.poller=setInterval(function(){
-         $.ajax({url:self.authUrl, dataType:'jsonp', jsonpCallback:'olAuth.callback'});
+         if (!self.olConnect) {
+           self.showPopup("#f00", "#fff", 'Cound not connect to Open Library for authentication. Please check to see if you are still connected to the Internet, and then reload this web page.');
+           clearInterval(self.poller);
+           self.ttsPoller = null;        
+         } else {
+           self.olConnect = false;
+           //be sure to add random param to authUrl to avoid stale cache
+           $.ajax({url:self.authUrl+'?rand='+Math.random(), dataType:'jsonp', jsonpCallback:'olAuth.callback'});
+         }
      },300000);   
  }