34
|
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
|
20
|
3 // - array with all attributes
|
|
4 var att = new Array();
|
|
5
|
34
|
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 }
|
20
|
27
|
34
|
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.addEventListener('keypress', parseKeypress, true);
|
|
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
|
20
|
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
|
34
|
70 var newURL = "dlImage.jsp?"
|
|
71 newURL += "fn=" + att[0] + "&pn=" + att[1] + "&ws=" + att[2] + "&mo=" + att[3];
|
20
|
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 }
|
34
|
83
|
|
84 newURL += "&mk=" + att[4] + "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8];
|
|
85 newURL += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30);
|
20
|
86
|
34
|
87 // debug window - checking the parameters passed to the next image
|
|
88 //alert ("DEBUG MESSAGE (complete URL in loadPicture):\n\n" + newURL);
|
20
|
89
|
34
|
90 location.href = newURL;
|
20
|
91 }
|
|
92
|
|
93
|
34
|
94 function backPage(keepArea) {
|
20
|
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
|
34
|
107 function nextPage(keepArea) {
|
20
|
108
|
|
109 att[1] = parseInt(att[1]) + 1;
|
|
110
|
34
|
111 loadPicture(0, keepArea);
|
20
|
112 }
|
|
113
|
|
114
|
34
|
115 function page(keepArea) {
|
20
|
116
|
|
117 do {
|
34
|
118 page = prompt("Goto Page:", 1);
|
|
119 } while ((page != null) && (page < 1));
|
20
|
120
|
|
121 if (page != null && page != att[1]) {
|
|
122 att[1] = page;
|
|
123 loadPicture(0, keepArea);
|
|
124 }
|
|
125 }
|
|
126
|
|
127
|
34
|
128 function digicat() {
|
20
|
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
|
34
|
135 function ref(refselect) {
|
20
|
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
|
34
|
152 function mark() {
|
20
|
153
|
|
154 if (att[4].split(";").length > 7) {
|
|
155 alert("Only 8 marks are possible at the moment!");
|
|
156 return;
|
|
157 }
|
|
158
|
34
|
159 function markEvent(event) {
|
20
|
160
|
|
161 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
162 att[4] += ";";
|
|
163 } else {
|
|
164 att[4] = "";
|
|
165 }
|
|
166
|
34
|
167 var markX = cropFloat(att[5]+att[7]*(event.pageX-parseInt(document.getElementById("lay1").style.left))/document.pic.offsetWidth);
|
|
168 var markY = cropFloat(att[6]+att[8]*(event.pageY-parseInt(document.getElementById("lay1").style.top))/document.pic.offsetHeight);
|
20
|
169
|
|
170 att[4] += markX + "/" + markY;
|
|
171
|
34
|
172 document.getElementById("lay1").removeEventListener("mousedown", markEvent, true);
|
|
173 setMarks();
|
20
|
174 }
|
|
175
|
34
|
176 document.getElementById("lay1").addEventListener("mousedown", markEvent, true);
|
20
|
177 }
|
|
178
|
|
179
|
34
|
180 function zoomArea() {
|
20
|
181 var state = 0;
|
|
182 var x1, y1, x2, y2;
|
|
183
|
34
|
184 function click(event) {
|
20
|
185
|
|
186 if (state == 0) {
|
|
187 state = 1;
|
|
188
|
|
189 x1 = event.pageX;
|
|
190 y1 = event.pageY;
|
|
191 x2 = x1;
|
|
192 y2 = y1;
|
|
193
|
34
|
194 document.getElementById("eck1").style.left = x1;
|
|
195 document.getElementById("eck1").style.top = y1;
|
|
196 document.getElementById("eck2").style.left = x2-12;
|
|
197 document.getElementById("eck2").style.top = y1;
|
|
198 document.getElementById("eck3").style.left = x1;
|
|
199 document.getElementById("eck3").style.top = y2-12;
|
|
200 document.getElementById("eck4").style.left = x2-12;
|
|
201 document.getElementById("eck4").style.top = y2-12;
|
20
|
202
|
34
|
203 document.getElementById("eck1").style.visibility="visible";
|
|
204 document.getElementById("eck2").style.visibility="visible";
|
|
205 document.getElementById("eck3").style.visibility="visible";
|
|
206 document.getElementById("eck4").style.visibility="visible";
|
20
|
207
|
34
|
208 document.getElementById("lay1").addEventListener("mousemove", move, true);
|
|
209 document.getElementById("eck4").addEventListener("mousemove", move, true);
|
20
|
210
|
|
211 } else {
|
|
212
|
34
|
213 x1 -= parseInt(document.getElementById("lay1").style.left);
|
|
214 y1 -= parseInt(document.getElementById("lay1").style.top);
|
20
|
215
|
34
|
216 x2 = event.pageX-parseInt(document.getElementById("lay1").style.left);
|
|
217 y2 = event.pageY-parseInt(document.getElementById("lay1").style.top);
|
20
|
218
|
34
|
219 document.getElementById("lay1").removeEventListener("mousedown", click, true);
|
|
220 document.getElementById("eck4").removeEventListener("mousedown", click, true);
|
20
|
221
|
34
|
222 document.getElementById("lay1").removeEventListener("mousemove", move, true);
|
|
223 document.getElementById("eck4").removeEventListener("mousemove", move, true);
|
20
|
224
|
34
|
225 document.getElementById("eck1").style.visibility="hidden";
|
|
226 document.getElementById("eck2").style.visibility="hidden";
|
|
227 document.getElementById("eck3").style.visibility="hidden";
|
|
228 document.getElementById("eck4").style.visibility="hidden";
|
20
|
229
|
34
|
230 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/document.pic.offsetWidth);
|
|
231 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/document.pic.offsetHeight);
|
20
|
232
|
34
|
233 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/document.pic.offsetWidth);
|
|
234 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/document.pic.offsetHeight);
|
20
|
235
|
|
236 if (att[7] != 0 && att[8] != 0) {
|
|
237 loadPicture(2);
|
|
238 }
|
|
239 }
|
|
240 }
|
|
241
|
34
|
242 function move(event) {
|
20
|
243
|
|
244 x2 = event.pageX;
|
|
245 y2 = event.pageY;
|
|
246
|
34
|
247 document.getElementById("eck1").style.left = ((x1 < x2) ? x1 : x2);
|
|
248 document.getElementById("eck1").style.top = ((y1 < y2) ? y1 : y2);
|
|
249 document.getElementById("eck2").style.left = ((x1 < x2) ? x2 : x1)-12;
|
|
250 document.getElementById("eck2").style.top = ((y1 < y2) ? y1 : y2);
|
|
251 document.getElementById("eck3").style.left = ((x1 < x2) ? x1 : x2);
|
|
252 document.getElementById("eck3").style.top = ((y1 < y2) ? y2 : y1)-12;
|
|
253 document.getElementById("eck4").style.left = ((x1 < x2) ? x2 : x1)-12;
|
|
254 document.getElementById("eck4").style.top = ((y1 < y2) ? y2 : y1)-12;
|
20
|
255 }
|
|
256
|
34
|
257 document.getElementById("lay1").addEventListener("mousedown", click, true);
|
|
258 document.getElementById("eck4").addEventListener("mousedown", click, true);
|
20
|
259 }
|
|
260
|
|
261
|
34
|
262 function zoomPoint() {
|
20
|
263
|
34
|
264 function zoomPointEvent(event) {
|
20
|
265
|
34
|
266 att[5] = cropFloat(att[5]+att[7]*(event.pageX-parseInt(document.getElementById("lay1").style.left))/document.pic.offsetWidth-0.5*att[7]*0.7);
|
|
267 att[6] = cropFloat(att[6]+att[8]*(event.pageY-parseInt(document.getElementById("lay1").style.top))/document.pic.offsetHeight-0.5*att[8]*0.7);
|
20
|
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
|
34
|
285 document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true);
|
20
|
286
|
|
287 loadPicture(2);
|
|
288 }
|
|
289
|
34
|
290 document.getElementById("lay1").addEventListener("mousedown", zoomPointEvent, true);
|
20
|
291 }
|
|
292
|
|
293
|
34
|
294 function zoomOut() {
|
20
|
295
|
|
296 loadPicture(1);
|
|
297 }
|
|
298
|
|
299
|
34
|
300 function moveTo() {
|
20
|
301
|
34
|
302 function moveToEvent(event) {
|
20
|
303
|
34
|
304 att[5] = cropFloat(att[5]+att[7]*(event.pageX-parseInt(document.getElementById("lay1").style.left))/document.pic.offsetWidth-0.5*att[7]);
|
|
305 att[6] = cropFloat(att[6]+att[8]*(event.pageY-parseInt(document.getElementById("lay1").style.top))/document.pic.offsetHeight-0.5*att[8]);
|
20
|
306
|
|
307 if (att[5] < 0) {
|
|
308 att[5] = 0;
|
|
309 }
|
|
310 if (att[6] < 0) {
|
|
311 att[6] = 0;
|
|
312 }
|
|
313 if (att[5]+att[7] > 1) {
|
|
314 att[5] = 1-att[7];
|
|
315 }
|
|
316 if (att[6]+att[8] > 1) {
|
|
317 att[6] = 1-att[8];
|
|
318 }
|
|
319
|
34
|
320 document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true);
|
20
|
321
|
|
322 loadPicture(2);
|
|
323 }
|
|
324
|
34
|
325 document.getElementById("lay1").addEventListener("mousedown", moveToEvent, true);
|
20
|
326 }
|
|
327
|
|
328
|
34
|
329 function scale(scaledef) {
|
20
|
330
|
|
331 att[2] = scaledef;
|
|
332 loadPicture(2);
|
|
333 }
|
|
334
|
|
335
|
34
|
336 function setMarks() {
|
20
|
337
|
|
338 if (att[4] != "" && att[4] != "0/0") {
|
|
339 var mark = att[4].split(";");
|
|
340
|
|
341 var countMarks = mark.length;
|
|
342
|
|
343 // maximum of marks is 8
|
|
344 // we do not report this error because this is already done in func. "Mark"
|
|
345 if (countMarks > 8) countMarks = 8;
|
|
346
|
34
|
347 var picWidth = document.pic.offsetWidth;
|
|
348 var picHeight = document.pic.offsetHeight;
|
20
|
349
|
|
350 // catch the cases where the picture had not been loaded already and
|
|
351 // make a timeout so that the coordinates are calculated with the real dimensions
|
34
|
352 if (document.pic.complete) {
|
|
353 var xoffset = parseInt(document.getElementById("lay1").style.left);
|
|
354 var yoffset = parseInt(document.getElementById("lay1").style.top);
|
20
|
355
|
|
356 for (var i = 0; i < countMarks; i++) {
|
|
357 mark[i] = mark[i].split("/");
|
|
358
|
|
359 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]))) {
|
|
360
|
|
361 mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]);
|
|
362 mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]);
|
|
363
|
|
364
|
34
|
365 document.getElementById("dot" + i).style.left = mark[i][0]-5;
|
|
366 document.getElementById("dot" + i).style.top = mark[i][1]-5;
|
|
367 document.getElementById("dot" + i).style.visibility = "visible";
|
20
|
368 }
|
|
369 }
|
|
370 } else {
|
34
|
371 setTimeout("setMarks()", 100);
|
20
|
372 }
|
|
373 }
|
|
374 }
|
|
375
|
|
376 // capturing keypresses for next and previous page
|
|
377 // ascii-values of n = 110, b = 98
|
|
378 function parseKeypress (event) {
|
|
379 if (event.charCode == 110) {
|
|
380 Nextpage();
|
|
381 }
|
|
382 if (event.charCode == 98) {
|
|
383 Backpage();
|
|
384 }
|
|
385 }
|
|
386
|
|
387
|
|
388 // auxiliary function to crop senseless precicsion
|
|
389 function cropFloat(tmp) {
|
|
390 return parseInt(10000*tmp)/10000;
|
|
391 }
|