diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-03-19 20:50:02 +0000 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-03-19 20:50:02 +0000 |
commit | a39e47202c108453cac8402b810cc0029c21c1c9 (patch) | |
tree | da4e27efe8b68acf3ba6e42392affb3398bb59f6 /web/nms.gathering.org/js/nms-info-box.js | |
parent | d637b9f2d67647fd14de3a814192b0d7dd3d332a (diff) |
NMS: Intelligent, undocumented active-ports-search
Diffstat (limited to 'web/nms.gathering.org/js/nms-info-box.js')
-rw-r--r-- | web/nms.gathering.org/js/nms-info-box.js | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index 6b13498..0175b6f 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -140,6 +140,38 @@ nmsInfoBox._makeCommentTable = function(content) { return table; } +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; + } + } + } + } + return false; +} + /* * FIXME: Not sure this belongs here, it's really part of the "Core" ui, * not just the infobox. @@ -153,11 +185,19 @@ nmsInfoBox._search = function() { } if(id) { for(var sw in nmsData.switches.switches) { - if(sw.indexOf(id) > -1) { - hits++; - nmsMap.setSwitchHighlight(sw,true); + if (id[0] == "/") { + if (nmsInfoBox._searchSmart(id.slice(1),sw)) { + nmsMap.setSwitchHighlight(sw,true); + } else { + nmsMap.setSwitchHighlight(sw,false); + } } else { - nmsMap.setSwitchHighlight(sw,false); + if(sw.indexOf(id) > -1) { + hits++; + nmsMap.setSwitchHighlight(sw,true); + } else { + nmsMap.setSwitchHighlight(sw,false); + } } } } else { |