X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=BookReaderIA%2Fdatanode%2FBookReaderJSIA.php;h=0f7b6bf00d4916d6d96d82903d297586484c4b92;hb=9b78fb72adadda83576c133dfc52423d3ea65f1c;hp=5fb5234c7b9b9df1b31af410866bafb5c38fc962;hpb=dfd68d79fe2b8936863572289fd5c347ec23077c;p=bookreader.git diff --git a/BookReaderIA/datanode/BookReaderJSIA.php b/BookReaderIA/datanode/BookReaderJSIA.php index 5fb5234..0f7b6bf 100644 --- a/BookReaderIA/datanode/BookReaderJSIA.php +++ b/BookReaderIA/datanode/BookReaderJSIA.php @@ -313,13 +313,16 @@ br.cleanupMetadata = function() { // getEmbedURL //________ // Returns a URL for an embedded version of the current book -br.getEmbedURL = function() { +br.getEmbedURL = function(viewParams) { // We could generate a URL hash fragment here but for now we just leave at defaults var url = 'http://' + window.location.host + '/stream/'+this.bookId; if (this.subPrefix != this.bookId) { // Only include if needed url += '/' + this.subPrefix; } url += '?ui=embed'; + if (viewParams) { + url += '#' + this.fragmentFromParams(viewParams); + } return url; } @@ -358,6 +361,50 @@ br.getOpenLibraryRecord = function(callback) { }); } +br.buildInfoDiv = function(jInfoDiv) { + // $$$ 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]; + + // $$$ cover looks weird before it loads + jInfoDiv.find('.BRfloatCover').append([ + '' + escapedTitle + ''].join('') + ); + + jInfoDiv.find('.BRfloatMeta').append([ + // $$$ description + //'

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

', + //'

Written in Language

', + '

Other Formats

', + '', + '

More information on ' + domain + '

'].join('\n')); + + jInfoDiv.find('.BRfloatFoot').append([ + '|', + 'Report a problem', + ].join('\n')); + + if (domain == 'archive.org') { + jInfoDiv.find('.BRfloatMeta p.moreInfo span').css( + {'background': 'url(http://www.archive.org/favicon.ico) no-repeat', 'width': 22, 'height': 18 } + ); + } + + jInfoDiv.find('.BRfloatTitle a').attr({'href': this.bookUrl, 'alt': this.bookTitle}).text(this.bookTitle); + +} + 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 @@ -465,23 +519,14 @@ if (typeof(brConfig) != 'undefined') { br.reduce = brConfig['reduce']; } } else if (brConfig['mode'] == 2) { - br.mode = 2; - - + br.mode = 2; } } // brConfig function OLAuth() { this.authUrl = 'http://openlibrary.org/ia_auth/' + br.bookId; + this.olConnect = false; return this; } @@ -524,6 +569,7 @@ OLAuth.prototype.initCallback = function(obj) { //user is authenticated this.setCookie(obj.token); + this.olConnect = true; this.startPolling(); br.init(); } @@ -534,6 +580,7 @@ OLAuth.prototype.callback = function(obj) { clearInterval(this.poller); this.ttsPoller = null; } else { + this.olConnect = true; this.setCookie(obj.token); } } @@ -551,7 +598,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); }