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
|
38
|
3 // array with all attributes
|
20
|
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 window.captureEvents(Event.KEYDOWN);
|
|
54 window.onkeydown = parseKeypress;
|
|
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=" + (innerWidth-30) + "&dh=" + (innerHeight-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(event.pageX);
|
|
97 this.pageY = parseInt(event.pageY);
|
|
98
|
|
99 this.x = this.pageX-document.lay1.left;
|
|
100 this.y = this.pageY-document.lay1.top;
|
|
101
|
|
102 this.relX = cropFloat(att[5]+(att[7]*this.x/document.lay1.clip.width));
|
|
103 this.relY = cropFloat(att[6]+(att[8]*this.y/document.lay1.clip.height));
|
|
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() {
|
50
|
144 var url = "digicat.html?" + att[0] + "+" + att[1];
|
20
|
145 win = window.open(url, "digicat");
|
|
146 win.focus();
|
|
147 }
|
|
148
|
|
149
|
34
|
150 function ref(refselect) {
|
20
|
151
|
50
|
152 var hyperlinkRef = baseUrl + "/digilib.jsp?";
|
20
|
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.lay1.captureEvents(Event.MOUSEDOWN);
|
|
170 document.lay1.onmousedown = function(event) {
|
38
|
171 var point = new Point(event);
|
20
|
172
|
|
173 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
174 att[4] += ";";
|
|
175 } else {
|
|
176 att[4] = "";
|
|
177 }
|
|
178
|
38
|
179 att[4] += point.relX + "/" + point.relY;
|
20
|
180
|
34
|
181 document.lay1.releaseEvents(Event.MOUSEDOWN);
|
|
182 setMarks();
|
38
|
183 }
|
20
|
184 }
|
|
185
|
|
186
|
34
|
187 function zoomArea() {
|
20
|
188 var state = 0;
|
38
|
189 var pt1, pt2;
|
20
|
190
|
34
|
191 function click(event) {
|
20
|
192
|
|
193 if (state == 0) {
|
|
194 state = 1;
|
|
195
|
38
|
196 pt1 = new Point(event);
|
|
197 pt2 = pt1;
|
20
|
198
|
38
|
199 document.eck1.moveTo(pt1.pageX, pt1.pageY);
|
|
200 document.eck2.moveTo(pt2.pageX-12, pt1.pageY);
|
|
201 document.eck3.moveTo(pt1.pageX, pt2.pageY-12);
|
|
202 document.eck4.moveTo(pt2.pageX-12, pt2.pageY-12);
|
20
|
203
|
34
|
204 document.eck1.visibility="show";
|
|
205 document.eck2.visibility="show";
|
|
206 document.eck3.visibility="show";
|
|
207 document.eck4.visibility="show";
|
20
|
208
|
34
|
209 document.lay1.captureEvents(Event.MOUSEMOVE);
|
|
210 document.eck4.captureEvents(Event.MOUSEMOVE);
|
20
|
211
|
34
|
212 document.lay1.onmousemove = move;
|
|
213 document.eck4.onmousemove = move;
|
20
|
214
|
|
215 } else {
|
|
216
|
38
|
217 pt2 = new Point(event);
|
20
|
218
|
34
|
219 document.lay1.releaseEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
|
|
220 document.eck4.releaseEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
|
20
|
221
|
34
|
222 document.eck1.visibility="hide";
|
|
223 document.eck2.visibility="hide";
|
|
224 document.eck3.visibility="hide";
|
|
225 document.eck4.visibility="hide";
|
20
|
226
|
38
|
227 att[5] = Math.min(pt1.relX, pt2.relX);
|
|
228 att[6] = Math.min(pt1.relY, pt2.relY);
|
20
|
229
|
38
|
230 att[7] = Math.abs(pt1.relX-pt2.relX);
|
|
231 att[8] = Math.abs(pt1.relY-pt2.relY);
|
20
|
232
|
|
233 if (att[7] != 0 && att[8] != 0) {
|
|
234 loadPicture(2);
|
|
235 }
|
|
236 }
|
|
237 }
|
|
238
|
34
|
239 function move(event) {
|
20
|
240
|
38
|
241 pt2 = new Point(event);
|
20
|
242
|
38
|
243 document.eck1.moveTo(((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX), ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY));
|
|
244 document.eck2.moveTo(((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12, ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY));
|
|
245 document.eck3.moveTo(((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX), ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12);
|
|
246 document.eck4.moveTo(((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12, ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12);
|
20
|
247 }
|
|
248
|
34
|
249 document.lay1.captureEvents(Event.MOUSEDOWN);
|
|
250 document.eck4.captureEvents(Event.MOUSEDOWN);
|
20
|
251
|
34
|
252 document.lay1.onmousedown = click;
|
|
253 document.eck4.onmousedown = click;
|
20
|
254 }
|
|
255
|
|
256
|
34
|
257 function zoomPoint() {
|
20
|
258
|
34
|
259 document.lay1.captureEvents(Event.MOUSEDOWN);
|
|
260 document.lay1.onmousedown = function(event) {
|
38
|
261 var point = new Point(event);
|
|
262
|
|
263 att[5] = cropFloat(point.relX-0.5*att[7]*0.7);
|
|
264 att[6] = cropFloat(point.relY-0.5*att[8]*0.7);
|
20
|
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
|
34
|
289 function zoomOut() {
|
20
|
290 loadPicture(1);
|
|
291 }
|
|
292
|
|
293
|
34
|
294 function moveTo() {
|
20
|
295
|
34
|
296 document.lay1.captureEvents(Event.MOUSEDOWN);
|
|
297 document.lay1.onmousedown = function(event) {
|
38
|
298 var point = new Point(event);
|
20
|
299
|
38
|
300 att[5] = cropFloat(point.relX-0.5*att[7]);
|
|
301 att[6] = cropFloat(point.relY-0.5*att[8]);
|
20
|
302
|
|
303 if (att[5] < 0) {
|
|
304 att[5] = 0;
|
|
305 }
|
|
306 if (att[6] < 0) {
|
|
307 att[6] = 0;
|
|
308 }
|
|
309 if (att[5]+att[7] > 1) {
|
|
310 att[5] = 1-att[7];
|
|
311 }
|
|
312 if (att[6]+att[8] > 1) {
|
|
313 att[6] = 1-att[8];
|
|
314 }
|
|
315
|
|
316 releaseEvents(Event.MOUSEDOWN);
|
|
317
|
|
318 loadPicture(2);
|
|
319 }
|
|
320 }
|
|
321
|
|
322
|
34
|
323 function scale(scaledef) {
|
20
|
324
|
|
325 att[2] = scaledef;
|
|
326 loadPicture(2);
|
|
327 }
|
|
328
|
|
329
|
34
|
330 function setMarks() {
|
20
|
331 if ((att[4] != "") && (att[4] != "0/0")) {
|
|
332 var mark = att[4].split(";");
|
|
333
|
|
334 var countMarks = mark.length;
|
|
335
|
|
336 // maximum of marks is 8
|
|
337 // we do not report this error because this is already done in func. "Mark"
|
|
338 if (countMarks > 8) countMarks = 8;
|
|
339
|
34
|
340 var picWidth = document.lay1.clip.width;
|
|
341 var picHeight = document.lay1.clip.height;
|
20
|
342
|
|
343 for (var i = 0; i < countMarks; i++) {
|
|
344 mark[i] = mark[i].split("/");
|
|
345
|
|
346 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]))) {
|
|
347
|
34
|
348 mark[i][0] = parseInt(document.lay1.x + (picWidth*(mark[i][0]-att[5]))/att[7]);
|
|
349 mark[i][1] = parseInt(document.lay1.y + (picHeight*(mark[i][1]-att[6]))/att[8]);
|
20
|
350
|
34
|
351 document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5);
|
|
352 document.layers[i+1].visibility = "show";
|
20
|
353 }
|
|
354 }
|
|
355 }
|
|
356 }
|
|
357
|
|
358
|
|
359 // capturing keypresses for next and previous page
|
|
360 function parseKeypress(event) {
|
|
361 var whichCode = (window.Event) ? event.which : event.keyCode;
|
|
362 if (String.fromCharCode(whichCode) == "n") {
|
38
|
363 nextPage();
|
20
|
364 }
|
|
365 if (String.fromCharCode(whichCode) == "b") {
|
38
|
366 backPage();
|
20
|
367 }
|
|
368 }
|
|
369
|
|
370
|
|
371 // auxiliary function to crop senseless precicsion
|
|
372 function cropFloat(tmp) {
|
|
373 return parseInt(10000*tmp)/10000;
|
|
374 }
|