Mercurial > hg > digilib
annotate client/digitallibrary/navigation.js @ 239:2f4764230089
new digimage with red triangles for moving the zoomed area
(can be switched off with "clop=noarrows")
author | robcast |
---|---|
date | Wed, 04 Aug 2004 20:35:35 +0200 |
parents | 9856cc853801 |
children |
rev | line source |
---|---|
129 | 1 /* |
2 | |
3 Copyright (C) 2003 WTWG, Uni Bern | |
4 | |
5 This program is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU General Public License | |
7 as published by the Free Software Foundation; either version 2 | |
8 of the License, or (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software | |
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
18 | |
19 Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.4 | |
20 | |
21 */ | |
22 | |
221 | 23 function identify() { |
24 return 'Digilib v0.6'; | |
25 } | |
26 | |
27 | |
129 | 28 var ZOOMFACTOR = Math.sqrt(2); |
29 | |
30 dlParams = new Object(); | |
31 | |
32 function newParameter(name, value, defaultValue, detail) { | |
33 | |
34 if ( !dlParams[name] ) { | |
35 | |
36 dlParams[name] = new Object(); | |
37 | |
38 dlParams[name].value = value; | |
39 dlParams[name].defaultValue = defaultValue; | |
40 dlParams[name].detail = detail; | |
41 | |
42 return dlParams[name]; | |
43 | |
44 } else { | |
45 | |
46 alert("Fatal: An object with name '" + name + "' already exists - cannot recreate!"); | |
47 return false; | |
48 | |
49 } | |
50 } | |
51 | |
52 function getParameter(name) { | |
53 | |
54 if ( dlParams[name] ) { | |
55 return dlParams[name].value; | |
56 } else { | |
57 return false; | |
58 } | |
59 } | |
60 | |
61 | |
62 | |
63 function listParametersAsString() { | |
64 | |
65 var params = new Array(); | |
66 | |
67 for ( param in dlParams ) { | |
68 params.push(param); | |
69 } | |
70 | |
71 return params.join(","); | |
72 | |
73 } | |
74 | |
75 | |
76 function listParameters() { | |
77 | |
78 var params = new Array(); | |
79 | |
80 for ( param in dlParams ) { | |
81 params.push(param); | |
82 } | |
83 | |
84 return params; | |
85 | |
86 } | |
87 | |
88 | |
89 function init() { | |
90 | |
91 // give a name to the window containing digilib - this way one can test if there is already a | |
92 // digilib-window open and replace the contents of it (ex. digicat) | |
93 top.window.name = "digilib"; | |
94 | |
95 placeMarks(); | |
96 | |
97 if ( document.all ) { | |
98 this.document.onkeypress = parseKeypress; | |
99 } else if ( typeof(document.addEventListener) == "function" ) { | |
100 this.document.addEventListener('keypress', parseKeypress, true); | |
101 } else { | |
102 window.captureEvents(Event.KEYDOWN); | |
103 window.onkeydown = parseKeypress; | |
104 } | |
105 | |
106 focus(); | |
107 } | |
108 | |
109 | |
110 function display(detail) { | |
111 | |
112 var queryString = ''; | |
113 | |
114 for ( param in dlParams ) { | |
115 | |
116 if ( dlParams[param].defaultValue != dlParams[param].value ) { | |
117 if ( dlParams[param].detail <= detail ) { | |
118 queryString += "&" + param + "=" + dlParams[param].value; | |
119 } else { | |
120 queryString += "&" + param + "=" + dlParams[param].defaultValue; | |
121 } | |
122 } | |
123 | |
124 } | |
125 | |
195
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
126 // window size |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
127 var wwidth, wheight; |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
128 if (self.innerHeight) // all except Explorer |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
129 { |
226 | 130 wwidth = self.innerWidth; |
131 wheight = self.innerHeight; | |
129 | 132 } |
195
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
133 else if (document.documentElement && document.documentElement.clientHeight) |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
134 // Explorer 6 Strict Mode |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
135 { |
226 | 136 wwidth = document.documentElement.clientWidth; |
137 wheight = document.documentElement.clientHeight; | |
195
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
138 } |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
139 else if (document.body) // other Explorers |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
140 { |
226 | 141 wwidth = document.body.clientWidth; |
142 wheight = document.body.clientHeight; | |
195
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
143 } |
226 | 144 queryString += "&dw=" + (wwidth-30) + "&dh=" + (wheight-30); |
129 | 145 |
146 queryString += "&lv=1"; | |
147 | |
148 queryString = queryString.slice(1); | |
149 | |
150 location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString; | |
151 | |
152 } | |
153 | |
154 | |
155 // constructor holding different values of a point | |
156 function Point(evt) { | |
157 | |
158 if ( document.all ) { | |
159 | |
160 this.pageX = parseInt(document.body.scrollLeft+event.clientX); | |
161 this.pageY = parseInt(document.body.scrollLeft+event.clientY); | |
162 | |
163 this.x = this.pageX-parseInt(document.all.lay1.style.left); | |
164 this.y = this.pageY-parseInt(document.all.lay1.style.top); | |
165 | |
166 this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.all.lay1.offsetWidth)); | |
167 this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.all.lay1.offsetHeight)); | |
168 | |
169 } else { | |
170 | |
171 this.pageX = parseInt(evt.pageX); | |
172 this.pageY = parseInt(evt.pageY); | |
173 | |
174 if ( typeof(document.getElementById) == "function" ) { | |
175 | |
176 this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); | |
177 this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); | |
178 | |
179 this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.pic.offsetWidth)); | |
180 this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.pic.offsetHeight)); | |
181 | |
182 } else { | |
183 | |
184 this.x = this.pageX-document.lay1.left; | |
185 this.y = this.pageY-document.lay1.top; | |
186 | |
187 this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.lay1.clip.width)); | |
188 this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.lay1.clip.height)); | |
189 | |
190 } | |
191 | |
192 } | |
193 | |
194 return this; | |
195 | |
196 } | |
197 | |
198 | |
199 function page(page, details) { | |
200 | |
201 if ( details == null ) { | |
202 details = 1; | |
203 } | |
204 | |
205 if ( page.indexOf('-') == 0 ) { | |
206 if ( dlParams.pn.value > 1 ) { | |
207 page = Math.max(parseInt(dlParams.pn.value) - parseInt(page.slice(1)), 1); | |
208 dlParams.pn.value = page; | |
209 display(details); | |
210 } else { | |
211 alert("You are already on the first page!"); | |
212 } | |
213 | |
214 } else if ( page.indexOf('+') == 0 ) { | |
215 page = parseInt(dlParams.pn.value) + parseInt(page.slice(1)); | |
216 dlParams.pn.value = page; | |
217 display(details); | |
218 } else if ( page == parseInt(page) ) { | |
219 dlParams.pn.value = parseInt(page); | |
220 display(details); | |
221 } | |
222 | |
223 } | |
224 | |
225 | |
226 function digicat() { | |
227 | |
228 var url = baseUrl + "/digicat.jsp?" + dlParams.fn.value + "+" + dlParams.pn.value; | |
229 win = window.open(url, "digicat"); | |
230 win.focus(); | |
231 | |
232 } | |
233 | |
234 | |
221 | 235 function ref() { |
129 | 236 |
237 var hyperlinkRef = baseUrl + "/digilib.jsp?"; | |
238 hyperlinkRef += dlParams.fn.value + "+" + dlParams.pn.value + "+" + dlParams.ws.value + "+"; | |
239 hyperlinkRef += dlParams.mo.value + "+" + dlParams.mk.value; | |
240 | |
241 if ( (dlParams.wx.value != 0) || (dlParams.wy.value != 0) || (dlParams.ww.value != 1) || (dlParams.wh.value != 1) ) { | |
242 hyperlinkRef += "+" + dlParams.wx.value + "+" + dlParams.wy.value + "+" + dlParams.ww.value; | |
243 hyperlinkRef += "+" + dlParams.wh.value; | |
244 } | |
245 | |
221 | 246 return hyperlinkRef; |
247 | |
248 } | |
249 | |
250 | |
251 function ref(select) { | |
252 | |
129 | 253 if ( select == 0 ) { |
221 | 254 prompt("Link for LaTeX-documents", "\\href{" + ref() + "}{TEXT}"); |
129 | 255 } else if ( select == 1 ) { |
221 | 256 prompt("Link for HTML-documents", ref()); |
129 | 257 } |
258 } | |
259 | |
260 | |
261 function mark() { | |
262 | |
263 if ( dlParams.mk.value.split(";").length > 7 ) { | |
264 alert("Only 8 marks are possible at the moment!"); | |
265 return; | |
266 } | |
267 | |
268 function markEvent(evt) { | |
269 | |
270 var point = new Point(evt); | |
271 | |
272 if ( dlParams.mk.value != '' ) { | |
273 dlParams.mk.value += ';'; | |
274 } | |
275 | |
276 dlParams.mk.value += point.relX + '/' + point.relY; | |
277 | |
278 // stopping event capture | |
279 if ( document.all ) { | |
280 document.all.lay1.onmousedown = null; | |
281 } else if ( typeof(document.removeEventListener) == "function" ) { | |
282 document.getElementById("lay1").removeEventListener("mousedown", markEvent, true); | |
283 } else { | |
284 document.lay1.releaseEvents(Event.MOUSEDOWN); | |
285 } | |
286 | |
287 placeMarks(); | |
288 | |
289 } | |
290 | |
291 // starting event capture | |
292 if ( document.all ) { | |
293 document.all.lay1.onmousedown = markEvent; | |
294 } else if ( typeof(document.addEventListener) == "function" ) { | |
295 document.getElementById("lay1").addEventListener("mousedown", markEvent, true); | |
296 } else { | |
297 document.lay1.captureEvents(Event.MOUSEDOWN); | |
298 document.lay1.onmousedown = markEvent; | |
299 } | |
300 } | |
301 | |
302 | |
303 function placeMarks() { | |
304 | |
305 if ( dlParams.mk.value != '' ) { | |
306 | |
307 var mark = dlParams.mk.value.split(";"); | |
308 var mark_count = mark.length; | |
309 | |
310 // maximum of marks is 8 | |
311 // we do not report this error because this is already done in function 'mark' | |
312 if ( mark_count > 8 ) mark_count = 8; | |
313 | |
314 var picWidth = (document.all) ? parseInt(document.all.lay1.offsetWidth) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetWidth) : parseInt(document.pic.clip.width); | |
315 var picHeight = (document.all) ? parseInt(document.all.lay1.offsetHeight) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetHeight) : parseInt(document.pic.clip.height); | |
316 | |
317 // catch the cases where the picture had not been loaded already and | |
318 // make a timeout so that the coordinates are calculated with the real dimensions | |
319 if ( (document.pic.complete) || (picWidth > 30) ) { | |
320 | |
321 var xOffset = (document.all) ? parseInt(document.all.lay1.style.left) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.left) : document.lay1.left; | |
322 var yOffset = (document.all) ? parseInt(document.all.lay1.style.top) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.top) : document.lay1.top; | |
323 | |
324 for (var i = 0; i < mark_count; i++) { | |
325 mark[i] = mark[i].split("/"); | |
326 | |
327 if ( (mark[i][0] >= dlParams.wx.value) && (mark[i][1] >= dlParams.wy.value) && (mark[i][0] <= (parseFloat(dlParams.wx.value) + parseFloat(dlParams.ww.value))) && (mark[i][1] <= (parseFloat(dlParams.wy.value) + parseFloat(dlParams.wh.value))) ) { | |
328 | |
329 mark[i][0] = parseInt(xOffset + picWidth * (mark[i][0] - dlParams.wx.value)/dlParams.ww.value); | |
330 mark[i][1] = parseInt(yOffset + picHeight * (mark[i][1] - dlParams.wy.value)/dlParams.wh.value); | |
331 | |
332 if ( (document.all) || (typeof(document.getElementById) == "function") ) { | |
333 // suboptimal to place -5 pixels and not half size of mark-image | |
334 // should be changed in the future | |
335 document.getElementById("dot" + i).style.left = mark[i][0]-5; | |
336 document.getElementById("dot" + i).style.top = mark[i][1]-5; | |
337 document.getElementById("dot" + i).style.visibility = "visible"; | |
338 } else { | |
339 document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5); | |
340 document.layers[i+1].visibility = "show"; | |
341 } | |
342 } | |
343 } | |
344 | |
345 } else { | |
346 setTimeout("placeMarks()", 100); | |
347 } | |
348 } | |
349 } | |
350 | |
351 | |
352 function zoomPoint() { | |
353 | |
354 function zoomPointEvent(evt) { | |
355 | |
356 var point = new Point(evt); | |
357 | |
358 dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value*(1/ZOOMFACTOR)); | |
359 dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value*(1/ZOOMFACTOR)); | |
360 | |
361 dlParams.ww.value = cropFloat(dlParams.ww.value*(1/ZOOMFACTOR)); | |
362 dlParams.wh.value = cropFloat(dlParams.wh.value*(1/ZOOMFACTOR)); | |
363 | |
364 if ( dlParams.wx.value < 0 ) { | |
365 dlParams.wx.value = 0; | |
366 } | |
367 if ( dlParams.wy.value < 0 ) { | |
368 dlParams.wy.value = 0; | |
369 } | |
370 if ( dlParams.wx.value + dlParams.ww.value > 1 ) { | |
371 dlParams.wx.value = 1 - dlParams.ww.value; | |
372 } | |
373 if ( dlParams.wy.value + dlParams.wh.value > 1 ) { | |
374 dlParams.wy.value = 1 - dlParams.wh.value; | |
375 } | |
376 | |
377 // stopping event capture | |
378 if ( document.all ) { | |
379 document.all.lay1.onmousedown = null; | |
380 } else if ( typeof(document.removeEventListener) == "function" ) { | |
381 document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true); | |
382 } else { | |
383 document.lay1.releaseEvents(Event.MOUSEDOWN); | |
384 } | |
385 | |
386 display(3); | |
387 } | |
388 | |
389 // starting event capture | |
390 if ( document.all ) { | |
391 document.all.lay1.onmousedown = zoomPointEvent; | |
392 } else if ( typeof(document.addEventListener) == "function" ) { | |
393 document.getElementById("lay1").addEventListener("mousedown", zoomPointEvent, true); | |
394 } else { | |
395 document.lay1.captureEvents(Event.MOUSEDOWN); | |
396 document.lay1.onmousedown = zoomPointEvent; | |
397 } | |
398 } | |
399 | |
400 | |
401 function zoomArea() { | |
402 var state = 0; | |
403 var pt1, pt2; | |
404 | |
405 function click(evt) { | |
406 | |
407 if (state == 0) { | |
408 state = 1; | |
409 | |
410 pt1 = new Point(evt); | |
411 pt2 = pt1; | |
412 | |
413 if ( document.all ) { | |
414 | |
415 document.all.eck1.style.left = pt1.pageX; | |
416 document.all.eck1.style.top = pt1.pageY; | |
417 document.all.eck2.style.left = pt2.pageX-12; | |
418 document.all.eck2.style.top = pt1.pageY; | |
419 document.all.eck3.style.left = pt1.pageX; | |
420 document.all.eck3.style.top = pt2.pageY-12; | |
421 document.all.eck4.style.left = pt2.pageX-12; | |
422 document.all.eck4.style.top = pt2.pageY-12; | |
423 | |
424 document.all.eck1.style.visibility="visible"; | |
425 document.all.eck2.style.visibility="visible"; | |
426 document.all.eck3.style.visibility="visible"; | |
427 document.all.eck4.style.visibility="visible"; | |
428 | |
429 document.all.lay1.onmousemove = move; | |
430 document.all.eck4.onmousemove = move; | |
431 | |
432 } else if ( typeof(document.addEventListener) == "function" ) { | |
433 | |
434 document.getElementById("eck1").style.left = pt1.pageX; | |
435 document.getElementById("eck1").style.top = pt1.pageY; | |
436 document.getElementById("eck2").style.left = pt2.pageX-12; | |
437 document.getElementById("eck2").style.top = pt1.pageY; | |
438 document.getElementById("eck3").style.left = pt1.pageX; | |
439 document.getElementById("eck3").style.top = pt2.pageY-12; | |
440 document.getElementById("eck4").style.left = pt2.pageX-12; | |
441 document.getElementById("eck4").style.top = pt2.pageY-12; | |
442 | |
443 document.getElementById("eck1").style.visibility="visible"; | |
444 document.getElementById("eck2").style.visibility="visible"; | |
445 document.getElementById("eck3").style.visibility="visible"; | |
446 document.getElementById("eck4").style.visibility="visible"; | |
447 | |
448 document.getElementById("lay1").addEventListener("mousemove", move, true); | |
449 document.getElementById("eck4").addEventListener("mousemove", move, true); | |
450 | |
451 } else { | |
452 | |
453 document.eck1.moveTo(pt1.pageX, pt1.pageY); | |
454 document.eck2.moveTo(pt2.pageX-12, pt1.pageY); | |
455 document.eck3.moveTo(pt1.pageX, pt2.pageY-12); | |
456 document.eck4.moveTo(pt2.pageX-12, pt2.pageY-12); | |
457 | |
458 document.eck1.visibility="show"; | |
459 document.eck2.visibility="show"; | |
460 document.eck3.visibility="show"; | |
461 document.eck4.visibility="show"; | |
462 | |
463 document.lay1.captureEvents(Event.MOUSEMOVE); | |
464 document.eck4.captureEvents(Event.MOUSEMOVE); | |
465 document.lay1.onmousemove = move; | |
466 document.eck4.onmousemove = move; | |
467 | |
468 } | |
469 | |
470 } else { | |
471 | |
472 pt2 = new Point(evt); | |
473 | |
474 if ( document.all ) { | |
475 | |
476 document.all.eck1.visibility="hidden"; | |
477 document.all.eck2.visibility="hidden"; | |
478 document.all.eck3.visibility="hidden"; | |
479 document.all.eck4.visibility="hidden"; | |
480 | |
481 document.all.lay1.onmousedown = null; | |
482 document.all.eck4.onmousedown = null; | |
483 document.all.lay1.onmousemove = null; | |
484 document.all.eck4.onmousemove = null; | |
485 | |
486 } else if ( typeof(document.removeEventListener) == "function" ) { | |
487 | |
488 document.getElementById("eck1").style.visibility="hidden"; | |
489 document.getElementById("eck2").style.visibility="hidden"; | |
490 document.getElementById("eck3").style.visibility="hidden"; | |
491 document.getElementById("eck4").style.visibility="hidden"; | |
492 | |
493 document.getElementById("lay1").removeEventListener("mousedown", click, true); | |
494 document.getElementById("eck4").removeEventListener("mousedown", click, true); | |
495 document.getElementById("lay1").removeEventListener("mousemove", move, true); | |
496 document.getElementById("eck4").removeEventListener("mousemove", move, true); | |
497 | |
498 } else { | |
499 | |
500 document.eck1.visibility="hide"; | |
501 document.eck2.visibility="hide"; | |
502 document.eck3.visibility="hide"; | |
503 document.eck4.visibility="hide"; | |
504 | |
505 document.lay1.releaseEvents(Event.MOUSEDOWN); | |
506 document.eck4.releaseEvents(Event.MOUSEDOWN); | |
507 document.lay1.releaseEvents(Event.MOUSEMOVE); | |
508 document.eck4.releaseEvents(Event.MOUSEMOVE); | |
509 | |
510 } | |
511 | |
512 dlParams.wx.value = cropFloat(parseFloat(Math.min(pt1.relX, pt2.relX))); | |
513 dlParams.wy.value = cropFloat(parseFloat(Math.min(pt1.relY, pt2.relY))); | |
514 | |
515 dlParams.ww.value = cropFloat(parseFloat(Math.abs(pt1.relX-pt2.relX))); | |
516 dlParams.wh.value = cropFloat(parseFloat(Math.abs(pt1.relY-pt2.relY))); | |
517 | |
518 if ( (dlParams.ww.value != 0) && (dlParams.wh.value != 0) ) { | |
519 display(3); | |
520 } | |
521 } | |
522 } | |
523 | |
524 function move(evt) { | |
525 | |
526 pt2 = new Point(evt); | |
527 | |
528 var eck1_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); | |
529 var eck1_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); | |
530 var eck2_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;; | |
531 var eck2_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); | |
532 var eck3_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); | |
533 var eck3_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; | |
534 var eck4_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; | |
535 var eck4_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; | |
536 | |
537 if ( document.all ) { | |
538 | |
539 document.all.eck1.style.left = eck1_left; | |
540 document.all.eck1.style.top = eck1_top; | |
541 document.all.eck2.style.left = eck2_left; | |
542 document.all.eck2.style.top = eck2_top; | |
543 document.all.eck3.style.left = eck3_left; | |
544 document.all.eck3.style.top = eck3_top; | |
545 document.all.eck4.style.left = eck4_left; | |
546 document.all.eck4.style.top = eck4_top; | |
547 | |
548 } else if ( typeof(document.getElementById) == "function" ) { | |
549 | |
550 document.getElementById("eck1").style.left = eck1_left; | |
551 document.getElementById("eck1").style.top = eck1_top; | |
552 document.getElementById("eck2").style.left = eck2_left; | |
553 document.getElementById("eck2").style.top = eck2_top; | |
554 document.getElementById("eck3").style.left = eck3_left; | |
555 document.getElementById("eck3").style.top = eck3_top; | |
556 document.getElementById("eck4").style.left = eck4_left; | |
557 document.getElementById("eck4").style.top = eck4_top; | |
558 | |
559 } else { | |
560 | |
561 document.eck1.moveTo(eck1_left, eck1_top); | |
562 document.eck2.moveTo(eck2_left, eck2_top); | |
563 document.eck3.moveTo(eck3_left, eck3_top); | |
564 document.eck4.moveTo(eck4_left, eck4_top); | |
565 | |
566 } | |
567 } | |
568 | |
569 // starting event capture | |
570 if ( document.all ) { | |
571 document.all.lay1.onmousedown = click; | |
572 document.all.eck4.onmousedown = click; | |
573 } else if ( typeof(document.addEventListener) == "function" ) { | |
574 document.getElementById("lay1").addEventListener("mousedown", click, true); | |
575 document.getElementById("eck4").addEventListener("mousedown", click, true); | |
576 } else { | |
577 document.lay1.captureEvents(Event.MOUSEDOWN); | |
578 document.eck4.captureEvents(Event.MOUSEDOWN); | |
579 document.lay1.onmousedown = click; | |
580 document.eck4.onmousedown = click; | |
581 } | |
582 } | |
583 | |
584 | |
585 function zoomExtends() { | |
586 | |
587 dlParams.wx.value = 0.0; | |
588 dlParams.wy.value = 0.0; | |
589 | |
590 dlParams.ww.value = 1.0; | |
591 dlParams.wh.value = 1.0; | |
592 | |
593 display(3); | |
594 | |
595 } | |
596 | |
597 | |
598 function zoomOut() { | |
599 | |
600 dlParams.wx.value = cropFloat(dlParams.wx.value-0.5*(dlParams.ww.value*(ZOOMFACTOR)-dlParams.ww.value)); | |
601 dlParams.wy.value = cropFloat(dlParams.wy.value-0.5*(dlParams.wh.value*(ZOOMFACTOR)-dlParams.wh.value)); | |
602 | |
603 dlParams.ww.value = cropFloat(dlParams.ww.value*(ZOOMFACTOR)); | |
604 dlParams.wh.value = cropFloat(dlParams.wh.value*(ZOOMFACTOR)); | |
605 | |
606 if ( dlParams.wx.value < 0 ) { | |
607 dlParams.wx.value = 0; | |
608 } | |
609 if ( dlParams.wy.value < 0 ) { | |
610 dlParams.wy.value = 0; | |
611 } | |
612 if ( dlParams.ww.value > 1 ) { | |
613 dlParams.ww.value = 1; | |
614 } | |
615 if ( dlParams.wh.value > 1 ) { | |
616 dlParams.wh.value = 1; | |
617 } | |
618 if ( dlParams.wx.value + dlParams.ww.value > 1 ) { | |
619 dlParams.wx.value = 1 - dlParams.ww.value; | |
620 } | |
621 if ( dlParams.wy.value + dlParams.wh.value > 1 ) { | |
622 dlParams.wy.value = 1 - dlParams.wh.value; | |
623 } | |
624 | |
625 display(3); | |
626 } | |
627 | |
628 | |
629 function moveTo() { | |
630 | |
631 if ( (parseFloat(dlParams.ww.value) == 1.0) && (parseFloat(dlParams.wh.value) == 1.0) ) { | |
632 alert("This function is only available when zoomed in!"); | |
633 return; | |
634 } | |
635 | |
636 function moveToEvent(event) { | |
637 | |
638 var point = new Point(event); | |
639 | |
640 dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value); | |
641 dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value); | |
642 | |
643 if ( dlParams.wx.value < 0 ) { | |
644 dlParams.wx.value = 0; | |
645 } | |
646 if ( dlParams.wy.value < 0 ) { | |
647 dlParams.wy.value = 0; | |
648 } | |
649 if ( dlParams.wx.value + dlParams.ww.value > 1 ) { | |
650 dlParams.wx.value = 1 - dlParams.ww.value; | |
651 } | |
652 if ( dlParams.wy.value + dlParams.wh.value > 1 ) { | |
653 dlParams.wy.value = 1 - dlParams.wh.value; | |
654 } | |
655 | |
656 // stopping event capture | |
657 if ( document.all ) { | |
658 document.all.lay1.onmousedown = null; | |
659 } else if ( typeof(document.removeEventListener) == "function" ) { | |
660 document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true); | |
661 } else { | |
662 document.lay1.releaseEvents(Event.MOUSEDOWN) | |
663 } | |
664 | |
665 display(3); | |
666 } | |
667 | |
668 // starting event capture | |
669 if ( document.all ) { | |
670 document.all.lay1.onmousedown = moveToEvent; | |
671 } else if ( typeof(document.addEventListener) == "function" ) { | |
672 document.getElementById("lay1").addEventListener("mousedown", moveToEvent, true); | |
673 } else { | |
674 document.lay1.captureEvents(Event.MOUSEDOWN); | |
675 document.lay1.onmousedown = moveToEvent; | |
676 } | |
677 } | |
678 | |
679 | |
680 function scale(factor) { | |
681 | |
682 dlParams.ws.value = cropFloat(factor); | |
683 display(3); | |
684 | |
685 } | |
686 | |
687 | |
688 // capturing keypresses for next and previous page | |
689 function parseKeypress(evt) { | |
690 | |
691 if ( document.all ) { | |
692 | |
693 if ( event.keyCode == 110 ) { | |
694 page('+1'); | |
695 } | |
696 if ( event.keyCode == 98 ) { | |
697 page('-1'); | |
698 } | |
699 | |
700 document.cancleBubble = true; | |
701 | |
702 } else { | |
703 | |
704 if ( evt.charCode == 110 ) { | |
705 page('+1'); | |
706 } else if ( evt.charCode == 98 ) { | |
707 page('-1'); | |
708 } else if ( evt.which == 110 ) { | |
709 page('+1'); | |
710 } else if ( evt.which == 98 ) { | |
711 // does not work currentlyfor Opera, because it catches the 'b'-key on it's own | |
712 // have to change the key or find another way - luginbuehl | |
713 page('-1'); | |
714 } | |
715 | |
716 } | |
717 } | |
718 | |
719 | |
720 // auxiliary function to crop senseless precicsion | |
721 function cropFloat(tmp) { | |
722 return parseInt(10000*tmp)/10000; | |
723 } |