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
|
35
|
94 // constructor holding different values of a point
|
|
95 function Point(event) {
|
|
96
|
|
97 this.pageX = parseInt(document.body.scrollLeft+event.x);
|
|
98 this.pageY = parseInt(document.body.scrollTop+event.y);
|
|
99
|
|
100 this.x = this.pageX-parseInt(document.all.lay1.style.left);
|
|
101 this.y = this.pageY-parseInt(document.all.lay1.style.top);
|
|
102
|
|
103 this.relX = cropFloat(att[5]+(att[7]*this.x/document.all.lay1.offsetWidth));
|
|
104 this.relY = cropFloat(att[6]+(att[8]*this.y/document.all.lay1.offsetHeight));
|
|
105
|
|
106 return this;
|
|
107 }
|
|
108
|
|
109
|
31
|
110 function backPage(keepArea) {
|
17
|
111
|
|
112 att[1] = parseInt(att[1]) - 1;
|
|
113
|
|
114 if (att[1] > 0) {
|
|
115 loadPicture(0, keepArea);
|
|
116 } else {
|
|
117 att[1] = parseInt(att[1]) + 1;
|
|
118 alert("You are already on the first page!");
|
|
119 }
|
|
120 }
|
|
121
|
|
122
|
31
|
123 function nextPage(keepArea) {
|
17
|
124
|
|
125 att[1] = parseInt(att[1]) + 1;
|
|
126
|
31
|
127 loadPicture(0, keepArea);
|
17
|
128 }
|
|
129
|
|
130
|
31
|
131 function page(keepArea) {
|
17
|
132
|
|
133 do {
|
31
|
134 page = prompt("Goto Page:", 1);
|
|
135 } while ((page != null) && (page < 1));
|
17
|
136
|
|
137 if (page != null && page != att[1]) {
|
|
138 att[1] = page;
|
|
139 loadPicture(0, keepArea);
|
|
140 }
|
|
141 }
|
|
142
|
|
143
|
31
|
144 function digicat() {
|
17
|
145 var url = "http://" + location.host + "/docuserver/digitallibrary/digicat.html?" + att[0] + "+" + att[1];
|
|
146 win = window.open(url, "digicat");
|
|
147 win.focus();
|
|
148 }
|
|
149
|
|
150
|
31
|
151 function ref(refselect) {
|
17
|
152
|
|
153 var hyperlinkRef = "http://" + location.host + "/docuserver/digitallibrary/digilib.jsp?";
|
|
154 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4];
|
|
155
|
|
156 if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) {
|
|
157 hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8];
|
|
158 }
|
|
159
|
|
160 if (refselect == 1) {
|
|
161 prompt("Link for HTML--documents", hyperlinkRef);
|
|
162 } else {
|
|
163 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}");
|
|
164 }
|
|
165 }
|
|
166
|
|
167
|
31
|
168 function mark(refselect) {
|
17
|
169
|
|
170 if (att[4].split(";").length > 7) {
|
|
171 alert("Only 8 marks are possible at the moment!");
|
|
172 return;
|
|
173 }
|
|
174
|
31
|
175 document.all.lay1.onmousedown = function() {
|
35
|
176 var point = new Point(event);
|
17
|
177
|
|
178 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
179 att[4] += ";";
|
|
180 } else {
|
|
181 att[4] = "";
|
|
182 }
|
|
183
|
35
|
184 att[4] += point.relX + "/" + point.relY;
|
17
|
185
|
31
|
186 document.all.lay1.cancleBubble = true;
|
17
|
187
|
31
|
188 setMarks();
|
17
|
189 }
|
|
190 }
|
|
191
|
|
192
|
31
|
193 function zoomArea() {
|
17
|
194 var state = 0;
|
35
|
195 var pt1, pt2;
|
17
|
196
|
31
|
197 function click() {
|
17
|
198 if (state == 0) {
|
|
199 state = 1;
|
|
200
|
35
|
201 pt1 = new Point(event);
|
|
202 pt2 = pt1;
|
17
|
203
|
35
|
204 document.all.eck1.style.left = pt1.pageX;
|
|
205 document.all.eck1.style.top = pt1.pageY;
|
|
206 document.all.eck2.style.left = pt2.pageX-12;
|
|
207 document.all.eck2.style.top = pt1.pageY;
|
|
208 document.all.eck3.style.left = pt1.pageX;
|
|
209 document.all.eck3.style.top = pt2.pageY-12;
|
|
210 document.all.eck4.style.left = pt2.pageX-12;
|
|
211 document.all.eck4.style.top = pt2.pageY-12;
|
17
|
212
|
31
|
213 document.all.eck1.style.visibility="visible";
|
|
214 document.all.eck2.style.visibility="visible";
|
|
215 document.all.eck3.style.visibility="visible";
|
|
216 document.all.eck4.style.visibility="visible";
|
17
|
217
|
31
|
218 document.all.lay1.onmousemove = move;
|
|
219 document.all.eck4.onmousemove = move;
|
17
|
220
|
|
221 } else {
|
35
|
222 pt2 = new Point(event);
|
17
|
223
|
31
|
224 document.all.eck1.visibility="hidden";
|
|
225 document.all.eck2.visibility="hidden";
|
|
226 document.all.eck3.visibility="hidden";
|
|
227 document.all.eck4.visibility="hidden";
|
17
|
228
|
31
|
229 document.all.lay1.cancleBubble = true;
|
|
230 document.all.eck4.cancleBubble = true;
|
17
|
231
|
35
|
232 att[5] = Math.min(pt1.relX, pt2.relX);
|
|
233 att[6] = Math.min(pt1.relY, pt2.relY);
|
17
|
234
|
35
|
235 att[7] = Math.abs(pt1.relX-pt2.relX);
|
|
236 att[8] = Math.abs(pt1.relY-pt2.relY);
|
17
|
237
|
|
238 if (att[7] != 0 && att[8] != 0) {
|
|
239 loadPicture(2);
|
|
240 }
|
|
241 }
|
|
242 }
|
|
243
|
31
|
244 function move() {
|
35
|
245 pt2 = new Point(event);
|
17
|
246
|
35
|
247 document.all.eck1.style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX);
|
|
248 document.all.eck1.style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY);
|
|
249 document.all.eck2.style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;
|
|
250 document.all.eck2.style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY);
|
|
251 document.all.eck3.style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX);
|
|
252 document.all.eck3.style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12;
|
|
253 document.all.eck4.style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;
|
|
254 document.all.eck4.style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12;
|
17
|
255 }
|
|
256
|
31
|
257 document.all.lay1.onmousedown = click;
|
|
258 document.all.eck4.onmousedown = click;
|
17
|
259 }
|
|
260
|
|
261
|
31
|
262 function zoomPoint() {
|
17
|
263
|
31
|
264 document.all.lay1.onmousedown = function() {
|
35
|
265 var point = new Point(event);
|
17
|
266
|
35
|
267 att[5] = cropFloat(point.relX-0.5*att[7]*0.7);
|
|
268 att[6] = cropFloat(point.relY-0.5*att[8]*0.7);
|
17
|
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
|
31
|
286 document.all.lay1.cancleBubble = true;
|
17
|
287
|
|
288 loadPicture(2);
|
|
289 }
|
|
290 }
|
|
291
|
|
292
|
31
|
293 function zoomOut() {
|
17
|
294 loadPicture(1);
|
|
295 }
|
|
296
|
|
297
|
31
|
298 function moveTo() {
|
17
|
299
|
31
|
300 document.all.lay1.onmousedown = function() {
|
35
|
301 var point = new Point(event);
|
17
|
302
|
35
|
303 att[5] = cropFloat(point.relX-0.5*att[7]);
|
|
304 att[6] = cropFloat(point.relY-0.5*att[8]);
|
17
|
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
|
31
|
319 document.all.lay1.cancleBubble = true;
|
17
|
320
|
|
321 loadPicture(2);
|
|
322 }
|
|
323 }
|
|
324
|
|
325
|
31
|
326 function scale(scaledef) {
|
17
|
327
|
|
328 att[2] = scaledef;
|
|
329 loadPicture(2);
|
|
330 }
|
|
331
|
|
332
|
31
|
333 function setMarks() {
|
17
|
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
|
31
|
343 var picWidth = document.all.lay1.offsetWidth;
|
|
344 var picHeight = document.all.lay1.offsetHeight;
|
17
|
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
|
31
|
350 var xoffset = parseInt(document.all.lay1.style.left);
|
|
351 var yoffset = parseInt(document.all.lay1.style.top);
|
17
|
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
|
31
|
361 document.getElementById("dot" + i).style.left = mark[i][0]-5;
|
|
362 document.getElementById("dot" + i).style.top = mark[i][1]-5;
|
|
363 document.getElementById("dot" + i).style.visibility = "visible";
|
17
|
364 }
|
|
365 }
|
|
366 } else {
|
31
|
367 setTimeout("setMarks()", 100);
|
17
|
368 }
|
|
369 }
|
|
370 }
|
|
371
|
|
372
|
|
373 // capturing keypresses for next and previous page
|
|
374 function parseKeypress() {
|
31
|
375 e = event;
|
17
|
376
|
|
377 if (e.keyCode == 110) {
|
|
378 Nextpage();
|
|
379 }
|
|
380 if (e.keyCode == 98) {
|
|
381 Backpage();
|
|
382 }
|
31
|
383 document.cancleBubble = true;
|
17
|
384 }
|
|
385
|
|
386
|
|
387 // auxiliary function to crop senseless precicsion
|
|
388 function cropFloat(tmp) {
|
|
389 return parseInt(10000*tmp)/10000;
|
|
390 }
|