31
|
1 // this global variable has to be initialised before the frist use of the functions below
|
|
2 // to fill in the attributes you can use the function init provided below
|
17
|
3 // - array with all attributes
|
|
4 var att = new Array();
|
|
5
|
31
|
6 // fill in the values of the "att"-array
|
|
7 function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) {
|
|
8
|
|
9 // debug window to check the parameters passed
|
|
10 //alert ("DEBUG message (parameters in init):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh);
|
|
11
|
|
12 // attaching the values to the att-array
|
|
13 att[0] = fn;
|
|
14 att[1] = parseInt(pn);
|
|
15 att[2] = parseFloat(ws);
|
|
16 att[3] = mo;
|
|
17 att[4] = mk;
|
|
18 att[5] = parseFloat(wx);
|
|
19 att[6] = parseFloat(wy);
|
|
20 att[7] = parseFloat(ww);
|
|
21 att[8] = parseFloat(wh);
|
|
22
|
|
23 // compatablility issue
|
|
24 if (att[3].indexOf("f") > -1) {
|
|
25 att[3] = "fit";
|
|
26 }
|
17
|
27
|
31
|
28 // converts the old mark format (0-1000) to new format(0.0 - 1.0)
|
|
29 // could even be useless now
|
|
30 if (att[4] != "0/0") {
|
|
31 var tmp = att[4].split(";");
|
|
32
|
|
33 att[4] = "";
|
|
34
|
|
35 for (i = 0; i < tmp.length; i++) {
|
|
36 tmp[i] = tmp[i].split("/");
|
|
37
|
|
38 if (tmp[i][0] > 1 && tmp[i][1] > 1) {
|
|
39 tmp[i][0] /= 1000;
|
|
40 tmp[i][1] /= 1000;
|
|
41 }
|
|
42
|
|
43 att[4] += tmp[i][0] + "/" + tmp[i][1] + ";";
|
|
44 }
|
|
45 att[4] = att[4].slice(0, -1);
|
|
46 }
|
|
47
|
|
48 // initialisation stuff
|
|
49 // ====================
|
|
50
|
|
51 setMarks();
|
|
52
|
|
53 this.document.onkeypress = parseKeypress;
|
|
54 focus();
|
|
55
|
|
56 // give a name to the window containing digilib - this way one can test if there is already a
|
|
57 // digilib-window open and replace the contents of it (ex. digicat)
|
|
58 top.window.name = "digilib";
|
|
59 }
|
|
60
|
17
|
61
|
|
62 // function that launches the ScaleServlet
|
|
63 // the different detailGrades:
|
|
64 // 0 -> back, next, page
|
|
65 // 1 -> zoomout
|
|
66 // 2 -> zoomarea, zoompoint, moveto, scaledef
|
|
67
|
|
68 function loadPicture(detailGrade, keepArea) {
|
|
69
|
31
|
70 var newURL = "dlImage.jsp?"
|
|
71 newURL += "fn=" + att[0] + "&pn=" + att[1] + "&ws=" + att[2] + "&mo=" + att[3];
|
17
|
72
|
|
73 if (detailGrade == 0) {
|
|
74 att[4] = "0/0";
|
|
75 }
|
|
76
|
|
77 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) {
|
|
78 att[5] = 0;
|
|
79 att[6] = 0;
|
|
80 att[7] = 1;
|
|
81 att[8] = 1;
|
|
82 }
|
31
|
83
|
|
84 newURL += "&mk=" + att[4] + "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8];
|
|
85 newURL += "&dw=" + (document.body.clientWidth-30) + "&dh=" + (document.body.clientHeight-30);
|
17
|
86
|
31
|
87 // debug window - checking the parameters passed to the next image
|
|
88 //alert ("DEBUG MESSAGE (complete URL in loadPicture):\n\n" + newURL);
|
17
|
89
|
31
|
90 location.href = newURL;
|
17
|
91 }
|
|
92
|
|
93
|
31
|
94 function backPage(keepArea) {
|
17
|
95
|
|
96 att[1] = parseInt(att[1]) - 1;
|
|
97
|
|
98 if (att[1] > 0) {
|
|
99 loadPicture(0, keepArea);
|
|
100 } else {
|
|
101 att[1] = parseInt(att[1]) + 1;
|
|
102 alert("You are already on the first page!");
|
|
103 }
|
|
104 }
|
|
105
|
|
106
|
31
|
107 function nextPage(keepArea) {
|
17
|
108
|
|
109 att[1] = parseInt(att[1]) + 1;
|
|
110
|
31
|
111 loadPicture(0, keepArea);
|
17
|
112 }
|
|
113
|
|
114
|
31
|
115 function page(keepArea) {
|
17
|
116
|
|
117 do {
|
31
|
118 page = prompt("Goto Page:", 1);
|
|
119 } while ((page != null) && (page < 1));
|
17
|
120
|
|
121 if (page != null && page != att[1]) {
|
|
122 att[1] = page;
|
|
123 loadPicture(0, keepArea);
|
|
124 }
|
|
125 }
|
|
126
|
|
127
|
31
|
128 function digicat() {
|
17
|
129 var url = "http://" + location.host + "/docuserver/digitallibrary/digicat.html?" + att[0] + "+" + att[1];
|
|
130 win = window.open(url, "digicat");
|
|
131 win.focus();
|
|
132 }
|
|
133
|
|
134
|
31
|
135 function ref(refselect) {
|
17
|
136
|
|
137 var hyperlinkRef = "http://" + location.host + "/docuserver/digitallibrary/digilib.jsp?";
|
|
138 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4];
|
|
139
|
|
140 if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) {
|
|
141 hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8];
|
|
142 }
|
|
143
|
|
144 if (refselect == 1) {
|
|
145 prompt("Link for HTML--documents", hyperlinkRef);
|
|
146 } else {
|
|
147 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}");
|
|
148 }
|
|
149 }
|
|
150
|
|
151
|
31
|
152 function mark(refselect) {
|
17
|
153
|
|
154 if (att[4].split(";").length > 7) {
|
|
155 alert("Only 8 marks are possible at the moment!");
|
|
156 return;
|
|
157 }
|
|
158
|
31
|
159 document.all.lay1.onmousedown = function() {
|
|
160 e = event;
|
17
|
161
|
|
162 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
163 att[4] += ";";
|
|
164 } else {
|
|
165 att[4] = "";
|
|
166 }
|
|
167
|
31
|
168 markX = cropFloat(att[5]+att[7]*(document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left))/document.all.lay1.offsetWidth);
|
|
169 markY = cropFloat(att[6]+att[8]*(document.body.scrollTop+e.y-parseInt(document.all.lay1.style.top))/document.all.lay1.offsetHeight);
|
17
|
170
|
|
171 att[4] += markX + "/" + markY;
|
|
172
|
31
|
173 document.all.lay1.cancleBubble = true;
|
17
|
174
|
31
|
175 setMarks();
|
17
|
176 }
|
|
177 }
|
|
178
|
|
179
|
31
|
180 function zoomArea() {
|
17
|
181 var state = 0;
|
|
182 var x1, y1, x2, y2;
|
|
183
|
31
|
184 function click() {
|
|
185 e = event;
|
17
|
186
|
|
187 if (state == 0) {
|
|
188 state = 1;
|
|
189
|
31
|
190 x1 = document.body.scrollLeft+e.x;
|
|
191 y1 = document.body.scrollTop+e.y;
|
17
|
192 x2 = x1;
|
|
193 y2 = y1;
|
|
194
|
31
|
195 document.all.eck1.style.left = x1;
|
|
196 document.all.eck1.style.top = y1;
|
|
197 document.all.eck2.style.left = x2-12;
|
|
198 document.all.eck2.style.top = y1;
|
|
199 document.all.eck3.style.left = x1;
|
|
200 document.all.eck3.style.top = y2-12;
|
|
201 document.all.eck4.style.left = x2-12;
|
|
202 document.all.eck4.style.top = y2-12;
|
17
|
203
|
31
|
204 document.all.eck1.style.visibility="visible";
|
|
205 document.all.eck2.style.visibility="visible";
|
|
206 document.all.eck3.style.visibility="visible";
|
|
207 document.all.eck4.style.visibility="visible";
|
17
|
208
|
31
|
209 document.all.lay1.onmousemove = move;
|
|
210 document.all.eck4.onmousemove = move;
|
17
|
211
|
|
212 } else {
|
|
213
|
31
|
214 x1 -= parseInt(document.all.lay1.style.left);
|
|
215 y1 -= parseInt(document.all.lay1.style.top);
|
17
|
216
|
31
|
217 x2 = document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left);
|
|
218 y2 = document.body.scrollTop+e.y-parseInt(document.all.lay1.style.left);
|
17
|
219
|
31
|
220 document.all.eck1.visibility="hidden";
|
|
221 document.all.eck2.visibility="hidden";
|
|
222 document.all.eck3.visibility="hidden";
|
|
223 document.all.eck4.visibility="hidden";
|
17
|
224
|
31
|
225 document.all.lay1.cancleBubble = true;
|
|
226 document.all.eck4.cancleBubble = true;
|
17
|
227
|
31
|
228 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/document.all.lay1.offsetWidth);
|
|
229 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/document.all.lay1.offsetHeight);
|
17
|
230
|
31
|
231 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/document.all.lay1.offsetWidth);
|
|
232 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/document.all.lay1.offsetHeight);
|
17
|
233
|
|
234 if (att[7] != 0 && att[8] != 0) {
|
|
235 loadPicture(2);
|
|
236 }
|
|
237 }
|
|
238 }
|
|
239
|
31
|
240 function move() {
|
|
241 e = event;
|
17
|
242
|
31
|
243 x2 = document.body.scrollLeft+e.x;
|
|
244 y2 = document.body.scrollTop+e.y;
|
17
|
245
|
31
|
246 document.all.eck1.style.left = ((x1 < x2) ? x1 : x2);
|
|
247 document.all.eck1.style.top = ((y1 < y2) ? y1 : y2);
|
|
248 document.all.eck2.style.left = ((x1 < x2) ? x2 : x1)-12;
|
|
249 document.all.eck2.style.top = ((y1 < y2) ? y1 : y2);
|
|
250 document.all.eck3.style.left = ((x1 < x2) ? x1 : x2);
|
|
251 document.all.eck3.style.top = ((y1 < y2) ? y2 : y1)-12;
|
|
252 document.all.eck4.style.left = ((x1 < x2) ? x2 : x1)-12;
|
|
253 document.all.eck4.style.top = ((y1 < y2) ? y2 : y1)-12;
|
17
|
254 }
|
|
255
|
31
|
256 document.all.lay1.onmousedown = click;
|
|
257 document.all.eck4.onmousedown = click;
|
17
|
258 }
|
|
259
|
|
260
|
31
|
261 function zoomPoint() {
|
17
|
262
|
31
|
263 document.all.lay1.onmousedown = function() {
|
|
264 e = event;
|
17
|
265
|
31
|
266 att[5] = cropFloat(att[5]+att[7]*(document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left))/document.all.lay1.offsetWidth-0.5*att[7]*0.7);
|
|
267 att[6] = cropFloat(att[6]+att[8]*(document.body.scrollTop+e.y-parseInt(document.all.lay1.style.top))/document.all.lay1.offsetHeight-0.5*att[8]*0.7);
|
17
|
268
|
|
269 att[7] = cropFloat(att[7]*0.7);
|
|
270 att[8] = cropFloat(att[8]*0.7);
|
|
271
|
|
272 if (att[5] < 0) {
|
|
273 att[5] = 0;
|
|
274 }
|
|
275 if (att[6] < 0) {
|
|
276 att[6] = 0;
|
|
277 }
|
|
278 if (att[5]+att[7] > 1) {
|
|
279 att[5] = 1-att[7];
|
|
280 }
|
|
281 if (att[6]+att[8] > 1) {
|
|
282 att[6] = 1-att[8];
|
|
283 }
|
|
284
|
31
|
285 document.all.lay1.cancleBubble = true;
|
17
|
286
|
|
287 loadPicture(2);
|
|
288 }
|
|
289 }
|
|
290
|
|
291
|
31
|
292 function zoomOut() {
|
17
|
293 loadPicture(1);
|
|
294 }
|
|
295
|
|
296
|
31
|
297 function moveTo() {
|
17
|
298
|
31
|
299 document.all.lay1.onmousedown = function() {
|
|
300 e = event;
|
17
|
301
|
31
|
302 att[5] = cropFloat(att[5]+att[7]*(document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left))/document.all.lay1.offsetWidth-0.5*att[7]);
|
|
303 att[6] = cropFloat(att[6]+att[8]*(document.body.scrollTop+e.y-parseInt(document.all.lay1.style.top))/document.all.lay1.offsetHeight-0.5*att[8]);
|
17
|
304
|
|
305 if (att[5] < 0) {
|
|
306 att[5] = 0;
|
|
307 }
|
|
308 if (att[6] < 0) {
|
|
309 att[6] = 0;
|
|
310 }
|
|
311 if (att[5]+att[7] > 1) {
|
|
312 att[5] = 1-att[7];
|
|
313 }
|
|
314 if (att[6]+att[8] > 1) {
|
|
315 att[6] = 1-att[8];
|
|
316 }
|
|
317
|
31
|
318 document.all.lay1.cancleBubble = true;
|
17
|
319
|
|
320 loadPicture(2);
|
|
321 }
|
|
322 }
|
|
323
|
|
324
|
31
|
325 function scale(scaledef) {
|
17
|
326
|
|
327 att[2] = scaledef;
|
|
328 loadPicture(2);
|
|
329 }
|
|
330
|
|
331
|
31
|
332 function setMarks() {
|
17
|
333 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
334 var mark = att[4].split(";");
|
|
335
|
|
336 var countMarks = mark.length;
|
|
337
|
|
338 // maximum of marks is 8
|
|
339 // we do not report this error because this is already done in func. "Mark"
|
|
340 if (countMarks > 8) countMarks = 8;
|
|
341
|
31
|
342 var picWidth = document.all.lay1.offsetWidth;
|
|
343 var picHeight = document.all.lay1.offsetHeight;
|
17
|
344
|
|
345 // catch the cases where the picture had not been loaded already and
|
|
346 // make a timeout so that the coordinates are calculated with the real dimensions
|
|
347 if (picWidth > 30) {
|
|
348
|
31
|
349 var xoffset = parseInt(document.all.lay1.style.left);
|
|
350 var yoffset = parseInt(document.all.lay1.style.top);
|
17
|
351
|
|
352 for (var i = 0; i < countMarks; i++) {
|
|
353 mark[i] = mark[i].split("/");
|
|
354
|
|
355 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]))) {
|
|
356
|
|
357 mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]);
|
|
358 mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]);
|
|
359
|
31
|
360 document.getElementById("dot" + i).style.left = mark[i][0]-5;
|
|
361 document.getElementById("dot" + i).style.top = mark[i][1]-5;
|
|
362 document.getElementById("dot" + i).style.visibility = "visible";
|
17
|
363 }
|
|
364 }
|
|
365 } else {
|
31
|
366 setTimeout("setMarks()", 100);
|
17
|
367 }
|
|
368 }
|
|
369 }
|
|
370
|
|
371
|
|
372 // capturing keypresses for next and previous page
|
|
373 function parseKeypress() {
|
31
|
374 e = event;
|
17
|
375
|
|
376 if (e.keyCode == 110) {
|
|
377 Nextpage();
|
|
378 }
|
|
379 if (e.keyCode == 98) {
|
|
380 Backpage();
|
|
381 }
|
31
|
382 document.cancleBubble = true;
|
17
|
383 }
|
|
384
|
|
385
|
|
386 // auxiliary function to crop senseless precicsion
|
|
387 function cropFloat(tmp) {
|
|
388 return parseInt(10000*tmp)/10000;
|
|
389 }
|