3 var mapper
= $('mapper');
4 ajaxCacheHtml(mapper
,url
);
7 function areaSelect(element
)
9 var mapper
= $('mapper');
10 var url
= 'ajax.php'+element
.value
;
11 if (!my_AJAX
.isCached(url
))
12 outLoadingText('mapperarea');
13 my_AJAX
.GETupload(url
, function (text
) {mapper
.innerHTML
= text
;});
16 // Объявим функцию для определения координат мыши
17 function defPosition(event
) {
19 if (document
.attachEvent
!= null) { // Internet Explorer & Opera
20 x
= window
.event
.clientX
+ document
.documentElement
.scrollLeft
+ document
.body
.scrollLeft
;
21 y
= window
.event
.clientY
+ document
.documentElement
.scrollTop
+ document
.body
.scrollTop
;
23 if (!document
.attachEvent
&& document
.addEventListener
) { // Gecko
24 x
= event
.clientX
+ window
.scrollX
;
25 y
= event
.clientY
+ window
.scrollY
;
32 return '<div style=\"position: absolute; left: -1px; top: -1px; white-space: nowrap; color: black;">' + out
+ '</div>' +
33 '<div style=\"position: absolute; left: -1px; top: 0px; white-space: nowrap; color: black;">' + out
+ '</div>' +
34 '<div style=\"position: absolute; left: -1px; top: 1px; white-space: nowrap; color: black;">' + out
+ '</div>' +
35 '<div style=\"position: absolute; left: 0px; top: -1px; white-space: nowrap; color: black;">' + out
+ '</div>' +
36 '<div style=\"position: absolute; left: 0px; top: 1px; white-space: nowrap; color: black;">' + out
+ '</div>' +
37 '<div style=\"position: absolute; left: 1px; top: -1px; white-space: nowrap; color: black;">' + out
+ '</div>' +
38 '<div style=\"position: absolute; left: 1px; top: 0px; white-space: nowrap; color: black;">' + out
+ '</div>' +
39 '<div style=\"position: absolute; left: 1px; top: 1px; white-space: nowrap; color: black;">' + out
+ '</div>' +
40 '<div style=\"position: absolute; left: 0px; top: 0px; white-space: nowrap; color: white;">' + out
+ '</div>';
43 function outLoadingText(div_id
)
48 var div
= insertElement(txt
, 'DIV', 'loading');
50 s
.position
='absolute';
51 s
.left
= (txt
.offsetWidth
/2 - 30) + 'px';
53 div
.innerHTML
= outText('Loading...');
57 function outMouseCoords(div
, event
, field
)
59 var mpos
= defPosition(event
|| window
.event
);
60 var vbound
= getBounds(div
);
61 var x
= 100 * (mpos
.x
- vbound
.left
) / vbound
.width
;
62 var y
= 100 * (mpos
.y
- vbound
.top
) / vbound
.height
;
66 txt
.innerHTML
= outText("(" + x
.toFixed(1) + ", " + y
.toFixed(1) + ")");
69 function cleanMouseCoords(field
)
71 $(field
).innerHTML
= "";
75 * New mapper functions
83 function setMapData(newData
)
88 function setScale(newscale
)
93 function changeSelect(newsel
)
95 if (newsel
== lastsel
)
97 renderInstance(lastId
, newsel
);
101 function changeScale(newscale
)
103 if (scale
== newscale
)
106 renderInstance(lastId
, lastsel
);
109 function setBestScale(width
)
111 var bestScale
= 640 / width
;
112 if (bestScale
> 0.00 && bestScale
< 0.40) scale
= 0.25;
113 else if (bestScale
> 0.40 && bestScale
< 0.62) scale
= 0.50;
114 else if (bestScale
> 0.62 && bestScale
< 0.87) scale
= 0.75;
115 else if (bestScale
> 0.87 && bestScale
< 1.5) scale
= 1.00;
118 function renderInstance(elementid
, selected
)
123 var mapper
= $(elementid
);
127 var map
= eval(mapData
);
129 map
.width
= map
.imageX
*scale
;
130 var rect
= getBounds(mapper
.offsetParent
);
131 map
.height
= map
.imageY
*scale
;
132 var rect
= getBounds(mapper
.offsetParent
);
134 '<table class="map" border=1 width=' + (map
.width
+ 10) + 'px>' +
135 '<tbody><tr><td class=mapname id=mappername>' + map
.header
+'</td></tr>' +
136 '<tr><td width=' + map
.width
+ 'px height=' + (map
.height
+ 4) + 'px align=left valign=top>' +
137 '<div id=mapperarea style="font-size: 10px; position: relative; left: 0px; top: 0px;">' +
138 '<img src=' + map
.image
+ ' width=' + map
.width
+ 'px height=' + map
.height
+ 'px>\n';
142 count
= map
.points
.length
;
143 for (var i
= 0; i
< count
; i
++)
145 var img
= map
.points
[i
].image
;
146 var imgX
= map
.points
[i
].icenterx
;
147 var imgY
= map
.points
[i
].icentery
;
148 if (map
.points
[i
].id
== selected
)
160 var x
= map
.points
[i
].x
* map
.width
/ 100 - imgX
;
161 var y
= map
.points
[i
].y
* map
.height
/ 100 - imgY
;
163 if (map
.points
[i
].tooltip
!=0)
164 tip
= 'onmouseover = "Tip(\'' + map
.points
[i
].tooltip
+ '\')"';
165 if (map
.points
[i
].href
!=0)
166 text
+='<a href=' + map
.points
[i
].href
+ '>';
167 text
+='<img src="' + img
+ '" style="position: absolute; border: 0px; left: ' + x
.toFixed(0) + 'px; top: ' + y
.toFixed(0) + 'px;" ' + tip
+ '>\n';
168 if (map
.points
[i
].href
)
172 '<div class=m_scale>' +
173 outText('25%<br>50%<br>75%<br>100%<br>200%') +
174 '<div style=\"position: absolute; left: 0px; top: 0px; white-space: nowrap;">' +
175 '<a href=# onclick="return changeScale(0.25);">25%</a><br>' +
176 '<a href=# onclick="return changeScale(0.50);">50%</a><br>' +
177 '<a href=# onclick="return changeScale(0.75);">75%</a><br>' +
178 '<a href=# onclick="return changeScale(1.00);">100%</a><br>' +
179 '<a href=# onclick="return changeScale(2.00);">200%</a></div>' +
182 '</td></tr></tbody>' +
184 mapper
.innerHTML
= text
;