Mercurial > hg > digilib
annotate client/digitallibrary/navigation.js @ 221:f9f9a4c86ffd
new digicat version with only one js file
author | luginbue |
---|---|
date | Fri, 09 Jul 2004 02:15:54 +0200 |
parents | 51aea2a9a172 |
children | 9856cc853801 |
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 |
221 | 127 |
195
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
128 var wwidth, wheight; |
221 | 129 |
195
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
130 if (self.innerHeight) // all except Explorer |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
131 { |
221 | 132 wwidth = self.innerWidth; |
133 wheight = self.innerWeight; | |
129 | 134 } |
195
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
135 else if (document.documentElement && document.documentElement.clientHeight) |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
136 // Explorer 6 Strict Mode |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
137 { |
221 | 138 wwidth = document.documentElement.clientWidth; |
139 wheight = document.doumentElement.clientHeight; | |
195
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
140 } |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
141 else if (document.body) // other Explorers |
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
142 { |
221 | 143 wwidth = document.body.clientWidth; |
144 wheight = doument.body.clientHeight; | |
195
51aea2a9a172
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
129
diff
changeset
|
145 } |
221 | 146 queryString += "&dw=" + (wwidth-30) + "&dh=" + (whewight-30); |
129 | 147 |
148 queryString += "&lv=1"; | |
149 | |
150 queryString = queryString.slice(1); | |
151 | |
152 location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString; | |
153 | |
154 } | |
155 | |
156 | |
157 // constructor holding different values of a point | |
158 function Point(evt) { | |
159 | |
160 if ( document.all ) { | |
161 | |
162 this.pageX = parseInt(document.body.scrollLeft+event.clientX); | |
163 this.pageY = parseInt(document.body.scrollLeft+event.clientY); | |
164 | |
165 this.x = this.pageX-parseInt(document.all.lay1.style.left); | |
166 this.y = this.pageY-parseInt(document.all.lay1.style.top); | |
167 | |
168 this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.all.lay1.offsetWidth)); | |
169 this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.all.lay1.offsetHeight)); | |
170 | |
171 } else { | |
172 | |
173 this.pageX = parseInt(evt.pageX); | |
174 this.pageY = parseInt(evt.pageY); | |
175 | |
176 if ( typeof(document.getElementById) == "function" ) { | |
177 | |
178 this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); | |
179 this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); | |
180 | |
181 this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.pic.offsetWidth)); | |
182 this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.pic.offsetHeight)); | |
183 | |
184 } else { | |
185 | |
186 this.x = this.pageX-document.lay1.left; | |
187 this.y = this.pageY-document.lay1.top; | |
188 | |
189 this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.lay1.clip.width)); | |
190 this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.lay1.clip.height)); | |
191 | |
192 } | |
193 | |
194 } | |
195 | |
196 return this; | |
197 | |
198 } | |
199 | |
200 | |
201 function page(page, details) { | |
202 | |
203 if ( details == null ) { | |
204 details = 1; | |
205 } | |
206 | |
207 if ( page.indexOf('-') == 0 ) { | |
208 if ( dlParams.pn.value > 1 ) { | |
209 page = Math.max(parseInt(dlParams.pn.value) - parseInt(page.slice(1)), 1); | |
210 dlParams.pn.value = page; | |
211 display(details); | |
212 } else { | |
213 alert("You are already on the first page!"); | |
214 } | |
215 | |
216 } else if ( page.indexOf('+') == 0 ) { | |
217 page = parseInt(dlParams.pn.value) + parseInt(page.slice(1)); | |
218 dlParams.pn.value = page; | |
219 display(details); | |
220 } else if ( page == parseInt(page) ) { | |
221 dlParams.pn.value = parseInt(page); | |
222 display(details); | |
223 } | |
224 | |
225 } | |
226 | |
227 | |
228 function digicat() { | |
229 | |
230 var url = baseUrl + "/digicat.jsp?" + dlParams.fn.value + "+" + dlParams.pn.value; | |
231 win = window.open(url, "digicat"); | |
232 win.focus(); | |
233 | |
234 } | |
235 | |
236 | |
221 | 237 function ref() { |
129 | 238 |
239 var hyperlinkRef = baseUrl + "/digilib.jsp?"; | |
240 hyperlinkRef += dlParams.fn.value + "+" + dlParams.pn.value + "+" + dlParams.ws.value + "+"; | |
241 hyperlinkRef += dlParams.mo.value + "+" + dlParams.mk.value; | |
242 | |
243 if ( (dlParams.wx.value != 0) || (dlParams.wy.value != 0) || (dlParams.ww.value != 1) || (dlParams.wh.value != 1) ) { | |
244 hyperlinkRef += "+" + dlParams.wx.value + "+" + dlParams.wy.value + "+" + dlParams.ww.value; | |
245 hyperlinkRef += "+" + dlParams.wh.value; | |
246 } | |
247 | |
221 | 248 return hyperlinkRef; |
249 | |
250 } | |
251 | |
252 | |
253 function ref(select) { | |
254 | |
129 | 255 if ( select == 0 ) { |
221 | 256 prompt("Link for LaTeX-documents", "\\href{" + ref() + "}{TEXT}"); |
129 | 257 } else if ( select == 1 ) { |
221 | 258 prompt("Link for HTML-documents", ref()); |
129 | 259 } |
260 } | |
261 | |
262 | |
263 function mark() { | |
264 | |
265 if ( dlParams.mk.value.split(";").length > 7 ) { | |
266 alert("Only 8 marks are possible at the moment!"); | |
267 return; | |
268 } | |
269 | |
270 function markEvent(evt) { | |
271 | |
272 var point = new Point(evt); | |
273 | |
274 if ( dlParams.mk.value != '' ) { | |
275 dlParams.mk.value += ';'; | |
276 } | |
277 | |
278 dlParams.mk.value += point.relX + '/' + point.relY; | |
279 | |
280 // stopping event capture | |
281 if ( document.all ) { | |
282 document.all.lay1.onmousedown = null; | |
283 } else if ( typeof(document.removeEventListener) == "function" ) { | |
284 document.getElementById("lay1").removeEventListener("mousedown", markEvent, true); | |
285 } else { | |
286 document.lay1.releaseEvents(Event.MOUSEDOWN); | |
287 } | |
288 | |
289 placeMarks(); | |
290 | |
291 } | |
292 | |
293 // starting event capture | |
294 if ( document.all ) { | |
295 document.all.lay1.onmousedown = markEvent; | |
296 } else if ( typeof(document.addEventListener) == "function" ) { | |
297 document.getElementById("lay1").addEventListener("mousedown", markEvent, true); | |
298 } else { | |
299 document.lay1.captureEvents(Event.MOUSEDOWN); | |
300 document.lay1.onmousedown = markEvent; | |
301 } | |
302 } | |
303 | |
304 | |
305 function placeMarks() { | |
306 | |
307 if ( dlParams.mk.value != '' ) { | |
308 | |
309 var mark = dlParams.mk.value.split(";"); | |
310 var mark_count = mark.length; | |
311 | |
312 // maximum of marks is 8 | |
313 // we do not report this error because this is already done in function 'mark' | |
314 if ( mark_count > 8 ) mark_count = 8; | |
315 | |
316 var picWidth = (document.all) ? parseInt(document.all.lay1.offsetWidth) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetWidth) : parseInt(document.pic.clip.width); | |
317 var picHeight = (document.all) ? parseInt(document.all.lay1.offsetHeight) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetHeight) : parseInt(document.pic.clip.height); | |
318 | |
319 // catch the cases where the picture had not been loaded already and | |
320 // make a timeout so that the coordinates are calculated with the real dimensions | |
321 if ( (document.pic.complete) || (picWidth > 30) ) { | |
322 | |
323 var xOffset = (document.all) ? parseInt(document.all.lay1.style.left) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.left) : document.lay1.left; | |
324 var yOffset = (document.all) ? parseInt(document.all.lay1.style.top) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.top) : document.lay1.top; | |
325 | |
326 for (var i = 0; i < mark_count; i++) { | |
327 mark[i] = mark[i].split("/"); | |
328 | |
329 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))) ) { | |
330 | |
331 mark[i][0] = parseInt(xOffset + picWidth * (mark[i][0] - dlParams.wx.value)/dlParams.ww.value); | |
332 mark[i][1] = parseInt(yOffset + picHeight * (mark[i][1] - dlParams.wy.value)/dlParams.wh.value); | |
333 | |
334 if ( (document.all) || (typeof(document.getElementById) == "function") ) { | |
335 // suboptimal to place -5 pixels and not half size of mark-image | |
336 // should be changed in the future | |
337 document.getElementById("dot" + i).style.left = mark[i][0]-5; | |
338 document.getElementById("dot" + i).style.top = mark[i][1]-5; | |
339 document.getElementById("dot" + i).style.visibility = "visible"; | |
340 } else { | |
341 document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5); | |
342 document.layers[i+1].visibility = "show"; | |
343 } | |
344 } | |
345 } | |
346 | |
347 } else { | |
348 setTimeout("placeMarks()", 100); | |
349 } | |
350 } | |
351 } | |
352 | |
353 | |
354 function zoomPoint() { | |
355 | |
356 function zoomPointEvent(evt) { | |
357 | |
358 var point = new Point(evt); | |
359 | |
360 dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value*(1/ZOOMFACTOR)); | |
361 dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value*(1/ZOOMFACTOR)); | |
362 | |
363 dlParams.ww.value = cropFloat(dlParams.ww.value*(1/ZOOMFACTOR)); | |
364 dlParams.wh.value = cropFloat(dlParams.wh.value*(1/ZOOMFACTOR)); | |
365 | |
366 if ( dlParams.wx.value < 0 ) { | |
367 dlParams.wx.value = 0; | |
368 } | |
369 if ( dlParams.wy.value < 0 ) { | |
370 dlParams.wy.value = 0; | |
371 } | |
372 if ( dlParams.wx.value + dlParams.ww.value > 1 ) { | |
373 dlParams.wx.value = 1 - dlParams.ww.value; | |
374 } | |
375 if ( dlParams.wy.value + dlParams.wh.value > 1 ) { | |
376 dlParams.wy.value = 1 - dlParams.wh.value; | |
377 } | |
378 | |
379 // stopping event capture | |
380 if ( document.all ) { | |
381 document.all.lay1.onmousedown = null; | |
382 } else if ( typeof(document.removeEventListener) == "function" ) { | |
383 document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true); | |
384 } else { | |
385 document.lay1.releaseEvents(Event.MOUSEDOWN); | |
386 } | |
387 | |
388 display(3); | |
389 } | |
390 | |
391 // starting event capture | |
392 if ( document.all ) { | |
393 document.all.lay1.onmousedown = zoomPointEvent; | |
394 } else if ( typeof(document.addEventListener) == "function" ) { | |
395 document.getElementById("lay1").addEventListener("mousedown", zoomPointEvent, true); | |
396 } else { | |
397 document.lay1.captureEvents(Event.MOUSEDOWN); | |
398 document.lay1.onmousedown = zoomPointEvent; | |
399 } | |
400 } | |
401 | |
402 | |
403 function zoomArea() { | |
404 var state = 0; | |
405 var pt1, pt2; | |
406 | |
407 function click(evt) { | |
408 | |
409 if (state == 0) { | |
410 state = 1; | |
411 | |
412 pt1 = new Point(evt); | |
413 pt2 = pt1; | |
414 | |
415 if ( document.all ) { | |
416 | |
417 document.all.eck1.style.left = pt1.pageX; | |
418 document.all.eck1.style.top = pt1.pageY; | |
419 document.all.eck2.style.left = pt2.pageX-12; | |
420 document.all.eck2.style.top = pt1.pageY; | |
421 document.all.eck3.style.left = pt1.pageX; | |
422 document.all.eck3.style.top = pt2.pageY-12; | |
423 document.all.eck4.style.left = pt2.pageX-12; | |
424 document.all.eck4.style.top = pt2.pageY-12; | |
425 | |
426 document.all.eck1.style.visibility="visible"; | |
427 document.all.eck2.style.visibility="visible"; | |
428 document.all.eck3.style.visibility="visible"; | |
429 document.all.eck4.style.visibility="visible"; | |
430 | |
431 document.all.lay1.onmousemove = move; | |
432 document.all.eck4.onmousemove = move; | |
433 | |
434 } else if ( typeof(document.addEventListener) == "function" ) { | |
435 | |
436 document.getElementById("eck1").style.left = pt1.pageX; | |
437 document.getElementById("eck1").style.top = pt1.pageY; | |
438 document.getElementById("eck2").style.left = pt2.pageX-12; | |
439 document.getElementById("eck2").style.top = pt1.pageY; | |
440 document.getElementById("eck3").style.left = pt1.pageX; | |
441 document.getElementById("eck3").style.top = pt2.pageY-12; | |
442 document.getElementById("eck4").style.left = pt2.pageX-12; | |
443 document.getElementById("eck4").style.top = pt2.pageY-12; | |
444 | |
445 document.getElementById("eck1").style.visibility="visible"; | |
446 document.getElementById("eck2").style.visibility="visible"; | |
447 document.getElementById("eck3").style.visibility="visible"; | |
448 document.getElementById("eck4").style.visibility="visible"; | |
449 | |
450 document.getElementById("lay1").addEventListener("mousemove", move, true); | |
451 document.getElementById("eck4").addEventListener("mousemove", move, true); | |
452 | |
453 } else { | |
454 | |
455 document.eck1.moveTo(pt1.pageX, pt1.pageY); | |
456 document.eck2.moveTo(pt2.pageX-12, pt1.pageY); | |
457 document.eck3.moveTo(pt1.pageX, pt2.pageY-12); | |
458 document.eck4.moveTo(pt2.pageX-12, pt2.pageY-12); | |
459 | |
460 document.eck1.visibility="show"; | |
461 document.eck2.visibility="show"; | |
462 document.eck3.visibility="show"; | |
463 document.eck4.visibility="show"; | |
464 | |
465 document.lay1.captureEvents(Event.MOUSEMOVE); | |
466 document.eck4.captureEvents(Event.MOUSEMOVE); | |
467 document.lay1.onmousemove = move; | |
468 document.eck4.onmousemove = move; | |
469 | |
470 } | |
471 | |
472 } else { | |
473 | |
474 pt2 = new Point(evt); | |
475 | |
476 if ( document.all ) { | |
477 | |
478 document.all.eck1.visibility="hidden"; | |
479 document.all.eck2.visibility="hidden"; | |
480 document.all.eck3.visibility="hidden"; | |
481 document.all.eck4.visibility="hidden"; | |
482 | |
483 document.all.lay1.onmousedown = null; | |
484 document.all.eck4.onmousedown = null; | |
485 document.all.lay1.onmousemove = null; | |
486 document.all.eck4.onmousemove = null; | |
487 | |
488 } else if ( typeof(document.removeEventListener) == "function" ) { | |
489 | |
490 document.getElementById("eck1").style.visibility="hidden"; | |
491 document.getElementById("eck2").style.visibility="hidden"; | |
492 document.getElementById("eck3").style.visibility="hidden"; | |
493 document.getElementById("eck4").style.visibility="hidden"; | |
494 | |
495 document.getElementById("lay1").removeEventListener("mousedown", click, true); | |
496 document.getElementById("eck4").removeEventListener("mousedown", click, true); | |
497 document.getElementById("lay1").removeEventListener("mousemove", move, true); | |
498 document.getElementById("eck4").removeEventListener("mousemove", move, true); | |
499 | |
500 } else { | |
501 | |
502 document.eck1.visibility="hide"; | |
503 document.eck2.visibility="hide"; | |
504 document.eck3.visibility="hide"; | |
505 document.eck4.visibility="hide"; | |
506 | |
507 document.lay1.releaseEvents(Event.MOUSEDOWN); | |
508 document.eck4.releaseEvents(Event.MOUSEDOWN); | |
509 document.lay1.releaseEvents(Event.MOUSEMOVE); | |
510 document.eck4.releaseEvents(Event.MOUSEMOVE); | |
511 | |
512 } | |
513 | |
514 dlParams.wx.value = cropFloat(parseFloat(Math.min(pt1.relX, pt2.relX))); | |
515 dlParams.wy.value = cropFloat(parseFloat(Math.min(pt1.relY, pt2.relY))); | |
516 | |
517 dlParams.ww.value = cropFloat(parseFloat(Math.abs(pt1.relX-pt2.relX))); | |
518 dlParams.wh.value = cropFloat(parseFloat(Math.abs(pt1.relY-pt2.relY))); | |
519 | |
520 if ( (dlParams.ww.value != 0) && (dlParams.wh.value != 0) ) { | |
521 display(3); | |
522 } | |
523 } | |
524 } | |
525 | |
526 function move(evt) { | |
527 | |
528 pt2 = new Point(evt); | |
529 | |
530 var eck1_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); | |
531 var eck1_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); | |
532 var eck2_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;; | |
533 var eck2_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); | |
534 var eck3_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); | |
535 var eck3_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; | |
536 var eck4_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; | |
537 var eck4_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; | |
538 | |
539 if ( document.all ) { | |
540 | |
541 document.all.eck1.style.left = eck1_left; | |
542 document.all.eck1.style.top = eck1_top; | |
543 document.all.eck2.style.left = eck2_left; | |
544 document.all.eck2.style.top = eck2_top; | |
545 document.all.eck3.style.left = eck3_left; | |
546 document.all.eck3.style.top = eck3_top; | |
547 document.all.eck4.style.left = eck4_left; | |
548 document.all.eck4.style.top = eck4_top; | |
549 | |
550 } else if ( typeof(document.getElementById) == "function" ) { | |
551 | |
552 document.getElementById("eck1").style.left = eck1_left; | |
553 document.getElementById("eck1").style.top = eck1_top; | |
554 document.getElementById("eck2").style.left = eck2_left; | |
555 document.getElementById("eck2").style.top = eck2_top; | |
556 document.getElementById("eck3").style.left = eck3_left; | |
557 document.getElementById("eck3").style.top = eck3_top; | |
558 document.getElementById("eck4").style.left = eck4_left; | |
559 document.getElementById("eck4").style.top = eck4_top; | |
560 | |
561 } else { | |
562 | |
563 document.eck1.moveTo(eck1_left, eck1_top); | |
564 document.eck2.moveTo(eck2_left, eck2_top); | |
565 document.eck3.moveTo(eck3_left, eck3_top); | |
566 document.eck4.moveTo(eck4_left, eck4_top); | |
567 | |
568 } | |
569 } | |
570 | |
571 // starting event capture | |
572 if ( document.all ) { | |
573 document.all.lay1.onmousedown = click; | |
574 document.all.eck4.onmousedown = click; | |
575 } else if ( typeof(document.addEventListener) == "function" ) { | |
576 document.getElementById("lay1").addEventListener("mousedown", click, true); | |
577 document.getElementById("eck4").addEventListener("mousedown", click, true); | |
578 } else { | |
579 document.lay1.captureEvents(Event.MOUSEDOWN); | |
580 document.eck4.captureEvents(Event.MOUSEDOWN); | |
581 document.lay1.onmousedown = click; | |
582 document.eck4.onmousedown = click; | |
583 } | |
584 } | |
585 | |
586 | |
587 function zoomExtends() { | |
588 | |
589 dlParams.wx.value = 0.0; | |
590 dlParams.wy.value = 0.0; | |
591 | |
592 dlParams.ww.value = 1.0; | |
593 dlParams.wh.value = 1.0; | |
594 | |
595 display(3); | |
596 | |
597 } | |
598 | |
599 | |
600 function zoomOut() { | |
601 | |
602 dlParams.wx.value = cropFloat(dlParams.wx.value-0.5*(dlParams.ww.value*(ZOOMFACTOR)-dlParams.ww.value)); | |
603 dlParams.wy.value = cropFloat(dlParams.wy.value-0.5*(dlParams.wh.value*(ZOOMFACTOR)-dlParams.wh.value)); | |
604 | |
605 dlParams.ww.value = cropFloat(dlParams.ww.value*(ZOOMFACTOR)); | |
606 dlParams.wh.value = cropFloat(dlParams.wh.value*(ZOOMFACTOR)); | |
607 | |
608 if ( dlParams.wx.value < 0 ) { | |
609 dlParams.wx.value = 0; | |
610 } | |
611 if ( dlParams.wy.value < 0 ) { | |
612 dlParams.wy.value = 0; | |
613 } | |
614 if ( dlParams.ww.value > 1 ) { | |
615 dlParams.ww.value = 1; | |
616 } | |
617 if ( dlParams.wh.value > 1 ) { | |
618 dlParams.wh.value = 1; | |
619 } | |
620 if ( dlParams.wx.value + dlParams.ww.value > 1 ) { | |
621 dlParams.wx.value = 1 - dlParams.ww.value; | |
622 } | |
623 if ( dlParams.wy.value + dlParams.wh.value > 1 ) { | |
624 dlParams.wy.value = 1 - dlParams.wh.value; | |
625 } | |
626 | |
627 display(3); | |
628 } | |
629 | |
630 | |
631 function moveTo() { | |
632 | |
633 if ( (parseFloat(dlParams.ww.value) == 1.0) && (parseFloat(dlParams.wh.value) == 1.0) ) { | |
634 alert("This function is only available when zoomed in!"); | |
635 return; | |
636 } | |
637 | |
638 function moveToEvent(event) { | |
639 | |
640 var point = new Point(event); | |
641 | |
642 dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value); | |
643 dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value); | |
644 | |
645 if ( dlParams.wx.value < 0 ) { | |
646 dlParams.wx.value = 0; | |
647 } | |
648 if ( dlParams.wy.value < 0 ) { | |
649 dlParams.wy.value = 0; | |
650 } | |
651 if ( dlParams.wx.value + dlParams.ww.value > 1 ) { | |
652 dlParams.wx.value = 1 - dlParams.ww.value; | |
653 } | |
654 if ( dlParams.wy.value + dlParams.wh.value > 1 ) { | |
655 dlParams.wy.value = 1 - dlParams.wh.value; | |
656 } | |
657 | |
658 // stopping event capture | |
659 if ( document.all ) { | |
660 document.all.lay1.onmousedown = null; | |
661 } else if ( typeof(document.removeEventListener) == "function" ) { | |
662 document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true); | |
663 } else { | |
664 document.lay1.releaseEvents(Event.MOUSEDOWN) | |
665 } | |
666 | |
667 display(3); | |
668 } | |
669 | |
670 // starting event capture | |
671 if ( document.all ) { | |
672 document.all.lay1.onmousedown = moveToEvent; | |
673 } else if ( typeof(document.addEventListener) == "function" ) { | |
674 document.getElementById("lay1").addEventListener("mousedown", moveToEvent, true); | |
675 } else { | |
676 document.lay1.captureEvents(Event.MOUSEDOWN); | |
677 document.lay1.onmousedown = moveToEvent; | |
678 } | |
679 } | |
680 | |
681 | |
682 function scale(factor) { | |
683 | |
684 dlParams.ws.value = cropFloat(factor); | |
685 display(3); | |
686 | |
687 } | |
688 | |
689 | |
690 // capturing keypresses for next and previous page | |
691 function parseKeypress(evt) { | |
692 | |
693 if ( document.all ) { | |
694 | |
695 if ( event.keyCode == 110 ) { | |
696 page('+1'); | |
697 } | |
698 if ( event.keyCode == 98 ) { | |
699 page('-1'); | |
700 } | |
701 | |
702 document.cancleBubble = true; | |
703 | |
704 } else { | |
705 | |
706 if ( evt.charCode == 110 ) { | |
707 page('+1'); | |
708 } else if ( evt.charCode == 98 ) { | |
709 page('-1'); | |
710 } else if ( evt.which == 110 ) { | |
711 page('+1'); | |
712 } else if ( evt.which == 98 ) { | |
713 // does not work currentlyfor Opera, because it catches the 'b'-key on it's own | |
714 // have to change the key or find another way - luginbuehl | |
715 page('-1'); | |
716 } | |
717 | |
718 } | |
719 } | |
720 | |
721 | |
722 // auxiliary function to crop senseless precicsion | |
723 function cropFloat(tmp) { | |
724 return parseInt(10000*tmp)/10000; | |
725 } |