1 | 1 | unreal | // -------------------------------------------------------- |
2 | 9 | unreal | // This script made by JKLIR as. Unreal][ [http://jklir.net] |
3 | 4 | unreal | // Map engine originally from Emcee Lam [http://sjsutech.com] |
4 | 1 | unreal | // Licence: GNU/GPL |
5 | 9 | unreal | // (c) 2011 All rights reserved |
6 | 1 | unreal | // -------------------------------------------------------- |
7 | | | |
8 | 9 | unreal | var mainMap; |
9 | | | var magnifier; |
10 | 1 | unreal | |
11 | 9 | unreal | var node = new Array(); |
12 | | | var nodecount; |
13 | | | var file_nodes = new Array(); |
14 | | | var file_noping = new Array(); |
15 | | | var file_links = new Array(); |
16 | | | var file_infopoints = new Array(); |
17 | | | var file_state = new Array(); |
18 | | | var ann; |
19 | | | var m1; |
20 | | | var m2; |
21 | | | var m3; |
22 | | | var m4; |
23 | | | var m5; |
24 | | | var m6; |
25 | | | var m7; |
26 | | | var m8; |
27 | | | var m9; |
28 | | | var m1_a; |
29 | | | var m2_a; |
30 | | | var m3_a; |
31 | | | var m4_a; |
32 | | | var m5_a; |
33 | | | var m6_a; |
34 | | | var m7_a; |
35 | | | var m8_a; |
36 | | | var m9_a; |
37 | | | var cntm; |
38 | | | var div_paint; |
39 | | | var div_points; |
40 | | | var div_wave; |
41 | | | var div_infopoint; |
42 | | | var div_name; |
43 | | | var div_ip; |
44 | | | var div_status; |
45 | | | var numoflinks = 0; |
46 | | | var maxnumoflinks = 17; |
47 | | | var is_ie = false; |
48 | | | if(typeof(G_vmlCanvasManager)!='undefined') { is_ie = true; } |
49 | | | actual_links = ""; |
50 | | | var drawing_timer; |
51 | | | var is_adding = true; |
52 | 1 | unreal | |
53 | 9 | unreal | Array.prototype.max = function() { |
54 | | | var max = this[0]; |
55 | | | var len = this.length; |
56 | | | for(var i=1; i<len; i++) if (this[i] > max) max = this[i]; |
57 | | | return max; |
58 | | | } |
59 | | | Array.prototype.min = function() { |
60 | | | var min = this[0]; |
61 | | | var len = this.length; |
62 | | | for(var i=1; i<len; i++) if (this[i] < min) min = this[i]; |
63 | | | return min; |
64 | | | } |
65 | 8 | unreal | |
66 | 9 | unreal | function mapInit (startzoom) { |
67 | | | magnifier = new Magnifier(); |
68 | | | mainMap = new MainMap(startzoom); |
69 | 1 | unreal | |
70 | 9 | unreal | var miniMapDiv = document.getElementById("miniMapInner"); |
71 | | | miniMapDiv.onmousedown = function (event) { return magnifier.startMove(event) }; |
72 | | | miniMapDiv.onmousemove = function (event) { return magnifier.processMove(event) }; |
73 | | | miniMapDiv.onmouseup = function (event) { return magnifier.stopMove(event) }; |
74 | | | miniMapDiv.ondragstart = function() { return false; } // for IE |
75 | | | } |
76 | 1 | unreal | |
77 | 9 | unreal | function Magnifier () { |
78 | | | var this1 = this; |
79 | | | this.f_dragging = false; |
80 | | | this.div = document.getElementById("magnifier"); |
81 | | | this.div.ondragstart = function() { return false; } // for IE |
82 | | | this.div.onmousedown = function (event) { return this1.startMove(event) }; |
83 | | | this.div.onmousemove = function (event) { return this1.processMove(event) }; |
84 | | | this.div.onmouseup = function (event) { return this1.stopMove(event) }; |
85 | | | } |
86 | 1 | unreal | |
87 | 9 | unreal | Magnifier.prototype.startMove = function (event) { |
88 | | | // for IE |
89 | | | if (!event) event = window.event; |
90 | 1 | unreal | |
91 | 9 | unreal | var magnifierDiv = document.getElementById("magnifier"); |
92 | | | //var magnifierDiv = this.div; |
93 | | | this.dragStartLeft = event.clientX; |
94 | | | this.dragStartTop = event.clientY; |
95 | 1 | unreal | |
96 | 9 | unreal | this.top = magnifierDiv.offsetTop; |
97 | | | this.left = magnifierDiv.offsetLeft; |
98 | 1 | unreal | |
99 | 9 | unreal | this.f_dragging = true; |
100 | | | return false; |
101 | | | } |
102 | 1 | unreal | |
103 | 9 | unreal | /* As you drag the mouse in the mini map, the magnifier responds by |
104 | | | moving. Likewise, the main map will show the current area |
105 | | | enclosed by the magnifier. */ |
106 | | | Magnifier.prototype.processMove = function (event) { |
107 | | | var magnifierDiv = this.div; |
108 | | | |
109 | | | if (!event) event = window.event; // for IE |
110 | | | if (this.f_dragging) { |
111 | | | |
112 | | | var minX = 0; |
113 | | | var maxX = magres_x - magnifierDiv.offsetWidth; |
114 | | | var minY = 0; |
115 | | | var maxY = magres_y - magnifierDiv.offsetHeight; |
116 | | | |
117 | | | var shiftedLeft = this.left + (event.clientX - this.dragStartLeft); |
118 | | | if (shiftedLeft < minX) shiftedLeft = minX; // map is not infinite |
119 | | | if (shiftedLeft > maxX) shiftedLeft = maxX; |
120 | | | magnifierDiv.style.left = shiftedLeft + "px"; |
121 | 1 | unreal | |
122 | 9 | unreal | var shiftedTop = this.top + (event.clientY - this.dragStartTop); |
123 | | | if (shiftedTop < minY) shiftedTop = minY; // map is not infinite |
124 | | | if (shiftedTop > maxY) shiftedTop = maxY; |
125 | | | magnifierDiv.style.top = shiftedTop + "px"; |
126 | 1 | unreal | |
127 | 9 | unreal | mainMap.setViewPort(); |
128 | | | } |
129 | | | } |
130 | 1 | unreal | |
131 | 9 | unreal | Magnifier.prototype.stopMove = function (event) { |
132 | | | this.f_dragging = false; |
133 | | | is_adding = true; |
134 | | | checkLinks(); |
135 | | | } |
136 | 1 | unreal | |
137 | 9 | unreal | Magnifier.prototype.setSize = function (innerDivWidth, innerDivHeight) { |
138 | | | var magnifierWidth = Math.round((magres_x * inres_x) / innerDivWidth) - 2; // 200 * 700px |
139 | | | /* We subtract 2 because the borders are 1 pixel each */ |
140 | | | var magnifierHeight = Math.round((magres_y * inres_y) / innerDivHeight) - 2; // 141 * 500px |
141 | | | /* We subtract 2 because the borders are 1 pixel each */ |
142 | | | var magnifierDiv = document.getElementById("magnifier"); |
143 | | | magnifierDiv.style.width = magnifierWidth + "px"; |
144 | | | magnifierDiv.style.height = magnifierHeight + "px"; |
145 | | | |
146 | | | document.getElementById("wrapper").style.width = inres_x + document.getElementById("menuset").clientWidth + 18 + "px"; |
147 | | | } |
148 | 1 | unreal | |
149 | 9 | unreal | Magnifier.prototype.setPosition = function () { |
150 | | | var innerDiv = document.getElementById("innerDiv"); |
151 | | | var innerDivWidth = innerDiv.clientWidth; |
152 | | | var innerDivHeight = innerDiv.clientHeight; |
153 | | | var innerDivLeft = innerDiv.offsetLeft; |
154 | | | var innerDivTop = innerDiv.offsetTop; |
155 | | | this.left = Math.round(Math.abs(innerDivLeft) * magres_x / innerDivWidth); |
156 | | | this.top = Math.round(Math.abs(innerDivTop) * magres_y / innerDivHeight); |
157 | 1 | unreal | |
158 | 9 | unreal | // alter magnifier |
159 | | | var magnifierDiv = this.div; |
160 | | | magnifierDiv.style.left = this.left + "px"; |
161 | | | magnifierDiv.style.top = this.top + "px"; |
162 | | | } |
163 | 1 | unreal | |
164 | 9 | unreal | function MainMap (zoomfirst) { |
165 | | | var this1 = this; |
166 | 1 | unreal | |
167 | 9 | unreal | // view port is the visible portion of the main map |
168 | | | this.viewPortWidth = inres_x; //500 |
169 | | | this.viewPortHeight = inres_y; //400 |
170 | 1 | unreal | |
171 | 9 | unreal | this.tileSize = 256; |
172 | | | this.f_dragging = false; |
173 | | | this.innerDiv = document.getElementById("innerDiv"); |
174 | | | this.innerDiv.style.cursor = "url('grab.cur'), default"; |
175 | | | |
176 | | | var outerDiv = document.getElementById("outerDiv"); |
177 | | | this.outerDiv = outerDiv; |
178 | 1 | unreal | outerDiv.style.width = inres_x + "px"; |
179 | | | outerDiv.style.height = inres_y + "px"; |
180 | 9 | unreal | var underMap = document.getElementById("underMap"); |
181 | 1 | unreal | underMap.style.width = (inres_x - 4) + "px"; |
182 | | | |
183 | 9 | unreal | outerDiv.onmousedown = function(event) { return this1.startMove(event) }; |
184 | | | outerDiv.onmousemove = function(event) { return this1.processMove(event) }; |
185 | | | outerDiv.onmouseup = function(event) { return this1.stopMove(event) }; |
186 | | | outerDiv.ondblclick = function(event) { return this1.doubleClick() }; |
187 | | | outerDiv.ondragstart = function() { return false; } // for IE |
188 | 1 | unreal | |
189 | | | if(zoomfirst==eq_mini) { zf = 0; } |
190 | 9 | unreal | else if(zoomfirst==eq_medi) { zf = 1; } |
191 | | | else if(zoomfirst==eq_high) { zf = 2; } |
192 | | | else if(zoomfirst==eq_orig) { zf = 3; } |
193 | | | else { zf = 0; } |
194 | 1 | unreal | |
195 | 9 | unreal | this.zoom = zf; |
196 | | | this.zoomDim = [ |
197 | | | { |
198 | | | width:parseInt(full_x * eq_mini), |
199 | | | height:parseInt(full_y * eq_mini), |
200 | | | size:1, |
201 | | | nasobek:eq_mini, |
202 | | | numoflinks:17 |
203 | | | }, |
204 | | | { |
205 | | | width:parseInt(full_x * eq_medi), |
206 | | | height:parseInt(full_y * eq_medi), |
207 | | | size:2, |
208 | | | nasobek:eq_medi, |
209 | | | numoflinks:12 |
210 | | | }, |
211 | | | { |
212 | | | width:parseInt(full_x * eq_high), |
213 | | | height:parseInt(full_y * eq_high), |
214 | | | size:3, |
215 | | | nasobek:eq_high, |
216 | | | numoflinks:10 |
217 | | | }, |
218 | | | { |
219 | | | width:parseInt(full_x * eq_orig), |
220 | | | height:parseInt(full_y * eq_orig), |
221 | | | size:4, |
222 | | | nasobek:eq_orig, |
223 | | | numoflinks:7 |
224 | | | }, |
225 | | | ] |
226 | 1 | unreal | |
227 | 9 | unreal | var zoomElt = this.zoomDim[this.zoom]; |
228 | | | this.setInnerDivSize (zoomElt.width, zoomElt.height, zoomElt.size, (parseInt(zoomfirst*1000)/10)); |
229 | | | document.getElementById("zoom"+this.zoom).className = "active"; |
230 | 1 | unreal | |
231 | 9 | unreal | var innerDiv = document.getElementById("innerDiv"); |
232 | | | innerDiv.style.left = -(start_left * start_mul) + "px"; |
233 | | | innerDiv.style.top = -(start_top * start_mul) + "px"; |
234 | 1 | unreal | |
235 | 9 | unreal | magnifier.setPosition(); |
236 | | | this.checkTiles(); |
237 | | | } |
238 | 1 | unreal | |
239 | 9 | unreal | MainMap.prototype.startMove = function (event) { |
240 | | | // for IE |
241 | | | if (!event) event = window.event; |
242 | 1 | unreal | |
243 | 9 | unreal | this.dragStartLeft = event.clientX; |
244 | | | this.dragStartTop = event.clientY; |
245 | | | var innerDiv = this.innerDiv; |
246 | | | innerDiv.style.cursor = "url('grabbing.cur'), default"; |
247 | 1 | unreal | |
248 | 9 | unreal | this.top = innerDiv.offsetTop; |
249 | | | this.left = innerDiv.offsetLeft; |
250 | 1 | unreal | |
251 | 9 | unreal | this.f_dragging = true; |
252 | | | is_adding = true; |
253 | | | window.clearInterval(drawing_timer); |
254 | | | drawing_timer = window.setInterval(checkLinks, 1100); |
255 | | | return false; |
256 | | | } |
257 | 1 | unreal | |
258 | 9 | unreal | MainMap.prototype.processMove = function (event) { |
259 | | | var zoomElt = this.zoomDim[this.zoom]; |
260 | | | var maxY = 0; |
261 | | | var minY = -(zoomElt.height - this.viewPortHeight); |
262 | | | var maxX = 0; |
263 | | | var minX = -(zoomElt.width - this.viewPortWidth); |
264 | 1 | unreal | |
265 | 9 | unreal | if (!event) event = window.event; // for IE |
266 | | | var innerDiv = this.innerDiv; |
267 | | | if (this.f_dragging) { |
268 | | | var shiftedTop = this.top + (event.clientY - this.dragStartTop); |
269 | | | if (shiftedTop > maxY) shiftedTop = maxY; // map is not infinite |
270 | | | if (shiftedTop < minY) shiftedTop = minY; |
271 | | | innerDiv.style.top = shiftedTop + "px"; |
272 | | | |
273 | | | var shiftedLeft = this.left + (event.clientX - this.dragStartLeft); |
274 | | | if (shiftedLeft > maxX) shiftedLeft = maxX; // map is not infinite |
275 | | | if (shiftedLeft < minX) shiftedLeft = minX; |
276 | | | innerDiv.style.left = shiftedLeft + "px"; |
277 | 1 | unreal | |
278 | 9 | unreal | this.checkTiles(); |
279 | | | magnifier.setPosition(); |
280 | | | } |
281 | 1 | unreal | |
282 | 9 | unreal | var konst = 0; |
283 | | | var nasobek = this.zoomDim[this.zoom].nasobek; |
284 | | | if (is_ie) { konst = -2; } |
285 | | | var outerDiv = this.outerDiv; |
286 | | | var infoDiv = document.getElementById("infoDiv"); |
287 | | | if(this.f_dragging) { |
288 | | | infoDiv.innerHTML = parseInt((Math.abs(shiftedLeft) + event.clientX - outerDiv.offsetLeft + konst)/nasobek) + " x " + parseInt((Math.abs(shiftedTop) + event.clientY - outerDiv.offsetTop + konst)/nasobek); |
289 | | | } else { |
290 | | | infoDiv.innerHTML = parseInt((Math.abs(parseInt(innerDiv.style.left)) + event.clientX - outerDiv.offsetLeft + konst)/nasobek) + " x " + parseInt((Math.abs(parseInt(innerDiv.style.top)) + event.clientY - outerDiv.offsetTop + konst)/nasobek); |
291 | | | } |
292 | | | } |
293 | 1 | unreal | |
294 | 9 | unreal | MainMap.prototype.checkZoom = function () { |
295 | | | window.clearInterval(drawing_timer); |
296 | | | var zoomElt = this.zoomDim[this.zoom]; |
297 | | | var maxY = 0; |
298 | | | var minY = -(zoomElt.height - this.viewPortHeight); |
299 | | | var maxX = 0; |
300 | | | var minX = -(zoomElt.width - this.viewPortWidth); |
301 | | | var chcky = 0; |
302 | | | var chckx = 0; |
303 | 1 | unreal | |
304 | 9 | unreal | var innerDiv = this.innerDiv; |
305 | | | var shiftedTop = innerDiv.offsetTop; |
306 | | | if (shiftedTop > maxY) { shiftedTop = maxY; chcky = 1; } // map is not infinite |
307 | | | if (shiftedTop < minY) { shiftedTop = minY; chcky = 1; } |
308 | | | if (chcky == 1) innerDiv.style.top = shiftedTop + "px"; |
309 | 1 | unreal | |
310 | 9 | unreal | var shiftedLeft = innerDiv.offsetLeft; |
311 | | | if (shiftedLeft > maxX) { shiftedLeft = maxX; chckx = 1; }// map is not infinite |
312 | | | if (shiftedLeft < minX) { shiftedLeft = minX; chckx = 1; } |
313 | | | if (chckx == 1) innerDiv.style.left = shiftedLeft + "px"; |
314 | 1 | unreal | |
315 | 9 | unreal | magnifier.setPosition(); |
316 | | | document.getElementById("zoom0").className = ""; |
317 | | | document.getElementById("zoom1").className = ""; |
318 | | | document.getElementById("zoom2").className = ""; |
319 | | | document.getElementById("zoom3").className = ""; |
320 | | | document.getElementById("zoom"+this.zoom).className = "active"; |
321 | | | } |
322 | | | |
323 | | | MainMap.prototype.checkTiles = function () { |
324 | | | var innerDiv = this.innerDiv; |
325 | | | var tileSize = this.tileSize; |
326 | | | var visibleTiles = this.getVisibleTiles(); |
327 | | | var visibleTilesMap = {}; |
328 | | | var i; |
329 | 1 | unreal | |
330 | 9 | unreal | var size = this.zoomDim[this.zoom].size; |
331 | | | for(i=0;i<visibleTiles.length; i++) { |
332 | | | var tile = visibleTiles[i]; |
333 | | | var xy = "x" + tile.x + "y" + tile.y; |
334 | | | var tileName = xy + "z" + this.zoom; |
335 | | | visibleTilesMap[tileName] = true; |
336 | | | var img = document.getElementById(tileName); |
337 | | | if (!img) { |
338 | | | img = document.createElement("img"); |
339 | | | img.src = "size" + size + "/" + xy + ".jpg"; |
340 | | | img.style.position = "absolute"; |
341 | | | img.style.left = (tile.x * tileSize) + "px"; |
342 | | | img.style.top = (tile.y * tileSize) + "px"; |
343 | | | img.setAttribute("id", tileName); |
344 | | | innerDiv.appendChild(img); |
345 | | | } |
346 | | | } |
347 | 1 | unreal | |
348 | 9 | unreal | var imgs = innerDiv.getElementsByTagName("img"); |
349 | | | for(i=0; i<imgs.length; i++) { |
350 | | | var id = imgs[i].getAttribute("id"); |
351 | | | if (!visibleTilesMap[id]) { |
352 | | | innerDiv.removeChild(imgs[i]); |
353 | | | i--; |
354 | | | } |
355 | | | } |
356 | | | } |
357 | 1 | unreal | |
358 | 9 | unreal | MainMap.prototype.getVisibleTiles = function () { |
359 | | | var innerDiv = this.innerDiv; |
360 | | | var mapX = innerDiv.offsetLeft; |
361 | | | var mapY = innerDiv.offsetTop; |
362 | | | var tileSize = this.tileSize; |
363 | 1 | unreal | |
364 | 9 | unreal | var startX = Math.abs(Math.floor(mapX / tileSize)) - 1; |
365 | | | if (startX < 0) startX = 0; |
366 | | | var startY = Math.abs(Math.floor(mapY / tileSize)) - 1; |
367 | | | if (startY < 0) startY = 0; |
368 | | | var tilesX = Math.ceil(this.viewPortWidth / tileSize) + 1; |
369 | | | var tilesY = Math.ceil(this.viewPortHeight / tileSize) + 1; |
370 | 1 | unreal | |
371 | 9 | unreal | var visibleTiles = []; |
372 | | | var counter = 0; |
373 | | | for (x = startX; x < (tilesX + startX); x++) { |
374 | | | for (y = startY; y < (tilesY + startY); y++) { |
375 | | | var tile = {}; |
376 | | | tile.x = x; |
377 | | | tile.y = y; |
378 | | | visibleTiles[counter++] = tile; |
379 | | | } |
380 | | | } |
381 | | | return visibleTiles; |
382 | | | } |
383 | 1 | unreal | |
384 | 9 | unreal | MainMap.prototype.stopMove = function (event) { |
385 | | | window.clearInterval(drawing_timer); |
386 | | | checkLinks(); |
387 | | | is_adding = false; |
388 | | | checkLinks(); |
389 | | | this.innerDiv.style.cursor = "url('grab.cur'), default"; |
390 | | | this.f_dragging = false; |
391 | | | } |
392 | 1 | unreal | |
393 | 9 | unreal | // movement in the magnifier moves main map's view port |
394 | | | MainMap.prototype.setViewPort = function () { |
395 | | | var magDiv = document.getElementById("magnifier"); |
396 | | | var innerDiv = this.innerDiv; |
397 | | | var magLeft = magDiv.offsetLeft; |
398 | | | var magTop = magDiv.offsetTop; |
399 | | | var innerDivWidth = innerDiv.clientWidth; |
400 | | | var innerDivHeight = innerDiv.clientHeight; |
401 | 1 | unreal | |
402 | 9 | unreal | /* set innerDivLeft */ |
403 | | | var innerDivLeftMin = inres_x - innerDivWidth; //500 |
404 | | | var innerDivLeft = Math.round((-magLeft) * innerDivWidth / magres_x); |
405 | | | if (innerDivLeft < innerDivLeftMin) innerDivLeft = innerDivLeftMin; |
406 | | | innerDiv.style.left = innerDivLeft + "px"; |
407 | 1 | unreal | |
408 | 9 | unreal | /* set innerDivTop */ |
409 | | | var innerDivTopMin = inres_y - innerDivHeight; //400 |
410 | | | var innerDivTop = Math.round((-magTop) * innerDivHeight / magres_y); |
411 | | | if (innerDivTop < innerDivTopMin) innerDivTop = innerDivTopMin; |
412 | | | innerDiv.style.top = innerDivTop + "px"; |
413 | 1 | unreal | |
414 | 9 | unreal | this.checkTiles(); |
415 | | | } |
416 | 1 | unreal | |
417 | 9 | unreal | MainMap.prototype.setInnerDivSize = function (width, height, size, percent) { |
418 | | | var innerDiv = this.innerDiv; |
419 | | | innerDiv.style.width = width + "px"; |
420 | | | innerDiv.style.height = height + "px"; |
421 | | | magnifier.setPosition(); |
422 | | | magnifier.setSize(width, height); |
423 | 1 | unreal | |
424 | 9 | unreal | var resolutionInfo = document.getElementById("resolutionInfo"); |
425 | | | resolutionInfo.innerHTML = percent + "%, " + width + " x " + height + "px"; |
426 | | | } |
427 | 1 | unreal | |
428 | 9 | unreal | MainMap.prototype.setZoom = function (newZoom) { |
429 | | | is_adding = true; |
430 | | | if (this.zoom == newZoom) return; |
431 | | | window.clearInterval(drawing_timer); |
432 | | | actual_links = ""; |
433 | | | numoflinks = 0; |
434 | | | var oldZ = this.zoomDim[this.zoom]; |
435 | | | var newZ = this.zoomDim[newZoom]; |
436 | | | var innerDiv = this.innerDiv; |
437 | | | var imgs = innerDiv.getElementsByTagName("img"); |
438 | | | while (imgs.length > 0) { |
439 | | | innerDiv.removeChild(imgs[0]); |
440 | | | } |
441 | 1 | unreal | |
442 | 9 | unreal | var oldLeft = innerDiv.offsetLeft; |
443 | | | var oldTop = innerDiv.offsetTop; |
444 | | | var wdth = Math.round(((magres_x * inres_x) / newZ.width) - 2); // 200 * 700px |
445 | | | var hght = Math.round(((magres_y * inres_y) / newZ.height) - 2); // 141 * 500px |
446 | | | var wdth2 = Math.round(((magres_x * inres_x) / oldZ.width) - 2); // 200 * 700px |
447 | | | var hght2 = Math.round(((magres_y * inres_y) / oldZ.height) - 2); // 141 * 500px |
448 | 5 | unreal | |
449 | 9 | unreal | innerDiv.style.left = Math.round(Math.round(newZ.width * oldLeft / oldZ.width) + ((wdth-wdth2)*4)) + "px"; |
450 | | | innerDiv.style.top = Math.round(Math.round(newZ.height * oldTop / oldZ.height) + ((hght-hght2)*4)) + "px"; |
451 | | | this.zoom = newZoom; // set the global zoom |
452 | | | this.setInnerDivSize(newZ.width, newZ.height, newZ.size, (newZ.nasobek*1000)/10); |
453 | | | maxnumoflinks = newZ.numoflinks; |
454 | 1 | unreal | |
455 | 9 | unreal | this.checkZoom(); |
456 | | | this.checkTiles(); |
457 | 1 | unreal | |
458 | 9 | unreal | deleteNames(); |
459 | | | canvasInit(newZ.nasobek); |
460 | 1 | unreal | |
461 | 9 | unreal | } |
462 | 1 | unreal | |
463 | 9 | unreal | MainMap.prototype.doubleClick = function () { |
464 | | | if (this.zoom == 3) return; |
465 | | | this.setZoom(this.zoom + 1); |
466 | | | } |
467 | 1 | unreal | |
468 | 9 | unreal | MainMap.prototype.addNewLinks = function (minx, maxx, miny, maxy, linkname) { |
469 | | | var innerDiv = this.innerDiv; |
470 | | | var frameLeft = -innerDiv.offsetLeft; |
471 | | | var frameTop = -innerDiv.offsetTop; |
472 | | | var frameRight = frameLeft + inres_x; |
473 | | | var frameBottom = frameTop + inres_y; |
474 | | | var regexp = new RegExp(linkname + ' ', 'gi'); |
475 | | | if(!regexp.test(actual_links)) { |
476 | | | return (minx <= frameRight && frameLeft <= maxx && miny <= frameBottom && frameTop <= maxy); |
477 | 1 | unreal | } |
478 | 9 | unreal | } |
479 | 1 | unreal | |
480 | 9 | unreal | MainMap.prototype.removeOldLinks = function (minx, maxx, miny, maxy, linkname) { |
481 | | | var innerDiv = this.innerDiv; |
482 | | | var frameLeft = -innerDiv.offsetLeft; |
483 | | | var frameTop = -innerDiv.offsetTop; |
484 | | | var frameRight = frameLeft + inres_x; |
485 | | | var frameBottom = frameTop + inres_y; |
486 | | | var regexp = new RegExp(linkname + ' ', 'gi'); |
487 | | | if(regexp.test(actual_links) && numoflinks>=maxnumoflinks) { |
488 | | | if(!(minx <= frameRight && frameLeft <= maxx && miny <= frameBottom && frameTop <= maxy)) { |
489 | | | actual_links = actual_links.replace(regexp, ""); |
490 | | | var linkDOM = document.getElementById(linkname); |
491 | | | if(is_ie) { |
492 | | | linkDOM.parentNode.parentNode.removeChild(linkDOM.parentNode); |
493 | | | } else { |
494 | | | linkDOM.parentNode.removeChild(linkDOM); |
495 | | | } |
496 | | | numoflinks--; |
497 | | | return; |
498 | | | } |
499 | | | } |
500 | | | } |
501 | 1 | unreal | |
502 | | | |
503 | 9 | unreal | function canvasInit(nasobek) { |
504 | | | is_adding = true; |
505 | | | actual_links = ""; |
506 | | | numoflinks = 0; |
507 | | | |
508 | | | div_paint = document.getElementById("paint"); |
509 | | | div_points = document.getElementById("mapstats_points"); |
510 | | | div_wave = document.getElementById("mapstats_wave"); |
511 | | | div_infopoint = document.getElementById("mapstats_infopoint"); |
512 | | | div_name = document.getElementById("mapstats_name"); |
513 | | | div_ip = document.getElementById("mapstats_ip"); |
514 | | | div_status = document.getElementById("mapstats_status"); |
515 | | | |
516 | | | div_paint.style.width = parseInt(full_x*nasobek) + "px"; |
517 | | | div_paint.style.height = parseInt(full_y*nasobek) + "px"; |
518 | | | |
519 | | | var mapstats_over = document.getElementById("mapstats_over"); |
520 | | | mapstats_over.style.width = parseInt(full_x*nasobek) + "px"; |
521 | | | mapstats_over.style.height = parseInt(full_y*nasobek) + "px"; |
522 | 1 | unreal | |
523 | 9 | unreal | ann = nasobek; |
524 | | | var pozdrav2 = new Array(); |
525 | | | var pozdr = new Array(); |
526 | | | var pozdrav = file_nodes.split('\n'); |
527 | | | var pozdrav1 = file_noping.split('\n'); |
528 | | | var a_cnt = 0; |
529 | | | var p0count = pozdrav.length; |
530 | | | var p1count = pozdrav1.length; |
531 | 1 | unreal | |
532 | 9 | unreal | for(a=0;a<p0count;a++){ |
533 | | | if(pozdrav[a]!=false) { |
534 | | | node[a] = new Array(); |
535 | | | pozdrav2 = pozdrav[a].split(';'); |
536 | | | for(b=0;b<pozdrav2.length;b++){ |
537 | | | node[a][b] = pozdrav2[b]; |
538 | | | } |
539 | | | a_cnt++; |
540 | | | } |
541 | | | } |
542 | | | for(e=0;e<p1count;e++) { |
543 | | | if(pozdrav1[e]!=false) { |
544 | | | node[(e+a_cnt)] = new Array(); |
545 | | | pozdr = pozdrav1[e].split(';'); |
546 | | | for(f=0;f<pozdr.length;f++){ |
547 | | | node[(e+a_cnt)][f] = pozdr[f]; |
548 | | | } |
549 | | | } |
550 | | | } |
551 | 1 | unreal | |
552 | 9 | unreal | nodecount = node.length; |
553 | | | var pozdrav3 = new Array(); |
554 | | | var pozdrav4 = new Array(); |
555 | | | var size; |
556 | | | var clrlnk; |
557 | | | m1 = 0; m1_a = 0; |
558 | | | m2 = 0; m2_a = 0; |
559 | | | m3 = 0; m3_a = 0; |
560 | | | m4 = 0; m4_a = 0; |
561 | | | m5 = 0; m5_a = 0; |
562 | | | m6 = 0; m6_a = 0; |
563 | | | m7 = 0; m7_a = 0; |
564 | | | m8 = 0; m8_a = 0; |
565 | | | m9 = 0; m9_a = 0; |
566 | | | cntm = 0; |
567 | | | |
568 | | | checkLinks(); |
569 | 1 | unreal | |
570 | 9 | unreal | cntm = m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + m9 + m1_a + m2_a + m3_a + m4_a + m5_a + m6_a + m7_a + m8_a + m9_a; |
571 | 1 | unreal | |
572 | 9 | unreal | var pozdrav5 = new Array(); |
573 | | | var pozdrav6 = new Array(); |
574 | | | if(ch_infopoint) { |
575 | | | if(file_infopoints.length>0) { |
576 | | | pozdrav5 = file_infopoints.split('\n'); |
577 | | | for(d=0;d<pozdrav5.length;d++) { |
578 | | | if(pozdrav5[d]!=false) { |
579 | | | pozdrav6 = pozdrav5[d].split(';'); |
580 | | | // Vykreslime si infopointy |
581 | | | if(ch_name) { |
582 | | | drawInfo(pozdrav6[0],pozdrav6[1],pozdrav6[2],nasobek); |
583 | 1 | unreal | } |
584 | 9 | unreal | drawInfoPoint(pozdrav6[1],pozdrav6[2],nasobek); |
585 | | | } |
586 | | | } |
587 | | | } |
588 | | | } |
589 | 1 | unreal | |
590 | 9 | unreal | for(e=0;e<p1count;e++) { |
591 | | | if(pozdrav1[e]!="") { |
592 | | | if(ch_noping) { |
593 | | | if(node[(a_cnt+e)][3]==1) { |
594 | | | drawClient(node[(a_cnt+e)][1],node[(a_cnt+e)][2],nasobek); |
595 | | | if(ch_name) { |
596 | | | drawName(node[(a_cnt+e)][0],(node[(a_cnt+e)][1])-1,(node[(a_cnt+e)][2])-1,nasobek) |
597 | 1 | unreal | } |
598 | 9 | unreal | } |
599 | | | if(node[(a_cnt+e)][3]==2) { |
600 | | | drawSwitch(node[(a_cnt+e)][1],node[(a_cnt+e)][2],nasobek); |
601 | | | } |
602 | | | } |
603 | | | } |
604 | | | } |
605 | 1 | unreal | |
606 | 9 | unreal | var pozdrav7 = file_state.split('\n'); |
607 | | | var pozdrav8 = new Array(); |
608 | | | var clrpnt; |
609 | | | var x_pos; |
610 | | | var y_pos; |
611 | | | var name_pos; |
612 | | | var title_pos; |
613 | | | var p7count = pozdrav7.length; |
614 | 1 | unreal | |
615 | 9 | unreal | for(c=0;c<p7count;c++){ |
616 | | | if(pozdrav7[c]!=false) { |
617 | | | pozdrav8 = pozdrav7[c].split(';'); |
618 | | | if(pozdrav8[1]==1) { clrpnt = "on"; pozdrav8[2] = pozdrav8[2] + ' ms'; } else { clrpnt = "off"; pozdrav8[2] = "offline"; } |
619 | | | if(pozdrav8[0]!=node[c][4]) { x_pos = ip2sour(pozdrav8[0],1); y_pos = ip2sour(pozdrav8[0],2); name_pos = ip2sour(pozdrav8[0],0); title_pos = ip2sour(pozdrav8[0],3); } else { x_pos = node[c][1]; y_pos = node[c][2]; name_pos = node[c][0]; title_pos = node[c][3]; } // check if the result doesnt replaced |
620 | 1 | unreal | |
621 | 9 | unreal | if(title_pos.toLowerCase()=="ap") { |
622 | | | if(ch_ap) { |
623 | | | drawAP(x_pos,y_pos,nasobek); |
624 | | | drawNode(x_pos,y_pos,nasobek,clrpnt); |
625 | | | if(ch_name) { |
626 | | | drawName(name_pos,x_pos,y_pos,nasobek); |
627 | | | } |
628 | | | if((ch_ip) && (ch_status)) { |
629 | | | drawStatus(pozdrav8[2],x_pos,y_pos,nasobek); |
630 | | | drawIP(pozdrav8[0],x_pos,y_pos,nasobek); |
631 | | | } else if((!ch_ip) && (ch_status)) { |
632 | | | drawStatus(pozdrav8[2],x_pos,y_pos-parseInt(12/nasobek),nasobek); |
633 | | | } else if((ch_ip) && (!ch_status)) { |
634 | | | drawIP(pozdrav8[0],x_pos,y_pos,nasobek); |
635 | | | } |
636 | | | } |
637 | | | } else if(title_pos.toLowerCase()=="router") { |
638 | | | if(ch_router) { |
639 | | | drawNode(x_pos,y_pos,nasobek,clrpnt); |
640 | | | if(ch_name) { |
641 | | | drawName(name_pos,x_pos,y_pos,nasobek); |
642 | 1 | unreal | } |
643 | 9 | unreal | if(ch_status) { |
644 | | | drawStatus(pozdrav8[2],x_pos,y_pos-parseInt(12/nasobek),nasobek); |
645 | 1 | unreal | } |
646 | 9 | unreal | } |
647 | | | } else { |
648 | | | if(ch_node) { |
649 | | | drawNode(x_pos,y_pos,nasobek,clrpnt); |
650 | | | if(ch_name) { |
651 | | | drawName(name_pos,x_pos,y_pos,nasobek); |
652 | | | } |
653 | | | } |
654 | | | } |
655 | | | } |
656 | | | } |
657 | 1 | unreal | |
658 | 9 | unreal | var legend = document.getElementById('legend'); |
659 | | | if((ch_legend) && (cntm>0)) { |
660 | | | drawLegend(); |
661 | | | legend.style.display = "block"; |
662 | | | } else { |
663 | | | legend.style.display = "none"; |
664 | 1 | unreal | } |
665 | 9 | unreal | } |
666 | 1 | unreal | |
667 | 9 | unreal | function drawLink(pos, size, nas, color) { |
668 | | | var linkname = "canvas" + pos.replace(/(#|&|_|\.|\:)/gi, ""); |
669 | | | var points = new Array(); |
670 | | | var posxy = new Array(); |
671 | | | var coordinates = new Array(); |
672 | | | var cor_x = new Array(); |
673 | | | var cor_y = new Array(); |
674 | | | points = pos.split('#'); |
675 | | | var reg=/(\d+)&(\d+)/; |
676 | | | for(i=0;i<points.length;i++){ |
677 | | | if (reg.test(points[i])) { |
678 | | | posxy = points[i].split('&'); |
679 | | | coordinates[i*2] = parseInt(posxy[0]*nas); |
680 | | | coordinates[i*2+1] = parseInt(posxy[1]*nas); |
681 | | | cor_x.push(coordinates[i*2]); |
682 | | | cor_y.push(coordinates[i*2+1]); |
683 | | | } else { |
684 | | | coordinates[i*2] = parseInt(node2sour(points[i],1)*nas); |
685 | | | coordinates[i*2+1] = parseInt(node2sour(points[i],2)*nas); |
686 | | | cor_x.push(coordinates[i*2]); |
687 | | | cor_y.push(coordinates[i*2+1]); |
688 | | | } |
689 | 1 | unreal | } |
690 | 9 | unreal | |
691 | | | var maxX = cor_x.max(); |
692 | | | var minX = cor_x.min(); |
693 | | | var maxY = cor_y.max(); |
694 | | | var minY = cor_y.min(); |
695 | | | if(is_adding) { |
696 | | | if(!mainMap.addNewLinks(minX, maxX, minY, maxY, linkname)) return; |
697 | | | } else { |
698 | | | if(!mainMap.removeOldLinks(minX, maxX, minY, maxY, linkname)) return; |
699 | | | } |
700 | | | numoflinks++; |
701 | | | actual_links = actual_links + linkname + " "; |
702 | | | var canvas = document.createElement("canvas"); |
703 | | | canvas.width = maxX - minX + 10; |
704 | | | canvas.height = maxY - minY + 10; |
705 | | | canvas.id = linkname; |
706 | | | |
707 | | | if(is_ie) { |
708 | | | // for IE's VML absolute positioning |
709 | | | var div = document.createElement("div"); |
710 | | | div.style.width = maxX - minX + 10 + "px"; |
711 | | | div.style.height = maxY - minY + 10 + "px"; |
712 | | | div.style.position = "absolute"; |
713 | | | div.style.left = (minX - 5) + "px"; |
714 | | | div.style.top = (minY - 5) + "px"; |
715 | | | div.appendChild(canvas); |
716 | | | div_paint.appendChild(div); |
717 | | | G_vmlCanvasManager.initElement(canvas); |
718 | | | } else { |
719 | | | canvas.setAttribute("style", "position:absolute;left:" + (minX - 5) + "px;top:" + (minY - 5) + "px;"); |
720 | | | div_paint.appendChild(canvas); |
721 | | | } |
722 | | | var ctx = document.getElementById(linkname).getContext('2d'); |
723 | | | |
724 | | | minX -= 5; |
725 | | | minY -= 5; |
726 | 1 | unreal | |
727 | 9 | unreal | ctx.lineJoin = "round"; |
728 | | | ctx.strokeStyle = "rgb(20, 20, 20)"; |
729 | | | ctx.lineWidth = size+1; |
730 | | | ctx.beginPath(); |
731 | | | ctx.moveTo(coordinates[0]-minX,coordinates[1]-minY); |
732 | | | for(i=2;i<coordinates.length;i+=2){ |
733 | | | ctx.lineTo(coordinates[i]-minX,coordinates[i+1]-minY); |
734 | 1 | unreal | } |
735 | 9 | unreal | ctx.stroke(); |
736 | 1 | unreal | |
737 | 9 | unreal | ctx.lineJoin = "round"; |
738 | | | ctx.strokeStyle = "rgb(0, 0, 0)"; |
739 | | | ctx.lineWidth = size+1; |
740 | | | ctx.beginPath(); |
741 | | | ctx.moveTo(coordinates[0]-minX,coordinates[1]-minY); |
742 | | | for(i=2;i<coordinates.length;i+=2){ |
743 | | | ctx.lineTo(coordinates[i]-minX,coordinates[i+1]-minY); |
744 | 1 | unreal | } |
745 | 9 | unreal | ctx.stroke(); |
746 | 1 | unreal | |
747 | 9 | unreal | ctx.lineJoin = "round"; |
748 | | | ctx.strokeStyle = color; |
749 | | | ctx.lineWidth = size-1; |
750 | | | ctx.beginPath(); |
751 | | | ctx.moveTo(coordinates[0]-minX,coordinates[1]-minY); |
752 | | | for(i=2;i<coordinates.length;i+=2){ |
753 | | | ctx.lineTo(coordinates[i]-minX,coordinates[i+1]-minY); |
754 | 1 | unreal | } |
755 | 9 | unreal | ctx.stroke(); |
756 | | | } |
757 | 1 | unreal | |
758 | 9 | unreal | function drawINPLink(pos, size, nas, color) { |
759 | | | var linkname = "canvas" + pos.replace(/(#|&|_|\.|\:)/gi, ""); |
760 | | | var points = new Array(); |
761 | | | var posxy = new Array(); |
762 | | | var coordinates = new Array(); |
763 | | | var cor_x = new Array(); |
764 | | | var cor_y = new Array(); |
765 | | | points = pos.split('#'); |
766 | | | var reg=/(\d+)&(\d+)/; |
767 | | | for(i=0;i<points.length;i++){ |
768 | | | if (reg.test(points[i])) { |
769 | | | posxy = points[i].split('&'); |
770 | | | coordinates[i*2] = parseInt(posxy[0]*nas); |
771 | | | coordinates[i*2+1] = parseInt(posxy[1]*nas); |
772 | | | cor_x.push(coordinates[i*2]); |
773 | | | cor_y.push(coordinates[i*2+1]); |
774 | | | } else { |
775 | | | coordinates[i*2] = parseInt(node2sour(points[i],1)*nas); |
776 | | | coordinates[i*2+1] = parseInt(node2sour(points[i],2)*nas); |
777 | | | cor_x.push(coordinates[i*2]); |
778 | | | cor_y.push(coordinates[i*2+1]); |
779 | | | } |
780 | 1 | unreal | } |
781 | 9 | unreal | |
782 | | | var maxX = cor_x.max(); |
783 | | | var minX = cor_x.min(); |
784 | | | var maxY = cor_y.max(); |
785 | | | var minY = cor_y.min(); |
786 | | | if(is_adding) { |
787 | | | if(!mainMap.addNewLinks(minX, maxX, minY, maxY, linkname)) return; |
788 | | | } else { |
789 | | | if(!mainMap.removeOldLinks(minX, maxX, minY, maxY, linkname)) return; |
790 | | | } |
791 | | | numoflinks++; |
792 | | | actual_links = actual_links + linkname + " "; |
793 | | | var canvas = document.createElement("canvas"); |
794 | | | canvas.width = maxX - minX + 10; |
795 | | | canvas.height = maxY - minY + 10; |
796 | | | canvas.id = linkname; |
797 | | | |
798 | | | if(is_ie) { |
799 | | | // for IE's VML absolute positioning |
800 | | | var div = document.createElement("div"); |
801 | | | div.style.width = maxX - minX + 10 + "px"; |
802 | | | div.style.height = maxY - minY + 10 + "px"; |
803 | | | div.style.position = "absolute"; |
804 | | | div.style.left = (minX - 5) + "px"; |
805 | | | div.style.top = (minY - 5) + "px"; |
806 | | | div.appendChild(canvas); |
807 | | | div_paint.appendChild(div); |
808 | | | G_vmlCanvasManager.initElement(canvas); |
809 | | | } else { |
810 | | | canvas.setAttribute("style", "position:absolute;left:" + (minX - 5) + "px;top:" + (minY - 5) + "px;"); |
811 | | | div_paint.appendChild(canvas); |
812 | | | } |
813 | | | var ctx = document.getElementById(linkname).getContext('2d'); |
814 | | | |
815 | | | minX -= 5; |
816 | | | minY -= 5; |
817 | 1 | unreal | |
818 | 9 | unreal | ctx.lineJoin = "round"; |
819 | | | ctx.strokeStyle = "rgba(0, 0, 0, 0.1)"; |
820 | | | ctx.lineWidth = size+1.5; |
821 | | | ctx.beginPath(); |
822 | | | ctx.moveTo(coordinates[0]-minX,coordinates[1]-minY); |
823 | | | for(i=2;i<coordinates.length;i+=2){ |
824 | | | ctx.lineTo(coordinates[i]-minX,coordinates[i+1]-minY); |
825 | 1 | unreal | } |
826 | 9 | unreal | ctx.stroke(); |
827 | 1 | unreal | |
828 | 9 | unreal | ctx.lineJoin = "round"; |
829 | | | ctx.strokeStyle = color; |
830 | | | ctx.lineWidth = size+0.5; |
831 | | | ctx.beginPath(); |
832 | | | ctx.moveTo(coordinates[0]-minX,coordinates[1]-minY); |
833 | | | for(i=2;i<coordinates.length;i+=2){ |
834 | | | ctx.lineTo(coordinates[i]-minX,coordinates[i+1]-minY); |
835 | 1 | unreal | } |
836 | 9 | unreal | ctx.stroke(); |
837 | | | } |
838 | 1 | unreal | |
839 | 9 | unreal | function checkLinks() { |
840 | | | if(file_links.length>0) { |
841 | | | pozdrav3 = file_links.split('\n'); |
842 | | | var p3count = pozdrav3.length; |
843 | | | for(a=0;a<p3count;a++){ |
844 | | | if(pozdrav3[a]!=false) { |
845 | | | pozdrav4 = pozdrav3[a].split(';'); |
846 | | | if(pozdrav4[1].toLowerCase()=="backbone") { size = 4.1; } else { size = 2.7; } |
847 | | | if(pozdrav4[2].toLowerCase()!="inp") { |
848 | | | if(pozdrav4[3]==1) { clrlnk = wifi_client; m1 = 1; } |
849 | | | else if(pozdrav4[3]==2) { clrlnk = wifi_backbone; m2 = 1; } |
850 | | | else if(pozdrav4[3]==3) { clrlnk = eth_100; m3 = 1; } |
851 | | | else if(pozdrav4[3]==4) { clrlnk = fso; m4 = 1; } |
852 | | | else if(pozdrav4[3]==5) { clrlnk = fso_backup; m5 = 1; } |
853 | | | else if(pozdrav4[3]==6) { clrlnk = ghz5; m6 = 1; } |
854 | | | else if(pozdrav4[3]==7) { clrlnk = ghz10; m7 = 1; } |
855 | | | else if(pozdrav4[3]==8) { clrlnk = fiber; m8 = 1; } |
856 | | | else { clrlnk = other; m9 = 1; } |
857 | | | } else { |
858 | | | if(pozdrav4[3]==1) { clrlnk = wifi_client_a; m1_a = 1; } |
859 | | | else if(pozdrav4[3]==2) { clrlnk = wifi_backbone_a; m2_a = 1; } |
860 | | | else if(pozdrav4[3]==3) { clrlnk = eth_100_a; m3_a = 1; } |
861 | | | else if(pozdrav4[3]==4) { clrlnk = fso_a; m4_a = 1; } |
862 | | | else if(pozdrav4[3]==5) { clrlnk = fso_backup_a; m5_a = 1; } |
863 | | | else if(pozdrav4[3]==6) { clrlnk = ghz5_a; m6_a = 1; } |
864 | | | else if(pozdrav4[3]==7) { clrlnk = ghz10_a; m7_a = 1; } |
865 | | | else if(pozdrav4[3]==8) { clrlnk = fiber_a; m8_a = 1; } |
866 | | | else { clrlnk = other_a; m9_a = 1; } |
867 | | | } |
868 | | | |
869 | | | if(pozdrav4[2].toLowerCase()!="inp") { |
870 | | | if((ch_backbone && size==4.1) || (ch_client && size==2.7)) { |
871 | | | drawLink(pozdrav4[0], size, ann, clrlnk); |
872 | | | } |
873 | | | } else { |
874 | | | if(ch_inp) { |
875 | | | drawINPLink(pozdrav4[0], size-1, ann, clrlnk); |
876 | | | } |
877 | | | } |
878 | | | } |
879 | | | } |
880 | 1 | unreal | } |
881 | 9 | unreal | } |
882 | 1 | unreal | |
883 | 9 | unreal | function drawNode(xo, yo, nas, img) { |
884 | | | xo = parseInt((xo*nas)-7); |
885 | | | yo = parseInt((yo*nas)-7); |
886 | | | var text = '<div class="node" style="position:absolute;left:' + xo + 'px;top:' + yo + 'px;background:url(\'' + img + '.png\');" unselectable = "on"></div>'; |
887 | | | div_points.innerHTML += text; |
888 | | | } |
889 | 1 | unreal | |
890 | 9 | unreal | function drawAP(xn, yn, nas) { |
891 | | | xn = parseInt((xn*nas)-31); |
892 | | | yn = parseInt((yn*nas)-17); |
893 | | | var text = '<div class="ap" style="position:absolute;left:' + xn + 'px;top:' + yn + 'px;" unselectable = "on"></div>'; |
894 | | | div_wave.innerHTML += text; |
895 | | | } |
896 | 1 | unreal | |
897 | 9 | unreal | function drawClient(xc, yc, nas) { |
898 | | | xc = parseInt((xc*nas)-7); |
899 | | | yc = parseInt((yc*nas)-7); |
900 | | | var text = '<div class="client" style="position:absolute;left:' + xc + 'px;top:' + yc + 'px;" unselectable = "on"></div>'; |
901 | | | div_wave.innerHTML += text; |
902 | | | } |
903 | 1 | unreal | |
904 | 9 | unreal | function drawSwitch(xs, ys, nas) { |
905 | | | xs = parseInt((xs*nas)-6); |
906 | | | ys = parseInt((ys*nas)-6); |
907 | | | var text = '<div class="switch" style="position:absolute;left:' + xs + 'px;top:' + ys + 'px;" unselectable = "on"></div>'; |
908 | | | div_wave.innerHTML += text; |
909 | | | } |
910 | 1 | unreal | |
911 | 9 | unreal | function drawInfoPoint(xl, yl, nas) { |
912 | | | xl = parseInt((xl*nas)-7); |
913 | | | yl = parseInt((yl*nas)-7); |
914 | | | var text = '<div class="infopoint" style="position:absolute;left:' + xl + 'px;top:' + yl + 'px;" unselectable = "on"></div>'; |
915 | | | div_wave.innerHTML += text; |
916 | | | } |
917 | 4 | unreal | |
918 | 9 | unreal | function drawInfo(txt, xa, ya, nas) { |
919 | | | xa = parseInt((xa*nas)+6); |
920 | | | ya = parseInt((ya*nas)-13); |
921 | | | var text = '<div class="stitek" style="position:absolute;left:' + xa + 'px;top:' + ya + 'px;" unselectable = "on">' + txt + '</div>'; |
922 | | | div_infopoint.innerHTML += text; |
923 | | | } |
924 | 1 | unreal | |
925 | 9 | unreal | function drawName(txt, xa, ya, nas) { |
926 | | | xa = parseInt((xa*nas)+6); |
927 | | | ya = parseInt((ya*nas)-13); |
928 | | | var text = '<div class="stitek" style="position:absolute;left:' + xa + 'px;top:' + ya + 'px;" unselectable = "on">' + txt + '</div>'; |
929 | | | div_name.innerHTML += text; |
930 | | | } |
931 | 1 | unreal | |
932 | 9 | unreal | function drawIP(txt, xb, yb, nas) { |
933 | | | xb = parseInt((xb*nas)+6); |
934 | | | yb = parseInt((yb*nas)-1); |
935 | | | var text = '<div class="stitek" style="position:absolute;left:' + xb + 'px;top:' + yb + 'px;" unselectable = "on">' + txt + '</div>'; |
936 | | | div_ip.innerHTML += text; |
937 | | | } |
938 | 1 | unreal | |
939 | 9 | unreal | function drawStatus(txt, xc, yc, nas) { |
940 | | | xc = parseInt((xc*nas)+6); |
941 | | | yc = parseInt((yc*nas)+11); |
942 | | | var text = '<div class="stitek" style="position:absolute;left:' + xc + 'px;top:' + yc + 'px;" unselectable = "on">' + txt + '</div>'; |
943 | | | div_status.innerHTML += text; |
944 | | | } |
945 | 1 | unreal | |
946 | 9 | unreal | function drawLegendText(txt) { |
947 | | | document.getElementById("mapstats_legend").innerHTML = '<div class="legend" unselectable = "on">' + txt + '</div>'; |
948 | | | } |
949 | 1 | unreal | |
950 | 9 | unreal | function drawLegend() { |
951 | | | var epsilon; |
952 | | | var cislo = 0; |
953 | | | var name = ""; |
954 | | | var paintlegend = document.getElementById('paintlegend'); |
955 | | | paintlegend.height = (((cntm-1) * 12)+13); |
956 | | | paintlegend.width = "25"; |
957 | | | var ctx = paintlegend.getContext('2d'); |
958 | | | ctx.clearRect(0,0,25,((cntm-1) * 12)+13); |
959 | | | if(m1==1) { epsilon = ((cislo*12)+5); drawLegendLink(epsilon,wifi_client,2.7); name = name + name1 + "<br/>"; cislo++; } |
960 | | | if(m2==1) { epsilon = ((cislo*12)+5); drawLegendLink(epsilon,wifi_backbone,4.1); name = name + name2 + "<br/>"; cislo++; } |
961 | | | if(m3==1) { epsilon = ((cislo*12)+5); drawLegendLink(epsilon,eth_100,4.1); name = name + name3 + "<br/>"; cislo++; } |
962 | | | if(m4==1) { epsilon = ((cislo*12)+5); drawLegendLink(epsilon,fso,4.1); name = name + name4 + "<br/>"; cislo++; } |
963 | | | if(m5==1) { epsilon = ((cislo*12)+5); drawLegendLink(epsilon,fso_backup,4.1); name = name + name5 + "<br/>"; cislo++; } |
964 | | | if(m6==1) { epsilon = ((cislo*12)+5); drawLegendLink(epsilon,ghz5,4.1); name = name + name6 + "<br/>"; cislo++; } |
965 | | | if(m7==1) { epsilon = ((cislo*12)+5); drawLegendLink(epsilon,ghz10,4.1); name = name + name7 + "<br/>"; cislo++; } |
966 | | | if(m8==1) { epsilon = ((cislo*12)+5); drawLegendLink(epsilon,fiber,4.1); name = name + name8 + "<br/>"; cislo++; } |
967 | | | if(m9==1) { epsilon = ((cislo*12)+5); drawLegendLink(epsilon,other,4.1); name = name + name9 + "<br/>"; cislo++; } |
968 | | | if(m1_a==1) { epsilon = ((cislo*12)+5); drawLegendINPLink(epsilon,wifi_client_a,2.7); name = name + name1 + " " + inp + "<br/>"; cislo++; } |
969 | | | if(m2_a==1) { epsilon = ((cislo*12)+5); drawLegendINPLink(epsilon,wifi_backbone_a,4.1); name = name + name2 + " " + inp + "<br/>"; cislo++; } |
970 | | | if(m3_a==1) { epsilon = ((cislo*12)+5); drawLegendINPLink(epsilon,eth_100_a,4.1); name = name + name3 + " " + inp + "<br/>"; cislo++; } |
971 | | | if(m4_a==1) { epsilon = ((cislo*12)+5); drawLegendINPLink(epsilon,fso_a,4.1); name = name + name4 + " " + inp + "<br/>"; cislo++; } |
972 | | | if(m5_a==1) { epsilon = ((cislo*12)+5); drawLegendINPLink(epsilon,fso_backup_a,4.1); name = name + name5 + " " + inp + "<br/>"; cislo++; } |
973 | | | if(m6_a==1) { epsilon = ((cislo*12)+5); drawLegendINPLink(epsilon,ghz5_a,4.1); name = name + name6 + " " + inp + "<br/>"; cislo++; } |
974 | | | if(m7_a==1) { epsilon = ((cislo*12)+5); drawLegendINPLink(epsilon,ghz10_a,4.1); name = name + name7 + " " + inp + "<br/>"; cislo++; } |
975 | | | if(m8_a==1) { epsilon = ((cislo*12)+5); drawLegendINPLink(epsilon,fiber_a,4.1); name = name + name8 + " " + inp + "<br/>"; cislo++; } |
976 | | | if(m9_a==1) { epsilon = ((cislo*12)+5); drawLegendINPLink(epsilon,other_a,4.1); name = name + name9 + " " + inp + "<br/>"; } |
977 | | | drawLegendText(name); |
978 | | | } |
979 | 1 | unreal | |
980 | 9 | unreal | function drawLegendLink(yg,color,size) { |
981 | | | var ctx = document.getElementById('paintlegend').getContext('2d'); |
982 | | | ctx.strokeStyle = "rgb(20, 20, 20)"; |
983 | | | ctx.lineWidth = size+1; |
984 | | | ctx.beginPath(); |
985 | | | ctx.moveTo(1,yg); |
986 | | | ctx.lineTo(24,yg); |
987 | | | ctx.stroke(); |
988 | 1 | unreal | |
989 | 9 | unreal | ctx.strokeStyle = "rgb(0, 0, 0)"; |
990 | | | ctx.lineWidth = size; |
991 | | | ctx.beginPath(); |
992 | | | ctx.moveTo(1,yg); |
993 | | | ctx.lineTo(24,yg); |
994 | | | ctx.stroke(); |
995 | 1 | unreal | |
996 | 9 | unreal | ctx.strokeStyle = color; |
997 | | | ctx.lineWidth = size-1; |
998 | | | ctx.beginPath(); |
999 | | | ctx.moveTo(1,yg); |
1000 | | | ctx.lineTo(24,yg); |
1001 | | | ctx.stroke(); |
1002 | | | } |
1003 | 1 | unreal | |
1004 | 9 | unreal | function drawLegendINPLink(yg,color,size) { |
1005 | | | var ctx = document.getElementById('paintlegend').getContext('2d'); |
1006 | | | ctx.strokeStyle = "rgba(255, 255, 255, 0.5)"; |
1007 | | | ctx.lineWidth = size; |
1008 | | | ctx.beginPath(); |
1009 | | | ctx.moveTo(1,yg); |
1010 | | | ctx.lineTo(24,yg); |
1011 | | | ctx.stroke(); |
1012 | 1 | unreal | |
1013 | 9 | unreal | ctx.strokeStyle = "rgba(0, 0, 0, 0.1)"; |
1014 | | | ctx.lineWidth = size; |
1015 | | | ctx.beginPath(); |
1016 | | | ctx.moveTo(1,yg); |
1017 | | | ctx.lineTo(24,yg); |
1018 | | | ctx.stroke(); |
1019 | 5 | unreal | |
1020 | 9 | unreal | ctx.strokeStyle = color; |
1021 | | | ctx.lineWidth = size-0.5; |
1022 | | | ctx.beginPath(); |
1023 | | | ctx.moveTo(1,yg); |
1024 | | | ctx.lineTo(24,yg); |
1025 | | | ctx.stroke(); |
1026 | | | } |
1027 | 1 | unreal | |
1028 | 9 | unreal | function clearMap() { |
1029 | | | div_paint.innerHTML = ""; |
1030 | | | } |
1031 | 1 | unreal | |
1032 | 9 | unreal | function node2sour(name, pos) { |
1033 | | | var ok = 0; |
1034 | | | for(k=0;k<nodecount;k++){ |
1035 | | | if(node[k][0]==name) { |
1036 | | | ok = node[k][pos]; |
1037 | | | } |
1038 | | | if(ok!=0) { return ok; } |
1039 | 1 | unreal | } |
1040 | 9 | unreal | return ok; |
1041 | | | } |
1042 | 1 | unreal | |
1043 | 9 | unreal | function ip2sour(ip, pos) { |
1044 | | | var ok = 0; |
1045 | | | for(k=0;k<nodecount;k++){ |
1046 | | | if(node[k][4]==ip) { |
1047 | | | ok = node[k][pos]; |
1048 | | | } |
1049 | | | if(ok!=0) { return ok; } |
1050 | 1 | unreal | } |
1051 | 9 | unreal | return ok; |
1052 | | | } |
1053 | 1 | unreal | |
1054 | 9 | unreal | function loadFiles() { |
1055 | | | var d = new Date(); |
1056 | | | var tm = d.getTime(); |
1057 | | | file_nodes = getFile(nodes + "?" + tm); |
1058 | | | file_noping = getFile(noping + "?" + tm); |
1059 | | | file_links = getFile(links + "?" + tm); |
1060 | | | file_infopoints = getFile(infopoints + "?" + tm); |
1061 | | | file_state = getFile(state + "?" + tm); |
1062 | | | redrawUpdate(); |
1063 | | | } |
1064 | 1 | unreal | |
1065 | 9 | unreal | function getFile(url) { |
1066 | | | AJAX = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false)); |
1067 | | | if (AJAX) { |
1068 | | | AJAX.open("GET", url, false); |
1069 | | | AJAX.setRequestHeader("Cache-Control", "no-store"); |
1070 | | | AJAX.setRequestHeader("Cache-Control", "no-cache"); |
1071 | | | AJAX.setRequestHeader("Cache-Control", "must-revalidate"); |
1072 | | | AJAX.setRequestHeader("Pragma", "no-cache"); |
1073 | | | AJAX.send(null); |
1074 | | | return AJAX.responseText; |
1075 | | | } else { |
1076 | | | return false; |
1077 | | | } |
1078 | | | } |
1079 | 1 | unreal | |
1080 | 9 | unreal | function setAutoLoader() { |
1081 | | | // auto-downloading source files every 2 minutes |
1082 | | | setInterval("loadFiles()", 2 * 60 * 1000); |
1083 | | | } |
1084 | 1 | unreal | |
1085 | 9 | unreal | function setCheckboxes() { |
1086 | | | document.form_map.ch_ap.checked = ch_ap; |
1087 | | | document.form_map.ch_router.checked = ch_router; |
1088 | | | document.form_map.ch_node.checked = ch_node; |
1089 | | | document.form_map.ch_infopoint.checked = ch_infopoint; |
1090 | | | document.form_map.ch_noping.checked = ch_noping; |
1091 | | | document.form_map.ch_legend.checked = ch_legend; |
1092 | | | document.form_map.ch_name.checked = ch_name; |
1093 | | | document.form_map.ch_ip.checked = ch_ip; |
1094 | | | document.form_map.ch_status.checked = ch_status; |
1095 | | | document.form_map.ch_backbone.checked = ch_backbone; |
1096 | | | document.form_map.ch_client.checked = ch_client; |
1097 | | | document.form_map.ch_inp.checked = ch_inp; |
1098 | | | } |
1099 | | | |
1100 | | | function deleteNames() { |
1101 | | | div_paint.innerHTML = ""; |
1102 | | | div_points.innerHTML = ""; |
1103 | | | div_wave.innerHTML = ""; |
1104 | | | div_infopoint.innerHTML = ""; |
1105 | | | div_name.innerHTML = ""; |
1106 | | | div_ip.innerHTML = ""; |
1107 | | | div_status.innerHTML = ""; |
1108 | | | document.getElementById("mapstats_legend").innerHTML = ""; |
1109 | | | } |
1110 | 1 | unreal | |
1111 | 9 | unreal | function reDraw() { |
1112 | | | if(document.form_map.ch_ap.checked) { ch_ap = true; } else { ch_ap = false; } |
1113 | | | if(document.form_map.ch_router.checked) { ch_router = true; } else { ch_router = false; } |
1114 | | | if(document.form_map.ch_node.checked) { ch_node = true; } else { ch_node = false; } |
1115 | | | if(document.form_map.ch_infopoint.checked) { ch_infopoint = true; } else { ch_infopoint = false; } |
1116 | | | if(document.form_map.ch_noping.checked) { ch_noping = true; } else { ch_noping = false; } |
1117 | | | if(document.form_map.ch_legend.checked) { ch_legend = true; } else { ch_legend = false; } |
1118 | | | if(document.form_map.ch_name.checked) { ch_name = true; } else { ch_name = false; } |
1119 | | | if(document.form_map.ch_ip.checked) { ch_ip = true; } else { ch_ip = false; } |
1120 | | | if(document.form_map.ch_status.checked) { ch_status = true; } else { ch_status = false; } |
1121 | | | if(document.form_map.ch_backbone.checked) { ch_backbone = true; } else { ch_backbone = false; } |
1122 | | | if(document.form_map.ch_client.checked) { ch_client = true; } else { ch_client = false; } |
1123 | | | if(document.form_map.ch_inp.checked) { ch_inp = true; } else { ch_inp = false; } |
1124 | | | deleteNames(); |
1125 | | | clearMap(); |
1126 | | | canvasInit(ann); |
1127 | | | } |
1128 | 1 | unreal | |
1129 | 9 | unreal | function changeOpacity(opc) { |
1130 | | | var opcprc = opc / 100; |
1131 | | | var mapstats_update = document.getElementById("mapstats_update"); |
1132 | 1 | unreal | |
1133 | 9 | unreal | if (is_ie) { |
1134 | | | mapstats_update.style.filter = 'alpha(opacity=' + opc + ');'; |
1135 | | | } else { |
1136 | | | mapstats_update.style.setProperty("-moz-opacity",opcprc,null); |
1137 | | | mapstats_update.style.setProperty("opacity",opcprc,null); |
1138 | 1 | unreal | } |
1139 | 9 | unreal | } |
1140 | 1 | unreal | |
1141 | 9 | unreal | function changeUpdate() { |
1142 | | | var promenna = new Date(); |
1143 | | | var rok = promenna.getFullYear(); |
1144 | | | var mesic = "" + (promenna.getMonth() + 1); |
1145 | | | var den = "" + (promenna.getDate()); |
1146 | | | var hodin = "" + (promenna.getHours()); |
1147 | | | var minut = "" + (promenna.getMinutes()); |
1148 | | | var sekund = "" + (promenna.getSeconds()); |
1149 | | | if(mesic.length==1) { mesic = "0" + mesic; } |
1150 | | | if(den.length==1) { den = "0" + den; } |
1151 | | | if(hodin.length==1) { hodin = "0" + hodin; } |
1152 | | | if(minut.length==1) { minut = "0" + minut; } |
1153 | | | if(sekund.length==1) { sekund = "0" + sekund; } |
1154 | | | document.getElementById("mapstats_update").innerHTML = den + ". " + mesic + ". " + rok + " " + hodin + ":" + minut + ":" + sekund; |
1155 | | | } |
1156 | | | |
1157 | | | function redrawUpdate() { |
1158 | | | setTimeout("changeOpacity(90)",100); |
1159 | | | setTimeout("changeOpacity(80)",200); |
1160 | | | setTimeout("changeOpacity(70)",300); |
1161 | | | setTimeout("changeOpacity(60)",400); |
1162 | | | setTimeout("changeOpacity(50)",500); |
1163 | | | setTimeout("changeOpacity(40)",600); |
1164 | | | setTimeout("changeOpacity(30)",700); |
1165 | | | setTimeout("changeOpacity(20)",800); |
1166 | | | setTimeout("changeOpacity(10)",900); |
1167 | | | setTimeout("changeOpacity(0)",1000); |
1168 | | | setTimeout("changeUpdate()",1050); |
1169 | | | setTimeout("changeOpacity(10)",1100); |
1170 | | | setTimeout("changeOpacity(20)",1200); |
1171 | | | setTimeout("changeOpacity(30)",1300); |
1172 | | | setTimeout("changeOpacity(40)",1400); |
1173 | | | setTimeout("changeOpacity(50)",1500); |
1174 | | | setTimeout("changeOpacity(60)",1600); |
1175 | | | setTimeout("changeOpacity(70)",1700); |
1176 | | | setTimeout("changeOpacity(80)",1800); |
1177 | | | setTimeout("changeOpacity(90)",1900); |
1178 | | | setTimeout("changeOpacity(100)",2000); |
1179 | | | } |