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