1 | function Mapper(C, D) {
|
---|
2 | cO(this, C);
|
---|
3 | if (this.parent) {
|
---|
4 | this.parent = $(this.parent)
|
---|
5 | } else {
|
---|
6 | return
|
---|
7 | }
|
---|
8 | var B;
|
---|
9 | this.mouseX = this.mouseY = 0;
|
---|
10 | this.editable = this.editable || false;
|
---|
11 | if (this.editable) {
|
---|
12 | this.zoomable = this.toggle = false;
|
---|
13 | this.show = this.mouse = true
|
---|
14 | } else {
|
---|
15 | this.zoomable = (this.zoomable == null ? true: this.zoomable);
|
---|
16 | this.toggle = (this.toggle == null ? true: this.toggle);
|
---|
17 | this.show = (this.show == null ? true: this.show);
|
---|
18 | this.mouse = (this.mouse == null ? false: this.mouse)
|
---|
19 | }
|
---|
20 | this.zoneLink = (this.zoneLink == null ? true: this.zoneLink);
|
---|
21 | if (location.href.indexOf("zone=") != -1) {
|
---|
22 | this.zoneLink = false
|
---|
23 | }
|
---|
24 | this.zoom = (this.zoom == null ? 0: this.zoom);
|
---|
25 | this.zone = (this.zone == null ? 0: this.zone);
|
---|
26 | this.locale = (this.locale == null ? "enus": this.locale);
|
---|
27 | this.pins = [];
|
---|
28 | this.nCoords = 0;
|
---|
29 | this.parent.className = "mapper";
|
---|
30 | this.parent.appendChild(this.span = ce("span"));
|
---|
31 | B = this.span.style;
|
---|
32 | B.display = "block";
|
---|
33 | B.position = "relative";
|
---|
34 | ns(this.span);
|
---|
35 | if (this.editable) {
|
---|
36 | this.span.onmouseup = this.addPin.bind(this);
|
---|
37 | B = g_createGlow(LANG.mapper_tippin);
|
---|
38 | B.style.fontSize = "11px";
|
---|
39 | B.style.position = "absolute";
|
---|
40 | B.style.bottom = B.style.right = "0";
|
---|
41 | ns(B);
|
---|
42 | this.parent.appendChild(B)
|
---|
43 | } else {
|
---|
44 | this.sToggle = B = g_createGlow(LANG.mapper_hidepins);
|
---|
45 | B.style.position = "absolute";
|
---|
46 | B.style.top = B.style.right = "0";
|
---|
47 | B.onclick = this.toggleShow.bind(this);
|
---|
48 | B.style.display = "none";
|
---|
49 | ns(B);
|
---|
50 | this.parent.appendChild(B)
|
---|
51 | }
|
---|
52 | if (this.zoomable) {
|
---|
53 | this.span.onclick = this.toggleZoom.bind(this);
|
---|
54 | this.sZoom = B = g_createGlow(LANG.mapper_tipzoom);
|
---|
55 | B.style.fontSize = "11px";
|
---|
56 | B.style.position = "absolute";
|
---|
57 | B.style.bottom = B.style.right = "0";
|
---|
58 | ns(B);
|
---|
59 | this.span.appendChild(B)
|
---|
60 | }
|
---|
61 | if (this.zoneLink) {
|
---|
62 | this.sZoneLink = B = g_createGlow("zone link");
|
---|
63 | var E = B.childNodes[4];
|
---|
64 | var A = ce("a");
|
---|
65 | A.href = "?zones";
|
---|
66 | ae(A, ct(E.firstChild.nodeValue));
|
---|
67 | de(E.firstChild);
|
---|
68 | ae(E, A);
|
---|
69 | B.style.display = "none";
|
---|
70 | B.style.position = "absolute";
|
---|
71 | B.style.top = B.style.left = "0";
|
---|
72 | this.parent.appendChild(B)
|
---|
73 | }
|
---|
74 | if (this.mouse) {
|
---|
75 | this.parent.onmouseout = (function() {
|
---|
76 | this.timeout = setTimeout((function() {
|
---|
77 | this.sMouse.style.display = "none"
|
---|
78 | }).bind(this), 1)
|
---|
79 | }).bind(this);
|
---|
80 | this.parent.onmouseover = (function() {
|
---|
81 | clearTimeout(this.timeout);
|
---|
82 | this.sMouse.style.display = ""
|
---|
83 | }).bind(this);
|
---|
84 | this.span.onmousemove = this.span.onmousedown = this.getMousePos.bind(this);
|
---|
85 | this.sMouse = B = g_createGlow("(0.0, 0.0)");
|
---|
86 | B.style.display = "none";
|
---|
87 | B.style.position = "absolute";
|
---|
88 | B.style.bottom = B.style.left = "0";
|
---|
89 | B.onmouseup = sp;
|
---|
90 | ns(B);
|
---|
91 | this.span.appendChild(B)
|
---|
92 | }
|
---|
93 | this.pinBag = B = ce("div");
|
---|
94 | ae(this.span, this.pinBag);
|
---|
95 | if (C.coords != null) {
|
---|
96 | this.setCoords(C.coords)
|
---|
97 | } else {
|
---|
98 | if (C.link != null) {
|
---|
99 | this.setLink(C.link)
|
---|
100 | }
|
---|
101 | }
|
---|
102 | this.updateMap(D)
|
---|
103 | }
|
---|
104 | Mapper.sizes = [[488, 325, "normal"], [772, 515, "zoom"]];
|
---|
105 | Mapper.prototype = {
|
---|
106 | update: function(A, B) {
|
---|
107 | if (A.zoom != null) {
|
---|
108 | this.zoom = A.zoom
|
---|
109 | }
|
---|
110 | if (A.zone != null) {
|
---|
111 | this.zone = A.zone
|
---|
112 | }
|
---|
113 | if (A.locale != null) {
|
---|
114 | this.locale = A.locale
|
---|
115 | }
|
---|
116 | if (A.show != null) {
|
---|
117 | this.show = A.show
|
---|
118 | }
|
---|
119 | if (A.coords != null) {
|
---|
120 | this.setCoords(A.coords)
|
---|
121 | } else {
|
---|
122 | if (A.link != null) {
|
---|
123 | this.setLink(A.link)
|
---|
124 | }
|
---|
125 | }
|
---|
126 | this.updateMap(B)
|
---|
127 | },
|
---|
128 | getZone: function() {
|
---|
129 | return this.zone
|
---|
130 | },
|
---|
131 | setZone: function(A, B) {
|
---|
132 | this.zone = A;
|
---|
133 | this.updateMap(B);
|
---|
134 | return true
|
---|
135 | },
|
---|
136 | getLocale: function() {
|
---|
137 | return this.locale
|
---|
138 | },
|
---|
139 | setLocale: function(A, B) {
|
---|
140 | this.locale = A;
|
---|
141 | this.updateMap(B)
|
---|
142 | },
|
---|
143 | getZoom: function() {
|
---|
144 | return this.zoom
|
---|
145 | },
|
---|
146 | setZoom: function(A, B) {
|
---|
147 | this.zoom = A;
|
---|
148 | this.updateMap(B)
|
---|
149 | },
|
---|
150 | toggleZoom: function(A) {
|
---|
151 | this.zoom = 1 - this.zoom;
|
---|
152 | this.updateMap();
|
---|
153 | this.getMousePos(A);
|
---|
154 | if (this.sZoom) {
|
---|
155 | this.sZoom.style.display = "none";
|
---|
156 | this.sZoom = null
|
---|
157 | }
|
---|
158 | },
|
---|
159 | getShow: function() {
|
---|
160 | return this.show
|
---|
161 | },
|
---|
162 | setShow: function(A) {
|
---|
163 | this.show = A;
|
---|
164 | var B = this.show ? "": "none";
|
---|
165 | this.pinBag.style.display = B;
|
---|
166 | g_setTextNodes(this.sToggle, (this.show ? LANG.mapper_hidepins: LANG.mapper_showpins))
|
---|
167 | },
|
---|
168 | toggleShow: function() {
|
---|
169 | this.setShow(!this.show)
|
---|
170 | },
|
---|
171 | getCoords: function() {
|
---|
172 | var A = [];
|
---|
173 | for (var B in this.pins) {
|
---|
174 | if (!this.pins[B].free) {
|
---|
175 | A.push([this.pins[B].x, this.pins[B].y])
|
---|
176 | }
|
---|
177 | }
|
---|
178 | return A
|
---|
179 | },
|
---|
180 | setCoords: function(D) {
|
---|
181 | var A;
|
---|
182 | for (var C in this.pins) {
|
---|
183 | this.pins[C].style.display = "none";
|
---|
184 | this.pins[C].free = true
|
---|
185 | }
|
---|
186 | this.nCoords = D.length;
|
---|
187 | for (var C in D) {
|
---|
188 | var E = D[C];
|
---|
189 | var B = E[2];
|
---|
190 | A = this.getPin();
|
---|
191 | A.x = E[0];
|
---|
192 | A.y = E[1];
|
---|
193 | A.style.left = A.x + "%";
|
---|
194 | A.style.top = A.y + "%";
|
---|
195 | if (this.editable) {
|
---|
196 | A.a.onmouseup = this.delPin.bind(this, A)
|
---|
197 | } else {
|
---|
198 | if (B && B.url) {
|
---|
199 | A.a.href = B.url;
|
---|
200 | A.a.style.cursor = "pointer"
|
---|
201 | }
|
---|
202 | }
|
---|
203 | if (B && B.label) {
|
---|
204 | A.a.tt = B.label
|
---|
205 | } else {
|
---|
206 | A.a.tt = "$"
|
---|
207 | }
|
---|
208 | if (B && B.type) {
|
---|
209 | A.className += " pin-" + B.type
|
---|
210 | }
|
---|
211 | A.a.tt = str_replace(A.a.tt, "$", A.x.toFixed(1) + ", " + A.y.toFixed(1))
|
---|
212 | }
|
---|
213 | this.onPinUpdate && this.onPinUpdate(this)
|
---|
214 | },
|
---|
215 | getLink: function() {
|
---|
216 | var B = "";
|
---|
217 | for (var A in this.pins) {
|
---|
218 | if (!this.pins[A].free) {
|
---|
219 | B += (this.pins[A].x < 10 ? "0": "") + (this.pins[A].x * 10).toFixed(0) + (this.pins[A].y < 10 ? "0": "") + (this.pins[A].y * 10).toFixed(0)
|
---|
220 | }
|
---|
221 | }
|
---|
222 | return (this.zone ? this.zone: "") + (B ? ":" + B: "")
|
---|
223 | },
|
---|
224 | setLink: function(D) {
|
---|
225 | var B = [];
|
---|
226 | D = D.split(":");
|
---|
227 | if (!this.setZone(D[0])) {
|
---|
228 | return false
|
---|
229 | }
|
---|
230 | if (D.length == 2) {
|
---|
231 | for (var C = 0; C < D[1].length; C += 6) {
|
---|
232 | var A = D[1].substr(C, 3) / 10;
|
---|
233 | var E = D[1].substr(C + 3, 3) / 10;
|
---|
234 | if (isNaN(A) || isNaN(E)) {
|
---|
235 | break
|
---|
236 | }
|
---|
237 | B.push([A, E])
|
---|
238 | }
|
---|
239 | }
|
---|
240 | this.setCoords(B);
|
---|
241 | return true
|
---|
242 | },
|
---|
243 | updateMap: function(C) {
|
---|
244 | this.parent.style.width = this.span.style.width = Mapper.sizes[this.zoom][0] + "px";
|
---|
245 | this.parent.style.height = this.span.style.height = Mapper.sizes[this.zoom][1] + "px";
|
---|
246 | if (!this.editable) {
|
---|
247 | this.parent.style.cssFloat = this.parent.style.styleFloat = "left"
|
---|
248 | }
|
---|
249 | if (this.zone == "0") {
|
---|
250 | this.span.style.background = "black"
|
---|
251 | } else {
|
---|
252 | this.span.style.background = "url(images/maps/" + this.locale + "/" + Mapper.sizes[this.zoom][2] + "/" + this.zone + ".jpg)"
|
---|
253 | }
|
---|
254 | if (this.zoneLink) {
|
---|
255 | var A = parseInt(this.zone);
|
---|
256 | var B = g_zones[A] != null;
|
---|
257 | if (B) {
|
---|
258 | g_setTextNodes(this.sZoneLink, g_zones[A]);
|
---|
259 | this.sZoneLink.childNodes[4].firstChild.href = "?zone=" + A
|
---|
260 | }
|
---|
261 | this.sZoneLink.style.display = B ? "": "none"
|
---|
262 | }
|
---|
263 | if (this.sToggle) {
|
---|
264 | this.sToggle.style.display = (this.toggle && this.nCoords ? "": "none")
|
---|
265 | }
|
---|
266 | if (!C) {
|
---|
267 | g_scrollTo(this.parent, 3)
|
---|
268 | }
|
---|
269 | this.onMapUpdate && this.onMapUpdate(this)
|
---|
270 | },
|
---|
271 | cleanPin: function(B) {
|
---|
272 | var A = this.pins[B];
|
---|
273 | A.style.display = "";
|
---|
274 | A.free = false;
|
---|
275 | A.className = "pin";
|
---|
276 | A.a.onmousedown = rf;
|
---|
277 | A.a.onmouseup = rf;
|
---|
278 | A.a.href = "javascript:;";
|
---|
279 | A.a.style.cursor = "default";
|
---|
280 | return A
|
---|
281 | },
|
---|
282 | getPin: function() {
|
---|
283 | for (var C = 0; C < this.pins.length; ++C) {
|
---|
284 | if (this.pins[C].free) {
|
---|
285 | return this.cleanPin(C)
|
---|
286 | }
|
---|
287 | }
|
---|
288 | var B = ce("div"),
|
---|
289 | A = ce("a");
|
---|
290 | B.className = "pin";
|
---|
291 | B.appendChild(A);
|
---|
292 | B.a = A;
|
---|
293 | A.onmouseover = this.pinOver;
|
---|
294 | A.onmouseout = Tooltip.hide;
|
---|
295 | A.onclick = sp;
|
---|
296 | this.pins.push(B);
|
---|
297 | this.cleanPin(this.pins.length - 1);
|
---|
298 | ae(this.pinBag, B);
|
---|
299 | return B
|
---|
300 | },
|
---|
301 | addPin: function(B) {
|
---|
302 | B = $E(B);
|
---|
303 | if (B._button >= 2) {
|
---|
304 | return
|
---|
305 | }
|
---|
306 | this.getMousePos(B);
|
---|
307 | var A = this.getPin();
|
---|
308 | A.x = this.mouseX;
|
---|
309 | A.y = this.mouseY;
|
---|
310 | A.style.left = A.x.toFixed(1) + "%";
|
---|
311 | A.style.top = A.y.toFixed(1) + "%";
|
---|
312 | A.a.onmouseup = this.delPin.bind(this, A);
|
---|
313 | A.a.tt = A.x.toFixed(1) + ", " + A.y.toFixed(1);
|
---|
314 | this.onPinUpdate && this.onPinUpdate(this);
|
---|
315 | return false
|
---|
316 | },
|
---|
317 | delPin: function(A, B) {
|
---|
318 | B = $E(B);
|
---|
319 | A.style.display = "none";
|
---|
320 | A.free = true;
|
---|
321 | sp(B);
|
---|
322 | this.onPinUpdate && this.onPinUpdate(this);
|
---|
323 | return
|
---|
324 | },
|
---|
325 | pinOver: function() {
|
---|
326 | Tooltip.show(this, this.tt, 4, 0)
|
---|
327 | },
|
---|
328 | getMousePos: function(B) {
|
---|
329 | B = $E(B);
|
---|
330 | var C = ac(this.parent);
|
---|
331 | var A = g_getScroll();
|
---|
332 | this.mouseX = Math.floor((B.clientX + A.x - C[0] - 3) / Mapper.sizes[this.zoom][0] * 1000) / 10;
|
---|
333 | this.mouseY = Math.floor((B.clientY + A.y - C[1] - 3) / Mapper.sizes[this.zoom][1] * 1000) / 10;
|
---|
334 | if (this.mouseX < 0) {
|
---|
335 | this.mouseX = 0
|
---|
336 | } else {
|
---|
337 | if (this.mouseX > 100) {
|
---|
338 | this.mouseX = 100
|
---|
339 | }
|
---|
340 | }
|
---|
341 | if (this.mouseY < 0) {
|
---|
342 | this.mouseY = 0
|
---|
343 | } else {
|
---|
344 | if (this.mouseY > 100) {
|
---|
345 | this.mouseY = 100
|
---|
346 | }
|
---|
347 | }
|
---|
348 | if (this.mouse) {
|
---|
349 | g_setTextNodes(this.sMouse, "(" + this.mouseX.toFixed(1) + ", " + this.mouseY.toFixed(1) + ")")
|
---|
350 | }
|
---|
351 | }
|
---|
352 | };
|
---|
353 | function ma_initShowOnMap() {
|
---|
354 | var D = ge("lenrlkn4");
|
---|
355 | var A = ce("select");
|
---|
356 | var C = ce("option");
|
---|
357 | C.value = "";
|
---|
358 | C.style.color = "#bbbbbb";
|
---|
359 | ae(C, ct(LANG.showonmap));
|
---|
360 | ae(A, C);
|
---|
361 | if (showOnMap.qg_alliance || showOnMap.qg_horde) {
|
---|
362 | var B = ce("optgroup", {
|
---|
363 | label: LANG.som_questgivers
|
---|
364 | });
|
---|
365 | if (showOnMap.qg_alliance) {
|
---|
366 | ae(B, ce("option", {
|
---|
367 | value: "qg_alliance",
|
---|
368 | innerHTML: g_sides[1] + sprintf(LANG.qty, showOnMap.qg_alliance.count)
|
---|
369 | }))
|
---|
370 | }
|
---|
371 | if (showOnMap.qg_horde) {
|
---|
372 | ae(B, ce("option", {
|
---|
373 | value: "qg_horde",
|
---|
374 | innerHTML: g_sides[2] + sprintf(LANG.qty, showOnMap.qg_horde.count)
|
---|
375 | }))
|
---|
376 | }
|
---|
377 | ae(A, B)
|
---|
378 | }
|
---|
379 | A.onchange = A.onkeyup = function() {
|
---|
380 | var E = this.options[this.selectedIndex].value;
|
---|
381 | myMapper.update({
|
---|
382 | zone: g_pageInfo.id,
|
---|
383 | coords: E ? showOnMap[E].coords: []
|
---|
384 | })
|
---|
385 | };
|
---|
386 | ae(D, A)
|
---|
387 | };
|
---|