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