X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=BookReaderIA%2Fdatanode%2FBookReaderJSIA.php;h=af5c795e65cad16172b2f8ed634de6335effda2a;hb=1b335ac642e4eb1fb808b17e940f112f8bb2bdba;hp=f894d234190e3e0fd47174938cded7268c59c354;hpb=e4cbc11a7e4ceb1bbc20aad1bde377ac35faa95c;p=bookreader.git diff --git a/BookReaderIA/datanode/BookReaderJSIA.php b/BookReaderIA/datanode/BookReaderJSIA.php index f894d23..af5c795 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; } @@ -327,7 +330,7 @@ br.getEmbedURL = function() { //________ // Returns the embed code HTML fragment suitable for copy and paste br.getEmbedCode = function() { - return ""; + return ""; } // getOpenLibraryRecord @@ -358,28 +361,23 @@ br.getOpenLibraryRecord = function(callback) { }); } -// getInfoDiv -br.getInfoDiv = function() { +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]; - // XXX use different icon for archive.org - var html = [ - '
', - '', escapedTitle, '', - '
', - '
', - '
', - '

', escapedTitle, '

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

Published ', this.bookPublished, + + // $$$ 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 + '.

', - '
', - '', - '
', - // XXX add link to bug tracker + '

More information on ' + domain + '

'].join('\n')); + + jInfoDiv.find('.BRfloatFoot').append([ + '|', 'Report a problem', - '|', - 'About the Bookreader', - '
' - ]; + ].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 } + ); + } - return html.join('\n'); + jInfoDiv.find('.BRfloatTitle a').attr({'href': this.bookUrl, 'alt': this.bookTitle}).text(this.bookTitle); + var bookPath = (window.location + '').replace('#','%23'); + jInfoDiv.find('a.problem').attr('href','http://openlibrary.org/contact?path=' + bookPath); + } br.pageW = [ @@ -518,23 +520,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; } @@ -543,7 +536,7 @@ OLAuth.prototype.init = function() { htmlStr += '

Please wait...

'; this.showPopup("#ddd", "#000", htmlStr); - $.ajax({url:this.authUrl, dataType:'jsonp', jsonpCallback:'olAuth.initCallback'}); + $.ajax({url:this.authUrl + '?rand='+Math.random(), dataType:'jsonp', jsonpCallback:'olAuth.initCallback'}); } OLAuth.prototype.showPopup = function(bgColor, textColor, msg) { @@ -577,6 +570,7 @@ OLAuth.prototype.initCallback = function(obj) { //user is authenticated this.setCookie(obj.token); + this.olConnect = true; this.startPolling(); br.init(); } @@ -587,6 +581,7 @@ OLAuth.prototype.callback = function(obj) { clearInterval(this.poller); this.ttsPoller = null; } else { + this.olConnect = true; this.setCookie(obj.token); } } @@ -604,7 +599,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); }