Mercurial > hg > digilib-old
comparison client/digitallibrary/navigation_n6.js @ 110:489f61d9feac
XUL Buttons in chrome
author | engler |
---|---|
date | Wed, 14 May 2003 12:00:40 +0200 |
parents | 866e798e2bef |
children |
comparison
equal
deleted
inserted
replaced
109:200584e60a0b | 110:489f61d9feac |
---|---|
1 /* | |
2 Copyright (C) 2003 WTWG, Uni Bern | |
3 | |
4 This program is free software; you can redistribute it and/or | |
5 modify it under the terms of the GNU General Public License | |
6 as published by the Free Software Foundation; either version 2 | |
7 of the License, or (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; if not, write to the Free Software | |
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
17 | |
18 Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.3 | |
19 */ | |
1 // this global variable has to be initialised before the frist use of the functions below | 20 // this global variable has to be initialised before the frist use of the functions below |
2 // to fill in the attributes you can use the function init provided below | 21 // to fill in the attributes you can use the function init provided below |
3 // - array with all attributes | 22 // - array with all attributes |
4 var att = new Array(); | 23 var att = new Object(); |
5 | 24 |
6 // fill in the values of the "att"-array | 25 // fill in the values of the "att"-array |
7 function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) { | 26 function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) { |
8 | 27 |
9 // debug window to check the parameters passed | 28 // debug window to check the parameters passed |
10 //alert ("DEBUG message (parameters in init):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh); | 29 //alert ("DEBUG message (parameters in init):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh); |
11 | 30 |
12 // attaching the values to the att-array | 31 // attaching the values to the att-array |
13 att[0] = fn; | 32 att.fn = fn; |
14 att[1] = parseInt(pn); | 33 att.pn = parseInt(pn); |
15 att[2] = parseFloat(ws); | 34 att.ws = parseFloat(ws); |
16 att[3] = mo; | 35 att.mo = mo; |
17 att[4] = mk; | 36 att.mk = mk; |
18 att[5] = parseFloat(wx); | 37 att.wx = parseFloat(wx); |
19 att[6] = parseFloat(wy); | 38 att.wy = parseFloat(wy); |
20 att[7] = parseFloat(ww); | 39 att.ww = parseFloat(ww); |
21 att[8] = parseFloat(wh); | 40 att.wh = parseFloat(wh); |
22 | 41 |
23 // compatablility issue | 42 // compatablility issue |
24 if (att[3].indexOf("f") > -1) { | 43 // dangerous at the time - lugi |
25 att[3] = "fit"; | 44 // if (att.mo.indexOf("f") > -1) { |
26 } | 45 // att.mo = "fit"; |
46 // } | |
27 | 47 |
28 // converts the old mark format (0-1000) to new format(0.0 - 1.0) | 48 // converts the old mark format (0-1000) to new format(0.0 - 1.0) |
29 // could even be useless now | 49 // could even be useless now |
30 if (att[4] != "0/0") { | 50 if (att.mk != "0/0" && att.mk != "") { |
31 var tmp = att[4].split(";"); | 51 var tmp = att.mk.split(";"); |
32 | 52 |
33 att[4] = ""; | 53 att.mk = ""; |
34 | 54 |
35 for (i = 0; i < tmp.length; i++) { | 55 for (i = 0; i < tmp.length; i++) { |
36 tmp[i] = tmp[i].split("/"); | 56 tmp[i] = tmp[i].split("/"); |
37 | 57 |
38 if (tmp[i][0] > 1 && tmp[i][1] > 1) { | 58 if (tmp[i][0] > 1 && tmp[i][1] > 1) { |
39 tmp[i][0] /= 1000; | 59 tmp[i][0] /= 1000; |
40 tmp[i][1] /= 1000; | 60 tmp[i][1] /= 1000; |
41 } | 61 } |
42 | 62 |
43 att[4] += tmp[i][0] + "/" + tmp[i][1] + ";"; | 63 att.mk += tmp[i][0] + "/" + tmp[i][1] + ";"; |
44 } | 64 } |
45 att[4] = att[4].slice(0, -1); | 65 att.mk = att.mk.slice(0, -1); |
46 } | 66 } |
47 | 67 |
48 // initialisation stuff | 68 // initialisation stuff |
49 // ==================== | 69 // ==================== |
50 | 70 |
65 // 1 -> zoomout | 85 // 1 -> zoomout |
66 // 2 -> zoomarea, zoompoint, moveto, scaledef | 86 // 2 -> zoomarea, zoompoint, moveto, scaledef |
67 | 87 |
68 function loadPicture(detailGrade, keepArea) { | 88 function loadPicture(detailGrade, keepArea) { |
69 | 89 |
70 var newQuery = "fn=" + att[0] + "&pn=" + att[1] + "&ws=" + att[2] + "&mo=" + att[3]; | 90 var newQuery = "fn=" + att.fn + "&pn=" + att.pn + "&ws=" + att.ws + "&mo=" + att.mo; |
71 | 91 |
72 if (detailGrade == 0) { | 92 if (detailGrade == 0) { |
73 att[4] = "0/0"; | 93 att.mk = "0/0"; |
74 } | 94 } |
75 | 95 |
76 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { | 96 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { |
77 att[5] = 0; | 97 att.wx = 0; |
78 att[6] = 0; | 98 att.wy = 0; |
79 att[7] = 1; | 99 att.ww = 1; |
80 att[8] = 1; | 100 att.wh = 1; |
81 } | 101 } |
82 | 102 |
83 newQuery += "&mk=" + att[4] + "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8]; | 103 newQuery += "&mk=" + att.mk + "&wx=" + att.wx + "&wy=" + att.wy + "&ww=" + att.ww + "&wh=" + att.wh; |
84 newQuery += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); | 104 newQuery += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); |
85 | 105 newQuery += "&lv=1" |
106 | |
86 // debug window - checking the parameters passed to the next image | 107 // debug window - checking the parameters passed to the next image |
87 //alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); | 108 alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); |
88 | 109 |
89 location.href = location.pathname + "?" + newQuery; | 110 location.href = location.protocol + "//" + location.host + location.pathname + "?" + newQuery; |
90 } | 111 } |
91 | 112 |
92 | 113 |
93 // constructor holding different values of a point | 114 // constructor holding different values of a point |
94 function Point(event) { | 115 function Point(event) { |
97 this.pageY = parseInt(event.pageY); | 118 this.pageY = parseInt(event.pageY); |
98 | 119 |
99 this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); | 120 this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); |
100 this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); | 121 this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); |
101 | 122 |
102 this.relX = cropFloat(att[5]+(att[7]*this.x/document.pic.offsetWidth)); | 123 this.relX = cropFloat(att.wx+(att.ww*this.x/document.pic.offsetWidth)); |
103 this.relY = cropFloat(att[6]+(att[8]*this.y/document.pic.offsetHeight)); | 124 this.relY = cropFloat(att.wy+(att.wh*this.y/document.pic.offsetHeight)); |
104 | 125 |
105 return this; | 126 return this; |
106 } | 127 } |
107 | 128 |
108 | 129 |
109 function backPage(keepArea) { | 130 function backPage(keepArea) { |
110 | 131 |
111 att[1] = parseInt(att[1]) - 1; | 132 att.pn = parseInt(att.pn) - 1; |
112 | 133 |
113 if (att[1] > 0) { | 134 if (att.pn > 0) { |
114 loadPicture(0, keepArea); | 135 loadPicture(0, keepArea); |
115 } else { | 136 } else { |
116 att[1] = parseInt(att[1]) + 1; | 137 att.pn = parseInt(att.pn) + 1; |
117 alert("You are already on the first page!"); | 138 alert("You are already on the first page!"); |
118 } | 139 } |
119 } | 140 } |
120 | 141 |
121 | 142 |
122 function nextPage(keepArea) { | 143 function nextPage(keepArea) { |
123 | 144 |
124 att[1] = parseInt(att[1]) + 1; | 145 att.pn = parseInt(att.pn) + 1; |
125 | 146 |
126 loadPicture(0, keepArea); | 147 loadPicture(0, keepArea); |
127 } | 148 } |
128 | 149 |
129 | 150 |
131 | 152 |
132 do { | 153 do { |
133 page = prompt("Goto Page:", 1); | 154 page = prompt("Goto Page:", 1); |
134 } while ((page != null) && (page < 1)); | 155 } while ((page != null) && (page < 1)); |
135 | 156 |
136 if (page != null && page != att[1]) { | 157 if (page != null && page != att.pn) { |
137 att[1] = page; | 158 att.pn = page; |
138 loadPicture(0, keepArea); | 159 loadPicture(0, keepArea); |
139 } | 160 } |
140 } | 161 } |
141 | 162 |
142 | 163 |
143 function digicat() { | 164 function digicat() { |
144 var url = "digicat.html?" + att[0] + "+" + att[1]; | 165 var url = baseUrl + "/digicat.jsp?" + att.fn + "+" + att.pn; |
145 win = window.open(url, "digicat"); | 166 win = window.open(url, "digicat"); |
146 win.focus(); | 167 win.focus(); |
147 } | 168 } |
148 | 169 |
149 | 170 |
150 function ref(refselect) { | 171 function ref(refselect) { |
151 | 172 |
152 var hyperlinkRef = baseUrl + "/digilib.jsp?"; | 173 var hyperlinkRef = baseUrl + "/digilib.jsp?"; |
153 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4]; | 174 hyperlinkRef += att.fn + "+" + att.pn + "+" + att.ws + "+" + att.mo + "+" + att.mk; |
154 | 175 |
155 if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) { | 176 if ((att.wx != 0) || (att.wy != 0) || (att.ww != 1) || (att.wh != 1)) { |
156 hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8]; | 177 hyperlinkRef += "+" + att.wx + "+" + att.wy + "+" + att.ww + "+" + att.wh; |
157 } | 178 } |
158 | 179 |
159 if (refselect == 1) { | 180 if (refselect == 1) { |
160 prompt("Link for HTML--documents", hyperlinkRef); | 181 prompt("Link for HTML--documents", hyperlinkRef); |
161 } else { | 182 } else { |
164 } | 185 } |
165 | 186 |
166 | 187 |
167 function mark() { | 188 function mark() { |
168 | 189 |
169 if (att[4].split(";").length > 7) { | 190 if (att.mk.split(";").length > 7) { |
170 alert("Only 8 marks are possible at the moment!"); | 191 alert("Only 8 marks are possible at the moment!"); |
171 return; | 192 return; |
172 } | 193 } |
173 | 194 |
174 function markEvent(event) { | 195 function markEvent(event) { |
175 var point = new Point(event); | 196 var point = new Point(event); |
176 | 197 |
177 if ((att[4] != "") && (att[4] != "0/0")) { | 198 if ((att.mk != "") && (att.mk != "0/0")) { |
178 att[4] += ";"; | 199 att.mk += ";"; |
179 } else { | 200 } else { |
180 att[4] = ""; | 201 att.mk = ""; |
181 } | 202 } |
182 att[4] += point.relX + "/" + point.relY; | 203 att.mk += point.relX + "/" + point.relY; |
183 | 204 |
184 document.getElementById("lay1").removeEventListener("mousedown", markEvent, true); | 205 document.getElementById("lay1").removeEventListener("mousedown", markEvent, true); |
185 setMarks(); | 206 setMarks(); |
186 } | 207 } |
187 | 208 |
231 document.getElementById("eck1").style.visibility="hidden"; | 252 document.getElementById("eck1").style.visibility="hidden"; |
232 document.getElementById("eck2").style.visibility="hidden"; | 253 document.getElementById("eck2").style.visibility="hidden"; |
233 document.getElementById("eck3").style.visibility="hidden"; | 254 document.getElementById("eck3").style.visibility="hidden"; |
234 document.getElementById("eck4").style.visibility="hidden"; | 255 document.getElementById("eck4").style.visibility="hidden"; |
235 | 256 |
236 att[5] = Math.min(pt1.relX, pt2.relX); | 257 att.wx = parseFloat(Math.min(pt1.relX, pt2.relX)); |
237 att[6] = Math.min(pt1.relY, pt2.relY); | 258 att.wy = parseFloat(Math.min(pt1.relY, pt2.relY)); |
238 | 259 |
239 att[7] = Math.abs(pt1.relX-pt2.relX); | 260 att.ww = parseFloat(Math.abs(pt1.relX-pt2.relX)); |
240 att[8] = Math.abs(pt1.relY-pt2.relY); | 261 att.wh = parseFloat(Math.abs(pt1.relY-pt2.relY)); |
241 | 262 |
242 if (att[7] != 0 && att[8] != 0) { | 263 if (att.ww != 0 && att.wh != 0) { |
243 loadPicture(2); | 264 loadPicture(2); |
244 } | 265 } |
245 } | 266 } |
246 } | 267 } |
247 | 268 |
267 function zoomPoint() { | 288 function zoomPoint() { |
268 | 289 |
269 function zoomPointEvent(event) { | 290 function zoomPointEvent(event) { |
270 var point = new Point(event); | 291 var point = new Point(event); |
271 | 292 |
272 att[5] = cropFloat(point.relX-0.5*att[7]*0.7); | 293 att.wx = cropFloat(point.relX-0.5*att.ww*0.7); |
273 att[6] = cropFloat(point.relY-0.5*att[8]*0.7); | 294 att.wy = cropFloat(point.relY-0.5*att.wh*0.7); |
274 | 295 |
275 att[7] = cropFloat(att[7]*0.7); | 296 att.ww = cropFloat(att.ww*0.7); |
276 att[8] = cropFloat(att[8]*0.7); | 297 att.wh = cropFloat(att.wh*0.7); |
277 | 298 |
278 if (att[5] < 0) { | 299 if (att.wx < 0) { |
279 att[5] = 0; | 300 att.wx = 0; |
280 } | 301 } |
281 if (att[6] < 0) { | 302 if (att.wy < 0) { |
282 att[6] = 0; | 303 att.wy = 0; |
283 } | 304 } |
284 if (att[5]+att[7] > 1) { | 305 if (att.wx+att.ww > 1) { |
285 att[5] = 1-att[7]; | 306 att.wx = 1-att.ww; |
286 } | 307 } |
287 if (att[6]+att[8] > 1) { | 308 if (att.wy+att.wh > 1) { |
288 att[6] = 1-att[8]; | 309 att.wy = 1-att.wh; |
289 } | 310 } |
290 | 311 |
291 document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true); | 312 document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true); |
292 | 313 |
293 loadPicture(2); | 314 loadPicture(2); |
307 | 328 |
308 function moveToEvent(event) { | 329 function moveToEvent(event) { |
309 | 330 |
310 var point = new Point(event); | 331 var point = new Point(event); |
311 | 332 |
312 att[5] = cropFloat(point.relX-0.5*att[7]); | 333 att.wx = cropFloat(point.relX-0.5*att.ww); |
313 att[6] = cropFloat(point.relY-0.5*att[8]); | 334 att.wy = cropFloat(point.relY-0.5*att.wh); |
314 | 335 |
315 if (att[5] < 0) { | 336 if (att.wx < 0) { |
316 att[5] = 0; | 337 att.wx = 0; |
317 } | 338 } |
318 if (att[6] < 0) { | 339 if (att.wy < 0) { |
319 att[6] = 0; | 340 att.wy = 0; |
320 } | 341 } |
321 if (att[5]+att[7] > 1) { | 342 if (att.wx+att.ww > 1) { |
322 att[5] = 1-att[7]; | 343 att.wx = 1-att.ww; |
323 } | 344 } |
324 if (att[6]+att[8] > 1) { | 345 if (att.wy+att.wh > 1) { |
325 att[6] = 1-att[8]; | 346 att.wy = 1-att.wh; |
326 } | 347 } |
327 | 348 |
328 document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true); | 349 document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true); |
329 | 350 |
330 loadPicture(2); | 351 loadPicture(2); |
334 } | 355 } |
335 | 356 |
336 | 357 |
337 function scale(scaledef) { | 358 function scale(scaledef) { |
338 | 359 |
339 att[2] = scaledef; | 360 att.ws = scaledef; |
340 loadPicture(2); | 361 loadPicture(2); |
341 } | 362 } |
342 | 363 |
343 | 364 |
344 function setMarks() { | 365 function setMarks() { |
345 | 366 |
346 if (att[4] != "" && att[4] != "0/0") { | 367 if (att.mk != "" && att.mk != "0/0") { |
347 var mark = att[4].split(";"); | 368 var mark = att.mk.split(";"); |
348 | 369 |
349 var countMarks = mark.length; | 370 var countMarks = mark.length; |
350 | 371 |
351 // maximum of marks is 8 | 372 // maximum of marks is 8 |
352 // we do not report this error because this is already done in func. "Mark" | 373 // we do not report this error because this is already done in func. "Mark" |
362 var yoffset = parseInt(document.getElementById("lay1").style.top); | 383 var yoffset = parseInt(document.getElementById("lay1").style.top); |
363 | 384 |
364 for (var i = 0; i < countMarks; i++) { | 385 for (var i = 0; i < countMarks; i++) { |
365 mark[i] = mark[i].split("/"); | 386 mark[i] = mark[i].split("/"); |
366 | 387 |
367 if ((mark[i][0] > att[5]) && (mark[i][1] > att[6]) && (mark[i][0] < (att[5]+att[7])) && (mark[i][1] < (att[6]+att[8]))) { | 388 if ((mark[i][0] >= att.wx) && (mark[i][1] >= att.wy) && (mark[i][0] <= (att.wx+att.ww)) && (mark[i][1] <= (att.wy+att.wh))) { |
368 | 389 |
369 mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]); | 390 mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att.wx)/att.ww); |
370 mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]); | 391 mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att.wy)/att.wh); |
371 | 392 |
372 | 393 |
373 document.getElementById("dot" + i).style.left = mark[i][0]-5; | 394 document.getElementById("dot" + i).style.left = mark[i][0]-5; |
374 document.getElementById("dot" + i).style.top = mark[i][1]-5; | 395 document.getElementById("dot" + i).style.top = mark[i][1]-5; |
375 document.getElementById("dot" + i).style.visibility = "visible"; | 396 document.getElementById("dot" + i).style.visibility = "visible"; |
383 | 404 |
384 // capturing keypresses for next and previous page | 405 // capturing keypresses for next and previous page |
385 // ascii-values of n = 110, b = 98 | 406 // ascii-values of n = 110, b = 98 |
386 function parseKeypress (event) { | 407 function parseKeypress (event) { |
387 if (event.charCode == 110) { | 408 if (event.charCode == 110) { |
388 Nextpage(); | 409 nextPage(); |
389 } | 410 } |
390 if (event.charCode == 98) { | 411 if (event.charCode == 98) { |
391 Backpage(); | 412 backPage(); |
392 } | 413 } |
393 } | 414 } |
394 | 415 |
395 | 416 |
396 // auxiliary function to crop senseless precicsion | 417 // auxiliary function to crop senseless precicsion |