20
|
1 /* navigation_ie -- JS library for digilib (IE version)
|
|
2
|
|
3 Digital Image Library servlet components
|
|
4
|
|
5 Copyright (C) 2001, 2002 Christian Luginbuehl (luginbuehl@student.unibe.ch)
|
|
6
|
|
7 This program is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2 of the License, or (at your
|
|
10 option) any later version.
|
|
11
|
|
12 Please read license.txt for the full details. A copy of the GPL
|
|
13 may be found at http://www.gnu.org/copyleft/lgpl.html
|
|
14
|
|
15 You should have received a copy of the GNU General Public License
|
|
16 along with this program; if not, write to the Free Software
|
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
|
19 */
|
|
20
|
|
21 // these two global variables have to be initialised before the frist use of the functions below
|
|
22 // to fill in the attributes you can use the function initPicture provided below
|
|
23 // - array with all attributes
|
|
24 var att = new Array();
|
|
25
|
|
26 // - variable to store the path to the frame, in which the pictures should be created
|
|
27 var whichFrame = parent.mainFrame;
|
|
28
|
|
29 // give a name to the window containing digilib - this way one can test if there is already a
|
|
30 // digilib-window open and replace the contents of it (ex. digicat)
|
|
31 window.name = "digilib";
|
|
32
|
|
33 // function that launches the ScaleServlet
|
|
34 // the different detailGrades:
|
|
35 // 0 -> back, next, page
|
|
36 // 1 -> zoomout
|
|
37 // 2 -> zoomarea, zoompoint, moveto, scaledef
|
|
38
|
|
39 function loadPicture(detailGrade, keepArea) {
|
|
40
|
|
41 // alert("wx: " + att[5] + "\tww: " + att[7] + "\nwy: " + att[6] + "\twh: " + att[8]);
|
|
42
|
|
43 // sorry about that, but IE needs to have a document body to calc the frames width and height
|
|
44 whichFrame.document.open();
|
|
45 whichFrame.document.write('<html><head></head><body bgcolor="#666666" topmargin="10" leftmargin="10" marginwidth="10" magrinheight="10">');
|
|
46
|
|
47 var newPicture = "http://" + location.host + "/docuserver/digitallibrary/servlet/Scaler/"
|
|
48 newPicture += att[0] + "?" + "pn=" + att[1] + "&ws=" + att[2];
|
|
49 newPicture += "&dw=" + (whichFrame.document.body.clientWidth-30) + "&dh=" + (whichFrame.document.body.clientHeight-30);
|
|
50 newPicture += "&mo=" + att[3];
|
|
51
|
|
52 if (detailGrade == 0) {
|
|
53 att[4] = "0/0";
|
|
54 }
|
|
55
|
|
56 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) {
|
|
57 att[5] = 0;
|
|
58 att[6] = 0;
|
|
59 att[7] = 1;
|
|
60 att[8] = 1;
|
|
61 }
|
|
62 newPicture += "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8];
|
|
63
|
|
64 whichFrame.document.write('<div ID="lay1" style="position:absolute; left:10; top:10; visibility:visible"><img name="pic" src="' + newPicture + '"></div>');
|
|
65 whichFrame.document.write('<div ID="dot0" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark1.gif"></div>');
|
|
66 whichFrame.document.write('<div ID="dot1" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark2.gif"></div>');
|
|
67 whichFrame.document.write('<div ID="dot2" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark3.gif"></div>');
|
|
68 whichFrame.document.write('<div ID="dot3" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark4.gif"></div>');
|
|
69 whichFrame.document.write('<div ID="dot4" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark5.gif"></div>');
|
|
70 whichFrame.document.write('<div ID="dot5" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark6.gif"></div>');
|
|
71 whichFrame.document.write('<div ID="dot6" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark7.gif"></div>');
|
|
72 whichFrame.document.write('<div ID="dot7" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark8.gif"></div>');
|
|
73 whichFrame.document.write('<div ID="eck1" style="position:absolute; left:-20; top:120; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/olinks.gif"></div>');
|
|
74 whichFrame.document.write('<div ID="eck2" style="position:absolute; left:-20; top:140; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/orechts.gif"></div>');
|
|
75 whichFrame.document.write('<div ID="eck3" style="position:absolute; left:-20; top:160; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/ulinks.gif"></div>');
|
|
76 whichFrame.document.write('<div ID="eck4" style="position:absolute; left:-20; top:180; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/urechts.gif"></div>');
|
|
77
|
|
78 whichFrame.document.write('</body></html>');
|
|
79
|
|
80 whichFrame.document.close();
|
|
81
|
|
82 initScripts();
|
|
83
|
|
84 pageInfo();
|
|
85
|
|
86 setmark();
|
|
87 }
|
|
88
|
|
89
|
|
90 function Backpage(keepArea) {
|
|
91
|
|
92 att[1] = parseInt(att[1]) - 1;
|
|
93
|
|
94 if (att[1] > 0) {
|
|
95 loadPicture(0, keepArea);
|
|
96 } else {
|
|
97 att[1] = parseInt(att[1]) + 1;
|
|
98 alert("You are already on the first page!");
|
|
99 }
|
|
100 }
|
|
101
|
|
102
|
|
103 function Nextpage(keepArea) {
|
|
104
|
|
105 att[1] = parseInt(att[1]) + 1;
|
|
106
|
|
107 if (att[1] <= parent.numPages) {
|
|
108 loadPicture(0, keepArea);
|
|
109 } else {
|
|
110 att[1] = parseInt(att[1]) - 1;
|
|
111 alert("You are already on the last page!");
|
|
112 }
|
|
113 }
|
|
114
|
|
115
|
|
116 function Page(keepArea) {
|
|
117
|
|
118 do {
|
|
119 page = prompt("Goto Page (1 - " + parent.numPages + "):", 1);
|
|
120 } while ((page != null) && ((page < 1) || (page > parent.numPages)));
|
|
121
|
|
122 if (page != null && page != att[1]) {
|
|
123 att[1] = page;
|
|
124 loadPicture(0, keepArea);
|
|
125 }
|
|
126 }
|
|
127
|
|
128
|
|
129 function Digicat() {
|
|
130 var url = "http://" + location.host + "/docuserver/digitallibrary/digicat.html?" + att[0] + "+" + att[1];
|
|
131 win = window.open(url, "digicat");
|
|
132 win.focus();
|
|
133 }
|
|
134
|
|
135
|
|
136 function Ref(refselect) {
|
|
137
|
|
138 var hyperlinkRef = "http://" + location.host + "/docuserver/digitallibrary/digilib.jsp?";
|
|
139 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4];
|
|
140
|
|
141 if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) {
|
|
142 hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8];
|
|
143 }
|
|
144
|
|
145 if (refselect == 1) {
|
|
146 prompt("Link for HTML--documents", hyperlinkRef);
|
|
147 } else {
|
|
148 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}");
|
|
149 }
|
|
150 }
|
|
151
|
|
152
|
|
153 function Mark(refselect) {
|
|
154
|
|
155 if (att[4].split(";").length > 7) {
|
|
156 alert("Only 8 marks are possible at the moment!");
|
|
157 return;
|
|
158 }
|
|
159
|
|
160 whichFrame.document.all.lay1.onmousedown = function() {
|
|
161 e = whichFrame.event;
|
|
162
|
|
163 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
164 att[4] += ";";
|
|
165 } else {
|
|
166 att[4] = "";
|
|
167 }
|
|
168
|
|
169 markX = cropFloat(att[5]+att[7]*(whichFrame.document.body.scrollLeft+e.x-parseInt(whichFrame.document.all.lay1.style.left))/whichFrame.document.all.lay1.offsetWidth);
|
|
170 markY = cropFloat(att[6]+att[8]*(whichFrame.document.body.scrollTop+e.y-parseInt(whichFrame.document.all.lay1.style.top))/whichFrame.document.all.lay1.offsetHeight);
|
|
171
|
|
172 att[4] += markX + "/" + markY;
|
|
173
|
|
174 whichFrame.document.all.lay1.cancleBubble = true;
|
|
175
|
|
176 setmark();
|
|
177 }
|
|
178 }
|
|
179
|
|
180
|
|
181 function Zoomrect() {
|
|
182 var state = 0;
|
|
183 var x1, y1, x2, y2;
|
|
184
|
|
185 function Click() {
|
|
186 e = whichFrame.event;
|
|
187
|
|
188 if (state == 0) {
|
|
189 state = 1;
|
|
190
|
|
191 x1 = whichFrame.document.body.scrollLeft+e.x;
|
|
192 y1 = whichFrame.document.body.scrollTop+e.y;
|
|
193 x2 = x1;
|
|
194 y2 = y1;
|
|
195
|
|
196 whichFrame.document.all.eck1.style.left = x1;
|
|
197 whichFrame.document.all.eck1.style.top = y1;
|
|
198 whichFrame.document.all.eck2.style.left = x2-12;
|
|
199 whichFrame.document.all.eck2.style.top = y1;
|
|
200 whichFrame.document.all.eck3.style.left = x1;
|
|
201 whichFrame.document.all.eck3.style.top = y2-12;
|
|
202 whichFrame.document.all.eck4.style.left = x2-12;
|
|
203 whichFrame.document.all.eck4.style.top = y2-12;
|
|
204
|
|
205 whichFrame.document.all.eck1.style.visibility="visible";
|
|
206 whichFrame.document.all.eck2.style.visibility="visible";
|
|
207 whichFrame.document.all.eck3.style.visibility="visible";
|
|
208 whichFrame.document.all.eck4.style.visibility="visible";
|
|
209
|
|
210 whichFrame.document.all.lay1.onmousemove = Move;
|
|
211 whichFrame.document.all.eck4.onmousemove = Move;
|
|
212
|
|
213 } else {
|
|
214
|
|
215 x1 -= parseInt(whichFrame.document.all.lay1.style.left);
|
|
216 y1 -= parseInt(whichFrame.document.all.lay1.style.top);
|
|
217
|
|
218 x2 = whichFrame.document.body.scrollLeft+e.x-parseInt(whichFrame.document.all.lay1.style.left);
|
|
219 y2 = whichFrame.document.body.scrollTop+e.y-parseInt(whichFrame.document.all.lay1.style.left);
|
|
220
|
|
221 whichFrame.document.all.eck1.visibility="hidden";
|
|
222 whichFrame.document.all.eck2.visibility="hidden";
|
|
223 whichFrame.document.all.eck3.visibility="hidden";
|
|
224 whichFrame.document.all.eck4.visibility="hidden";
|
|
225
|
|
226 whichFrame.document.all.lay1.cancleBubble = true;
|
|
227 whichFrame.document.all.eck4.cancleBubble = true;
|
|
228
|
|
229 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/whichFrame.document.all.lay1.offsetWidth);
|
|
230 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/whichFrame.document.all.lay1.offsetHeight);
|
|
231
|
|
232 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/whichFrame.document.all.lay1.offsetWidth);
|
|
233 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/whichFrame.document.all.lay1.offsetHeight);
|
|
234
|
|
235 if (att[7] != 0 && att[8] != 0) {
|
|
236 loadPicture(2);
|
|
237 }
|
|
238 }
|
|
239 }
|
|
240
|
|
241 function Move() {
|
|
242 e = whichFrame.event;
|
|
243
|
|
244 x2 = whichFrame.document.body.scrollLeft+e.x;
|
|
245 y2 = whichFrame.document.body.scrollTop+e.y;
|
|
246
|
|
247 whichFrame.document.all.eck1.style.left = ((x1 < x2) ? x1 : x2);
|
|
248 whichFrame.document.all.eck1.style.top = ((y1 < y2) ? y1 : y2);
|
|
249 whichFrame.document.all.eck2.style.left = ((x1 < x2) ? x2 : x1)-12;
|
|
250 whichFrame.document.all.eck2.style.top = ((y1 < y2) ? y1 : y2);
|
|
251 whichFrame.document.all.eck3.style.left = ((x1 < x2) ? x1 : x2);
|
|
252 whichFrame.document.all.eck3.style.top = ((y1 < y2) ? y2 : y1)-12;
|
|
253 whichFrame.document.all.eck4.style.left = ((x1 < x2) ? x2 : x1)-12;
|
|
254 whichFrame.document.all.eck4.style.top = ((y1 < y2) ? y2 : y1)-12;
|
|
255 }
|
|
256
|
|
257 whichFrame.document.all.lay1.onmousedown = Click;
|
|
258 whichFrame.document.all.eck4.onmousedown = Click;
|
|
259 }
|
|
260
|
|
261
|
|
262 function Zoomin() {
|
|
263
|
|
264 whichFrame.document.all.lay1.onmousedown = function() {
|
|
265 e = whichFrame.event;
|
|
266
|
|
267 att[5] = cropFloat(att[5]+att[7]*(whichFrame.document.body.scrollLeft+e.x-parseInt(whichFrame.document.all.lay1.style.left))/whichFrame.document.all.lay1.offsetWidth-0.5*att[7]*0.7);
|
|
268 att[6] = cropFloat(att[6]+att[8]*(whichFrame.document.body.scrollTop+e.y-parseInt(whichFrame.document.all.lay1.style.top))/whichFrame.document.all.lay1.offsetHeight-0.5*att[8]*0.7);
|
|
269
|
|
270 att[7] = cropFloat(att[7]*0.7);
|
|
271 att[8] = cropFloat(att[8]*0.7);
|
|
272
|
|
273 if (att[5] < 0) {
|
|
274 att[5] = 0;
|
|
275 }
|
|
276 if (att[6] < 0) {
|
|
277 att[6] = 0;
|
|
278 }
|
|
279 if (att[5]+att[7] > 1) {
|
|
280 att[5] = 1-att[7];
|
|
281 }
|
|
282 if (att[6]+att[8] > 1) {
|
|
283 att[6] = 1-att[8];
|
|
284 }
|
|
285
|
|
286 whichFrame.document.all.lay1.cancleBubble = true;
|
|
287
|
|
288 loadPicture(2);
|
|
289 }
|
|
290 }
|
|
291
|
|
292
|
|
293 function Zoomout() {
|
|
294 loadPicture(1);
|
|
295 }
|
|
296
|
|
297
|
|
298 function Moveto() {
|
|
299
|
|
300 whichFrame.document.all.lay1.onmousedown = function() {
|
|
301 e = whichFrame.event;
|
|
302
|
|
303 att[5] = cropFloat(att[5]+att[7]*(whichFrame.document.body.scrollLeft+e.x-parseInt(whichFrame.document.all.lay1.style.left))/whichFrame.document.all.lay1.offsetWidth-0.5*att[7]);
|
|
304 att[6] = cropFloat(att[6]+att[8]*(whichFrame.document.body.scrollTop+e.y-parseInt(whichFrame.document.all.lay1.style.top))/whichFrame.document.all.lay1.offsetHeight-0.5*att[8]);
|
|
305
|
|
306 if (att[5] < 0) {
|
|
307 att[5] = 0;
|
|
308 }
|
|
309 if (att[6] < 0) {
|
|
310 att[6] = 0;
|
|
311 }
|
|
312 if (att[5]+att[7] > 1) {
|
|
313 att[5] = 1-att[7];
|
|
314 }
|
|
315 if (att[6]+att[8] > 1) {
|
|
316 att[6] = 1-att[8];
|
|
317 }
|
|
318
|
|
319 whichFrame.document.all.lay1.cancleBubble = true;
|
|
320
|
|
321 loadPicture(2);
|
|
322 }
|
|
323 }
|
|
324
|
|
325
|
|
326 function Scaledef(scaledef) {
|
|
327
|
|
328 att[2] = scaledef;
|
|
329 loadPicture(2);
|
|
330 }
|
|
331
|
|
332
|
|
333 function setmark() {
|
|
334 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
335 var mark = att[4].split(";");
|
|
336
|
|
337 var countMarks = mark.length;
|
|
338
|
|
339 // maximum of marks is 8
|
|
340 // we do not report this error because this is already done in func. "Mark"
|
|
341 if (countMarks > 8) countMarks = 8;
|
|
342
|
|
343 var picWidth = whichFrame.document.all.lay1.offsetWidth;
|
|
344 var picHeight = whichFrame.document.all.lay1.offsetHeight;
|
|
345
|
|
346 // catch the cases where the picture had not been loaded already and
|
|
347 // make a timeout so that the coordinates are calculated with the real dimensions
|
|
348 if (picWidth > 30) {
|
|
349
|
|
350 var xoffset = parseInt(whichFrame.document.all.lay1.style.left);
|
|
351 var yoffset = parseInt(whichFrame.document.all.lay1.style.top);
|
|
352
|
|
353 for (var i = 0; i < countMarks; i++) {
|
|
354 mark[i] = mark[i].split("/");
|
|
355
|
|
356 if ((mark[i][0] > att[5]) && (mark[i][1] > att[6]) && (mark[i][0] < (att[5]+att[7])) && (mark[i][1] < (att[6]+att[8]))) {
|
|
357
|
|
358 mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]);
|
|
359 mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]);
|
|
360
|
|
361 whichFrame.document.getElementById("dot" + i).style.left = mark[i][0]-5;
|
|
362 whichFrame.document.getElementById("dot" + i).style.top = mark[i][1]-5;
|
|
363 whichFrame.document.getElementById("dot" + i).style.visibility = "visible";
|
|
364 }
|
|
365 }
|
|
366 } else {
|
|
367 setTimeout("setmark()", 100);
|
|
368 }
|
|
369 }
|
|
370 }
|
|
371
|
|
372
|
|
373 // capturing keypresses for next and previous page
|
|
374 function parseKeypress() {
|
|
375 e = whichFrame.event;
|
|
376
|
|
377 if (e.keyCode == 110) {
|
|
378 Nextpage();
|
|
379 }
|
|
380 if (e.keyCode == 98) {
|
|
381 Backpage();
|
|
382 }
|
|
383 whichFrame.document.cancleBubble = true;
|
|
384 }
|
|
385
|
|
386
|
|
387 // auxiliary function to crop senseless precicsion
|
|
388 function cropFloat(tmp) {
|
|
389 return parseInt(10000*tmp)/10000;
|
|
390 }
|
|
391
|
|
392
|
|
393 // initialize browser specific things (keypress caputring)
|
|
394 function initScripts() {
|
|
395 whichFrame.document.onkeypress = parseKeypress;
|
|
396 whichFrame.focus();
|
|
397 }
|
|
398
|
|
399
|
|
400 // fill in the values of the "att"-array
|
|
401 function initPicture(picURL) {
|
|
402 att = picURL.split("+");
|
|
403
|
|
404 if (att[0].lastIndexOf("/") == att[0].length-1) {
|
|
405 att[0] = att[0].substring(0, att[0].length-1);
|
|
406 }
|
|
407
|
|
408 if (att.length < 2 || att[1] == "") {
|
|
409 att[1] = 1;
|
|
410 }
|
|
411 if (att.length < 3 || att[2] == "") {
|
|
412 att[2] = "1.0";
|
|
413 }
|
|
414
|
|
415 if (att.length < 4) {
|
|
416 att[3] = "";
|
|
417 }
|
|
418
|
|
419 if (att[3].indexOf("f") > -1) {
|
|
420 att[3] = "fit";
|
|
421 }
|
|
422
|
|
423 if (att.length < 5 || att[4] == "") {
|
|
424 att[4] = "0/0";
|
|
425 }
|
|
426
|
|
427 // converts the old mark format (0-1000) to new format(0.0 - 1.0)
|
|
428 if (att[4] != "0/0") {
|
|
429 var tmp = att[4].split(";");
|
|
430
|
|
431 att[4] = "";
|
|
432
|
|
433 for (i = 0; i < tmp.length; i++) {
|
|
434 tmp[i] = tmp[i].split("/");
|
|
435
|
|
436 if (tmp[i][0] > 1 && tmp[i][1] > 1) {
|
|
437 tmp[i][0] /= 1000;
|
|
438 tmp[i][1] /= 1000;
|
|
439 }
|
|
440
|
|
441 att[4] += tmp[i][0] + "/" + tmp[i][1] + ";";
|
|
442 }
|
|
443 att[4] = att[4].slice(0, -1);
|
|
444 }
|
|
445
|
|
446 if (att.length < 7) {
|
|
447 att[5] = 0;
|
|
448 att[6] = 0;
|
|
449 att[7] = 1;
|
|
450 att[8] = 1;
|
|
451 } else {
|
|
452 att[5] = parseFloat(att[5]);
|
|
453 att[6] = parseFloat(att[6]);
|
|
454 att[7] = parseFloat(att[7]);
|
|
455 att[8] = parseFloat(att[8]);
|
|
456 }
|
|
457 }
|
|
458
|
|
459
|
|
460 function pageInfo() {
|
|
461
|
|
462 // bug in netscape 4.xx (confunding px and pt)
|
|
463 var fontsize = document.layers ? "11pt" : "11px";
|
|
464
|
|
465 if (window.pageFrame) {
|
|
466 pageFrame.document.open();
|
|
467 pageFrame.document.write('<html><head></head><body bgcolor="#CCCCCC" topmargin="5" marginheight="5">');
|
|
468 pageFrame.document.write('<p style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; color: #CC3333; font-size: ' + fontsize + '">');
|
|
469 pageFrame.document.write(att[1] + '<b> of </b>' + numPages + '</p></body></html>');
|
|
470 pageFrame.document.close();
|
|
471 }
|
|
472 }
|