2 // This file shows the minimum you need to provide to BookReader to display a book
4 // Copyright(c)2008-2009 Internet Archive. Software license AGPL version 3.
6 // Create the BookReader object
9 // Return the width of a given page. Here we assume all images are 800 pixels wide
10 br.getPageWidth = function(index) {
14 // Return the height of a given page. Here we assume all images are 1200 pixels high
15 br.getPageHeight = function(index) {
19 // We load the images from archive.org -- you can modify this function to retrieve images
20 // using a different URL structure
21 br.getPageURI = function(index, reduce, rotate) {
22 // reduce and rotate are ignored in this simple implementation, but we
23 // could e.g. look at reduce and load images from a different directory
24 // or pass the information to an image server
26 var imgStr = (index+1).toString();
27 var re = new RegExp("0{"+imgStr.length+"}$");
28 var url = 'http://www.archive.org/download/BookReader/img/page'+leafStr.replace(re, imgStr) + '.jpg';
32 // Return which side, left or right, that a given page should be displayed on
33 br.getPageSide = function(index) {
34 if (0 == (index & 0x1)) {
41 // This function returns the left and right indices for the user-visible
42 // spread that contains the given index. The return values may be
43 // null if there is no facing page or the index is invalid.
44 br.getSpreadIndices = function(pindex) {
45 var spreadIndices = [null, null];
46 if ('rl' == this.pageProgression) {
48 if (this.getPageSide(pindex) == 'R') {
49 spreadIndices[1] = pindex;
50 spreadIndices[0] = pindex + 1;
52 // Given index was LHS
53 spreadIndices[0] = pindex;
54 spreadIndices[1] = pindex - 1;
58 if (this.getPageSide(pindex) == 'L') {
59 spreadIndices[0] = pindex;
60 spreadIndices[1] = pindex + 1;
62 // Given index was RHS
63 spreadIndices[1] = pindex;
64 spreadIndices[0] = pindex - 1;
71 // For a given "accessible page index" return the page number in the book.
73 // For example, index 5 might correspond to "Page 1" if there is front matter such
74 // as a title page and table of contents.
75 br.getPageNum = function(index) {
79 // Total number of leafs
82 // Book title and the URL used for the book title link
83 br.bookTitle= 'Open Library BookReader Presentation';
84 br.bookUrl = 'http://openlibrary.org';
86 // Override the path used to find UI images
87 br.imagesBaseURL = '../BookReader/images/';
89 br.getEmbedCode = function(frameWidth, frameHeight, viewParams) {
90 return "Embed code not supported in bookreader demo.";
96 // read-aloud and search need backend compenents and are not supported in the demo
97 $('#BRtoolbar').find('.read').hide();
98 $('#textSrch').hide();