comparison client/digitallibrary/navigation_n6.js @ 31:84a481a388bb

first update of new client-version
author luginbue
date Thu, 21 Feb 2002 02:27:06 +0100
parents d407cb901df4
children 930413351738
comparison
equal deleted inserted replaced
30:054ebc851059 31:84a481a388bb
1 /* navigation_ie -- JS library for digilib (Mozilla version) 1 // this global variable has to be initialised before the frist use of the functions below
2 2 // to fill in the attributes you can use the function init provided below
3 Digital Image Library servlet components
4
5 Copyright (C) 2001, 2002 Christian Luginbuehl (luginbuehl@student.unibe.ch)
6
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
11
12 Please read license.txt for the full details. A copy of the GPL
13 may be found at http://www.gnu.org/copyleft/lgpl.html
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 */
20
21 // these two global variables have to be initialised before the frist use of the functions below
22 // to fill in the attributes you can use the function initPicture provided below
23 // - array with all attributes 3 // - array with all attributes
24 var att = new Array(); 4 var att = new Array();
25 5
26 // - variable to store the path to the frame, in which the pictures should be created 6 // fill in the values of the "att"-array
27 var whichFrame = parent.mainFrame; 7 function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) {
28 8
29 // give a name to the window containing digilib - this way one can test if there is already a 9 // debug window to check the parameters passed
30 // digilib-window open and replace the contents of it (ex. digicat) 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);
31 window.name = "digilib"; 11
12 // attaching the values to the att-array
13 att[0] = fn;
14 att[1] = parseInt(pn);
15 att[2] = parseFloat(ws);
16 att[3] = mo;
17 att[4] = mk;
18 att[5] = parseFloat(wx);
19 att[6] = parseFloat(wy);
20 att[7] = parseFloat(ww);
21 att[8] = parseFloat(wh);
22
23 // compatablility issue
24 if (att[3].indexOf("f") > -1) {
25 att[3] = "fit";
26 }
27
28 // converts the old mark format (0-1000) to new format(0.0 - 1.0)
29 // could even be useless now
30 if (att[4] != "0/0") {
31 var tmp = att[4].split(";");
32
33 att[4] = "";
34
35 for (i = 0; i < tmp.length; i++) {
36 tmp[i] = tmp[i].split("/");
37
38 if (tmp[i][0] > 1 && tmp[i][1] > 1) {
39 tmp[i][0] /= 1000;
40 tmp[i][1] /= 1000;
41 }
42
43 att[4] += tmp[i][0] + "/" + tmp[i][1] + ";";
44 }
45 att[4] = att[4].slice(0, -1);
46 }
47
48 // initialisation stuff
49 // ====================
50
51 setMarks();
52
53 this.document.addEventListener('keypress', parseKeypress, true);
54 focus();
55
56 // give a name to the window containing digilib - this way one can test if there is already a
57 // digilib-window open and replace the contents of it (ex. digicat)
58 top.window.name = "digilib";
59 }
60
32 61
33 // function that launches the ScaleServlet 62 // function that launches the ScaleServlet
34 // the different detailGrades: 63 // the different detailGrades:
35 // 0 -> back, next, page 64 // 0 -> back, next, page
36 // 1 -> zoomout 65 // 1 -> zoomout
37 // 2 -> zoomarea, zoompoint, moveto, scaledef 66 // 2 -> zoomarea, zoompoint, moveto, scaledef
38 67
39 function loadPicture(detailGrade, keepArea) { 68 function loadPicture(detailGrade, keepArea) {
40 69
41 // alert("wx: " + att[5] + "\tww: " + att[7] + "\nwy: " + att[6] + "\twh: " + att[8]); 70 var newURL = "dlImage.jsp?"
42 71 newURL += "fn=" + att[0] + "&pn=" + att[1] + "&ws=" + att[2] + "&mo=" + att[3];
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 72
54 if (detailGrade == 0) { 73 if (detailGrade == 0) {
55 att[4] = "0/0"; 74 att[4] = "0/0";
56 } 75 }
57 76
59 att[5] = 0; 78 att[5] = 0;
60 att[6] = 0; 79 att[6] = 0;
61 att[7] = 1; 80 att[7] = 1;
62 att[8] = 1; 81 att[8] = 1;
63 } 82 }
64 newPicture += "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8]; 83
65 84 newURL += "&mk=" + att[4] + "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8];
66 whichFrame.document.write('<div ID="lay1" style="position:absolute; left:10; top:10; visibility:visible"><img name="pic" src="' + newPicture + '"></div>'); 85 newURL += "&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>'); 86
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>'); 87 // debug window - checking the parameters passed to the next image
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>'); 88 //alert ("DEBUG MESSAGE (complete URL in loadPicture):\n\n" + newURL);
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>'); 89
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>'); 90 location.href = newURL;
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>'); 91 }
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>'); 92
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>'); 93
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>'); 94 function backPage(keepArea) {
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>');
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>');
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>');
79
80 whichFrame.document.write('</body></html>');
81
82 whichFrame.document.close();
83
84 initScripts();
85
86 pageInfo();
87
88 setmark();
89 }
90
91
92 function Backpage(keepArea) {
93 95
94 att[1] = parseInt(att[1]) - 1; 96 att[1] = parseInt(att[1]) - 1;
95 97
96 if (att[1] > 0) { 98 if (att[1] > 0) {
97 loadPicture(0, keepArea); 99 loadPicture(0, keepArea);
100 alert("You are already on the first page!"); 102 alert("You are already on the first page!");
101 } 103 }
102 } 104 }
103 105
104 106
105 function Nextpage(keepArea) { 107 function nextPage(keepArea) {
106 108
107 att[1] = parseInt(att[1]) + 1; 109 att[1] = parseInt(att[1]) + 1;
108 110
109 if (att[1] <= parent.numPages) { 111 loadPicture(0, keepArea);
110 loadPicture(0, keepArea); 112 }
111 } else { 113
112 att[1] = parseInt(att[1]) - 1; 114
113 alert("You are already on the last page!"); 115 function page(keepArea) {
114 }
115 }
116
117
118 function Page(keepArea) {
119 116
120 do { 117 do {
121 page = prompt("Goto Page (1 - " + parent.numPages + "):", 1); 118 page = prompt("Goto Page:", 1);
122 } while ((page != null) && ((page < 1) || (page > parent.numPages))); 119 } while ((page != null) && (page < 1));
123 120
124 if (page != null && page != att[1]) { 121 if (page != null && page != att[1]) {
125 att[1] = page; 122 att[1] = page;
126 loadPicture(0, keepArea); 123 loadPicture(0, keepArea);
127 } 124 }
128 } 125 }
129 126
130 127
131 function Digicat() { 128 function digicat() {
132 var url = "http://" + location.host + "/docuserver/digitallibrary/digicat.html?" + att[0] + "+" + att[1]; 129 var url = "http://" + location.host + "/docuserver/digitallibrary/digicat.html?" + att[0] + "+" + att[1];
133 win = window.open(url, "digicat"); 130 win = window.open(url, "digicat");
134 win.focus(); 131 win.focus();
135 } 132 }
136 133
137 134
138 function Ref(refselect) { 135 function ref(refselect) {
139 136
140 var hyperlinkRef = "http://" + location.host + "/docuserver/digitallibrary/digilib.jsp?"; 137 var hyperlinkRef = "http://" + location.host + "/docuserver/digitallibrary/digilib.jsp?";
141 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4]; 138 hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4];
142 139
143 if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) { 140 if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) {
150 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}"); 147 prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}");
151 } 148 }
152 } 149 }
153 150
154 151
155 function Mark() { 152 function mark() {
156 153
157 if (att[4].split(";").length > 7) { 154 if (att[4].split(";").length > 7) {
158 alert("Only 8 marks are possible at the moment!"); 155 alert("Only 8 marks are possible at the moment!");
159 return; 156 return;
160 } 157 }
161 158
162 function MarkEvent(event) { 159 function markEvent(event) {
163 160
164 if ((att[4] != "") && (att[4] != "0/0")) { 161 if ((att[4] != "") && (att[4] != "0/0")) {
165 att[4] += ";"; 162 att[4] += ";";
166 } else { 163 } else {
167 att[4] = ""; 164 att[4] = "";
168 } 165 }
169 166
170 var markX = cropFloat(att[5]+att[7]*(event.pageX-parseInt(whichFrame.document.getElementById("lay1").style.left))/whichFrame.document.pic.offsetWidth); 167 var markX = cropFloat(att[5]+att[7]*(event.pageX-parseInt(document.getElementById("lay1").style.left))/document.pic.offsetWidth);
171 var markY = cropFloat(att[6]+att[8]*(event.pageY-parseInt(whichFrame.document.getElementById("lay1").style.top))/whichFrame.document.pic.offsetHeight); 168 var markY = cropFloat(att[6]+att[8]*(event.pageY-parseInt(document.getElementById("lay1").style.top))/document.pic.offsetHeight);
172 169
173 att[4] += markX + "/" + markY; 170 att[4] += markX + "/" + markY;
174 171
175 whichFrame.document.getElementById("lay1").removeEventListener("mousedown", MarkEvent, true); 172 document.getElementById("lay1").removeEventListener("mousedown", markEvent, true);
176 setmark(); 173 setMarks();
177 } 174 }
178 175
179 whichFrame.document.getElementById("lay1").addEventListener("mousedown", MarkEvent, true); 176 document.getElementById("lay1").addEventListener("mousedown", markEvent, true);
180 } 177 }
181 178
182 179
183 function Zoomrect() { 180 function zoomArea() {
184 var state = 0; 181 var state = 0;
185 var x1, y1, x2, y2; 182 var x1, y1, x2, y2;
186 183
187 function Click(event) { 184 function click(event) {
188 185
189 if (state == 0) { 186 if (state == 0) {
190 state = 1; 187 state = 1;
191 188
192 x1 = event.pageX; 189 x1 = event.pageX;
193 y1 = event.pageY; 190 y1 = event.pageY;
194 x2 = x1; 191 x2 = x1;
195 y2 = y1; 192 y2 = y1;
196 193
197 whichFrame.document.getElementById("eck1").style.left = x1; 194 document.getElementById("eck1").style.left = x1;
198 whichFrame.document.getElementById("eck1").style.top = y1; 195 document.getElementById("eck1").style.top = y1;
199 whichFrame.document.getElementById("eck2").style.left = x2-12; 196 document.getElementById("eck2").style.left = x2-12;
200 whichFrame.document.getElementById("eck2").style.top = y1; 197 document.getElementById("eck2").style.top = y1;
201 whichFrame.document.getElementById("eck3").style.left = x1; 198 document.getElementById("eck3").style.left = x1;
202 whichFrame.document.getElementById("eck3").style.top = y2-12; 199 document.getElementById("eck3").style.top = y2-12;
203 whichFrame.document.getElementById("eck4").style.left = x2-12; 200 document.getElementById("eck4").style.left = x2-12;
204 whichFrame.document.getElementById("eck4").style.top = y2-12; 201 document.getElementById("eck4").style.top = y2-12;
205 202
206 whichFrame.document.getElementById("eck1").style.visibility="visible"; 203 document.getElementById("eck1").style.visibility="visible";
207 whichFrame.document.getElementById("eck2").style.visibility="visible"; 204 document.getElementById("eck2").style.visibility="visible";
208 whichFrame.document.getElementById("eck3").style.visibility="visible"; 205 document.getElementById("eck3").style.visibility="visible";
209 whichFrame.document.getElementById("eck4").style.visibility="visible"; 206 document.getElementById("eck4").style.visibility="visible";
210 207
211 whichFrame.document.getElementById("lay1").addEventListener("mousemove", Move, true); 208 document.getElementById("lay1").addEventListener("mousemove", move, true);
212 whichFrame.document.getElementById("eck4").addEventListener("mousemove", Move, true); 209 document.getElementById("eck4").addEventListener("mousemove", move, true);
213 210
214 } else { 211 } else {
215 212
216 x1 -= parseInt(whichFrame.document.getElementById("lay1").style.left); 213 x1 -= parseInt(document.getElementById("lay1").style.left);
217 y1 -= parseInt(whichFrame.document.getElementById("lay1").style.top); 214 y1 -= parseInt(document.getElementById("lay1").style.top);
218 215
219 x2 = event.pageX-parseInt(whichFrame.document.getElementById("lay1").style.left); 216 x2 = event.pageX-parseInt(document.getElementById("lay1").style.left);
220 y2 = event.pageY-parseInt(whichFrame.document.getElementById("lay1").style.top); 217 y2 = event.pageY-parseInt(document.getElementById("lay1").style.top);
221 218
222 whichFrame.document.getElementById("lay1").removeEventListener("mousedown", Click, true); 219 document.getElementById("lay1").removeEventListener("mousedown", click, true);
223 whichFrame.document.getElementById("eck4").removeEventListener("mousedown", Click, true); 220 document.getElementById("eck4").removeEventListener("mousedown", click, true);
224 221
225 whichFrame.document.getElementById("lay1").removeEventListener("mousemove", Move, true); 222 document.getElementById("lay1").removeEventListener("mousemove", move, true);
226 whichFrame.document.getElementById("eck4").removeEventListener("mousemove", Move, true); 223 document.getElementById("eck4").removeEventListener("mousemove", move, true);
227 224
228 whichFrame.document.getElementById("eck1").style.visibility="hidden"; 225 document.getElementById("eck1").style.visibility="hidden";
229 whichFrame.document.getElementById("eck2").style.visibility="hidden"; 226 document.getElementById("eck2").style.visibility="hidden";
230 whichFrame.document.getElementById("eck3").style.visibility="hidden"; 227 document.getElementById("eck3").style.visibility="hidden";
231 whichFrame.document.getElementById("eck4").style.visibility="hidden"; 228 document.getElementById("eck4").style.visibility="hidden";
232 229
233 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/whichFrame.document.pic.offsetWidth); 230 att[5] = cropFloat(att[5]+att[7]*((x1 < x2) ? x1 : x2)/document.pic.offsetWidth);
234 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/whichFrame.document.pic.offsetHeight); 231 att[6] = cropFloat(att[6]+att[8]*((y1 < y2) ? y1 : y2)/document.pic.offsetHeight);
235 232
236 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/whichFrame.document.pic.offsetWidth); 233 att[7] = cropFloat(att[7]*Math.abs(x1-x2)/document.pic.offsetWidth);
237 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/whichFrame.document.pic.offsetHeight); 234 att[8] = cropFloat(att[8]*Math.abs(y1-y2)/document.pic.offsetHeight);
238 235
239 if (att[7] != 0 && att[8] != 0) { 236 if (att[7] != 0 && att[8] != 0) {
240 loadPicture(2); 237 loadPicture(2);
241 } 238 }
242 } 239 }
243 } 240 }
244 241
245 function Move(event) { 242 function move(event) {
246 243
247 x2 = event.pageX; 244 x2 = event.pageX;
248 y2 = event.pageY; 245 y2 = event.pageY;
249 246
250 whichFrame.document.getElementById("eck1").style.left = ((x1 < x2) ? x1 : x2); 247 document.getElementById("eck1").style.left = ((x1 < x2) ? x1 : x2);
251 whichFrame.document.getElementById("eck1").style.top = ((y1 < y2) ? y1 : y2); 248 document.getElementById("eck1").style.top = ((y1 < y2) ? y1 : y2);
252 whichFrame.document.getElementById("eck2").style.left = ((x1 < x2) ? x2 : x1)-12; 249 document.getElementById("eck2").style.left = ((x1 < x2) ? x2 : x1)-12;
253 whichFrame.document.getElementById("eck2").style.top = ((y1 < y2) ? y1 : y2); 250 document.getElementById("eck2").style.top = ((y1 < y2) ? y1 : y2);
254 whichFrame.document.getElementById("eck3").style.left = ((x1 < x2) ? x1 : x2); 251 document.getElementById("eck3").style.left = ((x1 < x2) ? x1 : x2);
255 whichFrame.document.getElementById("eck3").style.top = ((y1 < y2) ? y2 : y1)-12; 252 document.getElementById("eck3").style.top = ((y1 < y2) ? y2 : y1)-12;
256 whichFrame.document.getElementById("eck4").style.left = ((x1 < x2) ? x2 : x1)-12; 253 document.getElementById("eck4").style.left = ((x1 < x2) ? x2 : x1)-12;
257 whichFrame.document.getElementById("eck4").style.top = ((y1 < y2) ? y2 : y1)-12; 254 document.getElementById("eck4").style.top = ((y1 < y2) ? y2 : y1)-12;
258 } 255 }
259 256
260 whichFrame.document.getElementById("lay1").addEventListener("mousedown", Click, true); 257 document.getElementById("lay1").addEventListener("mousedown", click, true);
261 whichFrame.document.getElementById("eck4").addEventListener("mousedown", Click, true); 258 document.getElementById("eck4").addEventListener("mousedown", click, true);
262 } 259 }
263 260
264 261
265 function Zoomin() { 262 function zoomPoint() {
266 263
267 function ZoominEvent(event) { 264 function zoomPointEvent(event) {
268 265
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); 266 att[5] = cropFloat(att[5]+att[7]*(event.pageX-parseInt(document.getElementById("lay1").style.left))/document.pic.offsetWidth-0.5*att[7]*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); 267 att[6] = cropFloat(att[6]+att[8]*(event.pageY-parseInt(document.getElementById("lay1").style.top))/document.pic.offsetHeight-0.5*att[8]*0.7);
271 268
272 att[7] = cropFloat(att[7]*0.7); 269 att[7] = cropFloat(att[7]*0.7);
273 att[8] = cropFloat(att[8]*0.7); 270 att[8] = cropFloat(att[8]*0.7);
274 271
275 if (att[5] < 0) { 272 if (att[5] < 0) {
283 } 280 }
284 if (att[6]+att[8] > 1) { 281 if (att[6]+att[8] > 1) {
285 att[6] = 1-att[8]; 282 att[6] = 1-att[8];
286 } 283 }
287 284
288 whichFrame.document.getElementById("lay1").removeEventListener("mousedown", ZoominEvent, true); 285 document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true);
289 286
290 loadPicture(2); 287 loadPicture(2);
291 } 288 }
292 289
293 whichFrame.document.getElementById("lay1").addEventListener("mousedown", ZoominEvent, true); 290 document.getElementById("lay1").addEventListener("mousedown", zoomPointEvent, true);
294 } 291 }
295 292
296 293
297 function Zoomout() { 294 function zoomOut() {
298 295
299 loadPicture(1); 296 loadPicture(1);
300 } 297 }
301 298
302 299
303 function Moveto() { 300 function moveTo() {
304 301
305 function MovetoEvent(event) { 302 function moveToEvent(event) {
306 303
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]); 304 att[5] = cropFloat(att[5]+att[7]*(event.pageX-parseInt(document.getElementById("lay1").style.left))/document.pic.offsetWidth-0.5*att[7]);
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]); 305 att[6] = cropFloat(att[6]+att[8]*(event.pageY-parseInt(document.getElementById("lay1").style.top))/document.pic.offsetHeight-0.5*att[8]);
309 306
310 if (att[5] < 0) { 307 if (att[5] < 0) {
311 att[5] = 0; 308 att[5] = 0;
312 } 309 }
313 if (att[6] < 0) { 310 if (att[6] < 0) {
318 } 315 }
319 if (att[6]+att[8] > 1) { 316 if (att[6]+att[8] > 1) {
320 att[6] = 1-att[8]; 317 att[6] = 1-att[8];
321 } 318 }
322 319
323 whichFrame.document.getElementById("lay1").removeEventListener("mousedown", MovetoEvent, true); 320 document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true);
324 321
325 loadPicture(2); 322 loadPicture(2);
326 } 323 }
327 324
328 whichFrame.document.getElementById("lay1").addEventListener("mousedown", MovetoEvent, true); 325 document.getElementById("lay1").addEventListener("mousedown", moveToEvent, true);
329 } 326 }
330 327
331 328
332 function Scaledef(scaledef) { 329 function scale(scaledef) {
333 330
334 att[2] = scaledef; 331 att[2] = scaledef;
335 loadPicture(2); 332 loadPicture(2);
336 } 333 }
337 334
338 335
339 function setmark() { 336 function setMarks() {
340 337
341 if (att[4] != "" && att[4] != "0/0") { 338 if (att[4] != "" && att[4] != "0/0") {
342 var mark = att[4].split(";"); 339 var mark = att[4].split(";");
343 340
344 var countMarks = mark.length; 341 var countMarks = mark.length;
345 342
346 // maximum of marks is 8 343 // maximum of marks is 8
347 // we do not report this error because this is already done in func. "Mark" 344 // we do not report this error because this is already done in func. "Mark"
348 if (countMarks > 8) countMarks = 8; 345 if (countMarks > 8) countMarks = 8;
349 346
350 var picWidth = whichFrame.document.pic.offsetWidth; 347 var picWidth = document.pic.offsetWidth;
351 var picHeight = whichFrame.document.pic.offsetHeight; 348 var picHeight = document.pic.offsetHeight;
352 349
353 // catch the cases where the picture had not been loaded already and 350 // 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 351 // make a timeout so that the coordinates are calculated with the real dimensions
355 if (whichFrame.document.pic.complete) { 352 if (document.pic.complete) {
356 var xoffset = parseInt(whichFrame.document.getElementById("lay1").style.left); 353 var xoffset = parseInt(document.getElementById("lay1").style.left);
357 var yoffset = parseInt(whichFrame.document.getElementById("lay1").style.top); 354 var yoffset = parseInt(document.getElementById("lay1").style.top);
358 355
359 for (var i = 0; i < countMarks; i++) { 356 for (var i = 0; i < countMarks; i++) {
360 mark[i] = mark[i].split("/"); 357 mark[i] = mark[i].split("/");
361 358
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]))) { 359 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]))) {
363 360
364 mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]); 361 mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]);
365 mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]); 362 mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]);
366 363
367 364
368 whichFrame.document.getElementById("dot" + i).style.left = mark[i][0]-5; 365 document.getElementById("dot" + i).style.left = mark[i][0]-5;
369 whichFrame.document.getElementById("dot" + i).style.top = mark[i][1]-5; 366 document.getElementById("dot" + i).style.top = mark[i][1]-5;
370 whichFrame.document.getElementById("dot" + i).style.visibility = "visible"; 367 document.getElementById("dot" + i).style.visibility = "visible";
371 } 368 }
372 } 369 }
373 } else { 370 } else {
374 setTimeout("setmark()", 100); 371 setTimeout("setMarks()", 100);
375 } 372 }
376 } 373 }
377 } 374 }
378 375
379 // capturing keypresses for next and previous page 376 // capturing keypresses for next and previous page
390 387
391 // auxiliary function to crop senseless precicsion 388 // auxiliary function to crop senseless precicsion
392 function cropFloat(tmp) { 389 function cropFloat(tmp) {
393 return parseInt(10000*tmp)/10000; 390 return parseInt(10000*tmp)/10000;
394 } 391 }
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 }