br = new BookReader(); br.titleLeaf = 7; br.getPageWidth = function(index) { return this.pageW[index]; } br.getPageHeight = function(index) { return this.pageH[index]; } // Returns true if page image is available rotated br.canRotatePage = function(index) { return 'jp2' == this.imageFormat; // Assume single format for now } // reduce defaults to 1 (no reduction) // rotate defaults to 0 (no rotation) br.getPageURI = function(index, reduce, rotate) { var _reduce; var _rotate; if ('undefined' == typeof(reduce)) { _reduce = 1; } else { _reduce = reduce; } if ('undefined' == typeof(rotate)) { _rotate = 0; } else { _rotate = rotate; } var file = this._getPageFile(index); // $$$ add more image stack formats here return 'http://'+this.server+'/BookReader/BookReaderImages.php?zip='+this.zip+'&file='+file+'&scale='+_reduce+'&rotate='+_rotate; } br._getPageFile = function(index) { var leafStr = '0000'; var imgStr = this.leafMap[index].toString(); var re = new RegExp("0{"+imgStr.length+"}$"); var insideZipPrefix = this.subPrefix.match('[^/]+$'); var file = insideZipPrefix + '_' + this.imageFormat + '/' + insideZipPrefix + '_' + leafStr.replace(re, imgStr) + '.' + this.imageFormat; return file; } br.getPageSide = function(index) { //assume the book starts with a cover (right-hand leaf) //we should really get handside from scandata.xml // $$$ we should get this from scandata instead of assuming the accessible // leafs are contiguous if ('rl' != this.pageProgression) { // If pageProgression is not set RTL we assume it is LTR if (0 == (index & 0x1)) { // Even-numbered page return 'R'; } else { // Odd-numbered page return 'L'; } } else { // RTL if (0 == (index & 0x1)) { return 'L'; } else { return 'R'; } } } br.getPageNum = function(index) { var pageNum = this.pageNums[index]; if (pageNum) { return pageNum; } else { return 'n' + index; } } // Single images in the Internet Archive scandata.xml metadata are (somewhat incorrectly) // given a "leaf" number. Some of these images from the scanning process should not // be displayed in the BookReader (for example colour calibration cards). Since some // of the scanned images will not be displayed in the BookReader (those marked with // addToAccessFormats false in the scandata.xml) leaf numbers and BookReader page // indexes are generally not the same. This function returns the BookReader page // index given a scanned leaf number. // // This function is used, for example, to map between search results (that use the // leaf numbers) and the displayed pages in the BookReader. br.leafNumToIndex = function(leafNum) { for (var index = 0; index < this.leafMap.length; index++) { if (this.leafMap[index] == leafNum) { return index; } } return null; } // This function returns the left and right indices for the user-visible // spread that contains the given index. The return values may be // null if there is no facing page or the index is invalid. br.getSpreadIndices = function(pindex) { // $$$ we could make a separate function for the RTL case and // only bind it if necessary instead of always checking // $$$ we currently assume there are no gaps var spreadIndices = [null, null]; if ('rl' == this.pageProgression) { // Right to Left if (this.getPageSide(pindex) == 'R') { spreadIndices[1] = pindex; spreadIndices[0] = pindex + 1; } else { // Given index was LHS spreadIndices[0] = pindex; spreadIndices[1] = pindex - 1; } } else { // Left to right if (this.getPageSide(pindex) == 'L') { spreadIndices[0] = pindex; spreadIndices[1] = pindex + 1; } else { // Given index was RHS spreadIndices[1] = pindex; spreadIndices[0] = pindex - 1; } } //console.log(" index %d mapped to spread %d,%d", pindex, spreadIndices[0], spreadIndices[1]); return spreadIndices; } // Remove the page number assertions for all but the highest index page with // a given assertion. Ensures there is only a single page "{pagenum}" // e.g. the last page asserted as page 5 retains that assertion. br.uniquifyPageNums = function() { var seen = {}; for (var i = br.pageNums.length - 1; i--; i >= 0) { var pageNum = br.pageNums[i]; if ( !seen[pageNum] ) { seen[pageNum] = true; } else { br.pageNums[i] = null; } } } br.cleanupMetadata = function() { br.uniquifyPageNums(); } // getEmbedURL //________ // Returns a URL for an embedded version of the current book br.getEmbedURL = function() { // 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'; return url; } // getEmbedCode //________ // Returns the embed code HTML fragment suitable for copy and paste br.getEmbedCode = function() { return ""; } br.pageW = [ 2196.0,2072.0,2072.0,1942.0,1942.0,2158.0,2158.0,2158.0,2158.0,2158.0,2158.0,2158.0,2158.0,2158.0,2158.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2034.0,2034.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2118.0,2112.0,2112.0,2112.0,2112.0,2080.0,2080.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2046.0,2008.0,2008.0,2008.0,2008.0,2008.0,2008.0,2008.0,2008.0,2008.0,2008.0,1930.0,1930.0,1930.0,1930.0,2060.0 ]; br.pageH = [ 3796.0,3528.0,3528.0,3528.0,3528.0,3510.0,3510.0,3510.0,3510.0,3510.0,3510.0,3510.0,3510.0,3510.0,3510.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3562.0,3562.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3580.0,3574.0,3574.0,3574.0,3574.0,3562.0,3562.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3568.0,3588.0,3588.0,3542.0,3542.0,3542.0,3542.0,3542.0,3542.0,3542.0,3542.0,3496.0,3496.0,3496.0,3496.0,3606.0 ]; br.leafMap = [ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222 ]; br.pageNums = [ null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,'10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84',null,'2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','96','97','98','99','100','101','102','103','104','105','106','107','108','109','110','111','112','113','114','115','116','117','118',null,null,'4','5','6','7','8','9',null,null,null,null,null,null ]; br.numLeafs = br.pageW.length; br.bookId = 'keytosolarcompas00burtrich'; br.zip = '/15/items/keytosolarcompas00burtrich/keytosolarcompas00burtrich_jp2.zip'; br.subPrefix = 'keytosolarcompas00burtrich'; br.server = 'ia700108.us.archive.org'; br.bookTitle= 'A key to the solar compass, and surveyor\'s companion : comprising all the rules necessary for use in the field. Also, description of the linear surveys, and public land system of the United States; notes on the barometer, suggestions for an outfit for a survey of four months, etc., etc.'; br.bookPath = '/15/items/keytosolarcompas00burtrich/keytosolarcompas00burtrich'; br.bookUrl = 'http://www.archive.org/details/keytosolarcompas00burtrich'; br.imageFormat = 'jp2'; br.archiveFormat = 'zip'; br.pageProgression = 'lr'; // Check for config object // $$$ change this to use the newer params object if (typeof(brConfig) != 'undefined') { if (typeof(brConfig["ui"]) != 'undefined') { br.ui = brConfig["ui"]; } if (brConfig['mode'] == 1) { br.mode = 1; if (typeof(brConfig['reduce'] != 'undefined')) { br.reduce = brConfig['reduce']; } } else if (brConfig['mode'] == 2) { br.mode = 2; } } // brConfig br.cleanupMetadata(); br.init();