X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=BookReaderIA%2Fdatanode%2FBookReaderJSIA.php;h=016e988a581c37273ee841f3347a29d070656c59;hb=16035a78509d0ec1d023dd92ea90d45e69f7748e;hp=c30222a986bec41a6e66234ea2d582fb6b5c04d7;hpb=a6ada111482d1b9d1805d5de95ea5e5364d222be;p=bookreader.git diff --git a/BookReaderIA/datanode/BookReaderJSIA.php b/BookReaderIA/datanode/BookReaderJSIA.php index c30222a..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 = [ + '
', + '', escapedTitle, '', + '
', + '
', + '
', + '

', escapedTitle, '

', + // $$$ lookup on OL + // 'by', + // 'Book Author', + '
', + '

Published ', this.bookPublished, + //, Publisher name', + '

', + //'

Written in Language

', + '

Other Formats

', + '', + '

More information on ' + domain + '.

', + '
', + '', + '
', + // XXX add link to bug tracker + 'Report a problem', + '|', + 'About the Bookreader', + '
' + ]; + + return html.join('\n'); +} + br.pageW = [ {'page-progression'}) { echo "br.pageProgression = 'lr';\n"; } -if ('browserlending' == $metaData->{'collection'}) { +$useOLAuth = false; +foreach ($metaData->xpath('//collection') as $collection) { + if('browserlending' == $collection) { + $useOLAuth = true; + } +} + +if ($useOLAuth) { echo "br.olAuth = true;\n"; } else { - echo "br.olAuth = false; //" . $metaData->{'collection'} ."\n"; + echo "br.olAuth = false;\n"; } # Special cases @@ -481,10 +534,8 @@ if (typeof(brConfig) != 'undefined') { function OLAuth() { - //this.authUrl = 'http://home.us.archive.org/~rkumar/olauth.php?id=' + br.bookId; - // XXXmang update to production - this.authUrl = 'http://ol-mang:8080/ia_auth/' + br.bookId; - //this.authUrl = 'http://openlibrary.org/ia_auth/' + br.bookId; + this.authUrl = 'http://openlibrary.org/ia_auth/' + br.bookId; + this.olConnect = false; return this; } @@ -527,6 +578,7 @@ OLAuth.prototype.initCallback = function(obj) { //user is authenticated this.setCookie(obj.token); + this.olConnect = true; this.startPolling(); br.init(); } @@ -537,6 +589,7 @@ OLAuth.prototype.callback = function(obj) { clearInterval(this.poller); this.ttsPoller = null; } else { + this.olConnect = true; this.setCookie(obj.token); } } @@ -554,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); }