X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=BookReaderIA%2Fdatanode%2FBookReaderJSIA.php;h=016e988a581c37273ee841f3347a29d070656c59;hb=0afd0adfdd1c1f29f61351a5bdfc03a06bdfe38d;hp=55436a1066f458315a38dee8736ee66c8f33227b;hpb=0a80175ec8aa59d62021557e9ed63ccaa364d77a;p=bookreader.git diff --git a/BookReaderIA/datanode/BookReaderJSIA.php b/BookReaderIA/datanode/BookReaderJSIA.php index 55436a1..016e988 100644 --- a/BookReaderIA/datanode/BookReaderJSIA.php +++ b/BookReaderIA/datanode/BookReaderJSIA.php @@ -358,6 +358,52 @@ br.getOpenLibraryRecord = function(callback) { }); } +// 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 = [ + '
', + 'Published ', this.bookPublished, + //, Publisher name', + '
', + //'Written in Language
', + 'More information on ' + domain + '.
', + 'Please wait...
'; this.showPopup("#ddd", "#000", htmlStr); - $.ajax({url:this.authUrl, dataType:'jsonp', jsonpCallback:'initCallback'}); + $.ajax({url:this.authUrl, dataType:'jsonp', jsonpCallback:'olAuth.initCallback'}); } OLAuth.prototype.showPopup = function(bgColor, textColor, msg) { @@ -524,6 +578,7 @@ OLAuth.prototype.initCallback = function(obj) { //user is authenticated this.setCookie(obj.token); + this.olConnect = true; this.startPolling(); br.init(); } @@ -534,6 +589,7 @@ OLAuth.prototype.callback = function(obj) { clearInterval(this.poller); this.ttsPoller = null; } else { + this.olConnect = true; this.setCookie(obj.token); } } @@ -551,7 +607,15 @@ OLAuth.prototype.setCookie = function(value) { OLAuth.prototype.startPolling = function () { var self = this; this.poller=setInterval(function(){ - $.ajax({url:self.authUrl, dataType:'jsonp', jsonpCallback:'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); }