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 window.captureEvents(Event.KEYDOWN);
|
|
54 window.onkeydown = parseKeypress;
|
|
55
|
|
56 focus();
|
|
57
|
|
58 // give a name to the window containing digilib - this way one can test if there is already a
|
|
59 // digilib-window open and replace the contents of it (ex. digicat)
|
|
60 top.window.name = "digilib";
|
|
61 }
|
|
62
|
17
|
63
|
|
64 // function that launches the ScaleServlet
|
|
65 // the different detailGrades:
|
|
66 // 0 -> back, next, page
|
|
67 // 1 -> zoomout
|
|
68 // 2 -> zoomarea, zoompoint, moveto, scaledef
|
|
69
|
|
70 function loadPicture(detailGrade, keepArea) {
|
|
71
|
31
|
72 var newURL = "dlImage.jsp?"
|
|
73 newURL += "fn=" + att[0] + "&pn=" + att[1] + "&ws=" + att[2] + "&mo=" + att[3];
|
17
|
74
|
|
75 if (detailGrade == 0) {
|
|
76 att[4] = "0/0";
|
|
77 }
|
|
78
|
|
79 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) {
|
|
80 att[5] = 0;
|
|
81 att[6] = 0;
|
|
82 att[7] = 1;
|
|
83 att[8] = 1;
|
|
84 }
|
31
|
85
|
|
86 newURL += "&mk=" + att[4] + "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8];
|
|
87 newURL += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30);
|
17
|
88
|
31
|
89 // debug window - checking the parameters passed to the next image
|
|
90 //alert ("DEBUG MESSAGE (complete URL in loadPicture):\n\n" + newURL);
|
17
|
91
|
31
|
92 location.href = newURL;
|
17
|
93 }
|
|
94
|
|
95
|
31
|
96 function backPage(keepArea) {
|
17
|
97
|
|
98 att[1] = parseInt(att[1]) - 1;
|
|
99
|
|
100 if (att[1] > 0) {
|
|
101 loadPicture(0, keepArea);
|
|
102 } else {
|
|
103 att[1] = parseInt(att[1]) + 1;
|
|
104 alert("You are already on the first page!");
|
|
105 }
|
|
106 }
|
|
107
|
|
108
|
31
|
109 function nextPage(keepArea) {
|
17
|
110
|
|
111 att[1] = parseInt(att[1]) + 1;
|
|
112
|
31
|
113 loadPicture(0, keepArea);
|
17
|
114 }
|
|
115
|
|
116
|
31
|
117 function page(keepArea) {
|
17
|
118
|
|
119 do {
|
31
|
120 page = prompt("Goto Page:", 1);
|
|
121 } while ((page != null) && (page < 1));
|
17
|
122
|
|
123 if (page != null && page != att[1]) {
|
|
124 att[1] = page;
|
|
125 loadPicture(0, keepArea);
|
|
126 }
|
|
127 }
|
|
128
|
|
129
|
31
|
130 function digicat() {
|
17
|
131 var url = "http://" + location.host + "/docuserver/digitallibrary/digicat.html?" + att[0] + "+" + att[1];
|
|
132 win = window.open(url, "digicat");
|
|
133 win.focus();
|
|
134 }
|
|
135
|
|
136
|
31
|
137 function ref(refselect) {
|
17
|
138
|
|
139 var hyperlinkRef = "http://" + location.host + "/docuserver/digitallibrary/digilib.jsp?";
|
|
140 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4];
|
|
141
|
|
142 if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) {
|
|
143 hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8];
|
|
144 }
|
|
145
|
|
146 if (refselect == 1) {
|
|
147 prompt("Link for HTML--documents", hyperlinkRef);
|
|
148 } else {
|
|
149 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}");
|
|
150 }
|
|
151 }
|
|
152
|
|
153
|
31
|
154 function mark(refselect) {
|
17
|
155
|
|
156 if (att[4].split(";").length > 7) {
|
|
157 alert("Only 8 marks are possible at the moment!");
|
|
158 return;
|
|
159 }
|
|
160
|
31
|
161 document.lay1.captureEvents(Event.MOUSEDOWN);
|
|
162 document.lay1.onmousedown = function(event) {
|
17
|
163
|
|
164 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
165 att[4] += ";";
|
|
166 } else {
|
|
167 att[4] = "";
|
|
168 }
|
|
169
|
31
|
170 var markX = cropFloat(att[5]+(att[7]*event.x/document.lay1.clip.width));
|
|
171 var markY = cropFloat(att[6]+(att[8]*event.y/document.lay1.clip.height));
|
17
|
172
|
|
173 att[4] += markX + "/" + markY;
|
|
174
|
31
|
175 document.lay1.releaseEvents(Event.MOUSEDOWN);
|
|
176 setMarks();
|
17
|
177 }
|
|
178 }
|
|
179
|
|
180
|
31
|
181 function zoomArea() {
|
17
|
182 var state = 0;
|
|
183 var x1, y1, x2, y2;
|
|
184
|
31
|
185 function click(event) {
|
17
|
186
|
|
187 if (state == 0) {
|
|
188 state = 1;
|
|
189
|
|
190 x1 = event.pageX;
|
|
191 y1 = event.pageY;
|
|
192 x2 = x1;
|
|
193 y2 = y1;
|
|
194
|
31
|
195 document.eck1.moveTo(((x1 < x2) ? x1 : x2), ((y1 < y2) ? y1 : y2));
|
|
196 document.eck2.moveTo(((x1 < x2) ? x2 : x1)-12, ((y1 < y2) ? y1 : y2));
|
|
197 document.eck3.moveTo(((x1 < x2) ? x1 : x2), ((y1 < y2) ? y2 : y1)-12);
|
|
198 document.eck4.moveTo(((x1 < x2) ? x2 : x1)-12, ((y1 < y2) ? y2 : y1)-12);
|
17
|
199
|
31
|
200 document.eck1.visibility="show";
|
|
201 document.eck2.visibility="show";
|
|
202 document.eck3.visibility="show";
|
|
203 document.eck4.visibility="show";
|
17
|
204
|
31
|
205 document.lay1.captureEvents(Event.MOUSEMOVE);
|
|
206 document.eck4.captureEvents(Event.MOUSEMOVE);
|
17
|
207
|
31
|
208 document.lay1.onmousemove = move;
|
|
209 document.eck4.onmousemove = move;
|
17
|
210
|
|
211 } else {
|
|
212
|
31
|
213 x1 -= document.lay1.x;
|
|
214 y1 -= document.lay1.y;
|
17
|
215
|
31
|
216 x2 = event.pageX-document.lay1.x;
|
|
217 y2 = event.pageY-document.lay1.y;
|
17
|
218
|
31
|
219 document.lay1.releaseEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
|
|
220 document.eck4.releaseEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
|
17
|
221
|
31
|
222 document.eck1.visibility="hide";
|
|
223 document.eck2.visibility="hide";
|
|
224 document.eck3.visibility="hide";
|
|
225 document.eck4.visibility="hide";
|
17
|
226
|
31
|
227 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/document.lay1.clip.width);
|
|
228 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/document.lay1.clip.height);
|
17
|
229
|
31
|
230 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/document.lay1.clip.width);
|
|
231 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/document.lay1.clip.height);
|
17
|
232
|
|
233 if (att[7] != 0 && att[8] != 0) {
|
|
234 loadPicture(2);
|
|
235 }
|
|
236 }
|
|
237 }
|
|
238
|
31
|
239 function move(event) {
|
17
|
240
|
|
241 x2 = event.pageX;
|
|
242 y2 = event.pageY;
|
|
243
|
31
|
244 document.eck1.moveTo(((x1 < x2) ? x1 : x2), ((y1 < y2) ? y1 : y2));
|
|
245 document.eck2.moveTo(((x1 < x2) ? x2 : x1)-12, ((y1 < y2) ? y1 : y2));
|
|
246 document.eck3.moveTo(((x1 < x2) ? x1 : x2), ((y1 < y2) ? y2 : y1)-12);
|
|
247 document.eck4.moveTo(((x1 < x2) ? x2 : x1)-12, ((y1 < y2) ? y2 : y1)-12);
|
17
|
248 }
|
|
249
|
31
|
250 document.lay1.captureEvents(Event.MOUSEDOWN);
|
|
251 document.eck4.captureEvents(Event.MOUSEDOWN);
|
17
|
252
|
31
|
253 document.lay1.onmousedown = click;
|
|
254 document.eck4.onmousedown = click;
|
17
|
255 }
|
|
256
|
|
257
|
31
|
258 function zoomPoint() {
|
17
|
259
|
31
|
260 document.lay1.captureEvents(Event.MOUSEDOWN);
|
|
261 document.lay1.onmousedown = function(event) {
|
17
|
262
|
31
|
263 att[5] = cropFloat(att[5]+(att[7]*event.x/document.lay1.clip.width-0.5*att[7]*0.7));
|
|
264 att[6] = cropFloat(att[6]+(att[8]*event.y/document.lay1.clip.height-0.5*att[8]*0.7));
|
17
|
265
|
|
266 att[7] = cropFloat(att[7]*0.7);
|
|
267 att[8] = cropFloat(att[8]*0.7);
|
|
268
|
|
269 if (att[5] < 0) {
|
|
270 att[5] = 0;
|
|
271 }
|
|
272 if (att[6] < 0) {
|
|
273 att[6] = 0;
|
|
274 }
|
|
275 if (att[5]+att[7] > 1) {
|
|
276 att[5] = 1-att[7];
|
|
277 }
|
|
278 if (att[6]+att[8] > 1) {
|
|
279 att[6] = 1-att[8];
|
|
280 }
|
|
281
|
|
282 releaseEvents(Event.MOUSEDOWN);
|
|
283
|
|
284 loadPicture(2);
|
|
285 }
|
|
286 }
|
|
287
|
|
288
|
31
|
289 function zoomOut() {
|
17
|
290 loadPicture(1);
|
|
291 }
|
|
292
|
|
293
|
31
|
294 function moveTo() {
|
17
|
295
|
31
|
296 document.lay1.captureEvents(Event.MOUSEDOWN);
|
|
297 document.lay1.onmousedown = function(event) {
|
17
|
298
|
31
|
299 att[5] = cropFloat(att[5]+(att[7]*event.x/document.lay1.clip.width-0.5*att[7]));
|
|
300 att[6] = cropFloat(att[6]+(att[8]*event.y/document.lay1.clip.height-0.5*att[8]));
|
17
|
301
|
|
302 if (att[5] < 0) {
|
|
303 att[5] = 0;
|
|
304 }
|
|
305 if (att[6] < 0) {
|
|
306 att[6] = 0;
|
|
307 }
|
|
308 if (att[5]+att[7] > 1) {
|
|
309 att[5] = 1-att[7];
|
|
310 }
|
|
311 if (att[6]+att[8] > 1) {
|
|
312 att[6] = 1-att[8];
|
|
313 }
|
|
314
|
|
315 releaseEvents(Event.MOUSEDOWN);
|
|
316
|
|
317 loadPicture(2);
|
|
318 }
|
|
319 }
|
|
320
|
|
321
|
31
|
322 function scale(scaledef) {
|
17
|
323
|
|
324 att[2] = scaledef;
|
|
325 loadPicture(2);
|
|
326 }
|
|
327
|
|
328
|
31
|
329 function setMarks() {
|
17
|
330 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
331 var mark = att[4].split(";");
|
|
332
|
|
333 var countMarks = mark.length;
|
|
334
|
|
335 // maximum of marks is 8
|
|
336 // we do not report this error because this is already done in func. "Mark"
|
|
337 if (countMarks > 8) countMarks = 8;
|
|
338
|
31
|
339 var picWidth = document.lay1.clip.width;
|
|
340 var picHeight = document.lay1.clip.height;
|
17
|
341
|
|
342 for (var i = 0; i < countMarks; i++) {
|
|
343 mark[i] = mark[i].split("/");
|
|
344
|
|
345 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]))) {
|
|
346
|
31
|
347 mark[i][0] = parseInt(document.lay1.x + (picWidth*(mark[i][0]-att[5]))/att[7]);
|
|
348 mark[i][1] = parseInt(document.lay1.y + (picHeight*(mark[i][1]-att[6]))/att[8]);
|
17
|
349
|
31
|
350 document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5);
|
|
351 document.layers[i+1].visibility = "show";
|
17
|
352 }
|
|
353 }
|
|
354 }
|
|
355 }
|
|
356
|
|
357
|
|
358 // capturing keypresses for next and previous page
|
|
359 function parseKeypress(event) {
|
|
360 var whichCode = (window.Event) ? event.which : event.keyCode;
|
|
361 if (String.fromCharCode(whichCode) == "n") {
|
|
362 Nextpage();
|
|
363 }
|
|
364 if (String.fromCharCode(whichCode) == "b") {
|
|
365 Backpage();
|
|
366 }
|
|
367 }
|
|
368
|
|
369
|
|
370 // auxiliary function to crop senseless precicsion
|
|
371 function cropFloat(tmp) {
|
|
372 return parseInt(10000*tmp)/10000;
|
|
373 }
|