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