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