forked from ajstanley/islandora_bookviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainpage.php
executable file
·221 lines (189 loc) · 8.59 KB
/
mainpage.php
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Islandora Reader</title>
<link rel="stylesheet" type="text/css" href="css/BookReader.css"/>
<!-- Custom CSS overrides -->
<link rel="stylesheet" type="text/css" href="css/BookReaderDemo.css"/>
<link rel="stylesheet" type="text/css" href="css/mods2html.css"/>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.5.custom.min.js"></script>
<script type="text/javascript" src="js/dragscrollable.js"></script>
<script type="text/javascript" src="js/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="js/jquery.ui.ipad.js"></script>
<script type="text/javascript" src="js/jquery.bt.min.js"></script>
<script type="text/javascript" src="js/BookReader.js"></script>
<script type="text/javascript" src="js/islandora_loader.js"></script>
</head>
<body style="background-color: #939598;">
<div id="BookReader" style="left:10px; right:10px; top:10px; bottom:2em;">Loading Bookreader, please wait...</div>
<script type="text/javascript">
//
// This file shows the minimum you need to provide to BookReader to display a book
//
// Copyright(c)2008-2009 Internet Archive. Software license AGPL version 3.
// Create the BookReader object
br = new BookReader();
br.structMap = new Array();
br.djatoka_prefix = islandora_params.DJATOKA_PREFIX;
br.islandora_prefix = islandora_params.ISLANDORA_PREFIX;
br.fedora_prefix = islandora_params.FEDORA_PREFIX;
br.width = parseInt(islandora_params.page_width);
br.height = parseInt(islandora_params.page_height);
br.pageProgression = islandora_params.page_progression;
br.structMap = islandora_params.book_pids;
br.compression = islandora_params.COMPRESSION;
br.baseUrl = islandora_params.base_url;
br.module_path = islandora_params.module_path;
br.getPageWidth = function(index) {
return br.width;
}
// Return the height of a given page.
br.getPageHeight = function(index) {
return br.height;
}
// We load the images from fedora
// using a different URL structure
br.getPageURI = function(index, reduce, rotate) {
// reduce and rotate are ignored in this simple implementation, but we
// could e.g. look at reduce and load images from a different directory
// or pass the information to an image server
var leafStr = br.structMap[index+1];//get the pid of the object from the struct map islandora specific
// var url = br.djatoka_prefix + br.islandora_prefix + leafStr + '/JP2/&svc_id=info:lanl-repo/svc/getRegion&svc_val_fmt=info:ofi/fmt:kev:mtx:jpeg2000&svc.format=image/png&svc.level=' + br.compression + '&svc.rotate=0';
var url = br.djatoka_prefix + br.fedora_prefix + '/objects/' + leafStr + '/datastreams/' + islandora_params.image_type + '/content&svc_id=info:lanl-repo/svc/getRegion&svc_val_fmt=info:ofi/fmt:kev:mtx:jpeg2000&svc.format=image/png&svc.level=' + br.compression + '&svc.rotate=0';
if(islandora_params.image_type == "JPEG"){
url = islandora_params.ISLANDORA_PREFIX + leafStr + '/JPEG';
}
return url;
}
br.getOcrURI = function (index){
var indices = br.getSpreadIndices(index);
var pidL = br.structMap[indices[0]]; // pid for left page
var pidR = br.structMap[indices[1]]; // pid for right page
if (typeof pidL == 'undefined') { pidL = '-'; }
if (typeof pidR == 'undefined') { pidR = '-'; }
return br.baseUrl+"/bookreader/ocr/" + pidL + '/' + pidR ;
}
br.getModsURI = function(index) {
//var leafStr = br.structMap[index+1];//get the pid of the object from the struct map islandora specific
//return br.islandora_prefix + leafStr + "/MODS";
//return "/mods2html/" + leafStr;
var indices = br.getSpreadIndices(index);
var pidL = br.structMap[indices[0]+1]; // pid for left page
var pidR = br.structMap[indices[1]+1]; // pid for right page
if (typeof pidL == 'undefined') { pidL = '-'; }
if (typeof pidR == 'undefined') { pidR = '-'; }
return br.baseUrl+"/mods2html/" + br.bookPid ;
}
br.getPid = function (index) {
var leafStr = br.structMap[index+1];//get the pid of the object from the struct map islandora specific
return leafStr;
}
// Return which side, left or right, that a given page should be displayed on
br.getPageSide = function(index) {
//$vals = ["R", "L"];
//return $vals[index & 0x1];
return br.pageProgression.toUpperCase()[1-(index & 0x1)]
}
// 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) {
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;
}
}
return spreadIndices;
}
br.search = function(term) {
var url = br.baseUrl + "/ocrsearch/" + br.bookPid + "/" + escape(term)
term = term.replace(/\//g, ' '); // strip slashes, since this goes in the url
this.searchTerm = term;
this.removeSearchResults();
this.showProgressPopup('<img id="searchmarker" src="'+this.imagesBaseURL + 'marker_srch-on.png'+'"> Search results will appear below...');
$.ajax({url:url, dataType:'json',
success: function(data, status, xhr) {
br.BRSearchCallback(data);
},
error: function() {
alert("Search call to " + url + " failed");
}
});
}
// For a given "accessible page index" return the page number in the book.
//
// For example, index 5 might correspond to "Page 1" if there is front matter such
// as a title page and table of contents.
// for now we just show the image number
br.getPageNum = function(index) {
return index+1;
}
br.leafNumToIndex = function(index) {
return index-1;
}
// Total number of leafs
br.numLeafs = islandora_params.page_count;
// Book title and the URL used for the book title link
br.bookTitle = islandora_params.label;
if (br.bookTitle.length > 100){
br.bookTitle = br.bookTitle.substring(0,97)+'...';
}
// book url should be created dynamically
br.bookUrl = br.islandora_prefix + PID;
br.bookPid = PID;
// Override the path used to find UI images
br.imagesBaseURL = 'images/';
br.logoURL = ""; //don't want to go to LOC so init it empty, the title already takes us back to the book
br.getEmbedCode = function(frameWidth, frameHeight, viewParams) {
return "Embed code not supported in bookreader demo.";
}
function getURLParam(name) {
// get query string part of url into its own variable
var url = window.location.href;
var query_string = url.split("?");
// make array of all name/value pairs in query string
var params = query_string[1].split(/\&|#/);
// loop through the parameters
var i = 0;
while (params.length > i) {
// compare param name against arg passed in
var param_item = params[i].split("=");
if (param_item[0] == name) {
// if they match, return the value
return param_item[1];
}
i++;
}
return "";
}
var query = getURLParam("solrq");
if (query != "") {
br.search(query);
}
// Let's go!
br.init();
// read-aloud and search need backend compenents and are not supported in the demo
$('#BRtoolbar').find('.read').hide();
//$('#textSrch').hide();
$('#btnSrch').hide();
</script>
</body>
</html>