diff options
Diffstat (limited to 'web/nms.gathering.org/js')
-rw-r--r-- | web/nms.gathering.org/js/nms-info-box.js | 77 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-map.js | 44 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms.js | 8 |
3 files changed, 84 insertions, 45 deletions
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index e0f9273..24c1e31 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -251,6 +251,8 @@ nmsInfoBox._windowTypes.switchInfo = { content.push([v, html]); } + content.sort(); + var table = nmsInfoBox._makeTable(content, "edit"); domObj.appendChild(table); @@ -318,6 +320,7 @@ nmsInfoBox._windowTypes.switchInfo = { nmsInfoBox.click = function(sw) { this.showWindow("switchInfo",sw); + this._windowTypes.switchInfo.showComments(); }; /* @@ -394,33 +397,37 @@ nmsInfoBox._makeCommentTable = function(content) { }; nmsInfoBox._searchSmart = function(id, sw) { - if (nmsData.smanagement.switches[sw].distro == id) { - console.log("ieh"); - return true; - } - if (id.match("[a-z]+.active")) { - console.log("hei: " + sw); - var family = id.match("[a-z]+"); - var limit = id; - limit = limit.replace(family + ".active>",""); - limit = limit.replace(family + ".active<",""); - limit = limit.replace(family + ".active=",""); - var operator = id.replace(family + ".active","")[0]; - if (limit == parseInt(limit)) { - if (operator == ">" ) { - if (nmsData.switchstate.switches[sw][family].live > limit) { - return true; - } - } else if (operator == "<") { - if (nmsData.switchstate.switches[sw][family].live < limit) { - return true; - } - } else if (operator == "=") { - if (nmsData.switchstate.switches[sw][family].live == limit) { - return true; + try { + if (nmsData.smanagement.switches[sw].distro == id) { + return true; + } + if (id.match("active")) { + var limit = id; + limit = limit.replace("active>",""); + limit = limit.replace("active<",""); + limit = limit.replace("active=",""); + var operator = id.replace("active","")[0]; + if (limit == parseInt(limit)) { + if (operator == ">" ) { + if (nmsData.switchstate.switches[sw]['totals'].live > limit) { + return true; + } + } else if (operator == "<") { + if (nmsData.switchstate.switches[sw]['totals'].live < limit) { + return true; + } + } else if (operator == "=") { + if (nmsData.switchstate.switches[sw]['totals'].live == limit) { + return true; + } } } } + if (nmsData.snmp.snmp[sw].misc.sysDescr[0].match(id)) { + return true; + } + } catch (e) { + return false; } return false; }; @@ -437,6 +444,7 @@ nmsInfoBox._search = function() { id = el.value; } if(id) { + nmsMap.enableHighlights(); for(var sw in nmsData.switches.switches) { if (id[0] == "/") { if (nmsInfoBox._searchSmart(id.slice(1),sw)) { @@ -455,23 +463,32 @@ nmsInfoBox._search = function() { } } } else { - nmsMap.removeAllSwitchHighlights(); + nmsMap.disableHighlights(); } if(matches.length == 1) { document.getElementById("searchbox-submit").classList.add("btn-primary"); document.getElementById("searchbox").dataset.match = matches[0]; - document.getElementById("searchbox").addEventListener("keydown",nmsInfoBox._searchKeyListener,false); } else { document.getElementById("searchbox-submit").classList.remove("btn-primary"); document.getElementById("searchbox").dataset.match = ''; - document.getElementById("searchbox").removeEventListener("keydown",nmsInfoBox._searchKeyListener,false); } }; nmsInfoBox._searchKeyListener = function(e) { - if(e.keyCode == 13) { - var sw = document.getElementById("searchbox").dataset.match; - nmsInfoBox.showWindow("switchInfo",sw); + switch (e.keyCode) { + case 13: + var sw = document.getElementById("searchbox").dataset.match; + if(sw != '') { + nmsInfoBox.showWindow("switchInfo",sw); + this._windowTypes.switchInfo.showComments(); + } + break; + case 27: + document.getElementById("searchbox").dataset.match = ''; + document.getElementById("searchbox").value = ''; + nmsInfoBox._search(); + nmsInfoBox.hide(); + break; } }; diff --git a/web/nms.gathering.org/js/nms-map.js b/web/nms.gathering.org/js/nms-map.js index c6bad49..ffedcbf 100644 --- a/web/nms.gathering.org/js/nms-map.js +++ b/web/nms.gathering.org/js/nms-map.js @@ -10,7 +10,8 @@ * nmsMap.setSwitchColor(switch,color) * nmsMap.setSwitchInfo(switch,info) * nmsMap.setSwitchHighlight(switch,true/false) - * nmsMap.removeAllSwitchHighlights() + * nmsMap.enableHighlights() + * nmsMap.disableHighlights() */ @@ -47,6 +48,7 @@ var nmsMap = nmsMap || { _color: { }, _highlight: { }, + _highlightActive: false, _c: {} }; @@ -73,21 +75,29 @@ nmsMap.setSwitchColor = function(sw, color) { } }; + nmsMap.setSwitchHighlight = function(sw, highlight) { - if(highlight) - highlight == true; - if (this._highlight[sw] != highlight) { - this._highlight[sw] = highlight; - this._drawSwitch(sw); - this.stats.highlightChange++; - } + if( highlight ) + highlight = true; + if ( this._highlight[sw] != highlight ) { + this.stats.highlightChange++; + this._highlight[sw] = highlight; + } + this._drawSwitch(sw); }; -nmsMap.removeAllSwitchHighlights = function() { - for(var sw in this._highlight) - this.setSwitchHighlight(sw,false); + +nmsMap.enableHighlights = function() { + this._highlightActive = true; }; + +nmsMap.disableHighlights = function() { + this._highlightActive = false; + this._drawAllSwitches(); +}; + + nmsMap.reset = function() { for (var sw in this._color) { nmsMap.setSwitchColor(sw, undefined); @@ -236,7 +246,7 @@ nmsMap._drawSwitchBlur = function(sw) this._c.blur.ctx.fillStyle = "red"; this._c.blur.ctx.shadowBlur = 30; this._c.blur.ctx.shadowColor = "white"; - this._c.blur.ctx.scale(this.scale, this.scale); // FIXME + this._c.blur.ctx.scale(this.scale, this.scale); // FIXME <- fix what?! this._c.blur.ctx.fillRect(box['x'],box['y'],box['width'],box['height']); this._c.blur.ctx.restore(); }; @@ -249,8 +259,12 @@ nmsMap._drawSwitch = function(sw) return; var box = this._getBox(sw); var color = nmsMap._color[sw]; - if(nmsMap._highlight[sw]) { - color = red; + if(this._highlightActive) { + if(nmsMap._highlight[sw]) { + color = green; + } else { + color = white; + } } if (color == undefined) { color = blue; @@ -336,7 +350,7 @@ nmsMap._drawAllBlur = function() { nmsMap._drawBox = function(ctx, x, y, boxw, boxh) { ctx.save(); - ctx.scale(this.scale, this.scale); // FIXME + ctx.scale(this.scale, this.scale); // FIXME <- what?! ctx.fillRect(x,y, boxw, boxh); ctx.lineWidth = 1; ctx.strokeStyle = "#000000"; diff --git a/web/nms.gathering.org/js/nms.js b/web/nms.gathering.org/js/nms.js index c1f8da2..8d28028 100644 --- a/web/nms.gathering.org/js/nms.js +++ b/web/nms.gathering.org/js/nms.js @@ -481,6 +481,7 @@ function initNMS() { detectHandler(); nms.playback.play(); setupKeyhandler(); + setupSearchKeyHandler(); } function detectHandler() { @@ -607,6 +608,13 @@ function setupKeyhandler() }); } +function setupSearchKeyHandler() +{ + $("#searchbox").keyup(function(e) { + nmsInfoBox._searchKeyListener(e); + }); +} + function getCookie(cname) { var name = cname + "="; |