jablonka.czprosek.czf

mapstats

Subversion Repositories:
[/] [mapstats.js] - Blame information for rev 3

 

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

Powered by WebSVN 2.2.1