Mercurial > hg > digilib
comparison client/digitallibrary/navigation_ie.js @ 35:930413351738
improvements in parsing points
author | luginbue |
---|---|
date | Sun, 24 Mar 2002 15:16:32 +0100 |
parents | 84a481a388bb |
children | 44f653ae5df5 |
comparison
equal
deleted
inserted
replaced
34:168ac828de3e | 35:930413351738 |
---|---|
89 | 89 |
90 location.href = newURL; | 90 location.href = newURL; |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 // constructor holding different values of a point | |
95 function Point(event) { | |
96 | |
97 this.pageX = parseInt(document.body.scrollLeft+event.x); | |
98 this.pageY = parseInt(document.body.scrollTop+event.y); | |
99 | |
100 this.x = this.pageX-parseInt(document.all.lay1.style.left); | |
101 this.y = this.pageY-parseInt(document.all.lay1.style.top); | |
102 | |
103 this.relX = cropFloat(att[5]+(att[7]*this.x/document.all.lay1.offsetWidth)); | |
104 this.relY = cropFloat(att[6]+(att[8]*this.y/document.all.lay1.offsetHeight)); | |
105 | |
106 return this; | |
107 } | |
108 | |
109 | |
94 function backPage(keepArea) { | 110 function backPage(keepArea) { |
95 | 111 |
96 att[1] = parseInt(att[1]) - 1; | 112 att[1] = parseInt(att[1]) - 1; |
97 | 113 |
98 if (att[1] > 0) { | 114 if (att[1] > 0) { |
155 alert("Only 8 marks are possible at the moment!"); | 171 alert("Only 8 marks are possible at the moment!"); |
156 return; | 172 return; |
157 } | 173 } |
158 | 174 |
159 document.all.lay1.onmousedown = function() { | 175 document.all.lay1.onmousedown = function() { |
160 e = event; | 176 var point = new Point(event); |
161 | 177 |
162 if ((att[4] != "") && (att[4] != "0/0")) { | 178 if ((att[4] != "") && (att[4] != "0/0")) { |
163 att[4] += ";"; | 179 att[4] += ";"; |
164 } else { | 180 } else { |
165 att[4] = ""; | 181 att[4] = ""; |
166 } | 182 } |
167 | 183 |
168 markX = cropFloat(att[5]+att[7]*(document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left))/document.all.lay1.offsetWidth); | 184 att[4] += point.relX + "/" + point.relY; |
169 markY = cropFloat(att[6]+att[8]*(document.body.scrollTop+e.y-parseInt(document.all.lay1.style.top))/document.all.lay1.offsetHeight); | |
170 | |
171 att[4] += markX + "/" + markY; | |
172 | 185 |
173 document.all.lay1.cancleBubble = true; | 186 document.all.lay1.cancleBubble = true; |
174 | 187 |
175 setMarks(); | 188 setMarks(); |
176 } | 189 } |
177 } | 190 } |
178 | 191 |
179 | 192 |
180 function zoomArea() { | 193 function zoomArea() { |
181 var state = 0; | 194 var state = 0; |
182 var x1, y1, x2, y2; | 195 var pt1, pt2; |
183 | 196 |
184 function click() { | 197 function click() { |
185 e = event; | |
186 | |
187 if (state == 0) { | 198 if (state == 0) { |
188 state = 1; | 199 state = 1; |
189 | 200 |
190 x1 = document.body.scrollLeft+e.x; | 201 pt1 = new Point(event); |
191 y1 = document.body.scrollTop+e.y; | 202 pt2 = pt1; |
192 x2 = x1; | 203 |
193 y2 = y1; | 204 document.all.eck1.style.left = pt1.pageX; |
194 | 205 document.all.eck1.style.top = pt1.pageY; |
195 document.all.eck1.style.left = x1; | 206 document.all.eck2.style.left = pt2.pageX-12; |
196 document.all.eck1.style.top = y1; | 207 document.all.eck2.style.top = pt1.pageY; |
197 document.all.eck2.style.left = x2-12; | 208 document.all.eck3.style.left = pt1.pageX; |
198 document.all.eck2.style.top = y1; | 209 document.all.eck3.style.top = pt2.pageY-12; |
199 document.all.eck3.style.left = x1; | 210 document.all.eck4.style.left = pt2.pageX-12; |
200 document.all.eck3.style.top = y2-12; | 211 document.all.eck4.style.top = pt2.pageY-12; |
201 document.all.eck4.style.left = x2-12; | |
202 document.all.eck4.style.top = y2-12; | |
203 | 212 |
204 document.all.eck1.style.visibility="visible"; | 213 document.all.eck1.style.visibility="visible"; |
205 document.all.eck2.style.visibility="visible"; | 214 document.all.eck2.style.visibility="visible"; |
206 document.all.eck3.style.visibility="visible"; | 215 document.all.eck3.style.visibility="visible"; |
207 document.all.eck4.style.visibility="visible"; | 216 document.all.eck4.style.visibility="visible"; |
208 | 217 |
209 document.all.lay1.onmousemove = move; | 218 document.all.lay1.onmousemove = move; |
210 document.all.eck4.onmousemove = move; | 219 document.all.eck4.onmousemove = move; |
211 | 220 |
212 } else { | 221 } else { |
213 | 222 pt2 = new Point(event); |
214 x1 -= parseInt(document.all.lay1.style.left); | |
215 y1 -= parseInt(document.all.lay1.style.top); | |
216 | |
217 x2 = document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left); | |
218 y2 = document.body.scrollTop+e.y-parseInt(document.all.lay1.style.left); | |
219 | 223 |
220 document.all.eck1.visibility="hidden"; | 224 document.all.eck1.visibility="hidden"; |
221 document.all.eck2.visibility="hidden"; | 225 document.all.eck2.visibility="hidden"; |
222 document.all.eck3.visibility="hidden"; | 226 document.all.eck3.visibility="hidden"; |
223 document.all.eck4.visibility="hidden"; | 227 document.all.eck4.visibility="hidden"; |
224 | 228 |
225 document.all.lay1.cancleBubble = true; | 229 document.all.lay1.cancleBubble = true; |
226 document.all.eck4.cancleBubble = true; | 230 document.all.eck4.cancleBubble = true; |
227 | 231 |
228 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/document.all.lay1.offsetWidth); | 232 att[5] = Math.min(pt1.relX, pt2.relX); |
229 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/document.all.lay1.offsetHeight); | 233 att[6] = Math.min(pt1.relY, pt2.relY); |
230 | 234 |
231 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/document.all.lay1.offsetWidth); | 235 att[7] = Math.abs(pt1.relX-pt2.relX); |
232 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/document.all.lay1.offsetHeight); | 236 att[8] = Math.abs(pt1.relY-pt2.relY); |
233 | 237 |
234 if (att[7] != 0 && att[8] != 0) { | 238 if (att[7] != 0 && att[8] != 0) { |
235 loadPicture(2); | 239 loadPicture(2); |
236 } | 240 } |
237 } | 241 } |
238 } | 242 } |
239 | 243 |
240 function move() { | 244 function move() { |
241 e = event; | 245 pt2 = new Point(event); |
242 | 246 |
243 x2 = document.body.scrollLeft+e.x; | 247 document.all.eck1.style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); |
244 y2 = document.body.scrollTop+e.y; | 248 document.all.eck1.style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); |
245 | 249 document.all.eck2.style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; |
246 document.all.eck1.style.left = ((x1 < x2) ? x1 : x2); | 250 document.all.eck2.style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); |
247 document.all.eck1.style.top = ((y1 < y2) ? y1 : y2); | 251 document.all.eck3.style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); |
248 document.all.eck2.style.left = ((x1 < x2) ? x2 : x1)-12; | 252 document.all.eck3.style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; |
249 document.all.eck2.style.top = ((y1 < y2) ? y1 : y2); | 253 document.all.eck4.style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; |
250 document.all.eck3.style.left = ((x1 < x2) ? x1 : x2); | 254 document.all.eck4.style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; |
251 document.all.eck3.style.top = ((y1 < y2) ? y2 : y1)-12; | |
252 document.all.eck4.style.left = ((x1 < x2) ? x2 : x1)-12; | |
253 document.all.eck4.style.top = ((y1 < y2) ? y2 : y1)-12; | |
254 } | 255 } |
255 | 256 |
256 document.all.lay1.onmousedown = click; | 257 document.all.lay1.onmousedown = click; |
257 document.all.eck4.onmousedown = click; | 258 document.all.eck4.onmousedown = click; |
258 } | 259 } |
259 | 260 |
260 | 261 |
261 function zoomPoint() { | 262 function zoomPoint() { |
262 | 263 |
263 document.all.lay1.onmousedown = function() { | 264 document.all.lay1.onmousedown = function() { |
264 e = event; | 265 var point = new Point(event); |
265 | 266 |
266 att[5] = cropFloat(att[5]+att[7]*(document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left))/document.all.lay1.offsetWidth-0.5*att[7]*0.7); | 267 att[5] = cropFloat(point.relX-0.5*att[7]*0.7); |
267 att[6] = cropFloat(att[6]+att[8]*(document.body.scrollTop+e.y-parseInt(document.all.lay1.style.top))/document.all.lay1.offsetHeight-0.5*att[8]*0.7); | 268 att[6] = cropFloat(point.relY-0.5*att[8]*0.7); |
268 | 269 |
269 att[7] = cropFloat(att[7]*0.7); | 270 att[7] = cropFloat(att[7]*0.7); |
270 att[8] = cropFloat(att[8]*0.7); | 271 att[8] = cropFloat(att[8]*0.7); |
271 | 272 |
272 if (att[5] < 0) { | 273 if (att[5] < 0) { |
295 | 296 |
296 | 297 |
297 function moveTo() { | 298 function moveTo() { |
298 | 299 |
299 document.all.lay1.onmousedown = function() { | 300 document.all.lay1.onmousedown = function() { |
300 e = event; | 301 var point = new Point(event); |
301 | 302 |
302 att[5] = cropFloat(att[5]+att[7]*(document.body.scrollLeft+e.x-parseInt(document.all.lay1.style.left))/document.all.lay1.offsetWidth-0.5*att[7]); | 303 att[5] = cropFloat(point.relX-0.5*att[7]); |
303 att[6] = cropFloat(att[6]+att[8]*(document.body.scrollTop+e.y-parseInt(document.all.lay1.style.top))/document.all.lay1.offsetHeight-0.5*att[8]); | 304 att[6] = cropFloat(point.relY-0.5*att[8]); |
304 | 305 |
305 if (att[5] < 0) { | 306 if (att[5] < 0) { |
306 att[5] = 0; | 307 att[5] = 0; |
307 } | 308 } |
308 if (att[6] < 0) { | 309 if (att[6] < 0) { |