!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is Mozilla Communicator client code, released
15 * March 31, 1998.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1999-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Dan Haddix (dan6992@hotmail.com)
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39 var downTool = false;
40 var dragActive = false;
41 var dragObject = false;
42 var startX = null;
43 var startY = null;
44 var endX = null;
45 var endY = null;
46 var downTool = false;
47 var currentElement = [];
48 var currentTool = "pointer";
49 var currentRect = null;
50 var currentCir = null;
51 var currentPoly = null;
52 var currentPoint = null;
53 var rectCount = 1;
54 var cirCount = 1;
55 var polyCount = 1;
56 var pointCount = 1;
57 var xlock = false;
58 var ylock = false;
59 var resize = false;
60 var currentZoom = 1;
61 var clipBoard = [];
62
Rect
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
63 function Rect(coords, href, target, alt, construct){
64 newRect = frameDoc.createElement("div");
65 newRect.setAttribute("class", "rect");
66 newRect.setAttribute("id", "rect"+rectCount++);
67 newRect.setAttribute("name", "hotspot");
68 currentRect = selectElement(frameDoc.body.appendChild(newRect));
69
70 // Add resize handles
71 // waiting for better drawing code
72 handletl = frameDoc.createElement("div");
73 handletl.setAttribute("class", "handletl");
74 handletl.setAttribute("name", "handle");
75 handletr = frameDoc.createElement("div");
76 handletr.setAttribute("class", "handletr");
77 handletr.setAttribute("name", "handle");
78 handlebl = frameDoc.createElement("div");
79 handlebl.setAttribute("class", "handlebl");
80 handlebl.setAttribute("name", "handle");
81 handlebr = frameDoc.createElement("div");
82 handlebr.setAttribute("class", "handlebr");
83 handlebr.setAttribute("name", "handle");
84 handlet = frameDoc.createElement("div");
85 handlet.setAttribute("class", "handlet");
86 handlet.setAttribute("name", "handle");
87 handlel = frameDoc.createElement("div");
88 handlel.setAttribute("class", "handlel");
89 handlel.setAttribute("name", "handle");
90 handler = frameDoc.createElement("div");
91 handler.setAttribute("class", "handler");
92 handler.setAttribute("name", "handle");
93 handleb = frameDoc.createElement("div");
94 handleb.setAttribute("class", "handleb");
95 handleb.setAttribute("name", "handle");
96 currentRect.appendChild(handletl);
97 currentRect.appendChild(handletr);
98 currentRect.appendChild(handlebl);
99 currentRect.appendChild(handlebr);
100 currentRect.appendChild(handlet);
101 currentRect.appendChild(handlel);
102 currentRect.appendChild(handler);
103 currentRect.appendChild(handleb);
104
105 if (!coords){
106 currentRect.style.left = startX+"px";
107 currentRect.style.top = startY+"px";
108 //currentRect.style.width = endX+"px";
109 //currentRect.style.height = endX+"px";
110 }
111 else{
112 var coordArray = coords.split(',');
113 currentRect.style.left = coordArray[0]+"px";
114 currentRect.style.top = coordArray[1]+"px";
115 currentRect.style.width = (parseInt(coordArray[2])-parseInt(coordArray[0]))+"px";
116 currentRect.style.height = (parseInt(coordArray[3])-parseInt(coordArray[1]))+"px";
117 if (href)
118 currentRect.setAttribute("hsHref", href);
119 if (target)
120 currentRect.setAttribute("hsTarget", target);
121 if (alt)
122 currentRect.setAttribute("hsAlt", alt);
123 }
124 if (construct)
125 currentRect = null;
126 }
127
Circle
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
128 function Circle(coords, href, target, alt, construct){
129 newCir = frameDoc.createElement("div");
130 newCir.setAttribute("class", "cir");
131 newCir.setAttribute("id", "cir"+cirCount++);
132 newCir.setAttribute("name", "hotspot");
133 currentCir = selectElement(frameDoc.body.appendChild(newCir));
134
135 // Add resize handles
136 handletl = frameDoc.createElement("div");
137 handletl.setAttribute("class", "handletl");
138 handletl.setAttribute("name", "handle");
139 handletr = frameDoc.createElement("div");
140 handletr.setAttribute("class", "handletr");
141 handletr.setAttribute("name", "handle");
142 handlebl = frameDoc.createElement("div");
143 handlebl.setAttribute("class", "handlebl");
144 handlebl.setAttribute("name", "handle");
145 handlebr = frameDoc.createElement("div");
146 handlebr.setAttribute("class", "handlebr");
147 handlebr.setAttribute("name", "handle");
148 currentCir.appendChild(handletl);
149 currentCir.appendChild(handletr);
150 currentCir.appendChild(handlebl);
151 currentCir.appendChild(handlebr);
152
153 if (!coords){
154 currentCir.style.left = startX+"px";
155 currentCir.style.top = startY+"px";
156 //currentCir.style.width = endX+"px";
157 //currentCir.style.height = endX+"px";
158 }
159 else{
160 var coordArray = coords.split(',');
161 radius = parseInt(coordArray[2]);
162 currentCir.style.left = (parseInt(coordArray[0])-radius)+"px";
163 currentCir.style.top = (parseInt(coordArray[1])-radius)+"px";
164 currentCir.style.width = (radius*2)+"px";
165 currentCir.style.height = (radius*2)+"px";
166 if (href)
167 currentCir.setAttribute("hsHref", href);
168 if (target)
169 currentCir.setAttribute("hsTarget", target);
170 if (alt)
171 currentCir.setAttribute("hsAlt", alt);
172 }
173 if (construct)
174 currentCir = null;
175 }
176
Poly
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
177 function Poly(coords, href, target, alt, construct){
178 dump('Poly Called\n');
179 newPoly = frameDoc.createElement("div");
180 newPoly.setAttribute("class", "poly");
181 newPoly.setAttribute("id", "poly"+polyCount++);
182 newPoly.setAttribute("name", "hotspot");
183 currentPoly = selectElement(frameDoc.body.appendChild(newPoly));
184 if (currentZoom > 1){
185 currentPoly.style.width = imageEl.offsetWidth+"px";
186 currentPoly.style.height = imageEl.offsetHeight+"px";
187 }
188 if (!coords){
189 addPoint(null, startX, startY, true);
190 //currentPoly.onclick = addPoint;
191 currentPoly.style.cursor = "crosshair";
192 }
193 else{
194 var coordArray = coords.split(',');
195 var len = coordArray.length;
196 for (i=0; i<len; i++){
197 addPoint(null, coordArray[i], coordArray[i+1]);
198 i++;
199 }
200 if (href)
201 currentPoly.setAttribute("hsHref", href);
202 if (target)
203 currentPoly.setAttribute("hsTarget", target);
204 if (alt)
205 currentPoly.setAttribute("hsAlt", alt);
206 polyFinish(null, construct);
207 }
208 }
209
addPoint
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
210 function addPoint(event, pointX, pointY, start){
211 if (event){
212 dump('addPoint Called with event\n');
213 pointX = event.clientX+window.frames[0].pageXOffset;
214 pointY = event.clientY+window.frames[0].pageYOffset;
215 event.stopPropagation();
216 if (event.detail == 2){
217 polyFinish();
218 return;
219 }
220 }
221 else
222 dump('addPoint Called\n');
223 newPoint = frameDoc.createElement("div");
224 newPoint.setAttribute("class", "point");
225 newPoint.setAttribute("id", "point"+pointCount++);
226 newPoint.style.left = pointX+"px";
227 newPoint.style.top = pointY+"px";
228 if (start){
229 newPoint.setAttribute("class", "pointStart");
230 newPoint.style.cursor = "pointer";
231 //newPoint.onclick = polyFinish;
232 //newPoint.addEventListener("click", polyFinish, false);
233 }
234 currentPoly.appendChild(newPoint);
235 }
236
polyFinish
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
237 function polyFinish(event, construct){
238 dump("polyfinish called\n");
239 var len = currentPoly.childNodes.length;
240 if (len >=3){
241 var polyLeft = 1000000;
242 var polyTop = 1000000;
243 var polyWidth = 0;
244 var polyHeight = 0;
245 for(p=0; p<len; p++){
246 var curEl = currentPoly.childNodes[p];
247 curEl.setAttribute("class", "point");
248 curEl.style.cursor = "default";
249 pointLeft = parseInt(curEl.style.left);
250 pointTop = parseInt(curEl.style.top);
251 polyLeft = Math.min(polyLeft, pointLeft);
252 polyTop = Math.min(polyTop, pointTop);
253 dump(polyLeft+"\n");
254 }
255 for(p=0; p<len; p++){
256 var curEl = currentPoly.childNodes[p];
257 curEl.style.left = (parseInt(curEl.style.left)-polyLeft)+"px";
258 curEl.style.top = (parseInt(curEl.style.top)-polyTop)+"px";
259 }
260 for(p=0; p<len; p++){
261 var curEl = currentPoly.childNodes[p];
262 polyWidth = Math.max(polyWidth, (parseInt(curEl.style.left)+3));
263 polyHeight = Math.max(polyHeight, (parseInt(curEl.style.top)+3));
264 }
265 if (parseInt(currentPoly.style.left) >= 0){
266 polyLeft += parseInt(currentPoly.style.left);
267 polyTop += parseInt(currentPoly.style.top);
268 }
269 currentPoly.style.left = polyLeft+"px";
270 currentPoly.style.top = polyTop+"px";
271 currentPoly.style.width = polyWidth+"px";
272 currentPoly.style.height = polyHeight+"px";
273 //currentPoly.childNodes[0].onclick = null;
274 //currentPoly.onclick = null;
275 currentPoly.style.cursor = "auto";
276 //currentPoly.childNodes[0].removeEventListener("click", polyFinish, false);
277 //currentPoly.removeEventListener("click", addPoint, true);
278 if (!construct)
279 hotSpotProps(currentPoly);
280 }
281 else
282 deleteElement(currentPoly);
283 if (event)
284 event.stopPropagation();
285
286 currentPoly = null;
287 }
288
deleteElement
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
289 function deleteElement(el){
290 if (el){
291 if (el.length){
292 var len = currentElement.length;
293 for(i=0; i<len; i++)
294 frameDoc.body.removeChild(currentElement[i]);
295 }
296 else
297 frameDoc.body.removeChild(el);
298 }
299 }
300
selectAll
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
301 function selectAll(){
302 objList = frameDoc.getElementsByName("hotspot");
303 listLen = objList.length;
304 var objCount = 0;
305 for(a=0; a<listLen; a++){
306 selectElement(objList[a], objCount);
307 objCount++;
308 }
309 }
310
selectElement
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
311 function selectElement(el, add){
312 if (add){
313 if (currentElement[0].getAttribute("class") != "poly"){
314 len = currentElement[0].childNodes.length;
315 for(i=0; i<len; i++)
316 currentElement[0].childNodes[i].style.visibility = "hidden";
317 }
318 currentElement.push(el);
319 document.getElementById("Map:Cut").setAttribute("disabled", "false");
320 document.getElementById("Map:Copy").setAttribute("disabled", "false");
321 return currentElement[currentElement.length-1];
322 }
323 else{
324 if (currentElement[0]){
325 if (currentElement[0].getAttribute("class") != "poly"){
326 len = currentElement[0].childNodes.length;
327 for(i=0; i<len; i++)
328 currentElement[0].childNodes[i].style.visibility = "hidden";
329 }
330 }
331 currentElement = null;
332 currentElement = [];
333 currentElement[0] = el;
334 if (el != null){
335 if (currentElement[0].getAttribute("class") != "poly"){
336 len = currentElement[0].childNodes.length;
337 for(i=0; i<len; i++)
338 currentElement[0].childNodes[i].style.visibility = "visible";
339 }
340 document.getElementById("Map:Cut").setAttribute("disabled", "false");
341 document.getElementById("Map:Copy").setAttribute("disabled", "false");
342 return currentElement[0];
343 }
344 else{
345 document.getElementById("Map:Cut").setAttribute("disabled", "true");
346 document.getElementById("Map:Copy").setAttribute("disabled", "true");
347 }
348 }
349 }
350
deSelectElement
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
351 function deSelectElement(el){
352 var len = currentElement.length;
353 var j=0;
354 for(i=0; i<len; i++){
355 dump(j+"\n");
356 currentElement[j] = currentElement[i];
357 if (currentElement[i] != el)
358 j++;
359 }
360 currentElement.pop();
361 if (currentElement.length == 1){
362 selectElement(currentElement[0]);
363 }
364 if (currentElement.length >= 1){
365 document.getElementById("Map:Cut").setAttribute("disabled", "false");
366 document.getElementById("Map:Copy").setAttribute("disabled", "false");
367 }
368 else{
369 document.getElementById("Map:Cut").setAttribute("disabled", "true");
370 document.getElementById("Map:Copy").setAttribute("disabled", "true");
371 }
372 }
373
marqueeSelect
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
374 function marqueeSelect(){
375 marTop = parseInt(marquee.style.top);
376 marLeft = parseInt(marquee.style.left);
377 marRight = parseInt(marquee.style.width)+marLeft;
378 marBottom = parseInt(marquee.style.height)+marTop;
379 marquee.style.visibility = "hidden";
380 marquee.style.top = "-5px";
381 marquee.style.left = "-5px";
382 marquee.style.width = "1px";
383 marquee.style.height = "1px";
384 marquee = null;
385 objList = frameDoc.getElementsByName("hotspot");
386 listLen = objList.length;
387 var objCount = 0;
388 for(a=0; a<listLen; a++){
389 objTop = parseInt(objList[a].style.top);
390 objLeft = parseInt(objList[a].style.left);
391 objRight = parseInt(objList[a].style.width)+objLeft;
392 objBottom = parseInt(objList[a].style.height)+objTop;
393 if ((objTop >= marTop) && (objLeft >= marLeft) && (objBottom <= marBottom) && (objRight <= marRight)){
394 //objList[i].style.borderColor = "#ffff00";
395 selectElement(objList[a], objCount);
396 objCount++;
397 }
398 }
399 }
400
upMouse
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
401 function upMouse(event){
402 if (currentTool != "poly"){
403 if (marquee){
404 marqueeSelect();
405 }
406 if (currentRect){
407 if (!resize)
408 hotSpotProps(currentRect);
409 else
410 resize = false;
411 }
412 else if (currentCir){
413 if (!resize)
414 hotSpotProps(currentCir);
415 else
416 resize = false;
417 }
418 else if (currentPoint)
419 polyFinish(null, true);
420
421 currentRect = null;
422 currentCir = null;
423 currentPoint=null;
424 downTool = false;
425 dragActive = false;
426 dragObject = false;
427 xlock = false;
428 ylock = false;
429 }
430 }
431
moveMouse
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
432 function moveMouse(event){
433 if (downTool){
434 endX = event.clientX+window.frames[0].pageXOffset;
435 endY = event.clientY+window.frames[0].pageYOffset;
436
437 if (dragActive){
438 if (currentElement.length > 0){
439 if (currentCir){
440 radiusWidth = Math.abs((endX-startX));
441 radiusHeight = Math.abs((endY-startY));
442 circleRadius = Math.max(radiusWidth, radiusHeight);
443 currentCir.style.top = Math.max(startY-circleRadius, 0)+"px";
444 currentCir.style.left = Math.max(startX-circleRadius, 0)+"px";
445 currentCir.style.width = (circleRadius*2)+"px";
446 currentCir.style.height = (circleRadius*2)+"px";
447 }
448 else if (currentRect || marquee){
449 var rectObject = (currentRect)? currentRect : marquee;
450 if (!xlock){
451 if (endX > startX){
452 rectWidth = endX-startX;
453 rectObject.style.left = Math.max(startX, 0 )+"px";
454 rectObject.style.width = rectWidth+"px";
455 }
456 else{
457 rectWidth = startX-endX;
458 rectObject.style.left = Math.max(endX, 0)+"px";
459 rectObject.style.width = rectWidth+"px";
460 }
461 }
462 if (!ylock){
463 if (endY > startY){
464 rectHeight = endY-startY;
465 rectObject.style.top = startY+"px";
466 rectObject.style.height = rectHeight+"px";
467 }
468 else{
469 rectHeight = startY-endY;
470 rectObject.style.top = endY+"px";
471 rectObject.style.height = rectHeight+"px";
472 }
473 }
474 }
475 }
476 }
477 else{
478 if (currentTool == "rect"){
479 if ((((endX-startX) > 1) || ((endX-startX) < -1)) && (((endY-startY) > 1) || ((endY-startY) < -1))){
480 Rect();
481 dragActive = true;
482 }
483 }
484 if (currentTool == "cir"){
485 if ((((endX-startX) > 1) || ((endX-startX) < -1)) && (((endY-startY) > 1) || ((endY-startY) < -1))){
486 Circle();
487 dragActive = true;
488 }
489 }
490 if (currentTool == "pointer"){
491 if (dragObject){
492 var len = currentElement.length;
493 var maxX = false;
494 var maxY = false;
495 for(i=0; i<len; i++){
496 newX = Math.max(0, (endX-currentElement[i].startX));
497 newY = Math.max(0, (endY-currentElement[i].startY));
498 if (newX == 0)
499 maxX = true;
500 if (newY == 0)
501 maxY = true;
502 }
503 for(i=0; i<len; i++){
504 newX = Math.max(0, (endX-currentElement[i].startX));
505 newY = Math.max(0, (endY-currentElement[i].startY));
506 if ((newX > 0) && (maxX != true))
507 currentElement[i].style.left = newX+"px";
508 if ((newY >0) && (maxY != true))
509 currentElement[i].style.top = newY+"px";
510 }
511 }
512 else if (currentPoint){
513 endX = endX-parseInt(currentPoint.parentNode.style.left);
514 endY = endY-parseInt(currentPoint.parentNode.style.top);
515 newX = Math.max((0-parseInt(currentPoint.parentNode.style.left)), (endX-currentPoint.startX));
516 newY = Math.max((0-parseInt(currentPoint.parentNode.style.top)), (endY-currentPoint.startY));
517 currentPoint.style.left = newX+"px";
518 currentPoint.style.top = newY+"px";
519 }
520 else{
521 marquee = frameDoc.getElementById("marquee");
522 marquee.style.visibility = "visible";
523 dragActive = true;
524 }
525 }
526 }
527 }
528 }
529
530
downMouse
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
531 function downMouse(event){
532 dump(event.target.parentNode.id+"\n");
533 if (event.button == 0){
534 if (currentTool != "poly"){
535 startX = event.clientX+window.frames[0].pageXOffset;
536 startY = event.clientY+window.frames[0].pageYOffset;
537 downTool = true;
538 if (currentTool == "pointer"){
539 if (event.target.getAttribute("name") == "hotspot"){
540 var el = event.target;
541 var isSelected = false;
542
543 if (event.target.getAttribute("cir") == "true")
544 el = event.target.parentNode;
545
546 if (event.shiftKey){
547 var len = currentElement.length;
548 var deselect = false;
549 for(i=0; i<len; i++){
550 if (currentElement[i] == el){
551 deSelectElement(el);
552 return;
553 }
554 }
555 selectElement(el, true);
556 isSelected = true;
557 }
558 else{
559 var len = currentElement.length;
560 for(i=0; i<len; i++){
561 if (currentElement[i] == el)
562 isSelected = true;
563 }
564 }
565
566 if (isSelected){
567 var len = currentElement.length;
568 for(i=0; i<len; i++){
569 currentElement[i].startX = parseInt(event.clientX+window.frames[0].pageXOffset)-parseInt(currentElement[i].style.left);
570 currentElement[i].startY = parseInt(event.clientY+window.frames[0].pageYOffset)-parseInt(currentElement[i].style.top);
571 }
572 }
573 else{
574 curObj = selectElement(el);
575 curObj.startX = parseInt(event.clientX+window.frames[0].pageXOffset)-parseInt(curObj.style.left);
576 curObj.startY = parseInt(event.clientY+window.frames[0].pageYOffset)-parseInt(curObj.style.top);
577 }
578 dragObject = true;
579 }
580 else if (event.target.getAttribute("name") == "handle"){
581 dump("down on a handle\n");
582 resize = true;
583 el = event.target;
584 curObj = selectElement(el.parentNode);
585 if (curObj.className == "rect"){
586 currentRect = curObj;
587 switch (el.className){
588 case "handletl":
589 startX = parseInt(curObj.style.left)+parseInt(curObj.style.width);
590 startY = parseInt(curObj.style.top)+parseInt(curObj.style.height);
591 break;
592 case "handletr":
593 startX = parseInt(curObj.style.left);
594 startY = parseInt(curObj.style.top)+parseInt(curObj.style.height);
595 break;
596 case "handlebl":
597 startX = parseInt(curObj.style.left)+parseInt(curObj.style.width);
598 startY = parseInt(curObj.style.top);
599 break;
600 case "handlebr":
601 startX = parseInt(curObj.style.left);
602 startY = parseInt(curObj.style.top);
603 break;
604 case "handlet":
605 xlock = true;
606 startY = parseInt(curObj.style.top)+parseInt(curObj.style.height);
607 break;
608 case "handleb":
609 xlock = true;
610 startY = parseInt(curObj.style.top);
611 break;
612 case "handlel":
613 ylock = true;
614 startX = parseInt(curObj.style.left)+parseInt(curObj.style.width);
615 break;
616 case "handler":
617 ylock = true;
618 startX = parseInt(curObj.style.left);
619 break;
620 default:
621 return;
622 }
623 }
624 else{
625 currentCir = curObj;
626 startX = parseInt(curObj.style.left)+(parseInt(curObj.style.width)/2);
627 startY = parseInt(curObj.style.top)+(parseInt(curObj.style.height)/2);
628 }
629 }
630 else if (event.target.getAttribute("class") == "point"){
631 dump("down on a point\n");
632 selectElement(event.target.parentNode);
633 currentPoint = event.target;
634 currentPoint.startX = parseInt(event.clientX+window.frames[0].pageXOffset)-(parseInt(currentPoint.style.left)+parseInt(currentPoint.parentNode.style.left));
635 currentPoint.startY = parseInt(event.clientY+window.frames[0].pageYOffset)-(parseInt(currentPoint.style.top)+parseInt(currentPoint.parentNode.style.top));
636 currentPoly = currentPoint.parentNode;
637 }
638 else{
639 dump(event.target+"\n");
640 selectElement(null);
641 }
642 }
643 }
644 }
645 }
646
clickMouse
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
647 function clickMouse(event){
648 if (event.button == 0){
649 dump("body clicked\n");
650 //alert(frameDoc.+'\n');
651 startX = event.clientX+window.frames[0].pageXOffset;
652 startY = event.clientY+window.frames[0].pageYOffset;
653 if (currentTool == "poly"){
654 if (event.target != currentPoly){
655 if (currentPoly != null){
656 if (event.target == currentPoly.childNodes[0]){
657 polyFinish();
658 }
659 else if (event.detail == 2){
660 polyFinish();
661 }
662 }
663 else{
664 Poly();
665 }
666 }
667 else{
668 addPoint(event);
669 }
670 }
671 }
672 }
673
changeTool
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
674 function changeTool(event, what){
675 if (!currentPoly){
676 for(i=0; i<4; i++){
677 buttonArray[i].setAttribute("toggled", 0);
678 if (event.target == buttonArray[i]){
679 buttonArray[i].setAttribute("toggled", 1);
680 }
681 }
682 currentTool = what;
683 if (currentTool != "pointer"){
684 frameDoc.getElementById("bgDiv").style.cursor = "crosshair";
685 frameDoc.body.style.cursor = "crosshair";
686 }
687 else{
688 frameDoc.getElementById("bgDiv").style.cursor = "default";
689 frameDoc.body.style.cursor = "default";
690 }
691
692 dump(what+" selected\n");
693 }
694 else {
695 for(i=0; i<4; i++){
696 if (event.target == buttonArray[i]){
697 buttonArray[i].setAttribute("toggled", 0);
698 }
699 }
700 }
701 }
702
zoom
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
703 function zoom(direction, ratio){
704 dump('zoom called; ratio='+ratio+'\n');
705 if (direction == "in")
706 ratio = currentZoom*2;
707 else if (direction == "out")
708 ratio = currentZoom/2;
709
710 if (ratio > 4 || ratio < 1 || ratio == currentZoom)
711 return;
712
713 if (ratio == 1){
714 document.getElementById('Map:ZoomIn').setAttribute('disabled', 'false');
715 document.getElementById('Map:ZoomOut').setAttribute('disabled', 'true');
716 document.getElementById('Map:Apercent').setAttribute('checked', 'true');
717 document.getElementById('Map:Bpercent').setAttribute('checked', 'false');
718 document.getElementById('Map:Cpercent').setAttribute('checked', 'false');
719 }
720 else if (ratio == 4){
721 document.getElementById('Map:ZoomIn').setAttribute('disabled', 'true');
722 document.getElementById('Map:ZoomOut').setAttribute('disabled', 'false');
723 document.getElementById('Map:Apercent').setAttribute('checked', 'false');
724 document.getElementById('Map:Bpercent').setAttribute('checked', 'false');
725 document.getElementById('Map:Cpercent').setAttribute('checked', 'true');
726 }
727 else {
728 document.getElementById('Map:ZoomIn').setAttribute('disabled', 'false');
729 document.getElementById('Map:ZoomOut').setAttribute('disabled', 'false');
730 document.getElementById('Map:Apercent').setAttribute('checked', 'false');
731 document.getElementById('Map:Bpercent').setAttribute('checked', 'true');
732 document.getElementById('Map:Cpercent').setAttribute('checked', 'false');
733 }
734
735 objList = frameDoc.getElementsByName("hotspot");
736 len = objList.length;
737 for(i=0; i<len; i++){
738 if (ratio > currentZoom){
739 objList[i].style.width = (parseInt(objList[i].style.width)*(ratio/currentZoom))+"px";
740 objList[i].style.height = (parseInt(objList[i].style.height)*(ratio/currentZoom))+"px";
741 objList[i].style.top = (parseInt(objList[i].style.top)*(ratio/currentZoom))+"px";
742 objList[i].style.left = (parseInt(objList[i].style.left)*(ratio/currentZoom))+"px";
743 }
744 else{
745 objList[i].style.width = (parseInt(objList[i].style.width)/(currentZoom/ratio))+"px";
746 objList[i].style.height = (parseInt(objList[i].style.height)/(currentZoom/ratio))+"px";
747 objList[i].style.top = (parseInt(objList[i].style.top)/(currentZoom/ratio))+"px";
748 objList[i].style.left = (parseInt(objList[i].style.left)/(currentZoom/ratio))+"px";
749 }
750 if (objList[i].getAttribute("class") == "poly"){
751 pointList = objList[i].childNodes;
752 plen = pointList.length;
753 dump('i='+i+'\n');
754 for(j=0; j<plen; j++){
755 dump('i='+i+'\n');
756 if (ratio > currentZoom){
757 pointList[j].style.top = (parseInt(pointList[j].style.top)*(ratio/currentZoom))+"px";
758 pointList[j].style.left = (parseInt(pointList[j].style.left)*(ratio/currentZoom))+"px";
759 }
760 else{
761 pointList[j].style.top = (parseInt(pointList[j].style.top)/(currentZoom/ratio))+"px";
762 pointList[j].style.left = (parseInt(pointList[j].style.left)/(currentZoom/ratio))+"px";
763 }
764 }
765 currentPoly = objList[i];
766 polyFinish(null, true);
767 currentPoly = null;
768 }
769 dump('i='+i+'\n');
770 }
771
772 imgEl = frameDoc.getElementById("mainImg");
773 bgDiv = frameDoc.getElementById("bgDiv");
774 dump(imgEl.getAttribute("width")+'\n');
775 if (ratio > currentZoom){
776 imgEl.setAttribute("width", (parseInt(imgEl.offsetWidth)*(ratio/currentZoom)));
777 imgEl.setAttribute("height", (parseInt(imgEl.offsetHeight)*(ratio/currentZoom)));
778 bgDiv.style.width = imgEl.offsetWidth;
779 bgDiv.style.height = imgEl.offsetHeight;
780 }
781 else{
782 imgEl.setAttribute("width", (parseInt(imgEl.offsetWidth)/(currentZoom/ratio)));
783 imgEl.setAttribute("height", (parseInt(imgEl.offsetHeight)/(currentZoom/ratio)));
784 bgDiv.style.width = imgEl.offsetWidth;
785 bgDiv.style.height = imgEl.offsetHeight;
786 }
787 currentZoom = ratio;
788 }
789
cutCopy
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
790 function cutCopy(cut){
791 len = currentElement.length;
792 if (len >= 1){
793 clipBoard = [];
794 for (i=0; i<len; i++){
795 el = currentElement[i];
796 if (el.className == 'rect'){
797 coords = parseInt(el.style.left)+","+parseInt(el.style.top)+","+(parseInt(el.style.left)+parseInt(el.style.width))+","+(parseInt(el.style.top)+parseInt(el.style.height));
798 href = el.getAttribute('hsHref');
799 target = el.getAttribute('hsTarget');
800 alt = el.getAttribute('hsAlt');
801 clipBoard[i] = 'Rect(\"'+coords+'\", \"'+href+'\", \"'+target+'\", \"'+alt+'\", true)';
802 }
803 else if (el.className == 'cir'){
804 radius = Math.floor(parseInt(el.style.width)/2);
805 coords = (parseInt(el.style.left)+radius)+","+(parseInt(el.style.top)+radius)+","+radius;
806 href = el.getAttribute('href');
807 target = el.getAttribute('hsTarget');
808 alt = el.getAttribute('hsAlt');
809 clipBoard[i] = 'Circle(\"'+coords+'\", \"'+href+'\", \"'+target+'\", \"'+alt+'\", true)';
810 }
811 else{
812 var coords = '';
813 var pointlen = el.childNodes.length;
814 for(j=0; j<pointlen; j++){
815 coords += (parseInt(el.style.left)+parseInt(el.childNodes[j].style.left))+","+(parseInt(el.style.top)+parseInt(el.childNodes[j].style.top))+",";
816 }
817 coords = coords.substring(0, (coords.length-1));
818 href = el.getAttribute('href');
819 target = el.getAttribute('hsTarget');
820 alt = el.getAttribute('hsAlt');
821 clipBoard[i] = 'Poly(\"'+coords+'\", \"'+href+'\", \"'+target+'\", \"'+alt+'\", true)';
822 }
823 if (cut){
824 deleteElement(el);
825 }
826 }
827 document.getElementById('Map:Paste').setAttribute('disabled', 'false');
828 }
829 }
830
paste
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
831 function paste(){
832 len = clipBoard.length;
833 func = '';
834 for (i=0; i<len; i++){
835 func += clipBoard[i]+'\;';
836 }
837 eval(func);
838 }
839
nudge
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
840 function nudge(event, dir){
841 /*prevent scrolling
842 event.stopPropagation();
843 event.preventDefault();*/
844
845 len = currentElement.length;
846 amount = 1;
847 if (event.shiftKey)
848 amount = 5;
849
850
851 boundRectTop = 1000000;
852 boundRectLeft = 1000000;
853 for (i=0; i<len; i++){
854 curTop = parseInt(currentElement[i].style.top);
855 curLeft = parseInt(currentElement[i].style.left);
856 if (curTop < boundRectTop)
857 boundRectTop = curTop;
858 if (curLeft < boundRectLeft)
859 boundRectLeft = curLeft;
860 }
861
862 for (i=0; i<len; i++){
863 if (dir == "up"){
864 curTop = parseInt(currentElement[i].style.top);
865 if (boundRectTop >= amount)
866 currentElement[i].style.top = (curTop-amount) + "px";
867 else
868 currentElement[i].style.top = (curTop-boundRectTop) + "px";
869 }
870 else if (dir == "left"){
871 curLeft = parseInt(currentElement[i].style.left);
872 if (boundRectLeft >= amount)
873 currentElement[i].style.left = (curLeft-amount) + "px";
874 else
875 currentElement[i].style.left = (curLeft-boundRectLeft) + "px";
876 }
877 else if (dir == "down"){
878 curTop = parseInt(currentElement[i].style.top);
879 currentElement[i].style.top = (curTop+amount) + "px";
880 }
881 else if (dir == "right"){
882 curLeft = parseInt(currentElement[i].style.left);
883 currentElement[i].style.left = (curLeft+amount) + "px";
884 }
885 }
886 }
887