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