Mercurial > hg > digilib-old
annotate client/digitallibrary/dllib.js @ 636:7049579a0097 jquery
last and next page works now
implemented redisplay function (only tested with fullscreen)
parameters that are changed need to be in data.queryParams to get in the url on redisplay
author | robcast |
---|---|
date | Tue, 18 Jan 2011 21:30:03 +0100 |
parents | 92e49afaea90 |
children |
rev | line source |
---|---|
243
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
1 /* Copyright (C) 2003,2004 IT-Group MPIWG, WTWG Uni Bern and others |
237 | 2 |
3 This program is free software; you can redistribute it and/or | |
4 modify it under the terms of the GNU General Public License | |
5 as published by the Free Software Foundation; either version 2 | |
6 of the License, or (at your option) any later version. | |
7 | |
8 This program is distributed in the hope that it will be useful, | |
9 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 GNU General Public License for more details. | |
12 | |
13 You should have received a copy of the GNU General Public License | |
14 along with this program; if not, write to the Free Software | |
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
16 | |
243
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
17 Authors: |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
18 Christian Luginbuehl, 01.05.2003 (first version) |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
19 DW 24.03.2004 (Changed for digiLib in Zope) |
386 | 20 Robert Casties, 8.11.2005 |
237 | 21 |
243
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
22 ! Requires baselib.js ! |
237 | 23 |
24 */ | |
25 | |
317 | 26 |
27 function identify() { | |
386 | 28 // used for identifying a digilib instance |
29 // Relato uses that function - lugi | |
30 return "Digilib 0.6"; | |
317 | 31 } |
32 | |
237 | 33 |
34 /* | |
35 * more parameter handling | |
36 */ | |
37 | |
38 function parseArea() { | |
39 // returns area Rectangle from current parameters | |
40 return new Rectangle(getParameter("wx"), getParameter("wy"), getParameter("ww"), getParameter("wh")); | |
41 } | |
42 | |
43 function setParamFromArea(rect) { | |
44 // sets digilib wx etc. from rect | |
45 setParameter("wx", cropFloat(rect.x)); | |
46 setParameter("wy", cropFloat(rect.y)); | |
47 setParameter("ww", cropFloat(rect.width)); | |
48 setParameter("wh", cropFloat(rect.height)); | |
49 return true; | |
50 } | |
51 | |
52 function parseTrafo(elem) { | |
53 // returns Transform from current dlArea and picsize | |
54 var picsize = getElementRect(elem); | |
55 var trafo = new Transform(); | |
56 // subtract area offset and size | |
57 trafo.concat(getTranslation(new Position(-dlArea.x, -dlArea.y))); | |
58 trafo.concat(getScale(new Size(1/dlArea.width, 1/dlArea.height))); | |
59 // scale to screen size | |
60 trafo.concat(getScale(picsize)); | |
61 trafo.concat(getTranslation(picsize)); | |
62 // rotate | |
63 //trafo.concat(getRotation(- getParameter("rot"), new Position(0.5*picsize.width, 0.5*picsize.height))); | |
64 // mirror | |
65 //if (hasFlag("hmir")) { | |
66 //trafo.m00 = - trafo.m00; | |
67 //} | |
68 //if (hasFlag("vmir")) { | |
69 //trafo.m11 = - trafo.m11; | |
70 //} | |
71 return trafo; | |
72 } | |
73 | |
74 | |
75 function parseMarks() { | |
76 // returns marks array from current parameters | |
77 var marks = new Array(); | |
78 var ma; | |
79 var mk = getParameter("mk"); | |
80 if (mk.indexOf(";") >= 0) { | |
386 | 81 // old format with ";" |
82 ma = mk.split(";"); | |
237 | 83 } else { |
386 | 84 ma = mk.split(","); |
237 | 85 } |
86 for (var i = 0; i < ma.length ; i++) { | |
386 | 87 var pos = ma[i].split("/"); |
88 if (pos.length > 1) { | |
89 marks.push(new Position(pos[0], pos[1])); | |
90 } | |
237 | 91 } |
92 return marks; | |
93 } | |
94 | |
95 function getAllMarks() { | |
96 // returns a string with all marks in query format | |
97 var marks = new Array(); | |
98 for (var i = 0; i < dlMarks.length; i++) { | |
386 | 99 marks.push(cropFloat(dlMarks[i].x) + "/" + cropFloat(dlMarks[i].y)); |
237 | 100 } |
101 return marks.join(","); | |
102 } | |
103 | |
104 function addMark(pos) { | |
105 // add a mark | |
106 dlMarks.push(pos); | |
107 setParameter("mk", getAllMarks()); | |
108 return true; | |
109 } | |
110 | |
111 function deleteMark() { | |
112 // delete the last mark | |
113 dlMarks.pop(); | |
114 setParameter("mk", getAllMarks()); | |
115 return true; | |
116 } | |
117 | |
118 function hasFlag(mode) { | |
119 // returns if mode flag is set | |
120 return (dlFlags[mode]); | |
121 } | |
122 | |
123 function addFlag(mode) { | |
124 // add a mode flag | |
125 dlFlags[mode] = mode; | |
239 | 126 setParameter("mo", getAllFlags()); |
237 | 127 return true; |
128 } | |
129 | |
130 function removeFlag(mode) { | |
131 // remove a mode flag | |
132 if (dlFlags[mode]) { | |
386 | 133 delete dlFlags[mode]; |
237 | 134 } |
239 | 135 setParameter("mo", getAllFlags()); |
237 | 136 return true; |
137 } | |
138 | |
139 function toggleFlag(mode) { | |
140 // change a mode flag | |
141 if (dlFlags[mode]) { | |
386 | 142 delete dlFlags[mode]; |
237 | 143 } else { |
386 | 144 dlFlags[mode] = mode; |
237 | 145 } |
239 | 146 setParameter("mo", getAllFlags()); |
237 | 147 return true; |
148 } | |
149 | |
150 function getAllFlags() { | |
151 // returns a string with all flags in query format | |
152 var fa = new Array(); | |
153 for (var f in dlFlags) { | |
386 | 154 if ((f != "")&&(dlFlags[f] != null)) { |
155 fa.push(f); | |
156 } | |
237 | 157 } |
158 return fa.join(","); | |
159 } | |
160 | |
161 function parseFlags() { | |
162 // sets dlFlags from the current parameters | |
163 var flags = new Object(); | |
164 var fa = getParameter("mo").split(","); | |
165 for (var i = 0; i < fa.length ; i++) { | |
386 | 166 var f = fa[i]; |
167 if (f != "") { | |
168 flags[f] = f; | |
169 } | |
237 | 170 } |
171 return flags; | |
172 } | |
173 | |
174 | |
175 function bestPicSize(elem, inset) { | |
176 // returns a Size with the best image size for the given element | |
177 if (! defined(inset)) { | |
386 | 178 inset = 25; |
237 | 179 } |
180 var ws = getWinSize(); | |
181 var es = getElementPosition(elem); | |
182 if (es) { | |
386 | 183 ws.width = ws.width - es.x - inset; |
184 ws.height = ws.height - es.y - inset; | |
237 | 185 } |
186 return ws; | |
187 } | |
188 | |
386 | 189 function setDLParam(e, s, relative) { |
190 // sets parameter based on HTML event | |
191 var nam; | |
192 var val; | |
193 if (s.type && (s.type == "select-one")) { | |
194 nam = s.name; | |
195 val = s.options[s.selectedIndex].value; | |
196 } else if (s.name && s.value) { | |
197 nam = s.name; | |
198 val = s.value; | |
199 } | |
200 if (nam && val) { | |
201 setParameter(nam, val, relative); | |
202 display(); | |
203 } else { | |
204 alert("ERROR: unable to process event!"); | |
205 } | |
206 return true; | |
207 } | |
208 | |
237 | 209 |
210 /* ********************************************** | |
211 * digilib specific routines | |
212 * ******************************************** */ | |
213 | |
238 | 214 |
215 function dl_param_init() { | |
216 // parameter initialisation before onload | |
332
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
217 if (!baseScriptVersion) { |
386 | 218 base_init(); |
332
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
219 } |
386 | 220 dlScriptVersion = "1.2b"; |
332
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
221 dlArea = new Rectangle(0.0, 0.0, 1.0, 1.0); |
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
222 dlMaxArea = new Rectangle(0.0, 0.0, 1.0, 1.0); |
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
223 dlTrafo = new Transform(); |
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
224 dlMarks = new Array(); |
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
225 dlFlags = new Object(); |
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
226 elemScaler = null; |
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
227 picElem = null; |
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
228 ZOOMFACTOR = Math.sqrt(2); |
238 | 229 |
230 // put the query parameters (sans "?") in the parameters array | |
231 parseParameters(location.search.slice(1)); | |
232 // treat special parameters | |
233 dlMarks = parseMarks(); | |
234 dlArea = parseArea(); | |
235 dlFlags = parseFlags(); | |
236 } | |
237 | |
238 | |
237 | 239 function dl_init() { |
238 | 240 // initalisation on load |
332
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
241 if (!dlScriptVersion) { |
386 | 242 dl_param_init(); |
332
d14782908c37
fixed problems with Netscape4 (silly error by me partly :-)
robcast
parents:
317
diff
changeset
|
243 } |
237 | 244 elemScaler = getElement("scaler", true); |
245 picElem = getElement("pic", true); | |
246 if (picElem == null && elemScaler) { | |
386 | 247 // in N4 pic is in the scaler layer |
248 picElem = elemScaler.document.images[0]; | |
237 | 249 } |
250 if ((!elemScaler)||(!picElem)) { | |
386 | 251 alert("Sorry, digilib doesn't work here!"); |
252 return false; | |
237 | 253 } |
254 // give a name to the window containing digilib | |
255 if (defined(dlTarget)&&(dlTarget)) { | |
386 | 256 window.name = dlTarget; |
237 | 257 } else { |
386 | 258 window.name = "digilib"; |
237 | 259 } |
260 // put the query parameters (sans "?") in the parameters array | |
261 parseParameters(location.search.slice(1)); | |
262 // treat special parameters | |
263 dlMarks = parseMarks(); | |
264 dlArea = parseArea(); | |
265 dlFlags = parseFlags(); | |
266 // wait for image to load and display marks | |
267 renderMarks(); | |
268 // done | |
269 focus(); | |
270 return; | |
271 } | |
272 | |
273 | |
274 function display(detail) { | |
275 // redisplay the page | |
276 if (! detail) { | |
386 | 277 detail = 255; |
237 | 278 } |
279 var queryString = getAllParameters(detail); | |
280 location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString; | |
281 } | |
282 | |
283 | |
284 /* ********************************************** | |
285 * interactive digilib functions | |
286 * ******************************************** */ | |
287 | |
288 | |
289 function renderMarks() { | |
290 // put the visible marks on the image | |
291 var mark_count = dlMarks.length; | |
292 // make shure the image is loaded so we know its size | |
293 if (defined(picElem.complete) && picElem.complete == false && ! browserType.isN4 ) { | |
386 | 294 setTimeout("renderMarks()", 100); |
237 | 295 } else { |
386 | 296 dlTrafo = parseTrafo(picElem); |
297 for (var i = 0; i < 8; i++) { | |
298 var me = getElement("dot"+i); | |
299 if (i < mark_count) { | |
300 if (dlArea.containsPosition(dlMarks[i])) { | |
301 var mpos = dlTrafo.transform(dlMarks[i]); | |
302 // suboptimal to place -5 pixels and not half size of mark-image | |
303 mpos.x = mpos.x -5; | |
304 mpos.y = mpos.y -5; | |
305 moveElement(me, mpos); | |
306 showElement(me, true); | |
307 } | |
308 } else { | |
309 // hide the other marks | |
310 showElement(me, false); | |
311 } | |
312 } | |
237 | 313 } |
314 } | |
315 | |
316 | |
239 | 317 function setMark(reload) { |
237 | 318 // add a mark where clicked |
319 if ( dlMarks.length > 7 ) { | |
386 | 320 alert("Only 8 marks are possible at the moment!"); |
321 return; | |
237 | 322 } |
317 | 323 window.focus(); |
237 | 324 |
325 function markEvent(evt) { | |
386 | 326 // event handler adding a new mark |
327 unregisterEvent("mousedown", elemScaler, markEvent); | |
328 var p = dlTrafo.invtransform(evtPosition(evt)); | |
329 addMark(p); | |
330 if (defined(reload)&&(!reload)) { | |
331 // don't redisplay | |
332 renderMarks(); | |
333 return; | |
334 } | |
335 display(); | |
237 | 336 } |
337 | |
338 // starting event capture | |
243
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
339 registerEvent("mousedown", elemScaler, markEvent); |
237 | 340 } |
341 | |
342 | |
239 | 343 function removeMark(reload) { |
344 // remove the last mark | |
345 deleteMark(); | |
346 if (defined(reload)&&(!reload)) { | |
386 | 347 // don't redisplay |
348 renderMarks(); | |
349 return; | |
239 | 350 } |
351 display(); | |
352 } | |
353 | |
354 | |
237 | 355 function zoomArea() { |
356 var click = 1; | |
357 var pt1, pt2; | |
358 var eck1pos, eck2pos, eck3pos, eck4pos; | |
359 window.focus(); | |
360 var eck1 = getElement("eck1"); | |
361 var eck2 = getElement("eck2"); | |
362 var eck3 = getElement("eck3"); | |
363 var eck4 = getElement("eck4"); | |
364 | |
365 function zoomClick(evt) { | |
386 | 366 // mouse click handler |
367 if (click == 1) { | |
368 // first click -- start moving | |
369 click = 2; | |
370 pt1 = evtPosition(evt); | |
371 pt2 = pt1; | |
372 eck1pos = pt1; | |
373 eck2pos = new Position(pt1.x - 12, pt1.y); | |
374 eck3pos = new Position(pt1.x, pt1.y - 12); | |
375 eck4pos = new Position(pt1.y - 12, pt1.y - 12); | |
376 moveElement(eck1, eck1pos); | |
377 moveElement(eck2, eck2pos); | |
378 moveElement(eck3, eck3pos); | |
379 moveElement(eck4, eck4pos); | |
380 showElement(eck1, true); | |
381 showElement(eck2, true); | |
382 showElement(eck3, true); | |
383 showElement(eck4, true); | |
384 // show moving | |
385 registerEvent("mousemove", elemScaler, zoomMove); | |
386 registerEvent("mousemove", eck4, zoomMove); | |
387 // enable drag-to-zoom | |
388 registerEvent("mouseup", elemScaler, zoomClick); | |
389 registerEvent("mouseup", eck4, zoomClick); | |
390 } else { | |
391 // second click -- end moving | |
392 pt2 = evtPosition(evt); | |
393 showElement(eck1, false); | |
394 showElement(eck2, false); | |
395 showElement(eck3, false); | |
396 showElement(eck4, false); | |
397 unregisterEvent("mousemove", elemScaler, zoomMove); | |
398 unregisterEvent("mousemove", eck4, zoomMove); | |
399 unregisterEvent("mousedown", elemScaler, zoomClick); | |
400 unregisterEvent("mousedown", eck4, zoomClick); | |
401 var p1 = dlTrafo.invtransform(pt1); | |
402 var p2 = dlTrafo.invtransform(pt2); | |
403 var ww = p2.x-p1.x; | |
404 var wh = p2.y-p1.y; | |
405 if ((ww > 0)&&(wh > 0)) { | |
406 setParameter("wx", cropFloat(p1.x)); | |
407 setParameter("wy", cropFloat(p1.y)); | |
408 setParameter("ww", cropFloat(ww)); | |
409 setParameter("wh", cropFloat(wh)); | |
410 parseArea(); | |
411 // zoomed is always fit | |
412 setParameter("ws", 1); | |
413 display(); | |
414 } | |
415 } | |
237 | 416 } |
417 | |
418 function zoomMove(evt) { | |
386 | 419 // mouse move handler |
420 pt2 = evtPosition(evt); | |
421 // restrict marks to move right and down | |
422 eck1pos = pt1; | |
423 eck2pos = new Position(Math.max(pt1.x, pt2.x)-12, pt1.y); | |
424 eck3pos = new Position(pt1.x, Math.max(pt1.y, pt2.y)-12); | |
425 eck4pos = new Position(Math.max(pt1.x, pt2.x)-12, Math.max(pt1.y, pt2.y)-12); | |
426 moveElement(eck1, eck1pos); | |
427 moveElement(eck2, eck2pos); | |
428 moveElement(eck3, eck3pos); | |
429 moveElement(eck4, eck4pos); | |
237 | 430 } |
431 | |
432 // starting event capture | |
243
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
433 registerEvent("mousedown", elemScaler, zoomClick); |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
434 registerEvent("mousedown", eck4, zoomClick); |
237 | 435 } |
436 | |
437 function zoomBy(factor) { | |
438 // zooms by the given factor | |
239 | 439 var newarea = dlArea.copy(); |
237 | 440 newarea.width /= factor; |
441 newarea.height /= factor; | |
442 newarea.x -= 0.5 * (newarea.width - dlArea.width); | |
443 newarea.y -= 0.5 * (newarea.height - dlArea.height); | |
444 newarea = dlMaxArea.fit(newarea); | |
445 setParamFromArea(newarea); | |
446 display(); | |
447 } | |
448 | |
449 | |
450 function zoomFullpage() { | |
451 // zooms out to show the whole image | |
452 setParameter("wx", 0.0); | |
453 setParameter("wy", 0.0); | |
454 setParameter("ww", 1.0); | |
455 setParameter("wh", 1.0); | |
456 display(); | |
457 } | |
458 | |
459 | |
460 function moveCenter() { | |
461 // move visible area so that it's centered around the clicked point | |
462 if ( (dlArea.width == 1.0) && (dlArea.height == 1.0) ) { | |
386 | 463 // nothing to do |
464 return; | |
237 | 465 } |
466 window.focus(); | |
467 | |
468 function moveCenterEvent(evt) { | |
386 | 469 // move to handler |
470 unregisterEvent("mousedown", elemScaler, moveCenterEvent); | |
471 var pt = dlTrafo.invtransform(evtPosition(evt)); | |
472 var newarea = new Rectangle(pt.x-0.5*dlArea.width, pt.y-0.5*dlArea.height, dlArea.width, dlArea.height); | |
473 newarea = dlMaxArea.fit(newarea); | |
474 // set parameters | |
475 setParamFromArea(newarea); | |
476 parseArea(); | |
477 display(); | |
237 | 478 } |
479 | |
480 // starting event capture | |
243
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
481 registerEvent("mousedown", elemScaler, moveCenterEvent); |
237 | 482 } |
483 | |
243
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
484 function moveBy(movx, movy) { |
386 | 485 // move visible area by movx and movy (in units of ww, wh) |
243
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
486 if ((dlArea.width == 1.0)&&(dlArea.height == 1.0)) { |
386 | 487 // nothing to do |
488 return; | |
243
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
489 } |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
490 var newarea = dlArea.copy(); |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
491 newarea.x += parseFloat(movx)*dlArea.width; |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
492 newarea.y += parseFloat(movy)*dlArea.height; |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
493 newarea = dlMaxArea.fit(newarea); |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
494 // set parameters |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
495 setParamFromArea(newarea); |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
496 parseArea(); |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
497 display(); |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
498 } |
4dbff786ff50
new digimage with red triangles for moving the zoomed area
robcast
parents:
239
diff
changeset
|
499 |
238 | 500 function getRef() { |
237 | 501 // returns a reference to the current digilib set |
502 if (! baseUrl) { | |
386 | 503 var baseUrl = location.protocol + "//" + location.host + location.pathname; |
237 | 504 } |
505 var hyperlinkRef = baseUrl; | |
386 | 506 var par = getAllParameters(7+16); // all without ddpi, pt |
237 | 507 if (par.length > 0) { |
386 | 508 hyperlinkRef += "?" + par; |
237 | 509 } |
510 return hyperlinkRef; | |
511 } | |
317 | 512 |
513 function getRefWin(type, msg) { | |
514 // shows an alert with a reference to the current digilib set | |
515 if (! msg) { | |
386 | 516 msg = "Link for HTML documents"; |
317 | 517 } |
518 prompt(msg, getRef()); | |
519 } | |
386 | 520 |
521 function getQuality() { | |
522 // returns the current q setting | |
523 for (var i = 0; i < 3; i++) { | |
524 if (hasFlag("q"+i)) { | |
525 return i; | |
526 } | |
527 } | |
528 return 1 | |
529 } | |
530 | |
531 function setQuality(qual) { | |
532 // set the image quality | |
533 for (var i = 0; i < 3; i++) { | |
534 removeFlag("q"+i); | |
535 if (i == qual) { | |
536 addFlag("q"+i); | |
537 } | |
538 } | |
539 setParameter("mo", getAllFlags()); | |
540 display(); | |
541 } | |
542 | |
543 function setQualityWin(msg) { | |
544 // dialog for setting quality | |
545 if (! msg) { | |
546 msg = "Quality (0..2)"; | |
547 } | |
548 var q = getQuality(); | |
549 var newq = window.prompt(msg, q); | |
550 if (newq) { | |
551 setQuality(newq); | |
552 } | |
553 } | |
554 | |
555 function mirror(dir) { | |
556 // mirror the image horizontally or vertically | |
557 if (dir == "h") { | |
558 toggleFlag("hmir"); | |
559 } else { | |
560 toggleFlag("vmir"); | |
561 } | |
562 setParameter("mo", getAllFlags()); | |
563 display(); | |
564 } | |
565 | |
566 function gotoPage(gopage, keep) { | |
567 // goto given page nr (+/-: relative) | |
568 var oldpn = parseInt(getParameter("pn")); | |
447
92e49afaea90
fixed problem with next/prev page button in oldskin
robcast
parents:
386
diff
changeset
|
569 // try setParameter with relative value |
386 | 570 setParameter("pn", gopage, true); |
447
92e49afaea90
fixed problem with next/prev page button in oldskin
robcast
parents:
386
diff
changeset
|
571 // check the result |
386 | 572 var pn = parseInt(getParameter("pn")); |
573 if (pn < 1) { | |
574 alert("No such page! (Page number too low)"); | |
575 setParameter("pn", oldpn); | |
576 return; | |
577 } | |
578 if (hasParameter("pt")) { | |
579 pt = parseInt(getParameter("pt")) | |
580 if (pn > pt) { | |
581 alert("No such page! (Page number too high)"); | |
582 setParameter("pn", oldpn); | |
583 return; | |
584 } | |
585 } | |
586 if (keep) { | |
587 display(15+32); // all, no mark | |
588 } else { | |
589 display(3+32); // fn, pn, ws, mo + pt | |
590 } | |
591 } | |
592 | |
593 function gotoPageWin() { | |
594 // dialog to ask for new page nr | |
595 var pn = getParameter("pn"); | |
596 var gopage = window.prompt("Go to page", pn); | |
597 if (gopage) { | |
598 gotoPage(gopage); | |
599 } | |
600 } | |
601 | |
602 function setParamWin(param, text, relative) { | |
603 // dialog to ask for new parameter value | |
604 var val = getParameter(param); | |
605 var newval = window.prompt(text, val); | |
606 if (newval) { | |
607 setParameter(param, newval, relative); | |
608 display(); | |
609 } | |
610 } | |
611 | |
612 function showOptions(show) { | |
613 // show or hide option div | |
614 var elem = getElement("dloptions"); | |
615 showElement(elem, show); | |
616 } |