From: rajbot Date: Wed, 10 Nov 2010 20:49:03 +0000 (+0000) Subject: Merge branch 'newui' of git@github.com:openlibrary/bookreader into newui X-Git-Url: http://git.rot13.org/?p=bookreader.git;a=commitdiff_plain;h=16035a78509d0ec1d023dd92ea90d45e69f7748e;hp=e4cbc11a7e4ceb1bbc20aad1bde377ac35faa95c Merge branch 'newui' of git@github.com:openlibrary/bookreader into newui --- diff --git a/BookReaderIA/datanode/BookReaderJSIA.php b/BookReaderIA/datanode/BookReaderJSIA.php index f894d23..016e988 100644 --- a/BookReaderIA/datanode/BookReaderJSIA.php +++ b/BookReaderIA/datanode/BookReaderJSIA.php @@ -535,6 +535,7 @@ if (typeof(brConfig) != 'undefined') { function OLAuth() { this.authUrl = 'http://openlibrary.org/ia_auth/' + br.bookId; + this.olConnect = false; return this; } @@ -577,6 +578,7 @@ OLAuth.prototype.initCallback = function(obj) { //user is authenticated this.setCookie(obj.token); + this.olConnect = true; this.startPolling(); br.init(); } @@ -587,6 +589,7 @@ OLAuth.prototype.callback = function(obj) { clearInterval(this.poller); this.ttsPoller = null; } else { + this.olConnect = true; this.setCookie(obj.token); } } @@ -604,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:'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); }