Mercurial > hg > digilib-old
comparison client/digitallibrary/navigation_n6.js @ 107:85126da2ae21 vendor start
XUL: Digilib Buttons in chrome
author | engler |
---|---|
date | Tue, 13 May 2003 21:02:22 +0200 |
parents | 254fca7a21ce |
children |
comparison
equal
deleted
inserted
replaced
105:ecee3ff2f4d0 | 107:85126da2ae21 |
---|---|
1 /* navigation_ie -- JS library for digilib (Mozilla version) | 1 /* |
2 | 2 Copyright (C) 2003 WTWG, Uni Bern |
3 Digital Image Library servlet components | 3 |
4 | 4 This program is free software; you can redistribute it and/or |
5 Copyright (C) 2001, 2002 Christian Luginbuehl (luginbuehl@student.unibe.ch) | 5 modify it under the terms of the GNU General Public License |
6 | 6 as published by the Free Software Foundation; either version 2 |
7 This program is free software; you can redistribute it and/or modify it | 7 of the License, or (at your option) any later version. |
8 under the terms of the GNU General Public License as published by the | 8 |
9 Free Software Foundation; either version 2 of the License, or (at your | 9 This program is distributed in the hope that it will be useful, |
10 option) any later version. | 10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 Please read license.txt for the full details. A copy of the GPL | 12 GNU General Public License for more details. |
13 may be found at http://www.gnu.org/copyleft/lgpl.html | 13 |
14 | 14 You should have received a copy of the GNU General Public License |
15 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 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 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 |
18 | 18 Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.3 |
19 */ | 19 */ |
20 | 20 // this global variable has to be initialised before the frist use of the functions below |
21 // these two global variables have to be initialised before the frist use of the functions below | 21 // to fill in the attributes you can use the function init provided below |
22 // to fill in the attributes you can use the function initPicture provided below | |
23 // - array with all attributes | 22 // - array with all attributes |
24 var att = new Array(); | 23 var att = new Object(); |
25 | 24 |
26 // - variable to store the path to the frame, in which the pictures should be created | 25 // fill in the values of the "att"-array |
27 var whichFrame = parent.mainFrame; | 26 function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) { |
28 | 27 |
29 // give a name to the window containing digilib - this way one can test if there is already a | 28 // debug window to check the parameters passed |
30 // digilib-window open and replace the contents of it (ex. digicat) | 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); |
31 window.name = "digilib"; | 30 |
31 // attaching the values to the att-array | |
32 att.fn = fn; | |
33 att.pn = parseInt(pn); | |
34 att.ws = parseFloat(ws); | |
35 att.mo = mo; | |
36 att.mk = mk; | |
37 att.wx = parseFloat(wx); | |
38 att.wy = parseFloat(wy); | |
39 att.ww = parseFloat(ww); | |
40 att.wh = parseFloat(wh); | |
41 | |
42 // compatablility issue | |
43 // dangerous at the time - lugi | |
44 // if (att.mo.indexOf("f") > -1) { | |
45 // att.mo = "fit"; | |
46 // } | |
47 | |
48 // converts the old mark format (0-1000) to new format(0.0 - 1.0) | |
49 // could even be useless now | |
50 if (att.mk != "0/0" && att.mk != "") { | |
51 var tmp = att.mk.split(";"); | |
52 | |
53 att.mk = ""; | |
54 | |
55 for (i = 0; i < tmp.length; i++) { | |
56 tmp[i] = tmp[i].split("/"); | |
57 | |
58 if (tmp[i][0] > 1 && tmp[i][1] > 1) { | |
59 tmp[i][0] /= 1000; | |
60 tmp[i][1] /= 1000; | |
61 } | |
62 | |
63 att.mk += tmp[i][0] + "/" + tmp[i][1] + ";"; | |
64 } | |
65 att.mk = att.mk.slice(0, -1); | |
66 } | |
67 | |
68 // initialisation stuff | |
69 // ==================== | |
70 | |
71 setMarks(); | |
72 | |
73 this.document.addEventListener('keypress', parseKeypress, true); | |
74 focus(); | |
75 | |
76 // give a name to the window containing digilib - this way one can test if there is already a | |
77 // digilib-window open and replace the contents of it (ex. digicat) | |
78 top.window.name = "digilib"; | |
79 } | |
80 | |
32 | 81 |
33 // function that launches the ScaleServlet | 82 // function that launches the ScaleServlet |
34 // the different detailGrades: | 83 // the different detailGrades: |
35 // 0 -> back, next, page | 84 // 0 -> back, next, page |
36 // 1 -> zoomout | 85 // 1 -> zoomout |
37 // 2 -> zoomarea, zoompoint, moveto, scaledef | 86 // 2 -> zoomarea, zoompoint, moveto, scaledef |
38 | 87 |
39 function loadPicture(detailGrade, keepArea) { | 88 function loadPicture(detailGrade, keepArea) { |
40 | 89 |
41 // alert("wx: " + att[5] + "\tww: " + att[7] + "\nwy: " + att[6] + "\twh: " + att[8]); | 90 var newQuery = "fn=" + att.fn + "&pn=" + att.pn + "&ws=" + att.ws + "&mo=" + att.mo; |
42 | |
43 // sorry about that, but Mozilla needs to have a document body to calc the frames width and height | |
44 whichFrame.document.open(); | |
45 whichFrame.document.write('<html><head></head><body bgcolor="#666666" topmargin="10" leftmargin="10" marginwidth="10" magrinheight="10">'); | |
46 | |
47 // alert(whichFrame.innerWidth); | |
48 | |
49 var newPicture = "http://" + location.host + "/docuserver/digitallibrary/servlet/Scaler/" | |
50 newPicture += att[0] + "?" + "pn=" + att[1] + "&ws=" + att[2]; | |
51 newPicture += "&dw=" + (whichFrame.innerWidth-30) + "&dh=" + (whichFrame.innerHeight-30); | |
52 newPicture += "&mo=" + att[3]; | |
53 | 91 |
54 if (detailGrade == 0) { | 92 if (detailGrade == 0) { |
55 att[4] = "0/0"; | 93 att.mk = "0/0"; |
56 } | 94 } |
57 | 95 |
58 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { | 96 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { |
59 att[5] = 0; | 97 att.wx = 0; |
60 att[6] = 0; | 98 att.wy = 0; |
61 att[7] = 1; | 99 att.ww = 1; |
62 att[8] = 1; | 100 att.wh = 1; |
63 } | 101 } |
64 newPicture += "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8]; | 102 |
65 | 103 newQuery += "&mk=" + att.mk + "&wx=" + att.wx + "&wy=" + att.wy + "&ww=" + att.ww + "&wh=" + att.wh; |
66 whichFrame.document.write('<div ID="lay1" style="position:absolute; left:10; top:10; visibility:visible"><img name="pic" src="' + newPicture + '"></div>'); | 104 newQuery += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); |
67 whichFrame.document.write('<div ID="dot0" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark1.gif"></div>'); | 105 newQuery += "&lv=1" |
68 whichFrame.document.write('<div ID="dot1" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark2.gif"></div>'); | 106 |
69 whichFrame.document.write('<div ID="dot2" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark3.gif"></div>'); | 107 // debug window - checking the parameters passed to the next image |
70 whichFrame.document.write('<div ID="dot3" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark4.gif"></div>'); | 108 alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); |
71 whichFrame.document.write('<div ID="dot4" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark5.gif"></div>'); | 109 |
72 whichFrame.document.write('<div ID="dot5" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark6.gif"></div>'); | 110 location.href = location.protocol + "//" + location.host + location.pathname + "?" + newQuery; |
73 whichFrame.document.write('<div ID="dot6" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark7.gif"></div>'); | 111 } |
74 whichFrame.document.write('<div ID="dot7" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/mark8.gif"></div>'); | 112 |
75 whichFrame.document.write('<div ID="eck1" style="position:absolute; left:-20; top:120; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/olinks.gif"></div>'); | 113 |
76 whichFrame.document.write('<div ID="eck2" style="position:absolute; left:-20; top:140; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/orechts.gif"></div>'); | 114 // constructor holding different values of a point |
77 whichFrame.document.write('<div ID="eck3" style="position:absolute; left:-20; top:160; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/ulinks.gif"></div>'); | 115 function Point(event) { |
78 whichFrame.document.write('<div ID="eck4" style="position:absolute; left:-20; top:180; visibility:hidden"><img src="http://' + location.host + '/docuserver/digitallibrary/urechts.gif"></div>'); | 116 |
79 | 117 this.pageX = parseInt(event.pageX); |
80 whichFrame.document.write('</body></html>'); | 118 this.pageY = parseInt(event.pageY); |
81 | 119 |
82 whichFrame.document.close(); | 120 this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); |
83 | 121 this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); |
84 initScripts(); | 122 |
85 | 123 this.relX = cropFloat(att.wx+(att.ww*this.x/document.pic.offsetWidth)); |
86 pageInfo(); | 124 this.relY = cropFloat(att.wy+(att.wh*this.y/document.pic.offsetHeight)); |
87 | 125 |
88 setmark(); | 126 return this; |
89 } | 127 } |
90 | 128 |
91 | 129 |
92 function Backpage(keepArea) { | 130 function backPage(keepArea) { |
93 | 131 |
94 att[1] = parseInt(att[1]) - 1; | 132 att.pn = parseInt(att.pn) - 1; |
95 | 133 |
96 if (att[1] > 0) { | 134 if (att.pn > 0) { |
97 loadPicture(0, keepArea); | 135 loadPicture(0, keepArea); |
98 } else { | 136 } else { |
99 att[1] = parseInt(att[1]) + 1; | 137 att.pn = parseInt(att.pn) + 1; |
100 alert("You are already on the first page!"); | 138 alert("You are already on the first page!"); |
101 } | 139 } |
102 } | 140 } |
103 | 141 |
104 | 142 |
105 function Nextpage(keepArea) { | 143 function nextPage(keepArea) { |
106 | 144 |
107 att[1] = parseInt(att[1]) + 1; | 145 att.pn = parseInt(att.pn) + 1; |
108 | 146 |
109 if (att[1] <= parent.numPages) { | 147 loadPicture(0, keepArea); |
110 loadPicture(0, keepArea); | 148 } |
111 } else { | 149 |
112 att[1] = parseInt(att[1]) - 1; | 150 |
113 alert("You are already on the last page!"); | 151 function page(keepArea) { |
114 } | |
115 } | |
116 | |
117 | |
118 function Page(keepArea) { | |
119 | 152 |
120 do { | 153 do { |
121 page = prompt("Goto Page (1 - " + parent.numPages + "):", 1); | 154 page = prompt("Goto Page:", 1); |
122 } while ((page != null) && ((page < 1) || (page > parent.numPages))); | 155 } while ((page != null) && (page < 1)); |
123 | 156 |
124 if (page != null && page != att[1]) { | 157 if (page != null && page != att.pn) { |
125 att[1] = page; | 158 att.pn = page; |
126 loadPicture(0, keepArea); | 159 loadPicture(0, keepArea); |
127 } | 160 } |
128 } | 161 } |
129 | 162 |
130 | 163 |
131 function Digicat() { | 164 function digicat() { |
132 var url = "http://" + location.host + "/docuserver/digitallibrary/digicat.html?" + att[0] + "+" + att[1]; | 165 var url = baseUrl + "/digicat.jsp?" + att.fn + "+" + att.pn; |
133 win = window.open(url, "digicat"); | 166 win = window.open(url, "digicat"); |
134 win.focus(); | 167 win.focus(); |
135 } | 168 } |
136 | 169 |
137 | 170 |
138 function Ref(refselect) { | 171 function ref(refselect) { |
139 | 172 |
140 var hyperlinkRef = "http://" + location.host + "/docuserver/digitallibrary/digilib.jsp?"; | 173 var hyperlinkRef = baseUrl + "/digilib.jsp?"; |
141 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4]; | 174 hyperlinkRef += att.fn + "+" + att.pn + "+" + att.ws + "+" + att.mo + "+" + att.mk; |
142 | 175 |
143 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)) { |
144 hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8]; | 177 hyperlinkRef += "+" + att.wx + "+" + att.wy + "+" + att.ww + "+" + att.wh; |
145 } | 178 } |
146 | 179 |
147 if (refselect == 1) { | 180 if (refselect == 1) { |
148 prompt("Link for HTML--documents", hyperlinkRef); | 181 prompt("Link for HTML--documents", hyperlinkRef); |
149 } else { | 182 } else { |
150 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}"); | 183 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}"); |
151 } | 184 } |
152 } | 185 } |
153 | 186 |
154 | 187 |
155 function Mark() { | 188 function mark() { |
156 | 189 |
157 if (att[4].split(";").length > 7) { | 190 if (att.mk.split(";").length > 7) { |
158 alert("Only 8 marks are possible at the moment!"); | 191 alert("Only 8 marks are possible at the moment!"); |
159 return; | 192 return; |
160 } | 193 } |
161 | 194 |
162 function MarkEvent(event) { | 195 function markEvent(event) { |
163 | 196 var point = new Point(event); |
164 if ((att[4] != "") && (att[4] != "0/0")) { | 197 |
165 att[4] += ";"; | 198 if ((att.mk != "") && (att.mk != "0/0")) { |
199 att.mk += ";"; | |
166 } else { | 200 } else { |
167 att[4] = ""; | 201 att.mk = ""; |
168 } | 202 } |
169 | 203 att.mk += point.relX + "/" + point.relY; |
170 var markX = cropFloat(att[5]+att[7]*(event.pageX-parseInt(whichFrame.document.getElementById("lay1").style.left))/whichFrame.document.pic.offsetWidth); | 204 |
171 var markY = cropFloat(att[6]+att[8]*(event.pageY-parseInt(whichFrame.document.getElementById("lay1").style.top))/whichFrame.document.pic.offsetHeight); | 205 document.getElementById("lay1").removeEventListener("mousedown", markEvent, true); |
172 | 206 setMarks(); |
173 att[4] += markX + "/" + markY; | 207 } |
174 | 208 |
175 whichFrame.document.getElementById("lay1").removeEventListener("mousedown", MarkEvent, true); | 209 document.getElementById("lay1").addEventListener("mousedown", markEvent, true); |
176 setmark(); | 210 } |
177 } | 211 |
178 | 212 |
179 whichFrame.document.getElementById("lay1").addEventListener("mousedown", MarkEvent, true); | 213 function zoomArea() { |
180 } | |
181 | |
182 | |
183 function Zoomrect() { | |
184 var state = 0; | 214 var state = 0; |
185 var x1, y1, x2, y2; | 215 var pt1, pt2; |
186 | 216 |
187 function Click(event) { | 217 function click(event) { |
188 | 218 |
189 if (state == 0) { | 219 if (state == 0) { |
190 state = 1; | 220 state = 1; |
191 | 221 |
192 x1 = event.pageX; | 222 pt1 = new Point(event); |
193 y1 = event.pageY; | 223 pt2 = pt1; |
194 x2 = x1; | 224 |
195 y2 = y1; | 225 document.getElementById("eck1").style.left = pt1.pageX; |
196 | 226 document.getElementById("eck1").style.top = pt1.pageY; |
197 whichFrame.document.getElementById("eck1").style.left = x1; | 227 document.getElementById("eck2").style.left = pt2.pageX-12; |
198 whichFrame.document.getElementById("eck1").style.top = y1; | 228 document.getElementById("eck2").style.top = pt1.pageY; |
199 whichFrame.document.getElementById("eck2").style.left = x2-12; | 229 document.getElementById("eck3").style.left = pt1.pageX; |
200 whichFrame.document.getElementById("eck2").style.top = y1; | 230 document.getElementById("eck3").style.top = pt2.pageY-12; |
201 whichFrame.document.getElementById("eck3").style.left = x1; | 231 document.getElementById("eck4").style.left = pt2.pageX-12; |
202 whichFrame.document.getElementById("eck3").style.top = y2-12; | 232 document.getElementById("eck4").style.top = pt2.pageY-12; |
203 whichFrame.document.getElementById("eck4").style.left = x2-12; | 233 |
204 whichFrame.document.getElementById("eck4").style.top = y2-12; | 234 document.getElementById("eck1").style.visibility="visible"; |
205 | 235 document.getElementById("eck2").style.visibility="visible"; |
206 whichFrame.document.getElementById("eck1").style.visibility="visible"; | 236 document.getElementById("eck3").style.visibility="visible"; |
207 whichFrame.document.getElementById("eck2").style.visibility="visible"; | 237 document.getElementById("eck4").style.visibility="visible"; |
208 whichFrame.document.getElementById("eck3").style.visibility="visible"; | 238 |
209 whichFrame.document.getElementById("eck4").style.visibility="visible"; | 239 document.getElementById("lay1").addEventListener("mousemove", move, true); |
210 | 240 document.getElementById("eck4").addEventListener("mousemove", move, true); |
211 whichFrame.document.getElementById("lay1").addEventListener("mousemove", Move, true); | |
212 whichFrame.document.getElementById("eck4").addEventListener("mousemove", Move, true); | |
213 | 241 |
214 } else { | 242 } else { |
215 | 243 |
216 x1 -= parseInt(whichFrame.document.getElementById("lay1").style.left); | 244 pt2 = new Point(event); |
217 y1 -= parseInt(whichFrame.document.getElementById("lay1").style.top); | 245 |
218 | 246 document.getElementById("lay1").removeEventListener("mousedown", click, true); |
219 x2 = event.pageX-parseInt(whichFrame.document.getElementById("lay1").style.left); | 247 document.getElementById("eck4").removeEventListener("mousedown", click, true); |
220 y2 = event.pageY-parseInt(whichFrame.document.getElementById("lay1").style.top); | 248 |
221 | 249 document.getElementById("lay1").removeEventListener("mousemove", move, true); |
222 whichFrame.document.getElementById("lay1").removeEventListener("mousedown", Click, true); | 250 document.getElementById("eck4").removeEventListener("mousemove", move, true); |
223 whichFrame.document.getElementById("eck4").removeEventListener("mousedown", Click, true); | 251 |
224 | 252 document.getElementById("eck1").style.visibility="hidden"; |
225 whichFrame.document.getElementById("lay1").removeEventListener("mousemove", Move, true); | 253 document.getElementById("eck2").style.visibility="hidden"; |
226 whichFrame.document.getElementById("eck4").removeEventListener("mousemove", Move, true); | 254 document.getElementById("eck3").style.visibility="hidden"; |
227 | 255 document.getElementById("eck4").style.visibility="hidden"; |
228 whichFrame.document.getElementById("eck1").style.visibility="hidden"; | 256 |
229 whichFrame.document.getElementById("eck2").style.visibility="hidden"; | 257 att.wx = parseFloat(Math.min(pt1.relX, pt2.relX)); |
230 whichFrame.document.getElementById("eck3").style.visibility="hidden"; | 258 att.wy = parseFloat(Math.min(pt1.relY, pt2.relY)); |
231 whichFrame.document.getElementById("eck4").style.visibility="hidden"; | 259 |
232 | 260 att.ww = parseFloat(Math.abs(pt1.relX-pt2.relX)); |
233 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/whichFrame.document.pic.offsetWidth); | 261 att.wh = parseFloat(Math.abs(pt1.relY-pt2.relY)); |
234 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/whichFrame.document.pic.offsetHeight); | 262 |
235 | 263 if (att.ww != 0 && att.wh != 0) { |
236 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/whichFrame.document.pic.offsetWidth); | |
237 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/whichFrame.document.pic.offsetHeight); | |
238 | |
239 if (att[7] != 0 && att[8] != 0) { | |
240 loadPicture(2); | 264 loadPicture(2); |
241 } | 265 } |
242 } | 266 } |
243 } | 267 } |
244 | 268 |
245 function Move(event) { | 269 function move(event) { |
246 | 270 |
247 x2 = event.pageX; | 271 pt2 = new Point(event); |
248 y2 = event.pageY; | 272 |
249 | 273 document.getElementById("eck1").style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); |
250 whichFrame.document.getElementById("eck1").style.left = ((x1 < x2) ? x1 : x2); | 274 document.getElementById("eck1").style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); |
251 whichFrame.document.getElementById("eck1").style.top = ((y1 < y2) ? y1 : y2); | 275 document.getElementById("eck2").style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; |
252 whichFrame.document.getElementById("eck2").style.left = ((x1 < x2) ? x2 : x1)-12; | 276 document.getElementById("eck2").style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); |
253 whichFrame.document.getElementById("eck2").style.top = ((y1 < y2) ? y1 : y2); | 277 document.getElementById("eck3").style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); |
254 whichFrame.document.getElementById("eck3").style.left = ((x1 < x2) ? x1 : x2); | 278 document.getElementById("eck3").style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; |
255 whichFrame.document.getElementById("eck3").style.top = ((y1 < y2) ? y2 : y1)-12; | 279 document.getElementById("eck4").style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; |
256 whichFrame.document.getElementById("eck4").style.left = ((x1 < x2) ? x2 : x1)-12; | 280 document.getElementById("eck4").style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; |
257 whichFrame.document.getElementById("eck4").style.top = ((y1 < y2) ? y2 : y1)-12; | 281 } |
258 } | 282 |
259 | 283 document.getElementById("lay1").addEventListener("mousedown", click, true); |
260 whichFrame.document.getElementById("lay1").addEventListener("mousedown", Click, true); | 284 document.getElementById("eck4").addEventListener("mousedown", click, true); |
261 whichFrame.document.getElementById("eck4").addEventListener("mousedown", Click, true); | 285 } |
262 } | 286 |
263 | 287 |
264 | 288 function zoomPoint() { |
265 function Zoomin() { | 289 |
266 | 290 function zoomPointEvent(event) { |
267 function ZoominEvent(event) { | 291 var point = new Point(event); |
268 | 292 |
269 att[5] = cropFloat(att[5]+att[7]*(event.pageX-parseInt(whichFrame.document.getElementById("lay1").style.left))/whichFrame.document.pic.offsetWidth-0.5*att[7]*0.7); | 293 att.wx = cropFloat(point.relX-0.5*att.ww*0.7); |
270 att[6] = cropFloat(att[6]+att[8]*(event.pageY-parseInt(whichFrame.document.getElementById("lay1").style.top))/whichFrame.document.pic.offsetHeight-0.5*att[8]*0.7); | 294 att.wy = cropFloat(point.relY-0.5*att.wh*0.7); |
271 | 295 |
272 att[7] = cropFloat(att[7]*0.7); | 296 att.ww = cropFloat(att.ww*0.7); |
273 att[8] = cropFloat(att[8]*0.7); | 297 att.wh = cropFloat(att.wh*0.7); |
274 | 298 |
275 if (att[5] < 0) { | 299 if (att.wx < 0) { |
276 att[5] = 0; | 300 att.wx = 0; |
277 } | 301 } |
278 if (att[6] < 0) { | 302 if (att.wy < 0) { |
279 att[6] = 0; | 303 att.wy = 0; |
280 } | 304 } |
281 if (att[5]+att[7] > 1) { | 305 if (att.wx+att.ww > 1) { |
282 att[5] = 1-att[7]; | 306 att.wx = 1-att.ww; |
283 } | 307 } |
284 if (att[6]+att[8] > 1) { | 308 if (att.wy+att.wh > 1) { |
285 att[6] = 1-att[8]; | 309 att.wy = 1-att.wh; |
286 } | 310 } |
287 | 311 |
288 whichFrame.document.getElementById("lay1").removeEventListener("mousedown", ZoominEvent, true); | 312 document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true); |
289 | 313 |
290 loadPicture(2); | 314 loadPicture(2); |
291 } | 315 } |
292 | 316 |
293 whichFrame.document.getElementById("lay1").addEventListener("mousedown", ZoominEvent, true); | 317 document.getElementById("lay1").addEventListener("mousedown", zoomPointEvent, true); |
294 } | 318 } |
295 | 319 |
296 | 320 |
297 function Zoomout() { | 321 function zoomOut() { |
298 | 322 |
299 loadPicture(1); | 323 loadPicture(1); |
300 } | 324 } |
301 | 325 |
302 | 326 |
303 function Moveto() { | 327 function moveTo() { |
304 | 328 |
305 function MovetoEvent(event) { | 329 function moveToEvent(event) { |
306 | 330 |
307 att[5] = cropFloat(att[5]+att[7]*(event.pageX-parseInt(whichFrame.document.getElementById("lay1").style.left))/whichFrame.document.pic.offsetWidth-0.5*att[7]); | 331 var point = new Point(event); |
308 att[6] = cropFloat(att[6]+att[8]*(event.pageY-parseInt(whichFrame.document.getElementById("lay1").style.top))/whichFrame.document.pic.offsetHeight-0.5*att[8]); | 332 |
309 | 333 att.wx = cropFloat(point.relX-0.5*att.ww); |
310 if (att[5] < 0) { | 334 att.wy = cropFloat(point.relY-0.5*att.wh); |
311 att[5] = 0; | 335 |
312 } | 336 if (att.wx < 0) { |
313 if (att[6] < 0) { | 337 att.wx = 0; |
314 att[6] = 0; | 338 } |
315 } | 339 if (att.wy < 0) { |
316 if (att[5]+att[7] > 1) { | 340 att.wy = 0; |
317 att[5] = 1-att[7]; | 341 } |
318 } | 342 if (att.wx+att.ww > 1) { |
319 if (att[6]+att[8] > 1) { | 343 att.wx = 1-att.ww; |
320 att[6] = 1-att[8]; | 344 } |
321 } | 345 if (att.wy+att.wh > 1) { |
322 | 346 att.wy = 1-att.wh; |
323 whichFrame.document.getElementById("lay1").removeEventListener("mousedown", MovetoEvent, true); | 347 } |
348 | |
349 document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true); | |
324 | 350 |
325 loadPicture(2); | 351 loadPicture(2); |
326 } | 352 } |
327 | 353 |
328 whichFrame.document.getElementById("lay1").addEventListener("mousedown", MovetoEvent, true); | 354 document.getElementById("lay1").addEventListener("mousedown", moveToEvent, true); |
329 } | 355 } |
330 | 356 |
331 | 357 |
332 function Scaledef(scaledef) { | 358 function scale(scaledef) { |
333 | 359 |
334 att[2] = scaledef; | 360 att.ws = scaledef; |
335 loadPicture(2); | 361 loadPicture(2); |
336 } | 362 } |
337 | 363 |
338 | 364 |
339 function setmark() { | 365 function setMarks() { |
340 | 366 |
341 if (att[4] != "" && att[4] != "0/0") { | 367 if (att.mk != "" && att.mk != "0/0") { |
342 var mark = att[4].split(";"); | 368 var mark = att.mk.split(";"); |
343 | 369 |
344 var countMarks = mark.length; | 370 var countMarks = mark.length; |
345 | 371 |
346 // maximum of marks is 8 | 372 // maximum of marks is 8 |
347 // 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" |
348 if (countMarks > 8) countMarks = 8; | 374 if (countMarks > 8) countMarks = 8; |
349 | 375 |
350 var picWidth = whichFrame.document.pic.offsetWidth; | 376 var picWidth = document.pic.offsetWidth; |
351 var picHeight = whichFrame.document.pic.offsetHeight; | 377 var picHeight = document.pic.offsetHeight; |
352 | 378 |
353 // catch the cases where the picture had not been loaded already and | 379 // catch the cases where the picture had not been loaded already and |
354 // make a timeout so that the coordinates are calculated with the real dimensions | 380 // make a timeout so that the coordinates are calculated with the real dimensions |
355 if (whichFrame.document.pic.complete) { | 381 if (document.pic.complete) { |
356 var xoffset = parseInt(whichFrame.document.getElementById("lay1").style.left); | 382 var xoffset = parseInt(document.getElementById("lay1").style.left); |
357 var yoffset = parseInt(whichFrame.document.getElementById("lay1").style.top); | 383 var yoffset = parseInt(document.getElementById("lay1").style.top); |
358 | 384 |
359 for (var i = 0; i < countMarks; i++) { | 385 for (var i = 0; i < countMarks; i++) { |
360 mark[i] = mark[i].split("/"); | 386 mark[i] = mark[i].split("/"); |
361 | 387 |
362 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))) { |
363 | 389 |
364 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); |
365 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); |
366 | 392 |
367 | 393 |
368 whichFrame.document.getElementById("dot" + i).style.left = mark[i][0]-5; | 394 document.getElementById("dot" + i).style.left = mark[i][0]-5; |
369 whichFrame.document.getElementById("dot" + i).style.top = mark[i][1]-5; | 395 document.getElementById("dot" + i).style.top = mark[i][1]-5; |
370 whichFrame.document.getElementById("dot" + i).style.visibility = "visible"; | 396 document.getElementById("dot" + i).style.visibility = "visible"; |
371 } | 397 } |
372 } | 398 } |
373 } else { | 399 } else { |
374 setTimeout("setmark()", 100); | 400 setTimeout("setMarks()", 100); |
375 } | 401 } |
376 } | 402 } |
377 } | 403 } |
378 | 404 |
379 // capturing keypresses for next and previous page | 405 // capturing keypresses for next and previous page |
380 // ascii-values of n = 110, b = 98 | 406 // ascii-values of n = 110, b = 98 |
381 function parseKeypress (event) { | 407 function parseKeypress (event) { |
382 if (event.charCode == 110) { | 408 if (event.charCode == 110) { |
383 Nextpage(); | 409 nextPage(); |
384 } | 410 } |
385 if (event.charCode == 98) { | 411 if (event.charCode == 98) { |
386 Backpage(); | 412 backPage(); |
387 } | 413 } |
388 } | 414 } |
389 | 415 |
390 | 416 |
391 // auxiliary function to crop senseless precicsion | 417 // auxiliary function to crop senseless precicsion |
392 function cropFloat(tmp) { | 418 function cropFloat(tmp) { |
393 return parseInt(10000*tmp)/10000; | 419 return parseInt(10000*tmp)/10000; |
394 } | 420 } |
395 | |
396 | |
397 // initialize browser specific things (keypress caputring) | |
398 function initScripts() { | |
399 // for (var f = 0; f < window.frames.length; f++) { | |
400 // window.frames[f].document.addEventListener('keypress', parseKeypress, true); | |
401 // } | |
402 whichFrame.document.addEventListener('keypress', parseKeypress, true); | |
403 whichFrame.focus(); | |
404 } | |
405 | |
406 | |
407 // fill in the values of the "att"-array | |
408 function initPicture(picURL) { | |
409 att = picURL.split("+"); | |
410 | |
411 if (att[0].lastIndexOf("/") == att[0].length-1) { | |
412 att[0] = att[0].substring(0, att[0].length-1); | |
413 } | |
414 | |
415 if (att.length < 2 || att[1] == "") { | |
416 att[1] = 1; | |
417 } | |
418 if (att.length < 3 || att[2] == "") { | |
419 att[2] = "1.0"; | |
420 } | |
421 | |
422 if (att.length < 4) { | |
423 att[3] = ""; | |
424 } | |
425 | |
426 if (att[3].indexOf("f") > -1) { | |
427 att[3] = "fit"; | |
428 } | |
429 | |
430 if (att.length < 5 || att[4] == "") { | |
431 att[4] = "0/0"; | |
432 } | |
433 | |
434 // converts the old mark format (0-1000) to new format(0.0 - 1.0) | |
435 if (att[4] != "0/0") { | |
436 var tmp = att[4].split(";"); | |
437 | |
438 att[4] = ""; | |
439 | |
440 for (i = 0; i < tmp.length; i++) { | |
441 tmp[i] = tmp[i].split("/"); | |
442 | |
443 if (tmp[i][0] > 1 && tmp[i][1] > 1) { | |
444 tmp[i][0] /= 1000; | |
445 tmp[i][1] /= 1000; | |
446 } | |
447 | |
448 att[4] += tmp[i][0] + "/" + tmp[i][1] + ";"; | |
449 } | |
450 att[4] = att[4].slice(0, -1); | |
451 } | |
452 | |
453 if (att.length < 7) { | |
454 att[5] = 0; | |
455 att[6] = 0; | |
456 att[7] = 1; | |
457 att[8] = 1; | |
458 } else { | |
459 att[5] = parseFloat(att[5]); | |
460 att[6] = parseFloat(att[6]); | |
461 att[7] = parseFloat(att[7]); | |
462 att[8] = parseFloat(att[8]); | |
463 } | |
464 } | |
465 | |
466 | |
467 function pageInfo() { | |
468 | |
469 // bug in netscape 4.xx (confunding px and pt) | |
470 var fontsize = document.layers ? "11pt" : "11px"; | |
471 | |
472 if (window.pageFrame) { | |
473 pageFrame.document.open(); | |
474 pageFrame.document.write('<html><head></head><body bgcolor="#CCCCCC" topmargin="5" marginheight="5">'); | |
475 pageFrame.document.write('<p style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; color: #CC3333; font-size: ' + fontsize + '">'); | |
476 pageFrame.document.write(att[1] + '<b> of </b>' + numPages + '</p></body></html>'); | |
477 pageFrame.document.close(); | |
478 } | |
479 } |